:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: rgba(18, 24, 34, 0.76);
  --surface-strong: rgba(24, 30, 42, 0.92);
  --ink: #fff8e8;
  --muted: #b9c0ca;
  --line: rgba(255, 255, 255, 0.12);
  --gold: #ffd166;
  --coral: #ff6b4a;
  --cyan: #55e6d5;
  --lime: #a7f06f;
  --violet: #b98cff;
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 107, 74, 0.22), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(85, 230, 213, 0.2), transparent 30rem),
    linear-gradient(145deg, #10141f 0%, #15121f 46%, #081a20 100%);
  color: var(--ink);
  font-family: Avenir, "Gill Sans", "Trebuchet MS", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.stage {
  min-height: calc(100vh - 40px);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 42%),
    rgba(9, 13, 20, 0.72);
  box-shadow: var(--shadow);
  padding: 22px;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.08), transparent 34rem);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.eyebrow,
.label {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  line-height: 0.86;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(54px, 7vw, 116px);
  text-shadow: 4px 5px 0 rgba(255, 107, 74, 0.7), 8px 10px 0 rgba(0, 0, 0, 0.28);
}

h2 {
  font-size: clamp(50px, 7vw, 112px);
  max-width: 780px;
}

.battle-banner {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  padding: 0 18px;
  color: var(--cyan);
  font-weight: 900;
  backdrop-filter: blur(18px);
}

.battle-banner {
  color: var(--muted);
  text-transform: uppercase;
}

.battle-banner strong {
  color: var(--coral);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 27px;
}

.screen {
  position: relative;
  z-index: 2;
}

.home-screen,
.setup-screen {
  display: grid;
  gap: 22px;
}

.home-copy,
.setup-copy {
  max-width: 820px;
}

.home-copy p:not(.eyebrow),
.setup-copy p {
  color: var(--muted);
  font-size: 20px;
  line-height: 1.45;
  max-width: 680px;
}

.legend-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.legend-roster span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid rgba(255, 209, 102, 0.34);
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.13);
  color: var(--ink);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

.mode-select,
.difficulty-select {
  display: grid;
  gap: 14px;
}

.mode-select {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.difficulty-select {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-card,
.difficulty-card,
.beat-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.mode-card {
  min-height: 126px;
}

.difficulty-card {
  min-height: 112px;
}

.mode-card:hover,
.mode-card.active,
.difficulty-card:hover,
.difficulty-card.active,
.beat-card:hover,
.beat-card.active {
  transform: translateY(-3px);
  border-color: rgba(255, 209, 102, 0.72);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.18), rgba(255, 255, 255, 0.08));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

.mode-card[data-mode="solo"]:hover,
.mode-card[data-mode="solo"].active {
  border-color: rgba(85, 230, 213, 0.78);
  background: linear-gradient(135deg, rgba(85, 230, 213, 0.2), rgba(255, 255, 255, 0.075));
}

.mode-card[data-mode="help"]:hover,
.mode-card[data-mode="help"].active {
  border-color: rgba(167, 240, 111, 0.78);
  background: linear-gradient(135deg, rgba(167, 240, 111, 0.2), rgba(255, 255, 255, 0.075));
}

.mode-card[data-mode="friend"]:hover,
.mode-card[data-mode="friend"].active {
  border-color: rgba(255, 107, 74, 0.78);
  background: linear-gradient(135deg, rgba(255, 107, 74, 0.2), rgba(255, 255, 255, 0.075));
}

.mode-card[data-mode="legend"]:hover,
.mode-card[data-mode="legend"].active {
  border-color: rgba(185, 140, 255, 0.78);
  background: linear-gradient(135deg, rgba(185, 140, 255, 0.2), rgba(255, 255, 255, 0.075));
}

.difficulty-card[data-difficulty="easy"]:hover,
.difficulty-card[data-difficulty="easy"].active {
  border-color: rgba(167, 240, 111, 0.8);
  background: linear-gradient(135deg, rgba(167, 240, 111, 0.2), rgba(255, 255, 255, 0.075));
}

.difficulty-card[data-difficulty="medium"]:hover,
.difficulty-card[data-difficulty="medium"].active {
  border-color: rgba(255, 209, 102, 0.82);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.22), rgba(255, 255, 255, 0.075));
}

.difficulty-card[data-difficulty="hard"]:hover,
.difficulty-card[data-difficulty="hard"].active {
  border-color: rgba(255, 107, 74, 0.82);
  background: linear-gradient(135deg, rgba(255, 107, 74, 0.22), rgba(255, 255, 255, 0.075));
}

.beat-card:nth-child(3n + 1):hover,
.beat-card:nth-child(3n + 1).active {
  border-color: rgba(85, 230, 213, 0.72);
  background: linear-gradient(135deg, rgba(85, 230, 213, 0.16), rgba(255, 255, 255, 0.075));
}

.beat-card:nth-child(3n + 2):hover,
.beat-card:nth-child(3n + 2).active {
  border-color: rgba(255, 159, 90, 0.74);
  background: linear-gradient(135deg, rgba(255, 159, 90, 0.17), rgba(255, 255, 255, 0.075));
}

.beat-card:nth-child(3n):hover,
.beat-card:nth-child(3n).active {
  border-color: rgba(185, 140, 255, 0.74);
  background: linear-gradient(135deg, rgba(185, 140, 255, 0.17), rgba(255, 255, 255, 0.075));
}

.mode-card span,
.mode-card small,
.difficulty-card span,
.difficulty-card small,
.beat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.mode-card > span,
.difficulty-card > span {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 10px;
  color: #10141f;
  font-size: 11px;
  font-weight: 1000;
  text-transform: uppercase;
}

.mode-card[data-mode="solo"] > span {
  background: var(--cyan);
}

.mode-card[data-mode="help"] > span,
.difficulty-card[data-difficulty="easy"] > span {
  background: var(--lime);
}

.mode-card[data-mode="friend"] > span,
.difficulty-card[data-difficulty="hard"] > span {
  background: var(--coral);
}

.mode-card[data-mode="legend"] > span {
  background: var(--violet);
}

.difficulty-card[data-difficulty="medium"] > span {
  background: var(--gold);
}

.mode-card strong,
.difficulty-card strong,
.beat-card strong {
  display: block;
  margin: 6px 0;
  color: var(--ink);
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 1000;
}

.cta {
  justify-self: center;
  min-width: min(360px, 100%);
  margin-top: 12px;
}

.beat-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.panel-heading strong {
  color: var(--ink);
}

.beat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.beat-card {
  min-height: 94px;
  font-weight: 1000;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
}

.beat-card[hidden] {
  display: none;
}

.beat-select,
.beat-play {
  border: 0;
  background: transparent;
  color: inherit;
}

.beat-select {
  min-width: 0;
  flex: 1;
  padding: 6px;
  text-align: left;
}

.beat-info {
  min-width: 0;
}

.beat-play {
  align-self: center;
  width: 50px;
  min-width: 50px;
  height: 50px;
  min-height: 50px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(85, 230, 213, 0.38);
  border-radius: 999px;
  background: rgba(85, 230, 213, 0.11);
  color: var(--cyan);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.beat-icon {
  display: block;
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid var(--cyan);
}

.beat-card.previewing .beat-play {
  border-color: rgba(255, 209, 102, 0.78);
  background: rgba(255, 209, 102, 0.18);
  color: var(--gold);
}

.beat-play.stopping .beat-icon {
  width: 14px;
  height: 14px;
  margin-left: 0;
  border: 0;
  border-radius: 3px;
  background: var(--gold);
}

.beat-play:hover,
.beat-play:focus-visible {
  transform: scale(1.04);
  border-color: rgba(255, 248, 232, 0.75);
}

.setup-actions,
.controls,
.result-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary,
.ghost,
.icon-btn {
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-weight: 1000;
}

.primary,
.ghost {
  padding: 0 22px;
}

.primary {
  background: linear-gradient(135deg, var(--coral), #ffb15b);
  color: #15110d;
  border-color: transparent;
  box-shadow: 0 12px 26px rgba(255, 107, 74, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, background 160ms ease;
}

.primary.recording {
  background: linear-gradient(135deg, var(--gold), var(--lime));
}

.primary:hover,
.primary:focus-visible {
  transform: translateY(-2px);
  background: linear-gradient(135deg, var(--gold), var(--coral));
  box-shadow: 0 18px 34px rgba(255, 209, 102, 0.24);
  filter: saturate(1.12);
}

.ghost:hover,
.icon-btn:hover {
  border-color: rgba(85, 230, 213, 0.72);
  background: rgba(85, 230, 213, 0.12);
}

.play-screen {
  display: grid;
  gap: 14px;
}

.play-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.play-hud span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.play-hud strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  font-weight: 1000;
}

.performance-stage {
  position: relative;
  min-height: 58vh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #05070b;
}

#arena3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  width: 100%;
  height: 20%;
  opacity: 0.24;
  mix-blend-mode: screen;
  pointer-events: none;
}

.arena-fallback {
  position: absolute;
  inset: 0;
  display: none;
  background: radial-gradient(circle at 50% 35%, rgba(255, 209, 102, 0.2), transparent 20rem), #070a10;
}

.fallback-crowd {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 22%;
  height: 82px;
  background: repeating-linear-gradient(90deg, rgba(85, 230, 213, 0.5), rgba(85, 230, 213, 0.5) 18px, transparent 18px, transparent 34px);
  border-radius: 16px 16px 0 0;
}

.fallback-rapper {
  position: absolute;
  left: 50%;
  bottom: 22%;
  width: 80px;
  height: 150px;
  border-radius: 40px 40px 18px 18px;
  background: var(--coral);
  transform: translateX(-50%);
}

.three-failed .arena-fallback {
  display: block;
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--gold);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(82px, 16vw, 190px);
  line-height: 1;
  text-shadow: 5px 6px 0 rgba(0, 0, 0, 0.65);
}

.help-rail {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(280px, calc(100% - 36px));
  display: grid;
  gap: 9px;
  border: 1px solid rgba(85, 230, 213, 0.35);
  border-radius: 20px;
  background: rgba(4, 10, 14, 0.64);
  padding: 13px;
  backdrop-filter: blur(12px);
}

.help-rail:not(.active) {
  display: none;
}

.help-rail span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.help-rail strong {
  color: var(--cyan);
  font-size: 18px;
}

.rhyme-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rhyme-chip {
  border: 1px solid rgba(85, 230, 213, 0.38);
  border-radius: 999px;
  background: rgba(85, 230, 213, 0.1);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
}

.rhyme-chip.slant {
  border-color: rgba(255, 209, 102, 0.48);
  background: rgba(255, 209, 102, 0.12);
}

.prompt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  padding: 16px 18px;
}

.prompt-row p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3.4vw, 44px);
  font-weight: 1000;
  line-height: 1.02;
}

.icon-btn {
  min-width: 54px;
  color: var(--gold);
}

.result-screen {
  display: grid;
  place-items: center;
  min-height: 58vh;
}

.result-card {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-strong);
  padding: clamp(20px, 4vw, 38px);
  box-shadow: var(--shadow);
}

.result-score {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: end;
  margin: 14px 0 18px;
}

.result-score span {
  color: var(--gold);
  font-size: 44px;
  font-weight: 1000;
}

.result-score strong {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(92px, 18vw, 170px);
  line-height: 0.84;
}

.result-score small {
  color: var(--muted);
  font-weight: 1000;
  padding-bottom: 14px;
}

.match-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.match-readout div {
  border-radius: 18px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.06);
}

.match-readout span,
.score-bars span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.match-readout strong {
  display: block;
  margin-top: 5px;
  color: var(--cyan);
  font-weight: 1000;
}

.score-bars {
  display: grid;
  gap: 11px;
  margin: 16px 0;
}

.score-bars div {
  display: grid;
  gap: 5px;
}

meter {
  width: 100%;
  height: 11px;
}

meter::-webkit-meter-bar {
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--lime));
}

.coach-note {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
}

@media (max-width: 1040px) {
  .mode-select,
  .difficulty-select,
  .beat-list {
    grid-template-columns: 1fr 1fr;
  }

  .play-hud {
    align-items: stretch;
    flex-direction: column;
  }

  .battle-banner {
    width: 100%;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 10px;
  }

  .stage {
    min-height: calc(100vh - 20px);
    border-radius: 18px;
    padding: 12px;
  }

  .mode-select,
  .difficulty-select,
  .beat-list,
  .match-readout {
    grid-template-columns: 1fr;
  }

  .performance-stage {
    min-height: 52vh;
  }

  .prompt-row,
  .controls,
  .setup-actions,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .ghost {
    width: 100%;
    justify-content: center;
  }

  .help-rail {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }
}
