/* ============================================================
   PIXEL RACER — STYLESHEET
   Organized into: Tokens → Reset → Layout → HUD → Stage →
   Touch Controls → Screens → Components → Animations →
   Responsive
   ============================================================ */

/* ------------------------------------------------------------
   1. DESIGN TOKENS — a single premium dark neon palette.
------------------------------------------------------------- */

:root {
  --font-display: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Consolas', 'Menlo', monospace;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition-fast: 120ms ease;
  --transition-med: 240ms ease;

  --bg: #0a0e1a;
  --bg-elevated: #10152a;
  --surface: rgba(21, 27, 48, 0.72);
  --surface-solid: #151b30;
  --border: #262f4d;
  --text: #eef1fb;
  --text-muted: #8891ab;

  --accent: #00f0ff;      /* cyan — primary */
  --accent-2: #ff2fd0;    /* pink — secondary */
  --gold: #ffd166;        /* coins */
  --danger: #ff4d6d;
  --success: #4ade80;

  --road: #23283a;
  --road-line: #eef1fb;
  --grass: #12331f;
  --sand: #4a3520;

  --shadow-glow: 0 0 24px rgba(0, 240, 255, 0.3);
  --shadow-glow-pink: 0 0 24px rgba(255, 47, 208, 0.35);
}

/* ------------------------------------------------------------
   2. RESET & BASE
------------------------------------------------------------- */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

/* Always reserve the scrollbar's width. Without this, any small
   change in page height (a power-up chip appearing, HUD content
   changing) can cross the "needs a scrollbar" threshold and shift
   every element's available width by ~15px — which reads as the
   game board "zooming". This one line removes that possibility
   for the entire app, permanently. */
html { scrollbar-gutter: stable; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(0, 240, 255, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(255, 47, 208, 0.06) 0%, transparent 45%);
  /* Fixed (not scroll) attachment anchors these corner glows to the
     viewport instead of the page. Without this, the same gradient
     is painted once across the *whole* scrollable menu — so on a
     tall screen you scroll straight past both corner glows into
     plain flat --bg, which reads as the background randomly
     changing shade as you scroll. Fixed attachment keeps the exact
     same look in view at all times, on every screen. */
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior: none;
  /* pan-y (not "manipulation"): keeps normal vertical scrolling on
     menu screens, but — unlike "manipulation" — also blocks pinch-
     zoom and double-tap-zoom everywhere. Pinch-zoom triggered by
     pressing two touch controls at once (e.g. accelerate + nitro)
     is what was causing the board to visually "grow/shrink" on
     power-ups; this removes the gesture at its source. See the
     matching JS-side belt-and-suspenders guard in INPUT. */
  touch-action: pan-y;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.hidden { display: none !important; }

.accent-pink { color: var(--accent-2); }

/* ------------------------------------------------------------
   3. LOADING SCREEN
------------------------------------------------------------- */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bg);
  transition: opacity 420ms ease;
}

.loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loading-logo { display: flex; align-items: center; gap: 10px; }
.loading-logo-icon { font-size: 34px; animation: loadingSpin 1.6s linear infinite; display: inline-block; }
.loading-logo-text {
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-shadow: 0 0 18px var(--accent);
}

.loading-bar { width: min(240px, 70vw); height: 6px; border-radius: 999px; background: var(--surface-solid); overflow: hidden; }
.loading-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 160ms ease; }
.loading-hint { font-size: 12px; color: var(--text-muted); }

@keyframes loadingSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .loading-logo-icon { animation: none; }
}

/* ------------------------------------------------------------
   4. APP LAYOUT
------------------------------------------------------------- */

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
  gap: 10px;
}

/* ------------------------------------------------------------
   5. HUD — fixed-height row above the stage. Its own height can
   vary slightly with the power-up strip's content, but because
   of scrollbar-gutter above, that never touches the stage's width.
------------------------------------------------------------- */

.hud {
  width: min(420px, 100%);
  flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }

.hud-stat { display: flex; flex-direction: column; min-width: 40px; }
.hud-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.hud-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-coins { color: var(--gold); }

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.icon-btn:hover { transform: scale(1.08); box-shadow: var(--shadow-glow); }

.hud-bars { gap: 10px; }
.bar-group { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 120px; }
.bar-label { font-size: 10px; color: var(--text-muted); width: 30px; }

.stat-bar {
  flex: 1; height: 8px; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--border); overflow: hidden;
}
.stat-bar-fill { height: 100%; width: 100%; transition: width 160ms ease; }
.stat-bar--health .stat-bar-fill { background: linear-gradient(90deg, var(--danger), var(--gold), var(--success)); }
.stat-bar--nitro .stat-bar-fill { background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* ------------------------------------------------------------
   6. STAGE — the locked-size game board.
   width + aspect-ratio + flex-shrink together guarantee this
   box's footprint never changes for ANY reason — not on window
   resize, not on nitro/power-ups, not on HUD content changing,
   not on layout changes anywhere else on the page.
------------------------------------------------------------- */

.stage {
  position: relative;
  width: min(420px, 100%);
  aspect-ratio: 420 / 760;
  max-height: 78vh;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-glow), 0 20px 60px rgba(0, 0, 0, 0.4);
  background: var(--bg-elevated);
  touch-action: none; /* the canvas itself never needs page scroll/zoom gestures */
  --powerup-color: var(--accent);
}

/* Power-up "border glow" — an animated box-shadow ring, set via JS
   in UI.setPowerUpAura(). box-shadow paints OUTSIDE the element's
   border box and is never part of its layout size, so this can
   pulse freely without ever affecting the board's actual pixel
   width/height (even though .stage clips its own contents with
   overflow: hidden — that only clips children, never the element's
   own shadow). Keep the blur/spread modest so the glow always
   reads as a border effect, never as the board itself growing. */
.stage.stage-powered {
  animation: powerupBorderPulse 1.1s ease-in-out infinite;
}

@keyframes powerupBorderPulse {
  0%, 100% {
    box-shadow: var(--shadow-glow), 0 0 0 2px var(--powerup-color), 0 20px 60px rgba(0, 0, 0, 0.4);
  }
  50% {
    box-shadow: var(--shadow-glow), 0 0 22px 4px var(--powerup-color), 0 20px 60px rgba(0, 0, 0, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage.stage-powered { animation: none; box-shadow: var(--shadow-glow), 0 0 0 2px var(--powerup-color), 0 20px 60px rgba(0, 0, 0, 0.4); }
}

/* When max-height: 78vh is the binding constraint (short viewports,
   landscape phones), width should shrink to match — otherwise the
   aspect-ratio box would overflow horizontally. This keeps the
   board's *proportions* fixed while its absolute size still only
   ever responds to viewport, never to gameplay events. */
@media (max-aspect-ratio: 420/760) {
  .stage { width: auto; height: 78vh; }
}

#race-canvas { width: 100%; height: 100%; display: block; }

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 8, 14, 0.6);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--transition-med);
}

.countdown-number {
  font-size: clamp(64px, 20vw, 120px);
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent);
  animation: countPulse 1s ease;
}

.overlay-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 30px;
  text-align: center;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 220px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.overlay-card h2 { font-size: 22px; }
.muted { color: var(--text-muted); font-size: 13px; }

.popup-layer { position: absolute; inset: 0; pointer-events: none; }
.score-popup {
  position: absolute;
  font-weight: 800; font-size: 16px;
  color: var(--gold); text-shadow: 0 0 10px var(--gold);
  animation: floatUp 800ms ease-out forwards;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}
.score-popup--drift { color: var(--accent); text-shadow: 0 0 10px var(--accent); }
.score-popup--powerup { font-size: 14px; }
.score-popup--overtake { color: var(--success); text-shadow: 0 0 10px var(--success); }

/* Power-up UI indicator strip — same safe pattern as the stat
   bars: it lives in the HUD's normal flow, and scrollbar-gutter
   plus the stage's flex-shrink:0 mean its content changing can
   never resize the board. */
.powerup-strip { display: flex; gap: 6px; flex-wrap: wrap; min-height: 0; }
.powerup-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 9px; font-size: 10px; font-weight: 700;
  animation: chipIn 200ms ease;
}
.powerup-chip .chip-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------
   7. TOUCH CONTROLS — large, thumb-friendly, mobile only.
   Positioned fixed at the bottom of the viewport so they always
   sit over the stage without participating in page flow (so
   they can never push/resize the board either).
------------------------------------------------------------- */

.touch-controls {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  z-index: 50;
}

.touch-cluster { display: flex; gap: 10px; pointer-events: auto; }
.touch-cluster--steer { align-items: center; }
.touch-cluster--action { flex-direction: column; align-self: center; }
.touch-cluster--pedals { flex-direction: column; }

.touch-btn {
  background: rgba(21, 27, 48, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 800;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  touch-action: none;
  transition: transform 80ms ease, background 80ms ease;
}

.touch-btn--round { width: 62px; height: 62px; border-radius: 50%; }
.touch-btn--gas { background: rgba(0, 240, 255, 0.16); border-color: var(--accent); }
.touch-btn--accent {
  width: 68px; height: 44px; border-radius: var(--radius-md);
  font-size: 11px; letter-spacing: 0.04em;
  background: rgba(255, 47, 208, 0.14); border-color: var(--accent-2);
}

.touch-btn:active,
.touch-btn.is-active {
  transform: scale(0.9);
  background: var(--accent);
  color: var(--bg);
  box-shadow: var(--shadow-glow);
}

/* ------------------------------------------------------------
   8. SCREENS (menu / setup / garage / etc.)
------------------------------------------------------------- */

.screen { width: 100%; display: flex; justify-content: center; padding: 20px 0 100px; }

.panel {
  width: min(440px, 100%);
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: riseIn var(--transition-med);
}

.panel--wide { width: min(680px, 100%); }

.panel h1 { font-size: 22px; }

.menu-logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.menu-logo-icon { font-size: 30px; }
.logo { font-size: clamp(26px, 6vw, 36px); text-align: center; letter-spacing: 0.02em; text-shadow: 0 0 24px var(--accent); }
.tagline { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: -8px; }
.menu-credit { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: -6px; }

.menu-nav { display: flex; flex-direction: column; gap: 8px; }

.menu-wallet { text-align: center; font-size: 13px; color: var(--gold); }

.app-footer { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ------------------------------------------------------------
   9. FORM / FIELD ELEMENTS
------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.field-hint { font-size: 12px; color: var(--text-muted); }

.segmented {
  display: flex; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 4px; gap: 4px;
}
.segmented--wrap { flex-wrap: wrap; }

.segment {
  flex: 1; min-width: 90px; padding: 10px 8px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  text-align: center;
}
.segment.active { background: var(--accent); color: var(--bg); box-shadow: var(--shadow-glow); }

/* ------------------------------------------------------------
   10. BUTTONS
------------------------------------------------------------- */

.btn {
  padding: 12px 20px; border-radius: var(--radius-md);
  font-weight: 700; font-size: 14px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  border: 1px solid transparent;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--bg); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.btn-lg { padding: 16px 24px; font-size: 16px; }
.btn-menu { background: var(--bg-elevated); border-color: var(--border); text-align: left; }
.btn-menu:hover { border-color: var(--accent); transform: translateX(3px); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--bg); }
.btn-sm { padding: 7px 12px; font-size: 12px; }

.start-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.controls-hint { border-top: 1px solid var(--border); padding-top: 12px; font-size: 12px; color: var(--text-muted); }
.controls-hint h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; color: var(--text-muted); }
.controls-hint ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
kbd { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-family: var(--font-mono); font-size: 10px; }

/* ------------------------------------------------------------
   11. CARD GRID (tracks / cars in race setup, garage, tracks screen)
------------------------------------------------------------- */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.card-grid--cars { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.pick-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px; text-align: left;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  position: relative;
}
.pick-card:hover { transform: translateY(-2px); }
.pick-card.selected { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.pick-card.locked { opacity: 0.6; }

.pick-card-preview {
  width: 100%; height: 64px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.pick-card-name { font-weight: 700; font-size: 13px; }
.pick-card-meta { font-size: 11px; color: var(--text-muted); }
.pick-card-lock { position: absolute; top: 8px; right: 8px; font-size: 13px; }

.mini-stats { display: flex; flex-direction: column; gap: 3px; }
.mini-stat { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-muted); }
.mini-stat-bar { flex: 1; height: 4px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.mini-stat-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ------------------------------------------------------------
   12. UPGRADES LIST
------------------------------------------------------------- */

.upgrade-list { display: flex; flex-direction: column; gap: 10px; }
.upgrade-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 14px; flex-wrap: wrap;
}
.upgrade-info { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.upgrade-name { font-weight: 700; font-size: 14px; }
.upgrade-dots { display: flex; gap: 4px; }
.upgrade-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.upgrade-dot.filled { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

/* ------------------------------------------------------------
   13. MISSIONS
------------------------------------------------------------- */

.mission-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.mission-item {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.mission-item.claimed { opacity: 0.55; }
.mission-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mission-name { font-size: 13px; font-weight: 700; }
.mission-reward { font-size: 12px; color: var(--gold); white-space: nowrap; }
.mission-progress-bar { height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.mission-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--success)); transition: width 200ms ease; }
.mission-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-muted); }

/* ------------------------------------------------------------
   14. ACHIEVEMENTS
------------------------------------------------------------- */

.achievement-list { list-style: none; display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow-y: auto; }
.achievement-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-elevated); opacity: 0.5;
}
.achievement-item.unlocked { opacity: 1; border-color: var(--accent); box-shadow: var(--shadow-glow); }
.achievement-icon { font-size: 20px; }
.achievement-name { font-weight: 700; font-size: 13px; }
.achievement-desc { font-size: 11px; color: var(--text-muted); }

/* ------------------------------------------------------------
   15. SETTINGS TOGGLES
------------------------------------------------------------- */

.setting-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.toggle { width: 46px; height: 26px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border); position: relative; transition: background var(--transition-fast); }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle-dot { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform var(--transition-fast); }
.toggle[aria-checked="true"] .toggle-dot { transform: translateX(20px); background: var(--bg); }

/* ------------------------------------------------------------
   16. RESULT SCREENS (race complete / game over)
------------------------------------------------------------- */

.result-title { text-align: center; text-shadow: 0 0 20px var(--accent); font-size: clamp(24px, 6vw, 32px); }
.result-title--danger { color: var(--danger); text-shadow: 0 0 20px var(--danger); animation: shake 400ms ease; }
.result-sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: -8px; }
.new-record { text-align: center; color: var(--gold); font-weight: 700; animation: pulse 1.2s infinite; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-stat { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.result-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.result-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------
   17. TOAST
------------------------------------------------------------- */

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--surface-solid); border: 1px solid var(--accent); box-shadow: var(--shadow-glow);
  border-radius: var(--radius-md); padding: 10px 16px;
  display: flex; align-items: center; gap: 10px; z-index: 999;
  animation: toastIn 380ms ease, toastOut 380ms ease 2.6s forwards;
}
.toast-title { font-size: 10px; text-transform: uppercase; color: var(--accent); letter-spacing: 0.05em; }
.toast-body { font-size: 12px; font-weight: 600; }

/* ------------------------------------------------------------
   18. ANIMATIONS
------------------------------------------------------------- */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes countPulse { 0% { transform: scale(0.6); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes floatUp { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.85); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1.15); } }
@keyframes chipIn { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, -20px); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------
   19. RESPONSIVE
------------------------------------------------------------- */

@media (min-width: 820px) {
  .touch-controls { display: none; }
}

@media (max-width: 480px) {
  .panel { padding: 22px 18px; }
  .hud-value { font-size: 13px; }
  .touch-btn--round { width: 56px; height: 56px; }
  .touch-btn--accent { width: 60px; height: 40px; }
}

/* Short/landscape viewports on phones — keep the HUD compact so
   the (still fixed-aspect-ratio) stage has room to breathe. */
@media (max-height: 560px) {
  .hud { padding: 5px 10px; }
  .hud-value { font-size: 12px; }
  .screen { padding-top: 10px; }
}
