:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: rgba(248, 251, 255, 0.68);
  --glass: rgba(8, 11, 28, 0.54);
  --glass-strong: rgba(8, 11, 28, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --cyan: #00dcff;
  --magenta: #ff37d2;
  --lime: #7cff3a;
  --yellow: #f4ff27;
  --danger: #ff4b61;
  --bass: 0;
  --mid: 0;
  --high: 0;
  --level: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: #050713;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
label {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button,
label {
  cursor: pointer;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(12px, 2vw, 22px);
  position: relative;
  overflow: hidden;
  padding: clamp(14px, 2.5vw, 32px);
  isolation: isolate;
}

.stage-bg,
.ambient-wash,
.audio-visualizer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-bg {
  object-fit: cover;
  transform: scale(calc(1.04 + var(--bass) * 0.025));
  filter: saturate(calc(1.12 + var(--mid) * 0.7)) contrast(calc(1.04 + var(--bass) * 0.22));
  animation: cinematicDrift 22s ease-in-out infinite alternate;
  z-index: -5;
}

.ambient-wash {
  background:
    linear-gradient(180deg, rgba(5, 7, 19, 0.54), rgba(5, 7, 19, 0.82)),
    radial-gradient(circle at 50% 34%, rgba(0, 220, 255, calc(0.15 + var(--bass) * 0.32)), transparent 34%),
    radial-gradient(circle at 22% 72%, rgba(255, 55, 210, calc(0.16 + var(--mid) * 0.32)), transparent 26%),
    radial-gradient(circle at 80% 78%, rgba(244, 255, 39, calc(0.12 + var(--high) * 0.28)), transparent 22%);
  z-index: -4;
}

.audio-visualizer {
  opacity: 0.8;
  mix-blend-mode: screen;
  z-index: -3;
}

.light-ribbons {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
}

.light-ribbons span {
  position: absolute;
  width: 42vw;
  height: 2px;
  left: -16vw;
  top: 24%;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 28px var(--cyan);
  transform: rotate(-18deg);
  animation: ribbonSweep 5.8s cubic-bezier(.45, 0, .25, 1) infinite;
}

.light-ribbons span:nth-child(2) {
  top: 42%;
  background: linear-gradient(90deg, transparent, var(--magenta), transparent);
  box-shadow: 0 0 28px var(--magenta);
  animation-delay: -1.5s;
  animation-duration: 6.4s;
}

.light-ribbons span:nth-child(3) {
  top: 66%;
  background: linear-gradient(90deg, transparent, var(--yellow), transparent);
  box-shadow: 0 0 28px var(--yellow);
  animation-delay: -3s;
}

.light-ribbons span:nth-child(4) {
  top: 82%;
  background: linear-gradient(90deg, transparent, var(--lime), transparent);
  box-shadow: 0 0 28px var(--lime);
  animation-delay: -4.2s;
  animation-duration: 7s;
}

.top-nav {
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 440px) auto;
  gap: 10px;
  align-items: center;
  position: relative;
  z-index: 3;
}

.brand-lockup {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand-lockup span {
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.16em;
}

.brand-lockup strong {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-loader {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: rgba(8, 11, 28, 0.5);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(22px);
}

.song-loader input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.song-loader label,
.primary-action,
.secondary-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 950;
  transition: transform 170ms ease, box-shadow 170ms ease, background 170ms ease, border-color 170ms ease;
}

.song-loader label,
.primary-action {
  color: #061019;
  background: linear-gradient(135deg, #fff 0%, var(--cyan) 48%, var(--yellow) 100%);
  box-shadow: 0 0 30px rgba(0, 220, 255, 0.34), 0 14px 34px rgba(0, 0, 0, 0.28);
}

.secondary-action {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.11);
  border-color: var(--line);
}

.song-loader label:hover,
.primary-action:hover,
.secondary-action:hover,
.menu-card:hover {
  transform: translateY(-2px);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.soon-action {
  color: rgba(248, 251, 255, 0.72);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--line);
}

#song-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-center {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 0.42fr) minmax(0, 1fr);
  gap: clamp(12px, 2vw, 24px);
  position: relative;
  z-index: 2;
}

.intro-panel {
  align-self: end;
  padding-bottom: clamp(12px, 4vh, 42px);
}

.eyebrow,
.hud-label,
.result-kicker {
  margin: 0;
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(244, 255, 39, 0.55);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 9ch;
  margin: 8px 0 16px;
  font-size: clamp(3.3rem, 8vw, 8.8rem);
  line-height: 0.88;
  font-weight: 950;
  text-shadow:
    0 0 14px rgba(0, 220, 255, 0.7),
    0 0 44px rgba(255, 55, 210, 0.64);
}

.lead {
  max-width: 430px;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.22rem);
  line-height: 1.8;
}

.game-surface {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto auto minmax(300px, 1fr) auto;
  gap: 8px;
  padding: clamp(9px, 1.2vw, 16px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.025)),
    var(--glass);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 28px 100px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(22px);
}

.menu-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.menu-card {
  min-width: 0;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
}

.menu-card[aria-pressed="true"] {
  border-color: rgba(0, 220, 255, 0.72);
  background: linear-gradient(135deg, rgba(0, 220, 255, 0.18), rgba(255, 55, 210, 0.12));
  box-shadow: 0 0 26px rgba(0, 220, 255, 0.2);
}

.menu-card small,
.menu-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-card small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.menu-card strong {
  margin-top: 5px;
  font-size: 1rem;
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.game-hud div {
  min-height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 10px;
  background: rgba(5, 7, 19, 0.46);
}

.game-hud strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.65rem, 3.5vw, 3rem);
  line-height: 0.95;
  font-weight: 950;
}

.lane-board {
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(0, 220, 255, 0.12), transparent 22%, transparent 78%, rgba(255, 55, 210, 0.12)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(5, 7, 19, 0.5));
}

.lane-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 24.75%, rgba(255, 255, 255, 0.2) 25%, transparent 25.25%),
    linear-gradient(90deg, transparent 49.75%, rgba(255, 255, 255, 0.2) 50%, transparent 50.25%),
    linear-gradient(90deg, transparent 74.75%, rgba(255, 255, 255, 0.2) 75%, transparent 75.25%);
  pointer-events: none;
}

.beat-grid {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0 1px,
    transparent 1px 54px
  );
  animation: gridRush 900ms linear infinite;
  opacity: 0.74;
}

.lane-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(0, 220, 255, calc(0.1 + var(--bass) * 0.28)),
    rgba(255, 55, 210, calc(0.08 + var(--mid) * 0.22)),
    rgba(244, 255, 39, calc(0.08 + var(--high) * 0.2))
  );
  mix-blend-mode: screen;
}

.note-layer {
  position: absolute;
  inset: 0;
}

.note {
  width: min(16vw, 128px);
  min-height: 46px;
  position: absolute;
  left: calc(var(--lane-left) + 12.5%);
  top: var(--note-y);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #041019;
  background: linear-gradient(135deg, #fff, var(--cyan) 45%, var(--yellow));
  box-shadow: 0 0 24px rgba(0, 220, 255, 0.72), 0 12px 32px rgba(0, 0, 0, 0.34);
  font-size: 0.9rem;
  font-weight: 950;
  transform: translate(-50%, -50%) scale(calc(1 + var(--level) * 0.08));
  will-change: top, transform, opacity;
}

.note:nth-child(4n + 2) {
  background: linear-gradient(135deg, #fff, var(--magenta), #ffd8fb);
}

.note:nth-child(4n + 3) {
  background: linear-gradient(135deg, #fff, var(--yellow), #ff833a);
}

.note:nth-child(4n + 4) {
  background: linear-gradient(135deg, #fff, var(--lime), var(--cyan));
}

.note.preview {
  opacity: 0.28;
  animation: previewFloat 2.2s ease-in-out infinite alternate;
  animation-delay: calc(var(--note-y) * -0.02s);
}

.note.live {
  top: -18%;
  opacity: 0;
  animation: noteDrop var(--note-speed) linear var(--note-delay) both;
}

.note.armed {
  box-shadow: 0 0 42px rgba(244, 255, 39, 0.9), 0 12px 32px rgba(0, 0, 0, 0.34);
}

.note.perfect,
.note.good {
  opacity: 0 !important;
  transform: translate(-50%, -50%) scale(2.05) rotate(8deg);
  transition: opacity 220ms ease, transform 220ms ease;
}

.note.miss {
  opacity: 0 !important;
  filter: grayscale(1);
  transform: translate(-50%, -50%) scale(0.52);
  transition: opacity 240ms ease, transform 240ms ease, filter 240ms ease;
}

.judgement {
  position: absolute;
  left: 50%;
  top: 44%;
  color: #fff;
  font-size: clamp(3rem, 9vw, 8.8rem);
  font-weight: 950;
  line-height: 0.82;
  opacity: 0.58;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 0 18px rgba(0, 220, 255, 0.92), 0 0 52px rgba(255, 55, 210, 0.82);
  transform: translate(-50%, -50%);
}

.judgement.pop {
  animation: judgePop 380ms cubic-bezier(.2, 1.4, .25, 1) both;
}

.receptors {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 12px;
}

.lane-hit {
  min-height: 70px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(5, 7, 19, 0.64);
  box-shadow: inset 0 0 26px rgba(255, 255, 255, 0.08), 0 0 20px rgba(0, 220, 255, 0.15);
}

.lane-hit span,
.lane-hit small {
  display: block;
}

.lane-hit span {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  font-weight: 950;
}

.lane-hit small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
}

.lane-hit.hit {
  animation: laneHit 190ms ease both;
}

.control-dock {
  display: grid;
  grid-template-columns: minmax(180px, 0.34fr) auto minmax(280px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.selected-dish,
.mini-result {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(5, 7, 19, 0.52);
}

.selected-dish span,
.selected-dish strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-dish span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.selected-dish strong {
  font-size: 1.05rem;
}

.mini-result {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
}

.mini-result h2,
.mini-result p {
  margin: 0;
}

.mini-result h2 {
  overflow: hidden;
  font-size: clamp(1rem, 1.8vw, 1.5rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-result #result-copy {
  grid-column: 1 / 4;
  color: var(--muted);
  line-height: 1.45;
}

.result-rank {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 950;
}

.result-actions {
  grid-column: 1 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-actions .primary-action,
.result-actions .secondary-action {
  min-height: 38px;
}

.mini-result.normal {
  border-color: rgba(0, 220, 255, 0.42);
  box-shadow: 0 0 30px rgba(0, 220, 255, 0.16);
}

.mini-result.perfect {
  border-color: rgba(255, 55, 210, 0.5);
  box-shadow: 0 0 36px rgba(255, 55, 210, 0.24);
}

.mini-result.failed {
  border-color: rgba(255, 75, 97, 0.44);
}

@keyframes cinematicDrift {
  from { transform: scale(calc(1.04 + var(--bass) * 0.025)) translate3d(-1.2%, -0.8%, 0); }
  to { transform: scale(calc(1.08 + var(--bass) * 0.025)) translate3d(1.2%, 0.8%, 0); }
}

@keyframes ribbonSweep {
  from { transform: translate3d(-25vw, 0, 0) rotate(-18deg); opacity: 0; }
  18% { opacity: 0.9; }
  82% { opacity: 0.7; }
  to { transform: translate3d(145vw, 0, 0) rotate(-18deg); opacity: 0; }
}

@keyframes gridRush {
  to { background-position-y: 54px; }
}

@keyframes previewFloat {
  to { transform: translate(-50%, -56%) scale(1.06); opacity: 0.45; }
}

@keyframes noteDrop {
  0% { top: -18%; opacity: 0; transform: translate(-50%, -50%) scale(0.82); }
  8% { opacity: 1; }
  86% { opacity: 1; }
  100% { top: calc(100% - 64px); opacity: 0.96; transform: translate(-50%, -50%) scale(calc(1.05 + var(--level) * 0.08)); }
}

@keyframes judgePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.75); }
  45% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0.62; transform: translate(-50%, -50%) scale(1); }
}

@keyframes laneHit {
  50% {
    color: #041019;
    background: linear-gradient(135deg, var(--cyan), var(--yellow));
    box-shadow: 0 0 42px rgba(244, 255, 39, 0.78);
    transform: translateY(4px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    height: auto;
    min-height: 100svh;
    overflow: auto;
  }

  .top-nav,
  .command-center {
    grid-template-columns: 1fr;
  }

  .intro-panel {
    align-self: auto;
    padding-bottom: 0;
  }

  h1 {
    max-width: 12ch;
    font-size: clamp(3rem, 12vw, 6rem);
  }

  .game-surface {
    min-height: 760px;
  }
}

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

  .song-loader,
  .game-hud,
  .menu-strip,
  .control-dock,
  .mini-result {
    grid-template-columns: 1fr;
  }

  .game-surface {
    min-height: 740px;
    padding: 10px;
  }

  .lane-board {
    min-height: 420px;
  }

  .note {
    width: 22vw;
    min-height: 40px;
    font-size: 0.75rem;
  }

  .receptors {
    gap: 5px;
    padding: 0 8px;
  }

  .lane-hit {
    min-height: 70px;
  }

  .mini-result #result-copy,
  .result-actions {
    grid-column: auto;
  }
}
