@font-face {
  font-family: BarlowCondensed;
  src: url('/minigames/sneaker-run/assets/fonts/barlow-condensed-black.ttf') format('truetype');
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: SpaceGrotesk;
  src: url('/minigames/sneaker-run/assets/fonts/space-grotesk.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: oklch(.22 .022 224);
  --ink-deep: oklch(.16 .02 224);
  --ink-soft: oklch(.31 .028 224);
  --paper: oklch(.95 .026 87);
  --paper-muted: oklch(.77 .03 87);
  --yellow: oklch(.88 .15 94);
  --coral: oklch(.64 .17 31);
  --cyan: oklch(.82 .14 204);
  --pink: oklch(.7 .19 350);
  --orange: oklch(.74 .16 55);
  --font-display: BarlowCondensed, Impact, sans-serif;
  --font-body: SpaceGrotesk, 'Helvetica Neue', sans-serif;
  color: var(--paper);
  font-family: var(--font-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { min-width: 320px; margin: 0; background: var(--ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { display: block; margin: 0; color: oklch(.46 .03 224); font-size: 9px; font-weight: 700; letter-spacing: .12em; line-height: 1.4; }

.cabinet { width: min(1080px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 28px; }
.topbar { min-height: 58px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid oklch(.95 .026 87 / .15); }
.back-link { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--paper-muted); font-size: 12px; font-weight: 600; transition: color .18s ease-out; }
.back-link:hover, .department:hover { color: var(--paper); }
.back-link:first-letter, .department:first-letter { color: var(--yellow); }
.department { display: inline-flex; align-items: center; gap: 9px; color: var(--paper); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.department span { color: var(--paper-muted); font-size: 9px; letter-spacing: .13em; }

.intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 28px 0 18px; }
.intro h1 { margin: 0; color: var(--paper); font: 900 58px/.9 var(--font-display); letter-spacing: -.015em; }
.intro h1 i { color: var(--yellow); font-style: normal; }
.intro p { max-width: 34ch; margin: 0; color: var(--paper-muted); font-size: 14px; line-height: 1.45; text-align: right; }

/* ---------- Stage ---------- */

.stage {
  --kick: 0;
  --hype: 0;
  position: relative;
  min-height: clamp(520px, 66vh, 620px);
  display: grid;
  place-items: center;
  padding: 88px 24px 28px;
  overflow: hidden;
  isolation: isolate;
  background: var(--ink-deep);
  touch-action: manipulation;
}
.stage::before {
  position: absolute;
  z-index: -3;
  inset: -2%;
  background: url('assets/stage-concert.png') center 22% / cover no-repeat;
  content: '';
  filter: brightness(calc(.62 + var(--kick) * .22 + var(--hype) * .12)) saturate(calc(.9 + var(--hype) * .35));
  transform: scale(calc(1 + var(--kick) * .008));
}
.stage::after { position: absolute; z-index: -2; inset: 0; background: linear-gradient(180deg, oklch(.16 .02 224 / .62) 0%, oklch(.16 .02 224 / .12) 38%, oklch(.16 .02 224 / .3) 66%, oklch(.16 .02 224 / .86) 100%); content: ''; pointer-events: none; }
.stage-lights { position: absolute; z-index: -1; inset: 0; pointer-events: none; opacity: calc(var(--kick) * (.35 + var(--hype) * .5)); background: radial-gradient(ellipse 30% 55% at 22% 0%, oklch(.88 .15 94 / .5), transparent 70%), radial-gradient(ellipse 30% 55% at 78% 0%, oklch(.82 .14 204 / .45), transparent 70%); mix-blend-mode: screen; }
.stage[data-bar='down'] .stage-lights { background: radial-gradient(ellipse 34% 60% at 50% 0%, oklch(.7 .19 350 / .55), transparent 70%), radial-gradient(ellipse 30% 55% at 15% 0%, oklch(.88 .15 94 / .45), transparent 70%), radial-gradient(ellipse 30% 55% at 85% 0%, oklch(.82 .14 204 / .45), transparent 70%); }
.stage.is-shaken { animation: shake .22s ease-out; }

.performer {
  position: absolute;
  z-index: 0;
  right: 2%;
  bottom: 11%;
  width: clamp(150px, 20vw, 240px);
  aspect-ratio: 1;
  background: url('assets/guitarist-loop.png') 0 0 / 200% 200% no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  transform-origin: 50% 100%;
  transform: translateY(calc(var(--kick) * -7px)) scaleY(calc(1 - var(--kick) * .025));
}
.performer[data-frame='1'] { background-position: 100% 0; }
.performer[data-frame='2'] { background-position: 0 100%; }
.performer[data-frame='3'] { background-position: 100% 100%; }
.crowd {
  --tile: 150px;
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: calc(var(--tile) * -.42);
  left: 0;
  height: var(--tile);
  background: url('assets/crowd-cheer-loop.png') 0 0 / calc(var(--tile) * 2) calc(var(--tile) * 2) repeat-x;
  image-rendering: pixelated;
  opacity: .82;
  pointer-events: none;
  transform: translateY(calc(var(--kick) * var(--hype) * -12px));
}
.crowd[data-frame='1'] { background-position: calc(var(--tile) * -1) 0; }
.crowd[data-frame='2'] { background-position: 0 calc(var(--tile) * -1); }
.crowd[data-frame='3'] { background-position: calc(var(--tile) * -1) calc(var(--tile) * -1); }

.hud { position: absolute; z-index: 3; top: 0; right: 0; left: 0; display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 18px; padding: 14px 18px 10px; }
.hud-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hud-stat:nth-child(3) { align-items: flex-end; }
.hud-stat span { color: var(--paper-muted); font-size: 8px; font-weight: 700; letter-spacing: .16em; }
.hud-stat strong { color: var(--paper); font: 900 30px/.9 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.hud-combo { align-items: center; }
.hud-combo strong { color: var(--yellow); font-size: 38px; transform: scale(calc(1 + var(--kick) * var(--hype) * .08)); }
.hud-combo em { color: var(--cyan); font-size: 11px; font-style: normal; font-weight: 800; letter-spacing: .08em; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid oklch(.95 .026 87 / .35); background: oklch(.16 .02 224 / .6); color: var(--paper); font-size: 16px; transition: background-color .15s ease-out, color .15s ease-out; }
.icon-button:hover:not(:disabled) { background: var(--yellow); color: var(--ink); }
.icon-button:disabled { opacity: .35; }
.song-progress { position: absolute; z-index: 3; top: 70px; right: 18px; left: 18px; height: 3px; background: oklch(.95 .026 87 / .16); }
.song-progress i { display: block; height: 100%; background: var(--yellow); transform: scaleX(0); transform-origin: left center; }
.stage[data-phase='menu'] .hud, .stage[data-phase='menu'] .song-progress { opacity: .35; }

.karaoke { position: absolute; z-index: 2; top: 104px; right: 0; left: 0; bottom: 24%; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; padding: 0 clamp(18px, 24vw, 280px) 0 clamp(18px, 6vw, 72px); text-align: center; cursor: text; }
.lyric-line { flex: none; max-width: 30ch; margin: 0; color: var(--paper); font-family: var(--font-display); font-weight: 900; line-height: 1.02; letter-spacing: .01em; text-wrap: balance; }
.lyric-line.is-previous { min-height: 1em; color: var(--paper-muted); font-size: clamp(18px, 2.2vw, 24px); opacity: .5; }
.lyric-line.is-current { min-height: 1.1em; max-width: 22ch; font-size: clamp(34px, 4.6vw, 58px); text-shadow: 3px 4px 0 oklch(.16 .02 224 / .85); }
.lyric-line.is-next { min-height: 1em; color: var(--paper-muted); font-size: clamp(20px, 2.6vw, 30px); opacity: .8; }
.karaoke.is-advancing .is-current { animation: line-in .28s cubic-bezier(.2, .9, .2, 1); }
.karaoke.is-waiting .is-current { opacity: .45; }
.word { --sing: 0; position: relative; display: inline-block; transition: color .12s ease-out, opacity .12s ease-out; }
.is-current .word::after { position: absolute; right: 0; bottom: -.08em; left: 0; height: .07em; background: oklch(.95 .026 87 / .18); content: ''; }
.is-current .word::before { position: absolute; z-index: 1; bottom: -.08em; left: 0; width: calc(var(--sing) * 100%); height: .07em; background: var(--pink); content: ''; }
.is-current .word.is-singing { color: oklch(.97 .03 87); text-shadow: 0 0 18px oklch(.7 .19 350 / .6), 3px 4px 0 oklch(.16 .02 224 / .85); }
.word.is-target { color: oklch(.95 .026 87 / .6); }
.word.is-target b { color: var(--yellow); font-weight: inherit; }
.word.is-target::after { height: .1em; background: var(--yellow); animation: target-blink .9s steps(2, end) infinite; }
.word.is-sync { color: var(--yellow); }
.word.is-early { color: var(--cyan); }
.word.is-late { color: var(--orange); }
.word.is-miss { color: var(--coral); opacity: .55; text-decoration: line-through .06em; }
.word.is-skip { opacity: .6; }
.word.is-wrong { animation: wrong .2s ease-out; }
.judgement { position: absolute; top: -30px; left: 50%; color: var(--paper); font: 900 24px/1 var(--font-display); letter-spacing: .06em; opacity: 0; pointer-events: none; transform: translateX(-50%); white-space: nowrap; text-shadow: 2px 3px 0 var(--ink); }
.judgement[data-kind='sync'] { color: var(--yellow); }
.judgement[data-kind='early'] { color: var(--cyan); }
.judgement[data-kind='late'] { color: var(--orange); }
.judgement[data-kind='miss'], .judgement[data-kind='typo'] { color: var(--coral); }
.judgement.is-showing { animation: judgement .55s ease-out forwards; }
.burst { position: absolute; z-index: 3; width: 150px; height: 150px; background: url('assets/hit-burst.png') center / contain no-repeat; image-rendering: pixelated; mix-blend-mode: screen; pointer-events: none; animation: burst .36s ease-out forwards; }

.break-card { position: absolute; z-index: 3; left: 50%; bottom: 7%; width: min(360px, calc(100% - 32px)); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 14px; padding: 12px 16px; background: oklch(.16 .02 224 / .88); border: 1px solid oklch(.95 .026 87 / .25); transform: translateX(-50%); }
.break-card span { color: var(--paper-muted); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.break-card strong { grid-row: span 2; color: var(--yellow); font: 900 44px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.break-meter { height: 4px; background: oklch(.95 .026 87 / .16); }
.break-meter i { display: block; height: 100%; background: var(--pink); transform: scaleX(0); transform-origin: left center; }
.skip-button { grid-column: 1 / -1; min-height: 40px; border: 1px solid oklch(.95 .026 87 / .35); background: transparent; color: var(--paper); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.skip-button:hover { border-color: var(--yellow); color: var(--yellow); }
.first-hint { position: absolute; z-index: 3; left: 50%; bottom: calc(7% + 110px); margin: 0; padding: 7px 12px; background: var(--yellow); color: var(--ink); font-size: 12px; font-weight: 700; transform: translateX(-50%); white-space: nowrap; pointer-events: none; }
.stage:not([data-phase='playing']) .first-hint { display: none; }
.lyrics-credit { position: absolute; z-index: 4; bottom: 12px; left: 16px; padding: 5px 8px; background: oklch(.16 .02 224 / .78); color: var(--paper-muted); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.lyrics-credit:hover { color: var(--yellow); }
.stage:not([data-phase='playing']):not([data-phase='paused']) .lyrics-credit { display: none; }
.break-card[hidden] + .first-hint { bottom: 7%; }
.mascot { position: absolute; z-index: 4; bottom: 0; left: 3%; width: clamp(120px, 15vw, 170px); aspect-ratio: 1; background: url('assets/beat-mascot.png') center bottom / contain no-repeat; image-rendering: pixelated; opacity: 0; pointer-events: none; transform: translateY(100%); }
.mascot span { position: absolute; bottom: 82%; left: 70%; padding: 6px 9px; background: var(--yellow); color: var(--ink); font: 900 22px/1 var(--font-display); letter-spacing: .03em; white-space: nowrap; box-shadow: 3px 3px 0 var(--coral); }
.mascot.is-showing { animation: mascot 1.5s cubic-bezier(.2, .9, .2, 1) forwards; }

.type-catcher-label { position: absolute; z-index: 1; top: 104px; right: 0; bottom: 24%; left: 0; }
.type-catcher { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; color: transparent; caret-color: transparent; font-size: 16px; opacity: 0; }
.stage:not([data-phase='playing']) .type-catcher-label { display: none; }
.type-hint { display: none; position: absolute; z-index: 4; bottom: 7%; left: 50%; margin: 0; padding: 8px 12px; background: var(--yellow); color: var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .06em; transform: translateX(-50%); pointer-events: none; white-space: nowrap; }
.stage.needs-keyboard[data-phase='playing'] .type-hint { display: block; }

/* ---------- Panels ---------- */

.stage:not([data-phase='playing']) .karaoke { visibility: hidden; }
.panel { position: relative; z-index: 6; width: min(640px, 100%); padding: 26px 28px 24px; background: oklch(.16 .02 224 / .92); border: 1px solid oklch(.95 .026 87 / .22); box-shadow: 10px 10px 0 oklch(.12 .02 224 / .6); backdrop-filter: blur(6px); animation: panel-in .28s cubic-bezier(.2, .9, .2, 1); }
.panel-eyebrow { margin: 0 0 6px; color: var(--yellow); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.panel h2 { margin: 0 0 16px; color: var(--paper); font: 900 44px/.9 var(--font-display); letter-spacing: .005em; }
.panel-hint { margin: 12px 0 0; color: var(--paper-muted); font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.song-list { display: grid; gap: 8px; }
.song-card { position: relative; min-height: 68px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 10px 56px 10px 16px; border: 1px solid oklch(.95 .026 87 / .22); background: oklch(.31 .028 224 / .55); text-align: left; transition: border-color .15s ease-out, background-color .15s ease-out, transform .15s ease-out; }
.song-card strong { color: var(--paper); font: 900 26px/1 var(--font-display); letter-spacing: .01em; }
.song-card span { color: var(--paper-muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.song-card em { position: absolute; top: 50%; right: 14px; width: 34px; height: 34px; display: grid; place-items: center; background: var(--yellow); color: var(--ink); font-size: 13px; font-style: normal; transform: translateY(-50%); box-shadow: 3px 3px 0 var(--coral); }
.song-card:hover:not(:disabled), .song-card:focus-visible { border-color: var(--yellow); background: oklch(.31 .028 224 / .85); transform: translateX(3px); }
.song-card:disabled { opacity: .55; }
.song-card:disabled em { display: none; }
.play-button { min-height: 54px; display: inline-flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 16px; padding: 0 20px; border: 0; background: var(--yellow); color: var(--ink); font-size: 13px; font-weight: 800; letter-spacing: .1em; box-shadow: 4px 4px 0 var(--coral); transition: transform .14s ease-out, box-shadow .14s ease-out; }
.play-button:hover:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--coral); }
.play-button:disabled { opacity: .6; }
.play-button span { color: var(--coral); font-size: 15px; }
.ghost-button { min-height: 54px; margin-top: 16px; padding: 0 18px; border: 1px solid oklch(.95 .026 87 / .35); background: transparent; font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.ghost-button:hover { border-color: var(--paper); background: oklch(.95 .026 87 / .08); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pause-panel { width: min(460px, 100%); }
.results-head { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; }
.results-head h2 { margin: 0 0 4px; }
.results-head p { margin: 0; color: var(--paper-muted); font-size: 12px; }
.grade { width: 96px; height: 96px; flex: none; display: grid; place-items: center; background: var(--yellow); color: var(--ink); font: 900 78px/1 var(--font-display); box-shadow: 5px 5px 0 var(--coral); animation: grade-in .55s cubic-bezier(.2, 1.4, .3, 1) both; }
.grade[data-grade='S'] { background: var(--cyan); }
.grade[data-grade='C'], .grade[data-grade='D'] { background: var(--paper-muted); }
.results-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0; background: oklch(.95 .026 87 / .14); border: 1px solid oklch(.95 .026 87 / .14); }
.results-best { min-height: 1em; margin: 10px 0 0; color: var(--paper-muted); font-size: 12px; }
.results-grid div { padding: 10px 12px; background: var(--ink-deep); }
.results-grid dt { color: var(--paper-muted); font-size: 8px; font-weight: 700; letter-spacing: .14em; }
.results-grid dd { margin: 4px 0 0; color: var(--paper); font: 900 26px/1 var(--font-display); font-variant-numeric: tabular-nums; }

/* ---------- Motion ---------- */

@keyframes judgement { 0% { opacity: 0; translate: 0 8px; scale: .7; } 18% { opacity: 1; translate: 0 0; scale: 1.12; } 70% { opacity: 1; scale: 1; } 100% { opacity: 0; translate: 0 -12px; } }
@keyframes burst { 0% { opacity: .9; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1) rotate(6deg); } }
@keyframes line-in { from { opacity: .3; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes target-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes mascot { 0% { opacity: 0; transform: translateY(100%); } 20% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(100%); } }
@keyframes wrong { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes shake { 30% { translate: -4px 1px; } 60% { translate: 3px -1px; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes grade-in { from { opacity: 0; transform: scale(.4) rotate(-12deg); } to { opacity: 1; transform: none; } }

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
  .cabinet { width: calc(100% - 24px); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .topbar { min-height: 50px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 6px; padding: 18px 0 14px; }
  .intro h1 { font-size: 46px; }
  .intro p { text-align: left; font-size: 13px; }
  .stage { min-height: 500px; padding: 80px 12px 18px; place-items: start center; }
  .stage::before { background-image: url('assets/stage-phone-concert.png'); background-position: center 30%; }
  .hud { gap: 10px; padding: 10px 12px 8px; }
  .hud-stat strong { font-size: 24px; }
  .hud-combo strong { font-size: 30px; }
  .song-progress { top: 60px; right: 12px; left: 12px; }
  .performer { right: -6%; bottom: 8%; width: 170px; opacity: .8; }
  .crowd { --tile: 110px; }
  .mascot { width: 110px; }
  .panel { padding: 20px 16px 18px; box-shadow: 6px 6px 0 oklch(.12 .02 224 / .6); }
  .panel h2 { font-size: 36px; }
  .results-head { gap: 14px; }
  .grade { width: 72px; height: 72px; font-size: 58px; }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* While a song runs, the stage owns the screen so the lyrics stay above the keyboard. */
  .karaoke { top: 108px; bottom: auto; height: 250px; justify-content: flex-start; padding: 22px 14px 0; gap: 10px; }
  .judgement { top: -2px; font-size: 20px; }
  .type-catcher-label { top: 108px; bottom: auto; height: 250px; }
  .lyric-line.is-current { font-size: clamp(32px, 9vw, 44px); }
  .lyric-line.is-next { font-size: 20px; }
  .lyric-line.is-previous { font-size: 16px; }
  .break-card, .first-hint, .type-hint, .break-card[hidden] + .first-hint { top: 368px; bottom: auto; }
  .break-card:not([hidden]) + .first-hint { top: 472px; }
  .song-card strong { font-size: 22px; }
  body[data-phase='playing'] .intro { display: none; }
  body[data-phase='playing'] .stage { min-height: calc(100dvh - 62px); }
}

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