:root {
  --font-display: 'Bungee', 'Trebuchet MS', sans-serif;
  --font-body: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --bg-0: #09131c;
  --bg-1: #12283a;
  --panel: rgba(8, 21, 32, 0.92);
  --panel-border: rgba(169, 206, 224, 0.24);
  --text-main: #f3f8fb;
  --text-soft: #c4dae8;
  --accent-1: #20d9b5;
  --accent-2: #ff9e3d;
  --accent-3: #72d8ff;
  --danger: #ff5f73;
  --lane-hihat: #3cb7ff;
  --lane-snare: #20d9b5;
  --lane-bass: #ffcf49;
  --lane-lowtom: #ff9e3d;
  --lane-hightom: #ffa54d;
  --lane-ride: #8b9cff;
  --lane-crash: #ff5f73;
  --hit-line-offset: 86px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at 18% 14%, rgba(114, 216, 255, 0.22), transparent 38%),
    radial-gradient(circle at 86% 80%, rgba(255, 158, 61, 0.18), transparent 34%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1));
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(1px);
  pointer-events: none;
  z-index: 0;
}

.shape-a {
  width: 460px;
  height: 460px;
  top: -180px;
  right: -120px;
  background: radial-gradient(circle at center, rgba(32, 217, 181, 0.2), rgba(32, 217, 181, 0));
  animation: driftA 11s ease-in-out infinite alternate;
}

.shape-b {
  width: 420px;
  height: 420px;
  bottom: -180px;
  left: -140px;
  background: radial-gradient(circle at center, rgba(255, 94, 124, 0.22), rgba(255, 94, 124, 0));
  animation: driftB 12s ease-in-out infinite alternate;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1180px, 92vw);
  margin: 0.65rem auto 1rem;
  display: grid;
  gap: 1.15rem;
}

.hero {
  text-align: center;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-3);
  font-size: 0.75rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

h1 {
  margin-top: 0.2rem;
  font-size: clamp(1.45rem, 3.2vw, 2.2rem);
}

.subtitle {
  margin: 0.35rem auto 0;
  max-width: 70ch;
  font-size: 0.96rem;
  color: var(--text-soft);
}

.panel,
.game-shell {
  background: var(--panel);
  border: none;
  border-radius: 18px;
  backdrop-filter: blur(7px);
  box-shadow: 0px 0px 0px 1px rgba(169, 206, 224, 0.18), 0 14px 35px rgba(2, 10, 18, 0.32);
}

.controls {
  padding: 1.25rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  align-items: end;
}

.controls label {
  display: grid;
  gap: 0.25rem;
  color: var(--text-soft);
  font-size: 0.82rem;
}

select,
button {
  width: 100%;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  background: rgba(11, 26, 40, 0.88);
  color: var(--text-main);
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  min-height: 40px;
  padding: 0.6rem 0.75rem;
}

button {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(114, 216, 255, 0.58);
}

button:active {
  transform: translateY(0px) scale(0.96);
  transition: transform 80ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(114, 216, 255, 0.95);
  outline-offset: 2px;
}

#jamBtn.active {
  background: rgba(32, 217, 181, 0.2);
  border-color: rgba(82, 237, 194, 0.82);
}

#recordBtn.recording {
  background: rgba(255, 95, 115, 0.18);
  border-color: rgba(255, 121, 138, 0.9);
}

.stats {
  padding: 1.15rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat {
  background: rgba(9, 21, 33, 0.7);
  border: none;
  box-shadow: 0px 0px 0px 1px rgba(255, 255, 255, 0.06), 0 2px 8px rgba(2, 10, 18, 0.2);
  border-radius: 12px;
  padding: 0.45rem 0.58rem;
  display: grid;
  gap: 0.15rem;
}

.stat span {
  color: var(--text-soft);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.38rem;
}

.status {
  grid-column: 1 / -1;
  font-size: 1.05rem;
  color: var(--accent-3);
}

.mode-readout {
  grid-column: 1 / -1;
  min-height: 1.3rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d9ebf5;
}

.mode-readout.playing {
  color: #7fdaff;
}

.mode-readout.jam {
  color: #87f4c9;
}

.mode-readout.recording {
  color: #ffb1b8;
  text-shadow: 0 0 14px rgba(255, 95, 115, 0.45);
}

.streak-readout {
  grid-column: 1 / -1;
  min-height: 1.4rem;
  font-size: 0.88rem;
  color: #b4cad7;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 130ms ease, text-shadow 130ms ease;
}

.streak-readout.hot {
  color: #ffd884;
  text-shadow: 0 0 16px rgba(255, 170, 50, 0.4);
}

.streak-readout.fire {
  color: #ffb18a;
  text-shadow: 0 0 18px rgba(255, 95, 115, 0.45);
}

.keymap {
  padding: 0.55rem 0.8rem;
}

.keymap h2,
.help h2 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.keymap > summary,
.help > summary {
  cursor: pointer;
  font-weight: 700;
  color: #d8edf9;
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}

.keymap > summary::-webkit-details-marker,
.help > summary::-webkit-details-marker {
  color: #9dd9f3;
}

.key-map-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.key-tile {
  background: rgba(9, 21, 33, 0.7);
  border: none;
  box-shadow: 0px 0px 0px 1px rgba(255, 255, 255, 0.06), 0 2px 8px rgba(2, 10, 18, 0.2);
  border-radius: 12px;
  padding: 0.45rem 0.55rem;
  display: grid;
  gap: 0.22rem;
}

.key-tile span {
  color: var(--text-soft);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.key-tile strong {
  font-size: 1.12rem;
}

.game-shell {
  padding: 0.85rem;
}

.game-area {
  position: relative;
  height: min(46vh, 360px);
  min-height: 250px;
  border-radius: 6px;
  overflow: hidden;
  border: none;
  box-shadow: 0px 0px 0px 2px rgba(129, 207, 242, 0.54), inset 0 0 40px rgba(0, 0, 0, 0.15);
  background:
    linear-gradient(180deg, rgba(6, 18, 29, 0.62), rgba(9, 21, 33, 0.92)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.015) 0,
      rgba(255, 255, 255, 0.015) 1px,
      transparent 1px,
      transparent 46px
    );
}

.game-area:focus-visible {
  outline: 2px solid rgba(114, 216, 255, 0.86);
  outline-offset: 2px;
}

.lanes {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.lane {
  position: relative;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: background-color 60ms ease-out, box-shadow 60ms ease-out, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lane:last-child {
  border-right: 0;
}

.lane::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
}

.lane[data-lane="hihat"]::before {
  background: var(--lane-hihat);
}

.lane[data-lane="snare"]::before {
  background: var(--lane-snare);
}

.lane[data-lane="bass"]::before {
  background: var(--lane-bass);
}

.lane[data-lane="lowtom"]::before {
  background: var(--lane-lowtom);
}

.lane[data-lane="hightom"]::before {
  background: var(--lane-hightom);
}

.lane[data-lane="ride"]::before {
  background: var(--lane-ride);
}

.lane[data-lane="crash"]::before {
  background: var(--lane-crash);
}

/* Lane-specific pressed flash colors */
.lane[data-lane="hihat"].pressed {
  background: rgba(60, 183, 255, 0.28);
  box-shadow: inset 0 0 40px rgba(60, 183, 255, 0.25), 0 0 24px rgba(60, 183, 255, 0.12);
}
.lane[data-lane="snare"].pressed {
  background: rgba(32, 217, 181, 0.28);
  box-shadow: inset 0 0 40px rgba(32, 217, 181, 0.25), 0 0 24px rgba(32, 217, 181, 0.12);
}
.lane[data-lane="bass"].pressed {
  background: rgba(255, 207, 73, 0.28);
  box-shadow: inset 0 0 40px rgba(255, 207, 73, 0.25), 0 0 24px rgba(255, 207, 73, 0.12);
}
.lane[data-lane="lowtom"].pressed {
  background: rgba(255, 158, 61, 0.28);
  box-shadow: inset 0 0 40px rgba(255, 158, 61, 0.25), 0 0 24px rgba(255, 158, 61, 0.12);
}
.lane[data-lane="hightom"].pressed {
  background: rgba(255, 165, 77, 0.28);
  box-shadow: inset 0 0 40px rgba(255, 165, 77, 0.25), 0 0 24px rgba(255, 165, 77, 0.12);
}
.lane[data-lane="ride"].pressed {
  background: rgba(139, 156, 255, 0.28);
  box-shadow: inset 0 0 40px rgba(139, 156, 255, 0.25), 0 0 24px rgba(139, 156, 255, 0.12);
}
.lane[data-lane="crash"].pressed {
  background: rgba(255, 95, 115, 0.28);
  box-shadow: inset 0 0 40px rgba(255, 95, 115, 0.25), 0 0 24px rgba(255, 95, 115, 0.12);
}

.lane::after {
  content: "";
  position: absolute;
  bottom: 86px; /* matches HIT_LINE_OFFSET */
  left: calc(50% - 26px);
  width: 52px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  z-index: 1;
  pointer-events: none;
}

.lane.pressed {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3), 0 0 30px rgba(255, 255, 255, 0.08);
  transform: scaleX(1.02);
}

/* Note burst on hit */
.note-hit {
  pointer-events: none;
  animation: noteBurst 280ms ease-out forwards;
}
.note-hit-perfect {
  box-shadow: 0 0 24px 8px rgba(87, 246, 202, 0.9), 0 0 48px 16px rgba(87, 246, 202, 0.4);
  border-color: rgba(87, 246, 202, 1);
}
.note-hit-good {
  box-shadow: 0 0 20px 6px rgba(127, 218, 255, 0.85), 0 0 40px 12px rgba(127, 218, 255, 0.35);
  border-color: rgba(127, 218, 255, 1);
}
.note-hit-ok {
  box-shadow: 0 0 16px 4px rgba(255, 215, 127, 0.8), 0 0 32px 10px rgba(255, 215, 127, 0.3);
  border-color: rgba(255, 215, 127, 1);
}

@keyframes noteBurst {
  0% {
    transform: translateY(var(--y, 0)) scale(1);
    opacity: 1;
    filter: brightness(1);
  }
  30% {
    transform: translateY(var(--y, 0)) scale(1.8);
    opacity: 1;
    filter: brightness(2.5);
  }
  100% {
    transform: translateY(var(--y, 0)) scale(2.5);
    opacity: 0;
    filter: brightness(3);
  }
}

.lane-name,
.lane-key {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
}

.lane-name {
  bottom: 52px;
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(245, 251, 255, 0.95);
  letter-spacing: 0.06em;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.55);
}

.lane-key {
  bottom: 8px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 0.28rem 0.58rem;
  min-width: 72px;
  white-space: nowrap;
  font-size: clamp(0.96rem, 1.7vw, 1.3rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: #ffffff;
  background: rgba(6, 16, 25, 0.9);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.55);
}

.flash-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.beat-guide-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.beat-guide {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  opacity: 0.7;
  transform: translateY(0);
  background: linear-gradient(
    90deg,
    rgba(120, 216, 255, 0.12),
    rgba(152, 231, 255, 0.6) 18%,
    rgba(152, 231, 255, 0.6) 82%,
    rgba(120, 216, 255, 0.12)
  );
}

.beat-guide.beat {
  height: 3px;
  opacity: 0.9;
  background: linear-gradient(
    90deg,
    rgba(137, 236, 203, 0.18),
    rgba(137, 236, 203, 0.75) 20%,
    rgba(137, 236, 203, 0.75) 80%,
    rgba(137, 236, 203, 0.18)
  );
}

.beat-guide.bar {
  height: 4px;
  opacity: 1;
  box-shadow: 0 0 12px rgba(137, 236, 203, 0.45);
  background: linear-gradient(
    90deg,
    rgba(255, 212, 120, 0.24),
    rgba(255, 212, 120, 0.85) 23%,
    rgba(255, 212, 120, 0.85) 77%,
    rgba(255, 212, 120, 0.24)
  );
}

.game-area.perfect-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 72%, rgba(72, 255, 217, 0.2), transparent 50%);
  pointer-events: none;
  animation: pulseFade 220ms ease-out;
  z-index: 5;
}

.hit-flash {
  position: absolute;
  left: 12%;
  width: 76%;
  height: 24px;
  bottom: calc(var(--hit-line-offset) - 10px);
  border-radius: 999px;
  opacity: 0;
  transform: scale(0.6);
  animation: hitFlash 240ms ease-out forwards;
}

.hit-flash.perfect {
  background: radial-gradient(circle at center, rgba(87, 246, 202, 0.85), rgba(87, 246, 202, 0));
}

.hit-flash.good {
  background: radial-gradient(circle at center, rgba(127, 218, 255, 0.82), rgba(127, 218, 255, 0));
}

.hit-flash.ok {
  background: radial-gradient(circle at center, rgba(255, 215, 127, 0.78), rgba(255, 215, 127, 0));
}

.hit-flash.miss {
  background: radial-gradient(circle at center, rgba(255, 95, 115, 0.75), rgba(255, 95, 115, 0));
}

.streak-line {
  position: absolute;
  bottom: var(--hit-line-offset);
  left: var(--x);
  width: 2px;
  height: var(--h);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(114, 216, 255, 0.9), rgba(255, 255, 255, 0));
  box-shadow: 0 0 10px rgba(127, 218, 255, 0.5);
  opacity: 0;
  transform: translateY(0);
  animation: streakDrop 320ms ease-out forwards;
}

.streak-line.hot {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 215, 127, 0.95), rgba(255, 255, 255, 0));
  box-shadow: 0 0 14px rgba(255, 170, 50, 0.48);
}

.streak-line.fire {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 128, 102, 0.96), rgba(255, 255, 255, 0));
  box-shadow: 0 0 16px rgba(255, 95, 115, 0.52);
}

.hit-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--hit-line-offset);
  height: 6px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 0 14px rgba(32, 217, 181, 0.5);
  z-index: 4;
}

.note {
  position: absolute;
  top: 0;
  left: calc(50% - 26px);
  width: 52px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  z-index: 2;
  will-change: transform;
}

.note-hihat {
  background: linear-gradient(135deg, #2ea9ff, #60e4ff);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(59, 183, 255, 0.6);
}

.note-snare {
  background: linear-gradient(135deg, #16c6a2, #62ffd6);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(32, 217, 181, 0.6);
}

.note-bass {
  background: linear-gradient(135deg, #f5bd36, #ffe781);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(255, 207, 73, 0.6);
}

.note-lowtom {
  background: linear-gradient(135deg, #ff8b2b, #ffca66);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(255, 158, 61, 0.6);
}

.note-hightom {
  background: linear-gradient(135deg, #ff9f45, #ffd06f);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(255, 165, 77, 0.6);
}

.note-ride {
  background: linear-gradient(135deg, #7388ff, #aeb8ff);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(139, 156, 255, 0.6);
}

.note-crash {
  background: linear-gradient(135deg, #ff5f73, #ff8a66);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.25), 0 0 14px rgba(255, 95, 115, 0.6);
}

.judgement,
.countdown {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.judgement {
  font-family: var(--font-display);
  bottom: calc(var(--hit-line-offset) + 28px);
  min-width: 10ch;
  font-size: clamp(1.45rem, 3vw, 2.5rem);
  text-align: center;
  opacity: 0;
  transition: opacity 170ms ease;
}

.judgement.show {
  opacity: 1;
}

.judgement.perfect {
  color: #57f6ca;
}

.judgement.good {
  color: #7fdaff;
}

.judgement.ok {
  color: #ffd77f;
}

.judgement.miss {
  color: var(--danger);
}

.countdown {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  top: 6%;
  font-size: clamp(1.3rem, 3.1vw, 2.2rem);
  color: #d9f4ff;
  text-shadow: 0 0 16px rgba(114, 216, 255, 0.4);
}

.help {
  padding: 0.55rem 0.8rem;
  color: var(--text-soft);
}

.help p {
  margin: 0.35rem 0;
}

.reveal-1,
.reveal-2,
.reveal-3,
.reveal-4,
.reveal-5,
.reveal-6 {
  opacity: 0;
  transform: translateY(12px);
  filter: blur(4px);
  animation: reveal 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.reveal-1 {
  animation-delay: 80ms;
}

.reveal-2 {
  animation-delay: 160ms;
}

.reveal-3 {
  animation-delay: 240ms;
}

.reveal-4 {
  animation-delay: 320ms;
}

.reveal-5 {
  animation-delay: 400ms;
}

.reveal-6 {
  animation-delay: 480ms;
}

@media (max-width: 900px) {
  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .game-area {
    height: min(50vh, 350px);
  }
}

@media (max-width: 640px) {
  .app {
    width: min(96vw, 1180px);
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-area {
    height: 44vh;
    min-height: 220px;
  }

  .key-map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lane-name {
    bottom: 44px;
    font-size: 0.64rem;
  }

  .lane-key {
    bottom: 10px;
    min-width: 0;
    font-size: clamp(0.72rem, 2.8vw, 0.95rem);
    padding: 0.2rem 0.32rem;
  }
}

@media (max-height: 830px) {
  .eyebrow,
  .subtitle {
    display: none;
  }

  .app {
    margin: 0.35rem auto 0.6rem;
    gap: 0.55rem;
  }

  h1 {
    margin-top: 0;
    font-size: clamp(1.25rem, 2.7vw, 1.72rem);
  }

  .controls {
    padding: 0.85rem;
    gap: 0.55rem;
  }

  .stats {
    padding: 0.75rem;
  }

  .game-shell {
    padding: 0.55rem;
  }

  .game-area {
    height: min(42vh, 300px);
    min-height: 205px;
  }

  .lane-name {
    bottom: 40px;
    font-size: 0.62rem;
  }

  .lane-key {
    bottom: 6px;
    font-size: clamp(0.68rem, 1.6vw, 0.92rem);
    padding: 0.18rem 0.28rem;
  }
}


@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes driftA {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(-18px, 20px) scale(1.06);
  }
}

@keyframes driftB {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(22px, -20px) scale(1.05);
  }
}

@keyframes hitFlash {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes streakDrop {
  0% {
    opacity: 0;
    transform: translateY(-22px);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(142px);
  }
}

@keyframes pulseFade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ── Skip Nav ──────────────────────────────────────────────────── */
.skip-nav {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 10000;
  background: var(--accent-1);
  color: var(--bg-0);
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 8px 0;
  font-weight: 700;
  text-decoration: none;
}

.skip-nav:focus {
  position: fixed;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
}

/* ── Audio Unlock Overlay ─────────────────────────────────────── */
.audio-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  transition: opacity 250ms ease;
}

.audio-overlay.hiding {
  opacity: 0;
  pointer-events: none;
}

.audio-overlay-card {
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--panel);
  border: none;
  box-shadow: 0px 0px 0px 1px rgba(169, 206, 224, 0.18), 0 0 48px rgba(32, 217, 181, 0.12);
  border-radius: 1rem;
  max-width: 340px;
  width: 90%;
}

.audio-overlay-icon {
  font-size: 3rem;
  margin: 0 0 0.75rem;
}

.audio-overlay-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent-1);
  margin: 0 0 0.5rem;
}

.audio-overlay-card p {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

#audioStartBtn {
  background: var(--accent-1);
  color: var(--bg-0);
  border: none;
  border-radius: 0.5rem;
  padding: 0.75rem 2rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

#audioStartBtn:hover {
  opacity: 0.85;
}

#audioStartBtn:active {
  transform: scale(0.96);
}

/* ── Share Modal ────────────────────────────────────────────── */
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 19, 28, 0.82);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.share-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.share-modal.visible .share-modal-card {
  transform: scale(1) translateY(0);
  filter: blur(0);
}

.share-modal-card {
  background: var(--bg-1);
  border: none;
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0px 0px 0px 1px rgba(169, 206, 224, 0.18), 0 0 48px rgba(32, 217, 181, 0.12);
  transform: scale(0.95) translateY(8px);
  filter: blur(4px);
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), filter 300ms ease;
}

.share-modal-icon {
  font-size: 2.5rem;
  margin: 0 0 0.5rem;
}

.share-modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent-1);
  margin: 0 0 1.25rem;
}

.share-stats {
  background: rgba(8, 21, 32, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 0.6rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-soft);
  line-height: 1.7;
}

.share-stats strong {
  color: var(--text-main);
}

.share-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-share-x {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #000;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-share-x svg path {
  fill: #fff;
}

.btn-share-x:hover {
  background: #1a1a1a;
}

.btn-share-x:active {
  transform: scale(0.96);
}

.btn-play-again {
  background: var(--accent-1);
  color: var(--bg-0);
  border: none;
  border-radius: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-play-again:hover {
  opacity: 0.85;
}

.btn-play-again:active {
  transform: scale(0.96);
}

/* Hit particles */
.hit-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 8;
  animation: particleBurst 400ms ease-out forwards;
}

@keyframes particleBurst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}

/* ── Reduced Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .reveal-1, .reveal-2, .reveal-3, .reveal-4, .reveal-5, .reveal-6 {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }
  .bg-shape { animation: none; }
  .hit-flash, .streak-line, .hit-particle { animation: none; display: none; }
  .game-area.perfect-pulse::after { animation: none; }
  .note-hit { animation-duration: 0.01ms; }
  .beat-guide, .beat-guide.beat, .beat-guide.bar { opacity: 0.5; }
}
