/* ------------------------------------------------------------------
   GoRun — a tiny, chunky, cute 100m dash
   ------------------------------------------------------------------ */

@font-face {
  font-family: 'Fredoka';
  src: url('./assets/fonts/Fredoka-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: 'Fredoka', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --ink: #46323c;
  --ink-soft: #7a626b;
  --cream: #fff5e6;
  --paper: #fffaf2;
  --coral: #ff778a;
  --coral-deep: #e55168;
  --coral-dark: #b93e52;
  --mint: #7dddc8;
  --mint-deep: #35b29b;
  --sun: #ffd36a;
  --lavender: #cbb7f4;
  --sky: #a8ddf7;
  --outline: 2px solid var(--ink);
  --hard-shadow: 0 5px 0 rgba(70, 50, 60, 0.16);
  --card-shadow: 0 5px 0 rgba(70, 50, 60, 0.14), 0 22px 50px rgba(70, 50, 60, 0.15);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --rush: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f8dfd2;
}

body {
  position: relative;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--mint-deep);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: none;
  fill: currentColor;
  vertical-align: -0.12em;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------
   Stage and atmosphere
   ------------------------------------------------------------------ */

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #8bd2f1 0%, #f4d4e2 55%, #ffe4ca 100%);
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.sky-wash,
.paper-grain,
.speed-vignette,
.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky-wash {
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(255, 243, 226, 0.06) 0%, transparent 24%, transparent 72%, rgba(60, 31, 42, 0.14) 100%),
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.12), transparent 56%);
}

.paper-grain {
  z-index: 2;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.65'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

.speed-vignette {
  z-index: 3;
  opacity: calc(var(--rush) * 0.95);
  background:
    radial-gradient(ellipse at 50% 52%, transparent 19%, rgba(255, 191, 199, 0.16) 49%, rgba(77, 25, 42, 0.5) 100%);
  transition: opacity 0.22s ease;
  overflow: hidden;
}

.speed-vignette::before {
  content: '';
  position: absolute;
  inset: -16%;
  background: repeating-linear-gradient(
    112deg,
    transparent 0 31px,
    rgba(255, 255, 255, 0.46) 31px 32px,
    transparent 32px 80px
  );
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 18%, rgba(0, 0, 0, 0.12) 42%, #000 86%);
  mask-image: radial-gradient(ellipse at center, transparent 18%, rgba(0, 0, 0, 0.12) 42%, #000 86%);
  opacity: 0.44;
  animation: speedScream 0.62s linear infinite;
}

.speed-vignette::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 28%, rgba(255, 139, 154, 0.16) 72%, rgba(255, 219, 212, 0.06) 100%);
  mix-blend-mode: screen;
}

.flash {
  z-index: 80;
  opacity: 0;
  background: #fff4e8;
}

/* ------------------------------------------------------------------
   Loader
   ------------------------------------------------------------------ */

.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 250, 240, 0.92) 0%, rgba(255, 239, 226, 0.8) 35%, rgba(255, 225, 211, 0.9) 100%),
    #fae6d9;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.loader-glow {
  position: absolute;
  width: min(58vw, 460px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 206, 191, 0.52), transparent 64%);
  filter: blur(10px);
  animation: loaderGlow 3.5s ease-in-out infinite;
}

.loader-runner {
  position: relative;
  z-index: 1;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 34px;
  background: linear-gradient(145deg, #fffaf1, #ffe9d9);
  box-shadow: 0 8px 0 rgba(70, 50, 60, 0.18), 0 22px 50px rgba(143, 58, 75, 0.22);
  transform: rotate(-4deg);
  animation: loaderBounce 1.6s var(--ease-out) infinite;
}

.loader-runner svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 0 rgba(96, 37, 51, 0.14));
}

.loader-title {
  position: relative;
  z-index: 1;
  margin: 22px 0 0;
  color: var(--ink);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}

.loader-copy {
  position: relative;
  z-index: 1;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.loader-dots {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 7px;
  margin-top: 16px;
}

.loader-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
  animation: loaderDot 1.2s ease-in-out infinite;
}

.loader-dots i:nth-child(2) {
  animation-delay: 0.16s;
  background: var(--mint-deep);
}

.loader-dots i:nth-child(3) {
  animation-delay: 0.32s;
  background: var(--sun);
}

body.is-ready .loader,
.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   Shared chunky elements
   ------------------------------------------------------------------ */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 22px;
  border: var(--outline);
  border-radius: 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out), background 0.16s ease;
}

.btn .icon {
  width: 1.1em;
  height: 1.1em;
}

.btn-primary {
  color: var(--cream);
  background: linear-gradient(180deg, #ff93a1 0%, #ff6d83 100%);
  box-shadow: 0 5px 0 var(--coral-dark), 0 12px 24px rgba(156, 47, 69, 0.22);
  text-shadow: 0 1px 0 rgba(110, 35, 49, 0.16);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--coral-dark), 0 16px 30px rgba(156, 47, 69, 0.24);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--coral-dark), 0 6px 12px rgba(156, 47, 69, 0.2);
}

.btn-soft {
  color: var(--ink);
  background: rgba(255, 250, 242, 0.86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 0 rgba(70, 50, 60, 0.24);
}

.btn-soft:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 250, 0.94);
  box-shadow: 0 6px 0 rgba(70, 50, 60, 0.2);
}

.btn-soft:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.24);
}

.btn-wide {
  width: 100%;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: color 0.2s ease, transform 0.2s ease;
}

.link-btn .icon {
  width: 14px;
  height: 14px;
}

.link-btn:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

kbd,
.mini-key,
.btn-space {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border: 1.5px solid rgba(70, 50, 60, 0.7);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.22);
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: var(--outline);
  border-radius: 50%;
  background: rgba(255, 249, 240, 0.84);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.22), 0 9px 20px rgba(70, 50, 60, 0.1);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: transform 0.18s var(--ease-out), background 0.18s ease, box-shadow 0.18s ease;
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  transform: translateY(-2px) rotate(-3deg);
  background: var(--paper);
  box-shadow: 0 5px 0 rgba(70, 50, 60, 0.2), 0 12px 22px rgba(70, 50, 60, 0.12);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(70, 50, 60, 0.22);
}

.icon-sound-off {
  display: none;
}

body.is-muted .icon-sound-on {
  display: none;
}

body.is-muted .icon-sound-off {
  display: block;
}

/* ------------------------------------------------------------------
   Top bar
   ------------------------------------------------------------------ */

.topbar {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.86);
  box-shadow: 0 4px 0 rgba(70, 50, 60, 0.16), 0 9px 22px rgba(70, 50, 60, 0.1);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  transform: rotate(-5deg);
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-name {
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  color: var(--ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

body[data-mode='countdown'] #helpBtn,
body[data-mode='running'] #helpBtn {
  display: none;
}

/* ------------------------------------------------------------------
   HUD
   ------------------------------------------------------------------ */

.hud {
  position: fixed;
  top: 86px;
  left: 50%;
  z-index: 26;
  width: min(1100px, calc(100vw - 56px));
  display: grid;
  grid-template-columns: 136px minmax(220px, 1fr) 148px;
  gap: 12px;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity 0.32s ease, transform 0.32s var(--ease-out);
}

body[data-mode='running'] .hud {
  opacity: 1;
  transform: translate(-50%, 0);
}

body[data-mode='finished'] .hud,
body[data-mode='paused'] .hud,
body.go-flash .hud {
  opacity: 0;
  transform: translate(-50%, -6px);
}

.hud-card,
.progress-card {
  border: var(--outline);
  border-radius: 18px;
  background: rgba(255, 249, 240, 0.86);
  box-shadow: 0 4px 0 rgba(70, 50, 60, 0.13), 0 16px 32px rgba(70, 50, 60, 0.12);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
}

.hud-card {
  padding: 9px 15px 10px;
  min-width: 0;
}

.hud-label {
  display: block;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: uppercase;
}

.hud-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-top: 4px;
  line-height: 1;
}

.hud-value strong {
  color: var(--ink);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hud-value em {
  color: var(--ink-soft);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.hud-speed .hud-value {
  gap: 3px;
}

.speed-meter {
  width: 100%;
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(70, 50, 60, 0.13);
}

.speed-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-deep), var(--sun), var(--coral));
  transition: width 0.12s linear;
}

.progress-card {
  padding: 9px 17px 13px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}

.progress-place strong {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.progress-distance {
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.progress-distance strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-rail {
  position: relative;
  height: 10px;
  margin-top: 7px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(70, 50, 60, 0.15), rgba(70, 50, 60, 0.08));
  box-shadow: inset 0 2px 2px rgba(70, 50, 60, 0.12);
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sun) 0%, #ffb281 55%, var(--coral) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.44);
  transition: width 0.1s linear;
}

.progress-runner {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 2;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.18);
  transform: translate(-50%, -50%);
  transition: left 0.1s linear;
}

.progress-runner::before {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--cream);
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 94%, 50% 72%, 21% 94%, 32% 57%, 2% 35%, 39% 34%);
}

.progress-runner::after {
  display: none;
}

.progress-flag {
  position: absolute;
  top: 50%;
  right: -10px;
  width: 15px;
  height: 15px;
  color: var(--ink);
  transform: translateY(-50%);
}

/* ------------------------------------------------------------------
   Step controls
   ------------------------------------------------------------------ */

.step-dock {
  position: fixed;
  bottom: max(22px, calc(12px + env(safe-area-inset-bottom)));
  left: 50%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s var(--ease-out), visibility 0.28s ease;
}

body[data-mode='running'] .step-dock {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.combo-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.22);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.combo-badge .icon {
  width: 13px;
  height: 13px;
  color: #b66d14;
}

.combo-badge strong {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.combo-badge.is-pop {
  animation: comboPop 0.32s var(--ease-out);
}

.step-hint {
  margin: 0;
  padding: 6px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 249, 240, 0.9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

.step-keys {
  display: flex;
  align-items: center;
  gap: 16px;
}

.step-key {
  position: relative;
  width: 88px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  background: rgba(255, 249, 240, 0.9);
  color: var(--ink);
  box-shadow: 0 7px 0 rgba(70, 50, 60, 0.34), 0 16px 26px rgba(70, 50, 60, 0.2);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.step-key .key-icon {
  width: 34px;
  height: 34px;
  transition: transform 0.18s var(--ease-out);
}

.step-key .key-name {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  line-height: 1;
}

.step-key:hover {
  transform: translateY(-2px);
}

.step-key:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.34);
}

.step-key.is-next {
  color: var(--cream);
  background: linear-gradient(180deg, #ff8c9c, #ff6f84);
  box-shadow: 0 7px 0 var(--coral-dark), 0 15px 26px rgba(219, 73, 96, 0.28);
}

.step-key.is-next .key-name {
  color: rgba(255, 245, 230, 0.8);
}

.step-key.is-next::after {
  content: '';
  position: absolute;
  inset: -7px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 28px;
  animation: keyRing 1.3s ease-out infinite;
  pointer-events: none;
}

.step-key.is-next .key-icon {
  transform: translateY(-2px) scale(1.04);
}

.step-key.is-locked {
  opacity: 0.46;
  filter: saturate(0.4);
  pointer-events: none;
  box-shadow: 0 4px 0 rgba(70, 50, 60, 0.2);
}

.step-key.is-hit {
  animation: keyHit 0.16s ease-out;
}

.step-dock.is-locked .step-hint {
  background: rgba(255, 249, 240, 0.74);
}

/* ------------------------------------------------------------------
   Countdown / finish flash
   ------------------------------------------------------------------ */

.countdown-screen {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  background: radial-gradient(circle at 50% 46%, rgba(54, 30, 40, 0.12), transparent 48%);
}

.countdown-screen.is-open {
  opacity: 1;
  visibility: visible;
}

.countdown-halo {
  position: absolute;
  width: min(58vw, 520px);
  aspect-ratio: 1;
  border: 2px dashed rgba(255, 246, 233, 0.44);
  border-radius: 50%;
  animation: haloSpin 19s linear infinite;
}

.countdown-halo::before,
.countdown-halo::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}

.countdown-halo::before {
  inset: 11%;
  border: 1px solid rgba(255, 246, 233, 0.24);
}

.countdown-halo::after {
  inset: 25%;
  background: radial-gradient(circle, rgba(255, 246, 233, 0.12), transparent 70%);
}

.countdown-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateY(-2vh);
  transition: transform 0.42s var(--ease-out);
  text-align: center;
}

.countdown-screen.is-go .countdown-inner {
  transform: translateY(-25vh) scale(0.9);
}

.countdown-screen.is-intro .countdown-inner {
  transform: translateY(-29vh) scale(0.58);
}

.countdown-screen.is-intro .countdown-kicker,
.countdown-screen.is-intro .countdown-sub {
  display: none;
}

.countdown-screen.is-intro .countdown-halo {
  opacity: 0.24;
}

.countdown-kicker {
  margin: 0 0 6px;
  padding: 6px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.18);
}

.countdown-number {
  min-width: 2ch;
  color: var(--cream);
  font-size: clamp(152px, 24vw, 270px);
  font-weight: 700;
  letter-spacing: -0.09em;
  line-height: 0.82;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 9px 0 var(--coral-deep), 0 18px 35px rgba(75, 40, 54, 0.2);
  transform-origin: center;
}

.countdown-number.is-pop {
  animation: countPop 0.74s var(--ease-out) both;
}

.countdown-sub {
  margin: 20px 0 0;
  padding: 7px 15px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 249, 240, 0.88);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.16);
}

.countdown-screen.is-go .countdown-number {
  color: var(--mint);
  font-size: clamp(105px, 15vw, 185px);
  letter-spacing: -0.06em;
  text-shadow: 0 9px 0 var(--mint-deep), 0 18px 35px rgba(75, 40, 54, 0.2);
}

.countdown-screen.is-go .countdown-kicker,
.countdown-screen.is-go .countdown-sub {
  display: none;
}

.countdown-screen.is-go .countdown-kicker {
  background: var(--sun);
  transform: rotate(-3deg);
}

.finish-banner {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: grid;
  place-content: center;
  gap: 4px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  text-align: center;
}

.finish-banner.is-visible {
  visibility: visible;
  animation: finishBurst 1.3s var(--ease-out) both;
}

.finish-banner span {
  display: block;
  color: var(--cream);
  font-size: clamp(86px, 14vw, 176px);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.9;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 0 9px 0 var(--coral-deep), 0 20px 38px rgba(70, 44, 54, 0.25);
  transform: rotate(-3deg);
}

.finish-banner small {
  justify-self: center;
  padding: 5px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  transform: rotate(2deg);
}

/* ------------------------------------------------------------------
   Screens
   ------------------------------------------------------------------ */

.screen {
  position: fixed;
  inset: 0;
  z-index: 28;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.48s ease, visibility 0.48s ease;
}

.screen.is-open {
  opacity: 1;
  visibility: visible;
}

/* ------------------------------------------------------------------
   Menu
   ------------------------------------------------------------------ */

.menu-screen {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(92px, 12vh, 138px) clamp(26px, 5.6vw, 86px) clamp(62px, 8vh, 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse 62% 82% at 12% 52%, rgba(255, 249, 240, 0.95) 0%, rgba(255, 249, 240, 0.74) 29%, rgba(255, 249, 240, 0) 68%),
    linear-gradient(90deg, rgba(255, 247, 236, 0.18) 0%, rgba(255, 247, 236, 0) 62%);
}

.menu-panel {
  position: relative;
  width: min(490px, 43vw);
  pointer-events: auto;
}

.menu-eyebrow,
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.19em;
  line-height: 1;
  text-transform: uppercase;
}

.eyebrow-mark {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.14);
}

.eyebrow-mark .icon {
  width: 11px;
  height: 11px;
}

.hero-logo {
  position: relative;
  width: fit-content;
  margin: 0;
  color: var(--coral);
  font-size: clamp(82px, 10.8vw, 154px);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.8;
  transform: rotate(-2deg);
  text-shadow:
    -4px -4px 0 var(--cream), 4px -4px 0 var(--cream),
    -4px 4px 0 var(--cream), 4px 4px 0 var(--cream),
    0 4px 0 var(--cream), 4px 0 0 var(--cream), -4px 0 0 var(--cream), 0 -4px 0 var(--cream),
    0 13px 0 rgba(70, 50, 60, 0.92),
    0 24px 36px rgba(85, 45, 57, 0.22);
}

.hero-accent {
  color: var(--mint-deep);
}

.logo-spark {
  position: absolute;
  top: -0.03em;
  right: -0.2em;
  width: 0.27em;
  height: 0.27em;
  animation: sparkleSpin 7s linear infinite;
}

.logo-spark svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 0 rgba(70, 50, 60, 0.18));
}

.hero-tagline {
  margin: clamp(30px, 4.2vh, 44px) 0 0;
  color: var(--ink);
  font-size: clamp(19px, 2vw, 25px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.hero-copy {
  max-width: 410px;
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.78;
}

.menu-actions {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: clamp(26px, 3.7vh, 38px);
}

.btn-hero {
  min-height: 64px;
  padding: 0 21px 0 15px;
  border-radius: 21px;
  font-size: 18px;
  letter-spacing: 0.01em;
  box-shadow: 0 7px 0 var(--coral-dark), 0 17px 30px rgba(156, 47, 69, 0.24);
}

.btn-hero:hover {
  box-shadow: 0 9px 0 var(--coral-dark), 0 22px 36px rgba(156, 47, 69, 0.27);
}

.btn-play {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(255, 249, 240, 0.64);
  border-radius: 50%;
  background: rgba(255, 249, 240, 0.15);
}

.btn-play .icon {
  width: 18px;
  height: 18px;
  margin-left: 2px;
}

.btn-space {
  height: 21px;
  margin-left: 3px;
  border-color: rgba(70, 50, 60, 0.18);
  background: rgba(255, 249, 240, 0.92);
  color: var(--ink);
  box-shadow: none;
  font-size: 9px;
  font-weight: 600;
}

.menu-actions .btn-soft {
  min-height: 56px;
  padding: 0 24px;
  border-radius: 18px;
  font-size: 14px;
}

.menu-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.best-pill,
.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  border: 1.5px solid rgba(70, 50, 60, 0.38);
  border-radius: 999px;
  background: rgba(255, 249, 240, 0.7);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 500;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.best-pill .icon {
  width: 15px;
  height: 15px;
  color: var(--coral-deep);
}

.best-pill strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.best-pill small {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
}

.key-pill {
  gap: 4px;
  padding-right: 12px;
}

.key-pill .mini-key {
  min-width: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-width: 1.5px;
  border-radius: 6px;
  font-size: 12px;
}

.key-pill > span:last-child {
  margin-left: 2px;
}

.menu-foot {
  position: fixed;
  right: clamp(26px, 4vw, 54px);
  bottom: max(22px, calc(12px + env(safe-area-inset-bottom)));
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: rgba(70, 50, 60, 0.48);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
}

.foot-dot {
  opacity: 0.6;
}

/* Staggered entrance on the title card. */
.menu-screen.is-open .menu-panel > * {
  opacity: 0;
  animation: revealUp 0.7s var(--ease-out) forwards;
}

.menu-screen.is-open .menu-panel > *:nth-child(1) {
  animation-delay: 0.05s;
}
.menu-screen.is-open .menu-panel > *:nth-child(2) {
  animation-delay: 0.1s;
}
.menu-screen.is-open .menu-panel > *:nth-child(3) {
  animation-delay: 0.17s;
}
.menu-screen.is-open .menu-panel > *:nth-child(4) {
  animation-delay: 0.22s;
}
.menu-screen.is-open .menu-panel > *:nth-child(5) {
  animation-delay: 0.27s;
}
.menu-screen.is-open .menu-panel > *:nth-child(6) {
  animation-delay: 0.32s;
}
.menu-screen.is-open .menu-panel > *:nth-child(7) {
  animation-delay: 0.36s;
}

/* ------------------------------------------------------------------
   Results
   ------------------------------------------------------------------ */

.results-screen {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(92px, 12vh, 120px) clamp(20px, 6vw, 96px) 42px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse 68% 88% at 8% 50%, rgba(58, 35, 44, 0.34) 0%, rgba(58, 35, 44, 0.14) 44%, transparent 72%),
    linear-gradient(90deg, rgba(58, 35, 44, 0.12), transparent 64%);
}

.result-card {
  position: relative;
  width: min(480px, 42vw);
  max-height: calc(100dvh - 110px);
  padding: 27px 30px 22px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 2.5px solid var(--ink);
  border-radius: 32px;
  background:
    radial-gradient(circle at 92% 5%, rgba(255, 211, 106, 0.14), transparent 28%),
    rgba(255, 250, 242, 0.96);
  box-shadow: 0 8px 0 rgba(70, 50, 60, 0.26), 0 35px 75px rgba(45, 25, 33, 0.28);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
  backdrop-filter: blur(20px) saturate(1.1);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(18px) rotate(-0.4deg) scale(0.98);
  transition: opacity 0.45s var(--ease-out), transform 0.55s var(--ease-out);
}

.results-screen.is-open .result-card {
  opacity: 1;
  transform: translateY(0) rotate(-0.4deg) scale(1);
  transition-delay: 0.12s;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--coral) 0 33%, var(--sun) 33% 66%, var(--mint-deep) 66% 100%);
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.finish-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  padding: 0 11px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  color: #22665c;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.12);
}

.finish-tag .icon {
  width: 12px;
  height: 12px;
}

.grade-badge {
  position: relative;
  width: 78px;
  height: 78px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(70, 50, 60, 0.22);
  transform: rotate(5deg);
}

.grade-badge::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(70, 50, 60, 0.34);
  border-radius: 50%;
}

.grade-badge strong {
  font-size: 35px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.grade-badge span {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 1;
}

.grade-badge[data-grade='S'] {
  background: linear-gradient(145deg, #ffe391, var(--sun));
}

.grade-badge[data-grade='A'] {
  background: linear-gradient(145deg, #9cead9, var(--mint));
}

.grade-badge[data-grade='B'] {
  background: linear-gradient(145deg, #dfd1ff, var(--lavender));
}

.grade-badge[data-grade='C'] {
  background: linear-gradient(145deg, #ffd9cb, #ffb7a7);
}

.place-badge {
  position: relative;
  width: 78px;
  height: 78px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe391, var(--sun));
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(70, 50, 60, 0.22);
  transform: rotate(5deg);
}

.place-badge::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(70, 50, 60, 0.34);
  border-radius: 50%;
}

.place-badge strong {
  font-size: 35px;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.place-badge span {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1;
}

.place-badge[data-place='2'] {
  background: linear-gradient(145deg, #eef2f3, #c8d5da);
}

.place-badge[data-place='3'] {
  background: linear-gradient(145deg, #f3c7ad, #dd9a77);
}

.place-badge[data-place='other'] {
  background: linear-gradient(145deg, #d8eee8, var(--mint));
}

.race-board {
  margin-top: 13px;
  overflow: hidden;
  border: 1.5px solid rgba(70, 50, 60, 0.15);
  border-radius: 14px;
  background: rgba(255, 246, 233, 0.72);
}

.race-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px 6px;
  border-bottom: 1px solid rgba(70, 50, 60, 0.12);
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.race-board-head span:last-child {
  letter-spacing: 0.06em;
}

.race-board-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.race-row {
  --row-color: var(--coral);
  display: grid;
  grid-template-columns: 18px 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 9px;
  border-top: 1px solid rgba(70, 50, 60, 0.075);
}

.race-row:first-child {
  border-top: 0;
}

.race-rank {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(70, 50, 60, 0.08);
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.race-row[data-rank='1'] .race-rank {
  background: var(--sun);
  color: var(--ink);
}

.race-row[data-rank='2'] .race-rank {
  background: #dce6e9;
  color: var(--ink);
}

.race-row[data-rank='3'] .race-rank {
  background: #e9b28f;
  color: var(--ink);
}

.race-dot {
  width: 8px;
  height: 8px;
  border: 1px solid rgba(70, 50, 60, 0.38);
  border-radius: 50%;
  background: var(--row-color);
}

.race-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
}

.race-name b {
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.race-name small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.race-time {
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.race-time small {
  margin-left: 1px;
  color: var(--ink-soft);
  font-size: 7px;
  font-weight: 500;
}

.race-row.is-you {
  background: rgba(107, 214, 192, 0.24);
  box-shadow: inset 0 0 0 1.5px var(--mint-deep);
}

.race-row.is-you .race-name b {
  color: #22665c;
}

.help-disclaimer {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.5;
  text-align: center;
  opacity: 0.76;
}

.result-card h2 {
  margin: 17px 0 5px;
  color: var(--ink);
  font-size: clamp(26px, 2.4vw, 32px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.result-summary {
  min-height: 2.8em;
  margin: 0 0 13px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.result-time-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 11px 14px;
  margin-bottom: 17px;
}

.result-time {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--ink);
}

.result-time strong {
  font-size: clamp(52px, 6.2vw, 76px);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.result-time span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.new-best {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--coral);
  color: var(--cream);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.16);
  transform: rotate(-2deg);
  animation: newBestPop 0.55s var(--ease-out) both 0.25s;
}

.new-best .icon {
  width: 12px;
  height: 12px;
  color: var(--sun);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 11px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 41px;
  padding: 6px 7px;
  border: 1.5px solid rgba(70, 50, 60, 0.14);
  border-radius: 11px;
  background: rgba(255, 246, 233, 0.7);
  text-align: center;
}

.result-stat span {
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.result-stat strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.result-stat small {
  margin-left: 3px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 500;
}

.result-actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
}

.result-actions .btn {
  flex: 1;
  min-height: 49px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 14px;
}

.result-actions .btn-primary {
  flex: 1.2;
}

#homeBtn {
  display: flex;
  margin: 8px auto 0;
}

/* ------------------------------------------------------------------
   Pause
   ------------------------------------------------------------------ */

.pause-screen {
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(54, 32, 41, 0.36);
  -webkit-backdrop-filter: blur(9px) saturate(0.9);
  backdrop-filter: blur(9px) saturate(0.9);
}

.pause-screen.is-open {
  pointer-events: auto;
}

.pause-card {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 27px 29px 22px;
  border: 2.5px solid var(--ink);
  border-radius: 32px;
  background: radial-gradient(circle at 80% 0%, rgba(255, 211, 106, 0.16), transparent 34%), var(--paper);
  box-shadow: 0 8px 0 rgba(70, 50, 60, 0.28), 0 30px 65px rgba(46, 25, 34, 0.34);
  text-align: center;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.4s var(--ease-out);
}

.pause-screen.is-open .pause-card {
  transform: translateY(0) scale(1);
}

.pause-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 4px 0 rgba(70, 50, 60, 0.18);
  transform: rotate(-4deg);
}

.pause-badge .icon {
  width: 25px;
  height: 25px;
}

.pause-card .eyebrow {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.pause-card h2 {
  margin: 0 0 7px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.pause-copy {
  margin: 0 auto 22px;
  max-width: 280px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.pause-actions .btn {
  min-height: 48px;
  border-radius: 16px;
}

.pause-hint {
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.pause-hint kbd {
  height: 20px;
  min-width: 20px;
  font-size: 9px;
}

/* ------------------------------------------------------------------
   Help modal
   ------------------------------------------------------------------ */

.modal-screen {
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(50, 30, 39, 0.4);
  -webkit-backdrop-filter: blur(10px) saturate(0.88);
  backdrop-filter: blur(10px) saturate(0.88);
}

.modal-screen.is-open {
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 29px 30px 23px;
  border: 2.5px solid var(--ink);
  border-radius: 30px;
  background: radial-gradient(circle at 100% 0%, rgba(255, 211, 106, 0.15), transparent 31%), var(--paper);
  box-shadow: 0 8px 0 rgba(70, 50, 60, 0.3), 0 35px 75px rgba(45, 25, 33, 0.36);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.4s var(--ease-out);
}

.modal-screen.is-open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 37px;
  height: 37px;
}

.modal-close .icon {
  width: 17px;
  height: 17px;
}

.help-card .eyebrow {
  margin-bottom: 8px;
}

.help-card h2 {
  margin: 0 0 14px;
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.help-demo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
  padding: 11px 13px;
  border: 1.5px dashed rgba(70, 50, 60, 0.28);
  border-radius: 16px;
  background: rgba(125, 221, 200, 0.16);
}

.demo-key {
  width: 45px;
  height: 43px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--paper);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.2);
  animation: demoKeyPulse 1.8s ease-in-out infinite;
}

.demo-key:nth-child(2) {
  animation-delay: 0.9s;
}

.demo-light {
  margin-left: 5px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-list li {
  display: flex;
  gap: 11px;
  padding: 9px 11px;
  border: 1.5px solid rgba(70, 50, 60, 0.1);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.34);
}

.help-list li.is-warning {
  border-color: rgba(229, 81, 104, 0.24);
  background: rgba(255, 119, 138, 0.08);
}

.help-num {
  width: 27px;
  height: 27px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.12);
}

.is-warning .help-num {
  background: var(--coral);
  color: var(--cream);
}

.help-list b {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.help-list p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.help-list kbd {
  height: 19px;
  min-width: 19px;
  padding: 0 4px;
  font-size: 9px;
}

.help-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 13px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.help-tip .icon {
  width: 12px;
  height: 12px;
  color: var(--coral);
}

/* ------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------ */

.toast {
  position: fixed;
  top: clamp(168px, 22vh, 212px);
  left: 50%;
  z-index: 45;
  max-width: min(88vw, 420px);
  padding: 9px 17px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 4px 0 rgba(70, 50, 60, 0.18), 0 12px 26px rgba(70, 50, 60, 0.18);
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.24s var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.toast[data-tone='good'] {
  background: var(--mint-deep);
  color: #053f36;
}

.toast[data-tone='bad'] {
  background: var(--coral);
  color: #4c1b25;
}

/* ------------------------------------------------------------------
   Fatal / no WebGL
   ------------------------------------------------------------------ */

.fatal-wrap {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 251, 242, 0.96), rgba(250, 225, 212, 0.98));
}

.fatal {
  width: min(460px, 100%);
  padding: 28px;
  border: 2.5px solid var(--ink);
  border-radius: 30px;
  background: var(--paper);
  box-shadow: var(--card-shadow);
  text-align: center;
}

.fatal h1 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.fatal p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

noscript .fatal {
  position: fixed;
  inset: 0;
  z-index: 200;
  width: 100%;
  max-width: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: #fae6d9;
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 1080px) {
  .hud {
    width: calc(100vw - 40px);
    grid-template-columns: 120px minmax(180px, 1fr) 132px;
    gap: 9px;
  }

  .menu-panel {
    width: min(470px, 52vw);
  }
}

@media (max-width: 900px) {
  .topbar {
    top: max(14px, env(safe-area-inset-top));
    left: 16px;
    right: 16px;
  }

  .hud {
    top: 78px;
    width: calc(100vw - 28px);
    grid-template-columns: 110px minmax(160px, 1fr) 124px;
    gap: 7px;
  }

  .hud-card {
    padding: 8px 11px 9px;
  }

  .hud-value strong {
    font-size: 23px;
  }

  .progress-card {
    padding: 8px 12px 11px;
  }

  .menu-screen {
    align-items: flex-end;
    justify-content: center;
    padding: max(80px, calc(66px + env(safe-area-inset-top))) 16px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(255, 247, 236, 0) 0%, rgba(255, 247, 236, 0) 52%, rgba(255, 247, 236, 0.08) 100%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    touch-action: pan-y;
  }

  .menu-panel {
    width: min(560px, 94vw);
    padding: 26px 24px 24px;
    border: 2.5px solid var(--ink);
    border-radius: 32px;
    background: rgba(255, 249, 240, 0.92);
    box-shadow: 0 7px 0 rgba(70, 50, 60, 0.18), 0 -18px 50px rgba(48, 27, 37, 0.14);
    -webkit-backdrop-filter: blur(18px) saturate(1.05);
    backdrop-filter: blur(18px) saturate(1.05);
    text-align: center;
  }

  .menu-eyebrow {
    justify-content: center;
  }

  .hero-logo {
    margin-inline: auto;
    font-size: clamp(88px, 17vw, 136px);
  }

  .hero-tagline {
    margin-top: 26px;
  }

  .hero-copy {
    margin: 9px auto 0;
  }

  .menu-actions,
  .menu-meta {
    justify-content: center;
  }

  .menu-actions {
    flex-wrap: wrap;
  }

  .menu-foot {
    display: none;
  }

  .results-screen {
    align-items: center;
    justify-content: center;
    padding: 92px 20px 30px;
    background: rgba(47, 28, 36, 0.34);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
  }

  .result-card {
    width: min(480px, 92vw);
    max-height: calc(100dvh - 122px);
    overflow-y: auto;
  }

  .toast {
    top: 154px;
  }
}

@media (max-width: 680px) {
  .brand {
    gap: 7px;
    padding: 4px 9px 4px 5px;
  }

  .brand-mark {
    width: 29px;
    height: 29px;
  }

  .brand-name {
    font-size: 17px;
  }

  .brand-chip {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 37px;
    height: 37px;
  }

  .icon-btn .icon {
    width: 18px;
    height: 18px;
  }

  .hud {
    top: max(69px, calc(60px + env(safe-area-inset-top)));
    width: calc(100vw - 20px);
    grid-template-columns: 84px minmax(0, 1fr) 91px;
    gap: 5px;
  }

  .hud-card {
    padding: 7px 9px 8px;
    border-radius: 14px;
  }

  .hud-label {
    font-size: 8px;
    letter-spacing: 0.12em;
  }

  .hud-value {
    gap: 2px;
    margin-top: 3px;
  }

  .hud-value strong {
    font-size: 20px;
  }

  .hud-value em {
    font-size: 8px;
  }

  .speed-meter {
    height: 4px;
    margin-top: 5px;
  }

  .progress-card {
    padding: 7px 10px 9px;
    border-radius: 14px;
  }

  .progress-meta {
    font-size: 8px;
  }

  .progress-meta > span:last-child {
    display: none;
  }

  .progress-place {
    letter-spacing: 0.04em;
  }

  .progress-place strong {
    font-size: 10px;
  }


  .progress-distance {
    font-size: 9px;
  }

  .progress-distance strong {
    font-size: 11px;
  }

  .progress-rail {
    height: 9px;
    margin-top: 5px;
  }

  .progress-runner {
    width: 18px;
    height: 18px;
  }

  .progress-runner::before {
    inset: 4px;
  }

  .progress-runner::after {
    display: none;
  }

  .progress-flag {
    width: 13px;
    height: 13px;
    right: -8px;
  }

  .step-dock {
    bottom: max(12px, calc(6px + env(safe-area-inset-bottom)));
    gap: 6px;
  }

  .step-hint {
    font-size: 10.5px;
    padding: 5px 11px;
  }

  .combo-badge {
    padding: 4px 9px;
    font-size: 10px;
  }

  .step-keys {
    gap: 12px;
  }

  .step-key {
    width: 74px;
    height: 68px;
    border-radius: 18px;
    border-width: 2px;
    box-shadow: 0 5px 0 rgba(70, 50, 60, 0.34), 0 12px 20px rgba(70, 50, 60, 0.18);
  }

  .step-key .key-icon {
    width: 28px;
    height: 28px;
  }

  .step-key .key-name {
    font-size: 8px;
  }

  .step-key.is-next {
    box-shadow: 0 5px 0 var(--coral-dark), 0 12px 20px rgba(219, 73, 96, 0.24);
  }

  .step-key.is-next::after {
    inset: -5px;
    border-radius: 22px;
  }

  .countdown-halo {
    width: min(80vw, 400px);
  }

  .countdown-sub {
    font-size: 10.5px;
    margin-top: 16px;
  }

  .menu-screen {
    align-items: flex-end;
    justify-content: center;
    padding: max(74px, calc(62px + env(safe-area-inset-top))) 10px max(10px, env(safe-area-inset-bottom));
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(255, 247, 236, 0) 0%, rgba(255, 247, 236, 0) 48%, rgba(255, 247, 236, 0.12) 100%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .menu-panel {
    width: min(540px, 100%);
    padding: 16px 17px calc(14px + env(safe-area-inset-bottom));
    border: 2.5px solid var(--ink);
    border-radius: 27px;
    background: rgba(255, 249, 240, 0.94);
    box-shadow: 0 7px 0 rgba(70, 50, 60, 0.2), 0 -18px 45px rgba(48, 27, 37, 0.14);
    -webkit-backdrop-filter: blur(18px) saturate(1.05);
    backdrop-filter: blur(18px) saturate(1.05);
    text-align: center;
  }

  .menu-eyebrow {
    margin-bottom: 5px;
    font-size: 8px;
    letter-spacing: 0.16em;
  }

  .eyebrow-mark {
    width: 18px;
    height: 18px;
  }

  .eyebrow-mark .icon {
    width: 9px;
    height: 9px;
  }

  .hero-logo {
    margin-inline: auto;
    font-size: clamp(58px, 20vw, 92px);
  }

  .logo-spark {
    right: -0.18em;
    top: -0.03em;
    width: 0.24em;
    height: 0.24em;
  }

  .hero-tagline {
    margin-top: 15px;
    font-size: 16px;
  }

  .hero-copy {
    display: block;
    max-width: 315px;
    margin: 6px auto 0;
    font-size: 11.5px;
    line-height: 1.55;
  }

  .menu-actions {
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 12px;
  }

  .btn-hero {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 51px;
    padding: 0 13px;
    font-size: 15px;
    border-radius: 16px;
  }

  .menu-actions .btn-soft {
    width: auto;
    flex: 0 0 auto;
    min-height: 51px;
    padding: 0 16px;
    font-size: 12.5px;
    border-radius: 16px;
  }

  .btn-space {
    display: none;
  }

  .btn-play {
    width: 30px;
    height: 30px;
  }

  .btn-play .icon {
    width: 15px;
    height: 15px;
  }

  .menu-meta {
    gap: 6px;
    margin-top: 9px;
  }

  .best-pill,
  .key-pill {
    min-height: 31px;
    padding: 0 9px;
    font-size: 9px;
  }

  .best-pill strong {
    font-size: 13px;
  }

  .key-pill .mini-key {
    width: 20px;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .results-screen {
    align-items: center;
    padding: max(74px, calc(62px + env(safe-area-inset-top))) 10px max(14px, calc(8px + env(safe-area-inset-bottom)));
  }

  .result-card {
    width: min(480px, 100%);
    max-height: calc(100dvh - 104px);
    overflow-y: auto;
    padding: 21px 18px 17px;
    border-radius: 26px;
  }

  .grade-badge {
    width: 66px;
    height: 66px;
  }

  .grade-badge strong {
    font-size: 30px;
  }

  .result-card h2 {
    margin-top: 13px;
    font-size: 25px;
  }

  .result-summary {
    min-height: 0;
    margin-bottom: 10px;
    font-size: 12px;
  }

  .result-time-wrap {
    margin-bottom: 13px;
    gap: 8px 10px;
  }

  .result-time strong {
    font-size: 48px;
  }

  .result-time span {
    font-size: 11px;
  }

  .new-best {
    font-size: 9px;
    padding: 4px 8px;
  }

  .result-stats {
    gap: 6px;
  }

  .result-stat {
    min-height: 50px;
    padding: 7px 10px;
  }

  .result-stat span {
    font-size: 8px;
  }

  .result-stat strong {
    font-size: 16px;
  }

  .result-actions {
    margin-top: 13px;
    gap: 7px;
  }

  .result-actions .btn {
    min-height: 45px;
    padding: 0 8px;
    font-size: 12.5px;
    border-radius: 14px;
  }

  #homeBtn {
    margin-top: 4px;
    font-size: 11px;
  }

  .pause-screen,
  .modal-screen {
    padding: 14px;
  }

  .pause-card {
    padding: 23px 20px 18px;
    border-radius: 27px;
  }

  .pause-badge {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
  }

  .pause-card h2 {
    font-size: 26px;
  }

  .pause-copy {
    margin-bottom: 17px;
    font-size: 12px;
  }

  .modal-card {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 28px);
    padding: 24px 17px 18px;
    border-radius: 25px;
  }

  .help-card h2 {
    font-size: 24px;
  }

  .help-demo {
    padding: 9px;
    margin-bottom: 11px;
  }

  .demo-key {
    width: 39px;
    height: 37px;
    font-size: 19px;
  }

  .demo-light {
    font-size: 10px;
  }

  .help-list li {
    padding: 8px 9px;
  }

  .help-list b {
    font-size: 12px;
  }

  .help-list p {
    font-size: 11px;
  }

  .help-num {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  .toast {
    top: max(128px, calc(118px + env(safe-area-inset-top)));
    max-width: 86vw;
    font-size: 11px;
    padding: 7px 13px;
  }

  .finish-banner span {
    font-size: clamp(66px, 17vw, 118px);
  }
}

@media (max-width: 380px) {
  .hud {
    grid-template-columns: 78px minmax(0, 1fr) 84px;
  }

  .hud-value strong {
    font-size: 18px;
  }

  .hero-logo {
    font-size: clamp(68px, 22vw, 96px);
  }

  .hero-tagline {
    font-size: 16px;
  }

  .step-hint {
    max-width: 92vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-height: 580px) and (orientation: landscape) {
  .topbar {
    top: 10px;
  }

  .brand {
    padding: 3px 9px 3px 4px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
  }

  .brand-name {
    font-size: 16px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .hud {
    top: 58px;
    width: min(840px, calc(100vw - 24px));
    grid-template-columns: 94px minmax(150px, 1fr) 105px;
    gap: 6px;
  }

  .hud-card {
    padding: 6px 10px;
  }

  .hud-value strong {
    font-size: 19px;
  }

  .progress-card {
    padding: 6px 11px 8px;
  }

  .menu-screen {
    align-items: center;
    justify-content: flex-start;
    padding: 60px 5vw 22px;
    background: radial-gradient(ellipse 50% 100% at 8% 50%, rgba(255, 249, 240, 0.9), transparent 68%);
  }

  .menu-panel {
    width: min(430px, 49vw);
    padding: 15px 18px;
    border: 0;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    text-align: left;
  }

  .menu-eyebrow {
    justify-content: flex-start;
    margin-bottom: 7px;
  }

  .hero-logo {
    margin-inline: 0;
    font-size: clamp(56px, 10vw, 84px);
  }

  .hero-tagline {
    margin-top: 17px;
    font-size: 16px;
  }

  .hero-copy {
    display: none;
  }

  .menu-actions {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .btn-hero {
    width: auto;
    flex: 0 1 auto;
    min-height: 47px;
    font-size: 15px;
    border-radius: 15px;
  }

  .menu-actions .btn-soft {
    width: auto;
    min-height: 43px;
    font-size: 12px;
    border-radius: 14px;
  }

  .menu-meta {
    justify-content: flex-start;
    margin-top: 11px;
  }

  .menu-foot {
    display: none;
  }

  .step-dock {
    bottom: 8px;
    gap: 4px;
  }

  .step-key {
    width: 66px;
    height: 58px;
    border-radius: 15px;
  }

  .step-key .key-icon {
    width: 23px;
    height: 23px;
  }

  .step-hint {
    font-size: 10px;
    padding: 4px 10px;
  }

  .countdown-number {
    font-size: clamp(110px, 18vw, 180px);
  }

  .countdown-screen.is-go .countdown-number {
    font-size: clamp(96px, 15vw, 160px);
  }

  .countdown-sub {
    margin-top: 10px;
  }

  .results-screen {
    align-items: center;
    justify-content: flex-start;
    padding: 52px 5vw 10px;
    background: radial-gradient(ellipse 62% 100% at 38% 50%, rgba(47, 28, 36, 0.34), transparent 76%);
  }

  .result-card {
    width: min(500px, 56vw);
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
    padding: 11px 15px 8px;
    border-radius: 20px;
  }

  .result-head {
    align-items: center;
    gap: 9px;
  }

  .finish-tag {
    min-height: 22px;
    padding: 0 8px;
    gap: 4px;
    font-size: 7.5px;
  }

  .finish-tag .icon {
    width: 10px;
    height: 10px;
  }

  .grade-badge {
    width: 50px;
    height: 50px;
  }

  .grade-badge strong {
    font-size: 22px;
  }

  .grade-badge span {
    font-size: 6.5px;
  }

  .result-card h2 {
    margin: 7px 0 2px;
    font-size: 19px;
  }

  .result-summary {
    min-height: 0;
    margin-bottom: 5px;
    font-size: 10px;
    line-height: 1.5;
  }

  .result-time-wrap {
    margin-bottom: 6px;
    gap: 5px 8px;
  }

  .result-time strong {
    font-size: 38px;
  }

  .result-time span {
    font-size: 10px;
  }

  .new-best {
    padding: 3px 6px;
    font-size: 8px;
  }

  .new-best .icon {
    width: 10px;
    height: 10px;
  }

  .result-stats {
    gap: 4px;
  }

  .result-stat {
    min-height: 34px;
    padding: 4px 8px;
    border-radius: 9px;
    gap: 1px;
  }

  .result-stat span {
    font-size: 7.5px;
  }

  .result-stat strong {
    font-size: 14px;
  }

  .result-stat small {
    font-size: 7px;
  }

  .result-actions {
    margin-top: 6px;
    gap: 6px;
  }

  .result-card .result-actions .btn {
    min-height: 32px;
    padding: 0 8px;
    font-size: 11px;
    border-radius: 11px;
  }

  #homeBtn {
    margin-top: 2px;
    padding: 2px 6px;
    font-size: 9px;
  }

  #homeBtn .icon {
    width: 10px;
    height: 10px;
  }

  .finish-banner span {
    font-size: clamp(68px, 13vw, 110px);
  }

  .pause-screen {
    padding: 10px;
  }

  .pause-card {
    max-height: calc(100dvh - 20px);
    padding: 13px 18px 10px;
    border-radius: 22px;
  }

  .pause-badge {
    width: 42px;
    height: 42px;
    margin-bottom: 7px;
  }

  .pause-badge .icon {
    width: 17px;
    height: 17px;
  }

  .pause-card .eyebrow {
    margin-bottom: 4px;
    font-size: 8px;
  }

  .pause-card h2 {
    margin-bottom: 3px;
    font-size: 22px;
  }

  .pause-copy {
    margin-bottom: 10px;
    font-size: 11px;
  }

  .pause-actions {
    gap: 6px;
  }

  .pause-actions .btn {
    min-height: 35px;
    border-radius: 12px;
    font-size: 12px;
  }

  .pause-hint {
    margin-top: 7px;
    font-size: 9px;
  }

  .pause-hint kbd {
    height: 17px;
    min-width: 17px;
    font-size: 8px;
  }
}

@media (max-height: 820px) and (min-width: 681px) {
  .results-screen {
    padding-top: 76px;
    padding-bottom: 24px;
  }

  .result-card {
    max-height: calc(100dvh - 90px);
    padding: 18px 24px 15px;
  }

  .result-card h2 {
    margin: 10px 0 3px;
    font-size: 26px;
  }

  .result-summary {
    min-height: 0;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.45;
  }

  .result-time-wrap {
    margin-bottom: 9px;
  }

  .result-time strong {
    font-size: 58px;
  }

  .place-badge {
    width: 64px;
    height: 64px;
  }

  .place-badge strong {
    font-size: 28px;
  }

  .result-stats {
    margin-top: 8px;
  }

  .race-board {
    margin-top: 8px;
  }

  .race-board-head {
    padding: 5px 9px;
  }

  .race-row {
    min-height: 24px;
    padding: 2px 8px;
  }

  .result-actions {
    margin-top: 10px;
  }

  .result-actions .btn {
    min-height: 40px;
  }

  .link-btn {
    margin-top: 8px;
  }
}

@media (max-width: 680px) {
  .place-badge {
    width: 64px;
    height: 64px;
  }

  .place-badge strong {
    font-size: 29px;
  }

  .place-badge span {
    font-size: 7px;
  }

  .result-time strong {
    font-size: clamp(44px, 12vw, 58px);
  }

  .race-board {
    margin-top: 10px;
  }

  .race-row {
    min-height: 26px;
    padding: 3px 8px;
  }

  .race-name b {
    font-size: 10px;
  }

  .race-name small {
    font-size: 7px;
  }

  .race-time {
    font-size: 10px;
  }
}

@media (max-height: 580px) and (orientation: landscape) {
  .place-badge {
    width: 54px;
    height: 54px;
  }

  .place-badge strong {
    font-size: 24px;
  }

  .place-badge span {
    font-size: 6px;
  }

  .result-card h2 {
    margin-top: 8px;
    font-size: 22px;
  }

  .result-summary {
    min-height: 0;
    margin-bottom: 8px;
    font-size: 10px;
  }

  .result-time-wrap {
    margin-bottom: 8px;
  }

  .result-time strong {
    font-size: 45px;
  }

  .race-board {
    margin-top: 8px;
  }

  .race-board-head {
    padding: 4px 8px;
  }

  .race-row {
    min-height: 23px;
    padding: 2px 8px;
  }

  .race-rank {
    width: 16px;
    height: 16px;
    font-size: 8px;
  }

  .result-stats {
    margin-top: 7px;
  }

  .result-stat {
    min-height: 34px;
    padding: 4px 6px;
  }

  .result-actions {
    margin-top: 10px;
  }
}

@media (max-height: 580px) and (orientation: landscape) {
  .results-screen {
    align-items: flex-start;
    justify-content: center;
    padding: 68px 14px 8px;
  }

  .result-card {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    grid-template-rows: auto auto auto auto auto auto auto;
    column-gap: 18px;
    width: min(760px, calc(100vw - 28px));
    max-height: calc(100dvh - 76px);
    padding: 13px 18px 10px;
    border-radius: 24px;
    overflow-y: auto;
  }

  .result-head {
    grid-column: 1;
    grid-row: 1;
  }

  .result-card h2 {
    grid-column: 1;
    grid-row: 2;
    margin: 8px 0 2px;
    font-size: 24px;
  }

  .result-summary {
    grid-column: 1;
    grid-row: 3;
    min-height: 0;
    margin-bottom: 6px;
    font-size: 10px;
    line-height: 1.4;
  }

  .result-time-wrap {
    grid-column: 1;
    grid-row: 4;
    margin-bottom: 7px;
  }

  .result-time strong {
    font-size: 44px;
  }

  .result-stats {
    grid-column: 1;
    grid-row: 5;
    margin-top: 0;
  }

  .race-board {
    grid-column: 2;
    grid-row: 1 / span 5;
    align-self: start;
    margin-top: 0;
  }

  .result-actions {
    grid-column: 1 / -1;
    grid-row: 6;
    margin-top: 8px;
  }

  .result-actions .btn {
    min-height: 35px;
    border-radius: 12px;
    font-size: 12px;
  }

  .link-btn {
    grid-column: 1 / -1;
    grid-row: 7;
    margin-top: 6px;
    min-height: 22px;
    font-size: 10px;
  }

  .place-badge {
    width: 52px;
    height: 52px;
  }

  .place-badge strong {
    font-size: 23px;
  }

  .place-badge span {
    font-size: 6px;
  }

  .race-board-head {
    padding: 4px 8px;
  }

  .race-row {
    min-height: 23px;
    padding: 2px 8px;
  }

  .race-rank {
    width: 16px;
    height: 16px;
    font-size: 8px;
  }

  .race-name b {
    font-size: 10px;
  }

  .race-name small {
    font-size: 7px;
  }

  .race-time {
    font-size: 10px;
  }

  .result-stat {
    min-height: 33px;
    padding: 4px 5px;
  }

  .result-stat span {
    font-size: 7px;
  }

  .result-stat strong {
    font-size: 12px;
  }
}

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

  .speed-vignette::before {
    display: none;
  }

  .menu-screen.is-open .menu-panel > * {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------------
   Keyframes
   ------------------------------------------------------------------ */

@keyframes loaderBounce {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  40% {
    transform: translateY(-10px) rotate(2deg);
  }
  60% {
    transform: translateY(-4px) rotate(-2deg);
  }
}

@keyframes loaderGlow {
  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.55;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

@keyframes loaderDot {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sparkleSpin {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(20deg) scale(1.08);
  }
}

@keyframes keyRing {
  0% {
    opacity: 0.7;
    transform: scale(0.94);
  }
  70% {
    opacity: 0;
    transform: scale(1.08);
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes keyHit {
  0% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(4px) scale(0.96);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes comboPop {
  0% {
    transform: scale(0.86) rotate(-2deg);
  }
  55% {
    transform: scale(1.08) rotate(1deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes countPop {
  0% {
    opacity: 0;
    transform: scale(1.42) rotate(-3deg);
  }
  24% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  75% {
    opacity: 1;
    transform: scale(0.94) rotate(0.5deg);
  }
  100% {
    opacity: 0.86;
    transform: scale(0.92) rotate(0deg);
  }
}

@keyframes haloSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes finishBurst {
  0% {
    opacity: 0;
    transform: scale(1.2) rotate(-2deg);
  }
  16% {
    opacity: 1;
    transform: scale(1) rotate(-2deg);
  }
  72% {
    opacity: 1;
    transform: scale(1) rotate(-2deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.96) translateY(-10px) rotate(-3deg);
  }
}

@keyframes newBestPop {
  from {
    opacity: 0;
    transform: scale(0.7) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(-2deg);
  }
}

@keyframes demoKeyPulse {
  0%,
  100% {
    background: var(--paper);
    color: var(--ink);
    transform: translateY(0);
  }
  14% {
    background: var(--coral);
    color: var(--cream);
    transform: translateY(-3px);
  }
  42% {
    background: var(--paper);
    color: var(--ink);
    transform: translateY(0);
  }
}

@keyframes speedScream {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(104px, 30px, 0);
  }
}


/* ------------------------------------------------------------------
   Podium ceremony
   ------------------------------------------------------------------ */

.podium-banner {
  position: fixed;
  top: max(82px, calc(66px + env(safe-area-inset-top)));
  left: 50%;
  z-index: 41;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: min(600px, calc(100vw - 28px));
  padding: 8px 14px 10px;
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: rgba(255, 249, 240, 0.92);
  box-shadow: 0 5px 0 rgba(70, 50, 60, 0.2), 0 18px 36px rgba(45, 25, 33, 0.16);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
  backdrop-filter: blur(16px) saturate(1.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -8px) scale(0.97);
  transition: opacity 0.35s ease, transform 0.45s var(--ease-out), visibility 0.35s ease;
}

.podium-banner.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.podium-kicker {
  margin: 0;
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1;
}

.podium-title {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.podium-names {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 1px;
}

.podium-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: 9px;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(70, 50, 60, 0.14);
}

.podium-chip i {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(70, 50, 60, 0.1);
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
}

.podium-chip b {
  max-width: 86px;
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.podium-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border: 1px solid rgba(70, 50, 60, 0.4);
  border-radius: 50%;
  background: var(--dot, var(--coral));
}

.podium-chip[data-place='1'] {
  background: var(--sun);
  transform: translateY(-3px);
}

.podium-chip[data-place='2'] {
  background: #dfe9ec;
}

.podium-chip[data-place='3'] {
  background: #e9b28f;
}

.podium-chip.is-player {
  box-shadow: 0 0 0 2px var(--mint-deep), 0 2px 0 rgba(70, 50, 60, 0.14);
}

@media (max-width: 680px) {
  .podium-banner {
    top: max(68px, calc(59px + env(safe-area-inset-top)));
    width: min(420px, calc(100vw - 18px));
    padding: 7px 10px 8px;
    border-radius: 18px;
  }

  .podium-title {
    font-size: 17px;
  }

  .podium-kicker {
    font-size: 7px;
  }

  .podium-chip {
    min-height: 22px;
    padding: 2px 7px;
    font-size: 8px;
  }

  .podium-chip b {
    max-width: 66px;
  }
}

@media (max-height: 580px) and (orientation: landscape) {
  .podium-banner {
    top: 56px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 8px;
    width: min(660px, calc(100vw - 120px));
    padding: 4px 10px;
    border-radius: 15px;
  }

  .podium-kicker {
    display: none;
  }

  .podium-title {
    font-size: 14px;
  }

  .podium-chip {
    min-height: 20px;
    font-size: 8px;
  }
}


/* ------------------------------------------------------------------
   Finish dive + large touch halves
   ------------------------------------------------------------------ */

.dive-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(70, 50, 60, 0.2);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.16s var(--ease-out), background 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.dive-btn .icon {
  width: 14px;
  height: 14px;
}

.dive-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(70, 50, 60, 0.2);
}

.dive-btn[disabled] {
  opacity: 0.42;
  cursor: default;
  filter: saturate(0.5);
}

.dive-btn.is-hot {
  background: var(--coral);
  color: var(--cream);
  animation: diveHot 0.9s ease-in-out infinite;
}

.dive-btn.is-lunging {
  background: var(--mint);
  color: #22665c;
}

.dive-btn.is-hot .icon {
  color: var(--cream);
}

.dive-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 18px;
  margin-left: 1px;
  padding: 0 5px;
  border: 1px solid rgba(70, 50, 60, 0.35);
  border-radius: 5px;
  background: rgba(255, 249, 240, 0.72);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}

body.is-touch .dive-key {
  display: none;
}

@keyframes diveHot {
  0%, 100% { transform: translateY(0) scale(1); box-shadow: 0 3px 0 rgba(70, 50, 60, 0.2); }
  50% { transform: translateY(-2px) scale(1.025); box-shadow: 0 5px 0 rgba(70, 50, 60, 0.18), 0 0 0 5px rgba(255, 117, 135, 0.1); }
}

.tap-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 20;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.tap-left {
  left: 0;
  background: linear-gradient(90deg, rgba(255, 247, 236, 0.1), transparent 36%);
}

.tap-right {
  right: 0;
  background: linear-gradient(270deg, rgba(255, 247, 236, 0.1), transparent 36%);
}

body.is-touch[data-mode='running'] .tap-zone {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tap-chevron {
  display: block;
  color: rgba(255, 247, 236, 0.36);
  font-family: Fredoka, Arial, sans-serif;
  font-size: 78px;
  font-weight: 600;
  line-height: 0.8;
  text-shadow: 0 4px 0 rgba(70, 50, 60, 0.08);
  transition: transform 0.15s var(--ease-out), color 0.15s ease;
}

.tap-label {
  padding: 3px 8px;
  border: 1px solid rgba(255, 247, 236, 0.26);
  border-radius: 999px;
  background: rgba(255, 247, 236, 0.28);
  color: rgba(255, 247, 236, 0.76);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1;
}

.tap-zone.is-hit .tap-chevron {
  color: rgba(255, 247, 236, 0.82);
  transform: scale(1.16);
}

.tap-zone.is-hit .tap-label {
  color: var(--ink);
  background: rgba(255, 247, 236, 0.8);
}

@media (max-width: 680px) {
  .dive-btn {
    min-height: 33px;
    padding: 5px 14px;
    font-size: 11px;
  }

  .dive-btn .icon {
    width: 15px;
    height: 15px;
  }

  .tap-chevron {
    font-size: 64px;
  }

  .tap-zone {
    justify-content: center;
  }
}

@media (max-height: 580px) and (orientation: landscape) {
  .dive-btn {
    min-height: 25px;
    padding: 2px 10px;
    font-size: 9px;
  }

  .dive-key {
    height: 15px;
    min-width: 28px;
    font-size: 6px;
  }

  .tap-chevron {
    font-size: 48px;
  }

  .tap-label {
    font-size: 7px;
  }
}

.is-lunging .speed-vignette {
  opacity: 1;
}
