/* Booster Race — UI styles. Cadet band (6-9). */

:root {
  --sky:        #7cc7e8;
  --sand-1:     #f5d98d;
  --sand-2:     #e8b04a;
  --dune:       #c47432;
  --livery-red: #d62828;
  --livery-yel: #f4b400;
  --silver:     #cccccc;
  --ink:        #2a1a0a;
  --paper:      #fff8e6;
  --shadow:     0 4px 0 rgba(0,0,0,0.20);
  --rad:        18px;
  --tap:        56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#stage {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ============================================================
 *   Start screen + Win screen (shared .screen)
 * ============================================================ */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
  pointer-events: auto;
  background: rgba(245, 217, 141, 0.40);
  backdrop-filter: blur(2px);
  /* v2.4.12: allow scrolling when expanded content (e.g. Championship Cups)
     exceeds the viewport. Without this, justify-content:center with a fixed
     viewport height causes flex-children to overflow above and below the
     visible area (instead of becoming reachable via scroll). */
  overflow-y: auto;
}

.title {
  font-size: clamp(48px, 10vw, 110px);
  margin: 0 0 6px;
  color: var(--livery-red);
  text-shadow: 4px 4px 0 var(--paper), 8px 8px 0 rgba(0,0,0,0.18);
  letter-spacing: 2px;
}
.tagline { font-size: clamp(16px, 2.5vw, 22px); margin: 0 0 28px; color: var(--ink); opacity: 0.9; }

.play-btn {
  min-width: 220px; min-height: var(--tap);
  padding: 18px 40px;
  border: 5px solid var(--ink);
  border-radius: var(--rad);
  background: var(--livery-yel);
  box-shadow: var(--shadow);
  font-family: inherit;
  font-weight: 900; font-size: 28px;
  color: var(--ink); letter-spacing: 3px;
  cursor: pointer;
  transition: transform 80ms ease, background 80ms ease;
}
.play-btn:hover { background: #ffc933; }
.play-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.20); }
.play-btn:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 4px; }

.btn-secondary {
  min-height: var(--tap);
  margin-top: 12px;
  padding: 12px 22px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.btn-secondary:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 2px; }

/* Difficulty picker — Casual / Normal / Expert per studio §4e.
 * Symmetric framing required: no labels like "easy for babies".
 * Reachable in 1 tap from the start screen. Persisted to Save. */
.diff-picker {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.diff-btn {
  min-width: 86px; min-height: 40px;
  padding: 8px 16px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 80ms ease, transform 80ms ease;
}
.diff-btn:hover { background: var(--sand-1); }
.diff-btn:active { transform: translateY(1px); }
.diff-btn:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 3px; }
.diff-btn.active { background: var(--livery-yel); }

/* Race-length picker — three buttons on ONE row at any portrait width down to 320px.
 * Honours the PM resolution that v1.0 ships with three start-screen
 * race options (translated from the original 2D timer picker to a
 * lap-count picker that fits the 3D racing-game shape). */
.race-picker {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: center;
  margin-bottom: 16px;
  width: 100%;
  max-width: 480px;
}
.race-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--tap);
  padding: 10px 8px;
  border: 4px solid var(--ink);
  border-radius: var(--rad);
  background: var(--paper);
  box-shadow: var(--shadow);
  font-family: inherit;
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: transform 80ms ease, background 80ms ease;
}
.race-btn-primary { background: var(--livery-yel); }
.race-btn:hover { background: var(--sand-1); }
.race-btn-primary:hover { background: #ffc933; }
.race-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.20); }
.race-btn:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 4px; }
.race-len { font-size: clamp(16px, 4vw, 22px); letter-spacing: 1px; }
.race-sub { font-size: clamp(9px, 2vw, 11px); opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }

.best-row {
  margin: 4px 0 8px;
  font-size: 13px;
  color: var(--ink);
  opacity: 0.65;
  font-family: "JetBrains Mono", monospace;
  /* Brand-keeper #4: passive personal-best display. Never a flash. */
}

/* Bank + shop button on start screen */
.bank-row {
  display: inline-flex; align-items: center; gap: 12px;
  margin: 0 0 16px;
  padding: 8px 16px;
  background: rgba(255, 248, 230, 0.78);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.btn-shop {
  min-height: 36px;
  padding: 6px 18px;
  background: var(--livery-yel);
  border: 3px solid var(--ink);
  border-radius: 10px;
  font-family: inherit;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--ink);
  cursor: pointer;
}
.btn-shop:hover { background: #ffc933; }
.btn-shop:active { transform: translateY(2px); }
.btn-shop:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 2px; }

/* ============================================================
 *   Shop screen (paint variants)
 * ============================================================ */
.screen.shop {
  padding: 32px 16px 16px;
  overflow-y: auto;
  align-items: stretch;
}
.shop-title {
  font-size: clamp(40px, 8vw, 72px);
  margin: 0 auto 4px;
  text-align: center;
}
.shop-bank {
  text-align: center;
  margin: 0 auto 16px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  background: rgba(255,248,230,0.78);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 18px;
  display: block;
  width: max-content;
  max-width: 90vw;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto 16px;
}
.shop-section-header {
  grid-column: 1 / -1;
  margin: 12px 0 -2px;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.85;
}
.shop-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.shop-card.equipped {
  outline: 4px solid var(--livery-red);
  outline-offset: -1px;
}
.shop-card-art {
  background: linear-gradient(180deg, var(--sky), var(--sand-1));
  padding: 12px 14px;
  border-bottom: 3px solid var(--ink);
}
.shop-card-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--paper);
}
.shop-card-meta b { font-size: 16px; }
.shop-cost {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  opacity: 0.85;
}
.shop-card-btn {
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--livery-yel);
  border: 0;
  border-top: 3px solid var(--ink);
  font-family: inherit;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--ink);
  cursor: pointer;
}
.shop-card.equipped .shop-card-btn {
  background: var(--paper);
  color: var(--livery-red);
}
.shop-card-btn:hover { background: #ffc933; }
.shop-card.equipped .shop-card-btn:hover { background: #fff; }
.shop-card-btn:focus-visible { outline: 4px solid var(--livery-red); outline-offset: -3px; }
.screen.shop .btn-secondary {
  align-self: center;
  margin-top: 8px;
}

/* Lost-state win-screen variant */
#win-art-lost {
  display: flex; flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}
#win-art-lost .finish-flag { filter: drop-shadow(0 5px 0 rgba(0,0,0,0.18)); }
.lost-line {
  margin: 14px 0 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 248, 230, 0.86);
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--ink);
}

.controls-hint { margin-top: 24px; font-size: 14px; opacity: 0.7; max-width: 80vw; }
.touch-hint { display: none; }
@media (pointer: coarse) {
  .controls-hint { opacity: 0.55; }
  .touch-hint { display: inline; opacity: 1; }
}

/* ============================================================
 *   HUD chips
 * ============================================================ */
.hud {
  position: absolute; top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  display: flex; gap: 8px; flex-wrap: wrap;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}
.hud .chip {
  background: rgba(42, 26, 10, 0.78);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: 10px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  display: flex; align-items: baseline; gap: 6px;
}
.hud .chip .lab { font-size: 10px; opacity: 0.65; letter-spacing: 1.5px; }
.hud .chip .unit { font-size: 10px; opacity: 0.65; }
/* Coin chip is visually distinct (gold) AND legible — ink on yellow = 9.10:1 (AA pass). */
.hud .chip-coin { background: var(--livery-yel); color: var(--ink); }
.hud .chip-coin .lab { opacity: 0.7; }
/* Boost chip — paper on red (~5.7:1 AA pass) when charged; pulses while active. */
.hud .chip-boost { background: var(--livery-red); color: var(--paper); }
.hud .chip-boost .lab { opacity: 0.85; }
.hud .chip-boost.active { animation: boost-pulse 0.4s ease-in-out infinite alternate; }
@keyframes boost-pulse {
  from { box-shadow: 0 0 0 0 rgba(244,180,0,0); }
  to   { box-shadow: 0 0 0 6px rgba(244,180,0,0.45); }
}
body.rm .hud .chip-boost.active { animation: none; }
@media (prefers-reduced-motion: reduce) { .hud .chip-boost.active { animation: none; } }

/* ============================================================
 *   Touch UI (wheel + pedals)
 * ============================================================ */
#touch-ui {
  position: absolute; inset: 0;
  pointer-events: none;
}
#touch-ui > * { pointer-events: auto; }

.touch-wheel {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(42, 26, 10, 0.30);
  border: 4px solid rgba(255, 248, 230, 0.55);
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
/* v2.5.19 D-pad: 4 arrows on outer ring of the wheel; light up when their direction is held. */
.wheel-arrow {
  position: absolute;
  font-family: sans-serif;
  font-size: 28px;
  line-height: 1;
  color: rgba(255, 248, 230, 0.55);
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
  pointer-events: none;
  transition: color 60ms ease, transform 60ms ease;
}
.wheel-arrow-up    { top: 6px;    left: 50%; transform: translateX(-50%); }
.wheel-arrow-down  { bottom: 6px; left: 50%; transform: translateX(-50%); }
.wheel-arrow-left  { left: 6px;   top: 50%; transform: translateY(-50%); }
.wheel-arrow-right { right: 6px;  top: 50%; transform: translateY(-50%); }
.touch-wheel.dpad-up    .wheel-arrow-up,
.touch-wheel.dpad-down  .wheel-arrow-down,
.touch-wheel.dpad-left  .wheel-arrow-left,
.touch-wheel.dpad-right .wheel-arrow-right {
  color: var(--livery-yel);
  text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 8px rgba(244, 180, 0, 0.8);
}
.touch-wheel.dpad-up    .wheel-arrow-up    { transform: translateX(-50%) translateY(-2px); }
.touch-wheel.dpad-down  .wheel-arrow-down  { transform: translateX(-50%) translateY( 2px); }
.touch-wheel.dpad-left  .wheel-arrow-left  { transform: translateY(-50%) translateX(-2px); }
.touch-wheel.dpad-right .wheel-arrow-right { transform: translateY(-50%) translateX( 2px); }
/* v2.5.21 — D-pad centre thumb. Small indicator that snaps to one of 4
 * cardinal positions when a direction is held. Purely visual; no input logic. */
.wheel-thumb {
  position: absolute;
  top: 50%; left: 50%;
  width: 50px; height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: rgba(255, 248, 230, 0.55);
  border: 2.5px solid rgba(255, 248, 230, 0.75);
  pointer-events: none;
  transition: transform 60ms ease, background 60ms ease, border-color 60ms ease, box-shadow 60ms ease;
  will-change: transform;
  transform: translate(0, 0);
}
/* Lit state: matches the lit arrow colour */
.touch-wheel.dpad-up    .wheel-thumb,
.touch-wheel.dpad-down  .wheel-thumb,
.touch-wheel.dpad-left  .wheel-thumb,
.touch-wheel.dpad-right .wheel-thumb {
  background: rgba(244, 180, 0, 0.82);
  border-color: var(--livery-yel);
  box-shadow: 0 0 8px rgba(244, 180, 0, 0.65);
}
.touch-wheel.dpad-up    .wheel-thumb { transform: translate(0, -36px); }
.touch-wheel.dpad-down  .wheel-thumb { transform: translate(0,  36px); }
.touch-wheel.dpad-left  .wheel-thumb { transform: translate(-36px, 0); }
.touch-wheel.dpad-right .wheel-thumb { transform: translate( 36px, 0); }
@media (max-width: 380px) {
  .wheel-thumb { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .touch-wheel.dpad-up    .wheel-thumb { transform: translate(0, -30px); }
  .touch-wheel.dpad-down  .wheel-thumb { transform: translate(0,  30px); }
  .touch-wheel.dpad-left  .wheel-thumb { transform: translate(-30px, 0); }
  .touch-wheel.dpad-right .wheel-thumb { transform: translate( 30px, 0); }
}
body.rm .wheel-thumb,
.wheel-thumb { transition: transform 60ms ease, background 60ms ease, border-color 60ms ease, box-shadow 60ms ease; }
@media (prefers-reduced-motion: reduce) {
  .wheel-thumb { transition: none; }
}
body.rm .wheel-thumb { transition: none !important; }

.wheel-label {
  position: absolute;
  top: -22px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--paper);
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
}

.touch-pedal {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  width: 110px; min-height: 80px;
  display: flex; align-items: center; justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 18px;
  touch-action: none;
  transition: transform 60ms ease, background 60ms ease;
}
/* v2.5.19 touch layout — 2×2 grid, all four buttons same width (110px):
 *       RESET   BOOST
 *       BRAKE   GO
 * GO and BRAKE shrunk to BOOST's height (64px). RESET keeps 50px.
 * Right column: GO bottom, BOOST above. Left column: BRAKE bottom, RESET above.
 */
.touch-pedal-go {
  bottom: max(24px, env(safe-area-inset-bottom));
  height: 64px;
  background: var(--livery-yel);
  box-shadow: 0 5px 0 rgba(0,0,0,0.30);
  font-size: 22px;
}
.touch-pedal-go.active {
  background: #ffc933;
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.30);
}
.touch-pedal-brake {
  /* Left of GO — same bottom, same height; offset = pedal width 110 + 8px gap */
  bottom: max(24px, env(safe-area-inset-bottom));
  right: calc(max(20px, env(safe-area-inset-right)) + 118px);
  height: 64px;
  width: 110px;
  background: rgba(42, 26, 10, 0.78);
  color: var(--paper);
  font-size: 18px;
  border-color: rgba(255,248,230,0.6);
}
.touch-pedal-brake.active {
  background: rgba(122, 31, 31, 0.95);
  transform: translateY(2px);
}
/* RESET — above BRAKE (left column) */
.touch-pedal-reset {
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 72px);
  right: calc(max(20px, env(safe-area-inset-right)) + 118px);
  width: 110px; height: 50px;
  background: rgba(70, 50, 30, 0.82);
  color: var(--paper);
  font-size: 12px;
  border-color: rgba(255,248,230,0.45);
}
.touch-pedal-reset.active {
  background: rgba(122, 80, 40, 0.95);
  transform: translateY(2px);
}
/* BOOST — above GO (right column) */
.touch-pedal-boost {
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 72px);
  right: max(20px, env(safe-area-inset-right));
  width: 110px; height: 64px;
  background: var(--livery-red);
  color: var(--paper);
  font-size: 14px;
  border-color: var(--ink);
  opacity: 0.55; /* dim when no charge available */
}
.touch-pedal-boost.charged { opacity: 1; }
.touch-pedal-boost.active {
  background: #a01a1a;
  transform: translateY(2px);
}

/* Track I — drift pedal: sits above the steering wheel on the left.
 * 60×40px — smaller than other pedals since it's a hold-action, not a tap. */
.touch-pedal-drift {
  right: auto;
  left: max(20px, env(safe-area-inset-left));
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 168px);
  width: 60px; height: 40px;
  min-height: 44px;
  background: rgba(42, 26, 10, 0.65);
  color: var(--paper);
  font-size: 11px;
  border-color: rgba(255, 248, 230, 0.55);
  opacity: 0.85;
}
.touch-pedal-drift.active {
  background: rgba(196, 116, 50, 0.90);
  transform: translateY(2px);
}

/* Smaller touch UI on tiny phones — v2.5.19 2×2 grid preserved */
@media (max-width: 380px) {
  .touch-wheel { width: 132px; height: 132px; }
  .wheel-arrow { font-size: 24px; }
  /* GO/BRAKE width 96, BOOST/RESET width 96. Heights match. */
  .touch-pedal-go    { width: 96px; height: 56px; font-size: 20px; bottom: max(24px, env(safe-area-inset-bottom)); right: max(20px, env(safe-area-inset-right)); }
  .touch-pedal-brake { width: 96px; height: 56px; bottom: max(24px, env(safe-area-inset-bottom)); right: calc(max(20px, env(safe-area-inset-right)) + 104px); font-size: 16px; }
  .touch-pedal-boost { width: 96px; height: 56px; right: max(20px, env(safe-area-inset-right)); bottom: calc(max(24px, env(safe-area-inset-bottom)) + 64px); }
  .touch-pedal-reset { width: 96px; height: 44px; right: calc(max(20px, env(safe-area-inset-right)) + 104px); bottom: calc(max(24px, env(safe-area-inset-bottom)) + 64px); font-size: 11px; }
  .touch-pedal-drift { width: 54px; min-height: 44px; height: 40px; bottom: calc(max(24px, env(safe-area-inset-bottom)) + 140px); }
}

/* ============================================================
 *   Countdown / "GO!" / "LAP 2" overlay
 * ============================================================ */
.overlay-msg {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bungee', system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(80px, 16vw, 220px);
  color: var(--livery-red);
  text-shadow: 6px 6px 0 var(--paper), 12px 12px 0 rgba(0,0,0,0.25);
  pointer-events: none;
  letter-spacing: 4px;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
  transform: scale(0.6);
}
.overlay-msg.show { opacity: 1; transform: scale(1); }

/* ============================================================
 *   Win screen
 * ============================================================ */
.screen.win { gap: 8px; padding: 24px 16px; overflow-y: auto; }
.win-art {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}
.win-art .trophy {
  filter: drop-shadow(0 6px 0 rgba(0,0,0,0.18));
  animation: trophy-bob 2.4s ease-in-out infinite;
}
.win-art .woohoo {
  margin-top: -42px;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.15));
  animation: woohoo-wobble 2s ease-in-out infinite;
}
@keyframes trophy-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes woohoo-wobble { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }

.win-stats {
  display: flex; gap: 14px; margin: 8px 0 18px;
  padding: 0; flex-wrap: wrap; justify-content: center;
}
.win-stat {
  background: rgba(42,26,10, 0.78);
  color: var(--paper);
  padding: 10px 20px;
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center;
  font-family: "JetBrains Mono", monospace;
  min-width: 110px;
}
.win-stat dt { font-size: 11px; letter-spacing: 2px; opacity: 0.6; text-transform: uppercase; margin: 0; }
.win-stat dd { margin: 4px 0 0; font-size: 22px; font-weight: 800; }
.win-stat-best { background: rgba(245, 217, 141, 0.85); color: var(--ink); }
.win-stat-best dt { opacity: 0.5; }
.win-stat-best dd { font-size: 16px; }
.win-stat-coins { color: var(--livery-yel); }

.win-btns { display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ============================================================
 *   Confetti burst — fires when win screen enters
 * ============================================================ */
.confetti {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 9px; height: 14px;
  border: 1.5px solid var(--ink);
  animation: confetti-fall 2.4s linear forwards;
  will-change: transform, opacity;
}
@keyframes confetti-fall {
  0%   { transform: translate3d(0, -20px, 0) rotate(0deg);  opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translate3d(var(--x-end, 0), 100vh, 0) rotate(var(--rot-end, 720deg)); opacity: 0; }
}
body.rm .confetti-piece { animation: none !important; opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .confetti-piece { animation: none !important; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .play-btn, .overlay-msg, .touch-pedal { transition: none; }
  .win-art .trophy, .win-art .woohoo { animation: none; }
}

/* In-app reduced-motion toggle: JS adds .rm to <body> when the user
 * flips the Settings switch, mirroring the OS @media rules above. */
body.rm .play-btn,
body.rm .overlay-msg,
body.rm .touch-pedal { transition: none !important; }
body.rm .win-art .trophy,
body.rm .win-art .woohoo { animation: none !important; }

/* ============================================================
 *   sr-only — visually hidden, screen-reader accessible
 * ============================================================ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
  border: 0;
}

/* ============================================================
 *   Gear button (always-visible top-right)
 * ============================================================ */
.gear-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 56px; height: 56px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 248, 230, 0.92);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 50;
  font-family: inherit;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18);
  transition: transform 80ms ease, background 80ms ease;
}
.gear-btn:hover { background: var(--paper); }
.gear-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.gear-btn:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 3px; }

/* ============================================================
 *   Settings modal
 * ============================================================ */
.settings-modal {
  position: fixed; inset: 0;
  background: rgba(42, 26, 10, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 200;
  touch-action: none;
}
.settings-panel {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 24px;
  padding: 24px;
  min-width: 280px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 8px 0 rgba(0,0,0,0.25);
}
.settings-panel h2 {
  margin: 0 0 18px;
  font-size: 22px;
  text-align: center;
  color: var(--ink);
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 2px solid rgba(42,26,10,0.12);
}
.settings-row:last-of-type { border-bottom: none; }
.settings-row label { font-size: 16px; font-weight: 700; color: var(--ink); }
.settings-toggle {
  min-width: 76px; min-height: 44px;
  padding: 8px 16px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--livery-yel);
  font-family: inherit;
  font-size: 14px; font-weight: 900;
  color: var(--ink);
  cursor: pointer;
  transition: background 80ms ease, transform 80ms ease;
}
.settings-toggle.off { background: var(--silver); }
.settings-toggle:active { transform: scale(0.96); }
.settings-toggle:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 2px; }
.settings-panel .btn-secondary { width: 100%; margin-top: 14px; }

/* v2.5.21 — Reset All Data button. Danger-styled, discoverable but not accident-prone.
 * Muted fill + red border; a sub-label makes the consequence visible before tapping. */
.btn-reset-data {
  width: 100%;
  min-height: 44px;
  margin-top: 24px;
  padding: 10px 16px;
  border: 2px solid #a01a1a;
  border-radius: 12px;
  background: rgba(42, 26, 10, 0.06);
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #a01a1a;
  cursor: pointer;
  transition: background 80ms ease;
}
.btn-reset-data:hover { background: rgba(160, 26, 26, 0.10); }
.btn-reset-data:active { transform: translateY(1px); }
.btn-reset-data:focus-visible { outline: 3px solid #a01a1a; outline-offset: 2px; }
.btn-reset-data-note {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(42, 26, 10, 0.45);
  letter-spacing: 0.5px;
  text-align: center;
  margin-top: 4px;
  text-transform: uppercase;
}

/* ============================================================
 *   Bandit hat-tip cameo on win screen
 * ============================================================ */
.bandit-cameo {
  display: flex; flex-direction: column;
  align-items: center;
  margin: -4px 0 16px;
}
.bandit-cameo svg {
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.18));
  animation: bandit-tip 2.4s ease-in-out infinite;
}
.bandit-cameo-line {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 248, 230, 0.8);
  padding: 4px 12px;
  border-radius: 999px;
}
@keyframes bandit-tip {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(3deg); }
}
@media (prefers-reduced-motion: reduce) {
  .bandit-cameo svg { animation: none; }
}
body.rm .bandit-cameo svg { animation: none !important; }

/* ============================================================
 *   §8a Update-check pill (a11y-spec-locked)
 * ============================================================
 * Sibling of #gear-btn, top-right corner, sits to the LEFT of the gear
 * so the gear-btn position never moves. Hidden by default; revealed by
 * the inline shim in index.html when version.json reports a newer build.
 * No pulse, no glow, no chime. Honour reduced motion. AA contrast: ink
 * on yellow = 9.10:1.
 */
.update-pill {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  /* Gear is 56px wide at right:12; sit to its left with a 12px gutter. */
  right: calc(max(12px, env(safe-area-inset-right)) + 80px);
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--livery-yel);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  transition: opacity 200ms ease;
}
.update-pill[data-shown="true"] { opacity: 1; }
.update-pill:focus-visible {
  outline: 4px solid var(--livery-red);
  outline-offset: 3px;
}
.update-pill:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.20);
}
.update-pill-glyph { flex: 0 0 auto; }
.update-pill-text  { white-space: nowrap; }

@media (max-width: 380px) {
  /* Phone: glyph-only round button, label moves to sr-only text. */
  .update-pill {
    padding: 0;
    width: 44px;
    min-width: 44px;
    justify-content: center;
  }
  .update-pill-text {
    position: absolute;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .update-pill { transition: none; }
}
body.rm .update-pill { transition: none !important; }

/* ============================================================
 *   Wave B2 — World Art Direction
 * ============================================================ */

/* Step 11 — Vignette overlay. Fixed full-screen, always on.
 * Sits above the canvas, below HUD chips (z-index between canvas default
 * and HUD). pointer-events:none — never blocks touch/mouse input.
 * Radial gradient: transparent centre, 8% black at edges (subtle, not gloomy).
 * Static — not animated — so it's always on and reduced-motion safe. */
#world-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* z-index between canvas (auto/0) and the HUD; below boost-speed-lines.
     Vignette is a subtle static effect — speed-lines read correctly on top. */
  z-index: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 58%,
    rgba(0, 0, 0, 0.08) 100%
  );
}

/* ============================================================
 *   Wave B1 — Boost Spectacle
 * ============================================================ */

/* Step 3 — Speed-lines overlay container.
 * Positioned over the canvas, behind all HUD/UI layers.
 * SVG children are appended/removed dynamically by spawnSpeedLines().
 * pointer-events:none so it never blocks input. */
.boost-speed-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;   /* above canvas (z-index:auto), below HUD (z-index unset but DOM order) */
  overflow: hidden;
}

/* Step 5 — Canvas CSS filter on boost.
 * Reduced-motion variant: saturate only (no blur, no scale changes).
 * The class is toggled by JS; transition eases the filter on/off. */
#stage.boosting {
  filter: saturate(1.3) blur(0.4px) contrast(1.02);
  transition: filter 220ms ease;
}
#stage:not(.boosting) {
  filter: none;
  transition: filter 300ms ease;
}
@media (prefers-reduced-motion: reduce) {
  #stage.boosting  { filter: saturate(1.3); transition: none; }
  #stage:not(.boosting) { filter: none; transition: none; }
}
body.rm #stage.boosting  { filter: saturate(1.3) !important; transition: none !important; }
body.rm #stage:not(.boosting) { filter: none !important; transition: none !important; }

/* Step 12 — Boost pip HUD.
 * Pips sit inside .chip-boost. Each pip is a small circle:
 *   .filled = charge available (solid gold fill)
 *   (no class) = spent (empty outline)
 * Constraint #9: no animation on state changes — instant flip. */
.boost-pips {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  margin-left: 2px;
}
.boost-pip {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 248, 230, 0.9);
  background: transparent;
  flex-shrink: 0;
}
.boost-pip.filled {
  background: var(--livery-yel);
  border-color: var(--livery-yel);
}

/* Step 11 — Cold-start boost button pulse.
 * Single gentle pulse animation on first race.
 * Reuses the .charged opacity to stay at full opacity during pulse.
 * Reduced-motion: animation is suppressed by the .rm guard. */
@keyframes boost-cold-pulse {
  0%   { box-shadow: 0 0 0 0  rgba(255,248,230,0); }
  50%  { box-shadow: 0 0 0 8px rgba(255,248,230,0.5); }
  100% { box-shadow: 0 0 0 0  rgba(255,248,230,0); }
}
.touch-pedal-boost.cold-pulse {
  animation: boost-cold-pulse 0.6s ease-in-out 1;
}
@media (prefers-reduced-motion: reduce) {
  .touch-pedal-boost.cold-pulse { animation: none; }
}
body.rm .touch-pedal-boost.cold-pulse { animation: none !important; }

/* ============================================================
 *   Wave B3 — Ghost Racer UI
 * ============================================================ */

/* Ghost toggle button on start screen (sits inside .bank-row) */
.btn-ghost-toggle {
  min-height: 36px;
  padding: 6px 14px;
  background: rgba(42, 26, 10, 0.14);
  border: 3px solid var(--ink);
  border-radius: 10px;
  font-family: inherit;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--ink);
  cursor: pointer;
  opacity: 0.65;
  transition: background 80ms ease, opacity 80ms ease;
}
.btn-ghost-toggle:hover { background: rgba(42, 26, 10, 0.22); }
.btn-ghost-toggle:active { transform: translateY(1px); }
.btn-ghost-toggle:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 2px; }
/* ON state: distinct but never coloured by ahead/behind */
.btn-ghost-toggle.ghost-btn-on {
  background: rgba(138, 184, 232, 0.28);
  opacity: 1;
  border-color: #5a90c8;
}

/* Ghost chip in HUD — pale blue, neutral at all times */
.hud .chip-ghost {
  background: rgba(90, 144, 200, 0.72);
  color: var(--paper);
  outline: none;
}
.hud .chip-ghost .lab { opacity: 0.75; }
.hud .chip-ghost:hover { background: rgba(90, 144, 200, 0.92); }
.hud .chip-ghost:focus-visible { outline: 3px solid var(--paper); outline-offset: 2px; }
/* ON state — slightly brighter; never changes during a race */
.hud .chip-ghost.ghost-chip-on {
  background: rgba(138, 184, 232, 0.88);
  color: var(--ink);
}

/* "Race the Ghost" sub-row on start screen */
.ghost-race-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.ghost-race-btn {
  min-height: 38px;
  padding: 8px 16px;
  border: 2px dashed rgba(90, 144, 200, 0.85);
  border-radius: 12px;
  background: rgba(138, 184, 232, 0.18);
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--ink);
  cursor: pointer;
  transition: background 80ms ease, transform 80ms ease;
}
.ghost-race-btn:hover { background: rgba(138, 184, 232, 0.34); }
.ghost-race-btn:active { transform: translateY(1px); }
.ghost-race-btn:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 2px; }

/* ============================================================
 *   Wave C2 — Post-race canvas overlay button row
 * ============================================================
 * Three HTML buttons absolutely-positioned over the canvas.
 * Cinematic (camera sweep, trophy, confetti, hat-tip) is THREE.js canvas.
 * Buttons stay HTML for accessibility: keyboard-focusable, tab order,
 * screen-reader-announceable, focus ring visible.
 * Fade in at t=1200ms (win) or t=1200ms (loss) via JS adding .visible.
 *
 * The existing #win-screen HTML overlay is kept as the reduced-motion
 * fallback path. Under reducedMotion the camera snaps and these buttons
 * fade in immediately.
 */
#postrace-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;        /* passthrough until buttons become visible */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 20;                 /* above canvas + vignette; below settings modal */
}
#postrace-overlay.visible {
  pointer-events: auto;
}

/* "Good race!" text for loss state */
#postrace-good-race {
  margin-bottom: 18px;
  padding: 12px 28px;
  background: rgba(255, 248, 230, 0.92);
  border: 3px solid var(--ink);
  border-radius: 999px;
  font-size: clamp(18px, 3.5vw, 26px);
  font-weight: 800;
  color: var(--ink);
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 280ms ease, transform 280ms ease;
  pointer-events: none;
}
#postrace-overlay.visible #postrace-good-race {
  opacity: 1;
  transform: translateY(0);
}
/* Hide when player won */
#postrace-good-race[hidden] { display: none !important; }

.postrace-btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 320ms ease, transform 320ms ease;
}
#postrace-overlay.visible .postrace-btn-row {
  opacity: 1;
  transform: translateY(0);
}

/* "Race Again" — primary action */
.postrace-btn-primary {
  min-width: 180px;
  min-height: var(--tap);
  padding: 16px 32px;
  border: 5px solid var(--ink);
  border-radius: var(--rad);
  background: var(--livery-yel);
  box-shadow: var(--shadow);
  font-family: inherit;
  font-weight: 900;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 80ms ease, background 80ms ease;
}
.postrace-btn-primary:hover { background: #ffc933; }
.postrace-btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.20); }
.postrace-btn-primary:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 4px; }

/* "Shop" and "Back to Start" — secondary actions */
.postrace-btn-secondary {
  min-height: var(--tap);
  min-width: 120px;
  padding: 12px 20px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: rgba(255, 248, 230, 0.90);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 80ms ease, background 80ms ease;
}
.postrace-btn-secondary:hover { background: var(--paper); }
.postrace-btn-secondary:active { transform: translateY(2px); }
.postrace-btn-secondary:focus-visible { outline: 4px solid var(--livery-red); outline-offset: 2px; }

/* Race stats chip row shown in post-race overlay */
#postrace-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 260ms ease 80ms, transform 260ms ease 80ms;
  pointer-events: none;
}
#postrace-overlay.visible #postrace-stats {
  opacity: 1;
  transform: translateY(0);
}
.postrace-stat {
  background: rgba(42, 26, 10, 0.78);
  color: var(--paper);
  padding: 8px 18px;
  border-radius: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}
.postrace-stat dt { font-size: 10px; letter-spacing: 2px; opacity: 0.6; text-transform: uppercase; margin: 0; }
.postrace-stat dd { margin: 3px 0 0; font-size: 18px; font-weight: 800; }
.postrace-stat-coins { color: var(--livery-yel); }
.postrace-stat-best  { background: rgba(245, 217, 141, 0.85); color: var(--ink); }
.postrace-stat-best dt { opacity: 0.5; }
.postrace-stat-best dd { font-size: 14px; }

/* Reduced-motion: no slide-in transitions on postrace row */
@media (prefers-reduced-motion: reduce) {
  .postrace-btn-row,
  #postrace-good-race,
  #postrace-stats {
    transition: opacity 180ms ease;
    transform: none !important;
  }
}
body.rm .postrace-btn-row,
body.rm #postrace-good-race,
body.rm #postrace-stats {
  transition: opacity 180ms ease !important;
  transform: none !important;
}

/* ============================================================
 *   Track B — Race fidelity HUD additions
 * ============================================================ */

/* Position chip (P1 / P2) — dark bg by default; green background when P1.
 * Constraint: no red/scolding colour for losing position. P2 stays neutral ink. */
.hud .chip-pos {
  background: rgba(42, 26, 10, 0.78);
  color: var(--paper);
  transition: background 220ms ease;
}
.hud .chip-pos .lab { opacity: 0.65; }
.hud .chip-pos.pos-first {
  background: rgba(60, 140, 60, 0.88);
  color: var(--paper);
}

/* Lap-split chip — shows running split for the current lap.
 * Tints green (ahead of PB split) or stays neutral (behind/no-PB).
 * Constraint #4: NO red when behind — neutral ink only. */
.hud .chip-split {
  background: rgba(42, 26, 10, 0.78);
  color: var(--paper);
  transition: background 220ms ease;
}
.hud .chip-split .lab { opacity: 0.65; }
.hud .chip-split.split-ahead {
  background: rgba(40, 120, 60, 0.84);
  color: var(--paper);
}

/* Lap-split flash overlay — shown briefly at lap completion.
 * Slides up from bottom-centre, fades out after 1.5s.
 * No red; delta shown as "+0.8" (neutral) or "-1.2" (green-tinted only). */
#lap-split-flash {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%) translateY(0);
  background: rgba(42, 26, 10, 0.88);
  color: var(--paper);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 800;
  letter-spacing: 1px;
  padding: 8px 20px;
  border-radius: 12px;
  border: 2px solid rgba(255, 248, 230, 0.25);
  pointer-events: none;
  white-space: nowrap;
  z-index: 12;
  opacity: 0;
  transition: opacity 180ms ease;
}
#lap-split-flash.flash-visible {
  opacity: 1;
}
#lap-split-flash.flash-faster {
  background: rgba(40, 120, 60, 0.92);
}
@media (prefers-reduced-motion: reduce) {
  #lap-split-flash { transition: none; }
}
body.rm #lap-split-flash { transition: none !important; }

/* Corner indicator — bottom-centre, above touch-UI layer.
 * Chevron arrow — left or right depending on upcoming corner direction.
 * Non-coercive: neutral ink on semi-transparent sand. No flashing. */
#corner-indicator {
  position: absolute;
  left: 50%;
  bottom: max(108px, calc(env(safe-area-inset-bottom) + 96px));
  transform: translateX(-50%);
  background: rgba(245, 217, 141, 0.75);
  border: 2px solid rgba(42, 26, 10, 0.60);
  border-radius: 12px;
  padding: 6px 20px;
  pointer-events: none;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Default hidden — JS adds [hidden] to remove via [hidden]{display:none!important} */
}
.corner-arrow {
  font-size: clamp(22px, 5vw, 36px);
  color: var(--ink);
  font-weight: 900;
  line-height: 1;
}
/* On phone keep the indicator away from pedals */
@media (pointer: coarse) {
  #corner-indicator {
    bottom: max(220px, calc(env(safe-area-inset-bottom) + 200px));
  }
}

/* ============================================================
 *   v2.3 — Championship Cup strip (start screen)
 * ============================================================ */
.cup-strip {
  width: 100%;
  max-width: 560px;
  margin: 10px 0 6px;
  border: 2px solid var(--ink);
  border-radius: var(--rad);
  background: rgba(255, 248, 230, 0.70);
  /* v2.4.12: do NOT clip overflow + do NOT shrink below content size.
     The .screen flex parent has fixed viewport height with center-aligned
     content; without flex-shrink:0 the cup-strip got squished to ~85 px
     when total content exceeded the viewport, hiding ~94 px of expanded
     cup cards (that's the "dropdown empty" maker report). overflow:hidden
     compounded the problem by clipping rather than overflowing visibly. */
  flex-shrink: 0;
}

.cup-strip-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(11px, 2vw, 14px);
  color: var(--ink);
  letter-spacing: 2px;
  text-transform: uppercase;
  min-height: var(--tap);
  touch-action: manipulation;
}
.cup-strip-header:focus-visible {
  outline: 3px solid var(--livery-red);
  outline-offset: 2px;
}
.cup-strip-chevron {
  font-size: 12px;
  margin-left: 8px;
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.cup-strip-body {
  padding: 6px 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  /* JS sets max-height for the reveal animation */
  overflow: hidden;
}

/* Cup card — compact square badge per cup.
 * v2.5.21: whole card is the click target; no separate Start button.
 * Locked cups are listed but dimmed + pointer-events:none. */
.cup-card {
  width: clamp(120px, 28vw, 152px);
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: rgba(245, 217, 141, 0.50);
  padding: 8px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
  transition: background 80ms ease, transform 80ms ease;
}
.cup-card:hover { background: rgba(245, 217, 141, 0.75); }
.cup-card:active { transform: translateY(1px); }
.cup-card:focus-visible { outline: 3px solid var(--livery-red); outline-offset: 2px; }
.cup-card-won {
  background: rgba(244, 180, 0, 0.35);
  border-color: var(--livery-yel);
}
.cup-card-won:hover { background: rgba(244, 180, 0, 0.52); }
/* Locked cup: dimmed, not interactive */
.cup-card-locked {
  opacity: 0.48;
  pointer-events: none;
  cursor: default;
}

.cup-card-header {
  font-weight: 700;
  font-size: clamp(10px, 2vw, 13px);
  letter-spacing: 1.5px;
  text-align: center;
  position: relative;
  width: 100%;
}

.cup-won-badge {
  color: var(--livery-yel);
  font-size: 14px;
  margin-right: 4px;
  text-shadow: 0 1px 0 var(--ink);
}

.cup-progress-chip {
  display: inline-block;
  background: var(--livery-red);
  color: var(--paper);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 20px;
  margin-top: 2px;
}

.cup-try-hint {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--dune);
  margin-top: 3px;
  letter-spacing: 0.5px;
}

/* v2.5.21 — cup card name (replaces old header+pips+button layout) */
.cup-card-name {
  font-weight: 800;
  font-size: clamp(11px, 2.5vw, 14px);
  letter-spacing: 1.5px;
  text-align: center;
  color: var(--ink);
}

/* v2.5.21 — cup card locked tag */
.cup-locked-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(42, 26, 10, 0.55);
  background: rgba(42, 26, 10, 0.10);
  border: 1px solid rgba(42, 26, 10, 0.25);
  border-radius: 10px;
  padding: 2px 7px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Cup card race-pip row — kept for future re-use if desired but hidden by default.
 * The v2.5.21 card shows only the progress hint text, not pips. */
.cup-card-races { display: none; }
.cup-race-pip   { display: none; }

/* Start button inside cup card — removed from v2.5.21 markup.
 * Rules kept temporarily so any cached HTML renders without broken layout. */
.btn-cup-start  { display: none; }

/* Narrow viewport: cups collapse into two per row */
@media (max-width: 380px) {
  .cup-strip-body { gap: 6px; }
  .cup-card { width: clamp(110px, 44vw, 145px); }
}

/* ============================================================
 *   v2.3 — Trophies section in shop
 * ============================================================ */
.shop-card-trophy {
  border: 2px solid var(--livery-yel);
}
.shop-card-locked {
  opacity: 0.60;
}
.trophy-unlock-cond {
  font-size: 10px;
  color: var(--dune);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.shop-card-trophy .shop-card-btn[disabled] {
  background: rgba(42, 26, 10, 0.12);
  cursor: not-allowed;
  border-color: rgba(42, 26, 10, 0.25);
}
