/* GOLD RUSH — Grillz #39
   Tokens first, then layout. The arena is dark by nature, so the app runs in dark
   mode; the light set is declared so the token contract stays complete. */

:root,
[data-app-mode='dark'] {
  --app-bg: #05070c;
  --app-bg-deep: #020306;
  --app-panel: rgba(11, 15, 23, 0.74);
  --app-panel-solid: #0b0f17;
  --app-border: rgba(242, 193, 78, 0.2);
  --app-border-strong: rgba(242, 193, 78, 0.45);
  --app-text: #f4eee2;
  --app-text-dim: rgba(244, 238, 226, 0.62);
  --app-text-faint: rgba(244, 238, 226, 0.4);
  --app-gold: #f2c14e;
  --app-gold-bright: #ffdf8a;
  --app-gold-deep: #a9761f;
  --app-ice: #86dcff;
  --app-hot: #ff6a45;
  --app-good: #7ff2b0;
  --app-radius: 16px;
  --app-radius-sm: 10px;
  --app-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
  --app-glow: 0 0 24px rgba(242, 193, 78, 0.35);
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-num: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
}

[data-app-mode='light'] {
  --app-bg: #f6f1e6;
  --app-bg-deep: #e8e0cf;
  --app-panel: rgba(255, 253, 248, 0.86);
  --app-panel-solid: #fffdf8;
  --app-border: rgba(120, 86, 20, 0.24);
  --app-border-strong: rgba(120, 86, 20, 0.5);
  --app-text: #1b1409;
  --app-text-dim: rgba(27, 20, 9, 0.66);
  --app-text-faint: rgba(27, 20, 9, 0.44);
  --app-gold: #a97c14;
  --app-gold-bright: #c8951d;
  --app-gold-deep: #6f4f0d;
  --app-ice: #1a7fa8;
  --app-hot: #c53a17;
  --app-good: #18794a;
  --app-shadow: 0 24px 70px rgba(80, 60, 20, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--font-ui);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

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

.hud {
  position: fixed;
  inset: 0;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  pointer-events: none;
  opacity: 0;
  transition: opacity 240ms ease;
  z-index: 5;
}

.hud.live {
  opacity: 1;
}

.hud-corner {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
}

.hud-tl {
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.hud-tr {
  right: max(14px, env(safe-area-inset-right));
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 14px 10px;
  border-radius: var(--app-radius-sm);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.36);
}

.hud-stat-right {
  align-items: flex-end;
}

.hud-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--app-text-faint);
}

.hud-value {
  font-family: var(--font-num);
  font-size: clamp(22px, 5.4vw, 34px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--app-gold-bright);
  text-shadow: 0 0 18px rgba(242, 193, 78, 0.35);
}

.hud-tl .hud-value {
  color: var(--app-text);
  text-shadow: none;
}

#timer.hot {
  color: var(--app-hot);
  text-shadow: 0 0 22px rgba(255, 106, 69, 0.55);
}

#timer.hot.tick {
  animation: tickPulse 420ms ease-out;
}

@keyframes tickPulse {
  0% {
    transform: scale(1.24);
  }
  100% {
    transform: scale(1);
  }
}

/* combo */

.combo {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.42;
  transition: opacity 180ms ease;
}

.combo.active {
  opacity: 1;
}

.combo-mult {
  font-family: var(--font-num);
  font-size: clamp(15px, 3.4vw, 20px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--app-text-dim);
  transition: color 160ms ease, transform 160ms ease;
}

.combo.active .combo-mult {
  color: var(--app-gold);
  text-shadow: 0 0 16px rgba(242, 193, 78, 0.5);
}

.combo.bump .combo-mult {
  animation: multBump 260ms cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes multBump {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.combo-track {
  position: relative;
  display: block;
  width: clamp(64px, 16vw, 104px);
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.combo-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  border-radius: 99px;
  background: linear-gradient(90deg, var(--app-gold-deep), var(--app-gold), var(--app-gold-bright));
  box-shadow: 0 0 12px rgba(242, 193, 78, 0.6);
}

/* loading / load-failure line, top centre, only while the HUD is live */

.hud-status {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(60vw, 320px);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-num);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  color: var(--app-text-dim);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 200ms ease;
}

.hud-status.show {
  opacity: 1;
}

.hud-status.error {
  color: var(--app-hot);
  border-color: rgba(255, 106, 69, 0.45);
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: var(--font-ui);
  font-size: 11px;
}

/* collect flash */
.flash {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, 0);
  font-family: var(--font-num);
  font-size: clamp(20px, 4.6vw, 30px);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--app-gold-bright);
  text-shadow: 0 0 26px rgba(242, 193, 78, 0.7);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.flash.fire {
  animation: flashRise 620ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

@keyframes flashRise {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.86);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -2px) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -34px) scale(1);
  }
}

/* ---------------------------------------------- model load / Start gate */

/* The Start button hangs on the chosen model actually being ready — downloaded,
   parsed, in the scene and compiled — never on a timer. While it is not, the
   button is visibly inert and this line sits directly under it, where the button
   acts: a real byte percentage, "Preparing…" for the compile, or a plain retry. */

.cta:disabled {
  cursor: progress;
  opacity: 0.4;
  filter: saturate(0.5);
  box-shadow: none;
}

.cta:disabled:hover {
  filter: saturate(0.5);
  box-shadow: none;
}

.load {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(300px, 76vw);
  margin-top: 14px;
}

.load.hidden {
  display: none;
}

.load-track {
  position: relative;
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--app-panel);
  box-shadow: inset 0 0 0 1px var(--app-border);
}

.load-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  border-radius: 99px;
  background: linear-gradient(90deg, var(--app-gold-deep), var(--app-gold), var(--app-gold-bright));
  box-shadow: 0 0 12px rgba(242, 193, 78, 0.6);
  transition: transform 120ms linear;
}

/* No content-length: no honest percentage, so a sweep rather than a fake bar. */
.load.indeterminate .load-fill {
  transform: none;
  width: 34%;
  animation: loadSweep 1.15s ease-in-out infinite;
}

@keyframes loadSweep {
  0% {
    left: -36%;
  }
  100% {
    left: 102%;
  }
}

/* Bytes are in; this is the parse and shader compile. The bar holds full. */
.load.preparing .load-fill {
  animation: loadBreathe 1.05s ease-in-out infinite;
}

@keyframes loadBreathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.load-text {
  margin: 0;
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--app-text-dim);
}

.load.error .load-track {
  display: none;
}

.load.error .load-text {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--app-hot);
}

/* mute */

.mute {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  /* Above every .overlay (10) and the pause panel (12): the music bed keeps
     playing while a panel is up, so the one control that silences it has to stay
     reachable there. At 8 the panels covered it and a tap hit the backdrop. */
  z-index: 20;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  color: var(--app-text-dim);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.mute:hover {
  color: var(--app-gold-bright);
  border-color: var(--app-border-strong);
}

.mute:active {
  transform: scale(0.94);
}

.mute .mute-off {
  display: none;
}

.mute.muted .mute-on {
  display: none;
}

.mute.muted .mute-off {
  display: block;
  color: var(--app-hot);
}

/* ------------------------------------------------------------ overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  /* margin:auto on the inner panel centres it when it fits and never clips the top
     when it does not — the select grid has to scroll on a short phone. */
  display: flex;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(120% 100% at 50% 40%, rgba(4, 6, 11, 0.18) 0%, rgba(3, 4, 8, 0.72) 62%, rgba(2, 3, 6, 0.92) 100%);
  transition: opacity 260ms ease;
  visibility: visible;
}

/* Fade the opacity out, then take the panel out of the page for good: without
   `visibility: hidden` an overlay at opacity 0 is still a full-screen box in the
   tab order and the accessibility tree, sitting on top of the menu it was meant
   to leave. The zero-length visibility step is delayed by the fade so the fade
   still plays. */
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 260ms ease, visibility 0s linear 260ms;
}

.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  max-width: 520px;
  width: 100%;
  margin: auto;
}

.eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--app-text-faint);
}

.title {
  margin: 2px 0 0;
  font-family: var(--font-ui);
  font-size: clamp(46px, 15vw, 104px);
  line-height: 0.9;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--app-gold-bright) 0%, var(--app-gold) 46%, var(--app-gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 30px rgba(242, 193, 78, 0.32));
}

.subtitle {
  margin: 6px 0 0;
  font-family: var(--font-num);
  font-size: clamp(12px, 3vw, 15px);
  font-weight: 700;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--app-text-dim);
}

.controls {
  margin: 18px 0 0;
  max-width: 30ch;
  font-size: clamp(12px, 3vw, 14px);
  line-height: 1.5;
  color: var(--app-text-dim);
}

/* The start screen's sound switch — same state as the round's HUD button. */
.mute-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 14px;
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-text-dim);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  cursor: pointer;
}

.mute-pill:hover {
  color: var(--app-gold-bright);
  border-color: var(--app-border-strong);
}

.mute-pill:active {
  transform: scale(0.96);
}

.mute-pill .mute-pill-slash {
  display: none;
}

.mute-pill.muted {
  color: var(--app-hot);
  border-color: var(--app-hot);
}

.mute-pill.muted .mute-pill-wave {
  display: none;
}

.mute-pill.muted .mute-pill-slash {
  display: block;
}

.cta {
  margin-top: 22px;
  padding: 13px 40px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #191203;
  background: linear-gradient(180deg, var(--app-gold-bright), var(--app-gold));
  border: 1px solid rgba(255, 236, 178, 0.7);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(242, 193, 78, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.cta:hover {
  filter: brightness(1.06);
  box-shadow: 0 14px 42px rgba(242, 193, 78, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.cta:active {
  transform: translateY(1px) scale(0.985);
}

.status {
  min-height: 16px;
  margin: 12px 0 0;
  font-family: var(--font-num);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--app-text-faint);
}

.status.error {
  color: var(--app-hot);
  letter-spacing: 0.06em;
  text-transform: none;
  font-family: var(--font-ui);
  font-size: 12px;
  max-width: 40ch;
  line-height: 1.45;
}

/* end panel */

.panel {
  padding: 30px 30px 26px;
  border-radius: var(--app-radius);
  background: linear-gradient(180deg, rgba(14, 18, 28, 0.9), rgba(6, 8, 14, 0.94));
  border: 1px solid var(--app-border);
  box-shadow: var(--app-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  max-width: 380px;
}

.new-best {
  margin: 8px 0 0;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #1a1204;
  background: linear-gradient(180deg, var(--app-gold-bright), var(--app-gold));
  box-shadow: 0 0 28px rgba(242, 193, 78, 0.45);
}

.new-best.hidden {
  display: none;
}

.score-block {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.final-score {
  font-family: var(--font-num);
  font-size: clamp(44px, 13vw, 68px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--app-gold-bright);
  text-shadow: 0 0 34px rgba(242, 193, 78, 0.4);
}

.best-line {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: center;
}

.best-value {
  font-family: var(--font-num);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--app-text-dim);
}

.hint {
  margin: 10px 0 0;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--app-text-faint);
}

/* ------------------------------------------------- character select */

.select-inner {
  max-width: 760px;
  gap: 2px;
}

.roster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin: 14px 0 0;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 10px 8px 11px;
  min-height: 44px;
  border-radius: var(--app-radius);
  border: 1px solid var(--app-border);
  background: linear-gradient(180deg, rgba(16, 21, 32, 0.84), rgba(7, 9, 15, 0.92));
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease,
    background 150ms ease;
}

.card:hover {
  transform: translateY(-1px);
  border-color: var(--app-border-strong);
  background: linear-gradient(180deg, rgba(24, 29, 42, 0.9), rgba(9, 11, 18, 0.94));
}

.card:active {
  transform: translateY(0) scale(0.988);
}

.card:focus-visible {
  outline: 2px solid var(--app-ice);
  outline-offset: 3px;
}

.card[aria-checked='true'] {
  border-color: var(--app-gold);
  background: linear-gradient(180deg, rgba(38, 29, 12, 0.92), rgba(13, 11, 7, 0.94));
  box-shadow: inset 0 0 0 1px rgba(255, 223, 138, 0.35), var(--app-glow),
    0 14px 34px rgba(0, 0, 0, 0.46);
}

/* The art well is a rounded rectangle, not a disc: the card shows the full-body
   transparent artwork, which is wider than tall (props stick out sideways). The
   well is completely unframed — no plate, no disc, no ring, no shadow — so the
   Grillz himself sits on the card and the only outline on a card is the card's
   own (which turns gold when he is the chosen one). */
.card-art {
  position: relative;
  display: block;
  width: 100%;
  max-width: 190px;
  aspect-ratio: 5 / 4;
  border-radius: var(--app-radius-sm);
  overflow: hidden;
  background: transparent;
}

.card-art img {
  display: block;
  width: 100%;
  height: 100%;
  /* contain, never cover: nothing may be cropped — head, shoes or the props that
     stick out to the sides all stay inside the well. */
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
}

/* The Grillz number, on its own under the artwork: the card no longer carries a
   traits line, so the number takes the space (and the gap) it left behind. */
.card-token {
  margin-top: 8px;
  font-family: var(--font-num);
  font-size: clamp(12px, 3.1vw, 15px);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--app-text);
  transition: color 150ms ease;
}

.card[aria-checked='true'] .card-token {
  color: var(--app-gold-bright);
  text-shadow: 0 0 16px rgba(242, 193, 78, 0.45);
}

.card-check {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #191203;
  background: linear-gradient(180deg, var(--app-gold-bright), var(--app-gold));
  box-shadow: 0 0 16px rgba(242, 193, 78, 0.5);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 150ms ease, transform 150ms ease;
}

.card[aria-checked='true'] .card-check {
  opacity: 1;
  transform: scale(1);
}

.select-best {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 0;
}

.select-best-token {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--app-gold);
}

.select-best-value {
  font-family: var(--font-num);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--app-text);
}

/* in-round badge: which Grillz you are */

.hud-who {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 5px;
  border-radius: 999px;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34);
  opacity: 0.9;
}

.hud-who-art {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(242, 193, 78, 0.28);
}

.hud-who-token {
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--app-gold);
}

/* end screen: who you played, and the way back to the selection */

/* The end panel shows the same full-body transparent art as the select cards,
   so it wears the same well: a rounded rectangle with a gold hairline rim, an
   empty (transparent) inside and no circle crop. It sits above the score so the
   Grillz you played reads first. The in-game HUD badge stays a round pfp. */
.end-who {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 12px 0 0;
}

.end-art {
  display: block;
  width: min(60vw, 236px);
  aspect-ratio: 5 / 4;
  border-radius: var(--app-radius-sm);
  overflow: hidden;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(242, 193, 78, 0.3), 0 0 26px rgba(242, 193, 78, 0.16),
    0 12px 30px rgba(0, 0, 0, 0.52);
}

.end-who-art {
  display: block;
  width: 100%;
  height: 100%;
  /* contain, never cover: the whole figure — head, shoes and any prop that
     sticks out sideways — stays inside the frame. */
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
}

.end-who-token {
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--app-gold);
}

.end-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  width: 100%;
}

.end-actions .cta,
.end-actions .ghost {
  margin-top: 0;
  width: 100%;
  max-width: 240px;
}

/* The end panel carries four controls — Play again, Share to X, Change Grillz
   and Main menu. Two up in a grid keeps every one of them on screen and
   hit-sized at 360x640, where a single column would run off the bottom. */
#end .end-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 9px;
  margin-top: 16px;
}

#end .end-actions > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  max-width: none;
  min-height: 44px;
  padding-left: 10px;
  padding-right: 10px;
  font-size: 11.5px;
}

/* Four labels in two columns: on a 360px phone the pills get ~135px each, so
   shrink the type rather than let "Change Grillz" break over two lines. */
@media (max-width: 430px) {
  #end .end-actions > button {
    gap: 5px;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  #share svg {
    width: 12px;
    height: 12px;
  }
}

/* Share is the one new action, so it reads as the secondary hero: same pill as
   the ghosts, gold rim instead of grey. */
#share {
  color: var(--app-gold);
  border-color: var(--app-border-strong);
  background: rgba(242, 193, 78, 0.07);
}

#share svg {
  flex: none;
}

/* Says what actually happened after a share tap. */
.share-hint {
  margin: 10px 0 0;
  max-width: 34ch;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.45;
  color: var(--app-text-dim);
}

.share-hint.hidden {
  display: none;
}

.ghost {
  padding: 12px 24px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--app-text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease,
    transform 140ms ease;
}

.ghost:hover {
  color: var(--app-gold-bright);
  border-color: var(--app-border-strong);
  background: rgba(242, 193, 78, 0.08);
}

.ghost:active {
  transform: translateY(1px) scale(0.985);
}

/* ------------------------------------- countdown · in-game menu · pause */

/* The HUD's top-right corner stacks the clock and, under it, the menu control. */
.hud-tr {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hud-menu {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 13px 0 11px;
  pointer-events: auto;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--app-text-dim);
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 140ms ease, border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

/* Never live-tappable when there is no round on screen. */
.hud:not(.live) .hud-menu {
  pointer-events: none;
}

.hud-menu:hover {
  color: var(--app-gold-bright);
  border-color: var(--app-border-strong);
  background: rgba(242, 193, 78, 0.08);
}

.hud-menu:active {
  transform: scale(0.95);
}

.hud-menu:focus-visible {
  outline: 2px solid var(--app-ice);
  outline-offset: 3px;
}

/* 3 · 2 · 1 · GO. Sits over the arena (which keeps rendering underneath — no
   opaque sheet) and never reaches the timer in the corner. */
.countdown {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 0 20px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

.countdown::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 46% 34% at 50% 50%, rgba(5, 7, 12, 0.66), rgba(5, 7, 12, 0) 72%);
}

.countdown.show {
  opacity: 1;
}

.countdown-label {
  margin: 0;
  font-family: var(--font-num);
  font-size: clamp(10px, 2.8vw, 12px);
  font-weight: 700;
  letter-spacing: 0.44em;
  text-indent: 0.44em;
  text-transform: uppercase;
  color: var(--app-text-dim);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

.countdown-count {
  margin: 0;
  font-family: var(--font-num);
  font-size: clamp(64px, 16vw, 112px);
  line-height: 0.94;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--app-gold-bright);
  text-shadow: 0 0 42px rgba(242, 193, 78, 0.5), 0 8px 34px rgba(0, 0, 0, 0.72);
}

.countdown-count.beat {
  animation: countBeat 520ms cubic-bezier(0.2, 1.25, 0.4, 1);
}

@keyframes countBeat {
  0% {
    transform: scale(1.34);
    opacity: 0.3;
  }
  45% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* GO: one short flash in the display face, then it clears itself. */
.countdown.go .countdown-label {
  display: none;
}

.countdown.go .countdown-count {
  font-family: var(--font-ui);
  font-size: clamp(56px, 14vw, 96px);
  letter-spacing: 0.04em;
  animation: countGo 560ms cubic-bezier(0.18, 1.1, 0.32, 1) forwards;
}

@keyframes countGo {
  0% {
    transform: scale(0.82);
    opacity: 0;
  }
  30% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1.24);
    opacity: 0;
  }
}

/* Pause panel (opened by the HUD menu) — above the HUD, over the arena. */
.overlay-pause {
  z-index: 12;
}

.pause-score {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 0;
}

/* --------------------------------------------------------- small screens */

@media (max-width: 640px) {
  /* Three across on a phone too: two rows of full-body art keeps the Play button
     above the fold at 360x640, where three rows would push it off. */
  .roster {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 12px;
  }

  .select-inner {
    max-width: 420px;
  }

  .overlay-select .title {
    font-size: clamp(36px, 12.6vw, 54px);
  }

  .card {
    padding: 8px 6px 9px;
    gap: 4px;
  }

  .card-token {
    margin-top: 6px;
  }

  .card-art {
    /* Fill the narrower card — the well keeps its 5/4 shape. */
    max-width: none;
  }

  .select-best {
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  .hud-stat {
    padding: 6px 11px 8px;
  }

  .hud-menu {
    height: 40px;
    padding: 0 11px 0 9px;
    font-size: 10px;
    letter-spacing: 0.12em;
  }

  .countdown-count {
    font-size: clamp(58px, 18vw, 90px);
  }

  .hud-label {
    font-size: 9px;
    letter-spacing: 0.18em;
  }

  .title {
    font-size: clamp(42px, 17vw, 70px);
  }

  .subtitle {
    letter-spacing: 0.32em;
  }

  .controls {
    margin-top: 14px;
    max-width: 26ch;
  }

  .cta {
    padding: 12px 32px;
  }

  .panel {
    padding: 24px 20px 22px;
  }

  .flash {
    top: 26%;
  }
}

/* The end panel has to show its figure and both buttons without scrolling on a
   short phone (360x640) and on a landscape window, so the art gives a little
   width back there. */
@media (max-width: 480px), (max-height: 760px) {
  .end-who {
    margin-top: 8px;
  }

  .end-art {
    width: min(52vw, 196px);
  }

  .end-actions {
    margin-top: 12px;
    gap: 8px;
  }
}

@media (max-height: 460px) {
  .controls {
    display: none;
  }

  .title {
    font-size: clamp(34px, 11vh, 64px);
  }

  .cta {
    margin-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flash.fire,
  .combo.bump .combo-mult,
  #timer.hot.tick,
  .load.preparing .load-fill,
  .countdown-count.beat,
  .countdown.go .countdown-count {
    animation-duration: 1ms;
  }

  /* The sweep is indefinite, so park it rather than shorten it. */
  .load.indeterminate .load-fill {
    animation: none;
    left: 0;
    width: 100%;
    opacity: 0.5;
  }
}
