/* ============================================================
   NITRO//RUN V2 — AAA Arcade Visual Design System
   Palette: Near-black asphalt base, high-contrast neon accents
   Typefaces: Rajdhani (UI / Headers), Space Mono (Data / Stats)
   ============================================================ */

:root {
  --bg:            #06070a;
  --bg-2:          #0c0e15;
  --panel:         #0e111a;
  --panel-line:    #1c2233;
  --panel-glow:    rgba(63, 227, 224, 0.15);
  --text-hi:       #eef1fa;
  --text-lo:       #767d94;

  --cyan:          #3fe3e0;
  --violet:        #8a6bff;
  --pink:          #ff4d8d;
  --amber:         #ffb84d;
  --danger:        #ff4d4d;
  --green:         #57e08a;

  --coin:          #ffcf5c;
  --diamond:       #59d0ff;
  --petrol:        #6bff9e;
  --nitro:         #ff5fa2;

  --radius-s: 5px;
  --radius-m: 10px;
  --radius-l: 14px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Universal Visibility Rules */
.hidden { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Rajdhani', sans-serif;
  color: var(--text-hi);
  background-color: var(--bg);
}

.mono { font-family: 'Space Mono', monospace; }

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg);
  touch-action: none;
}

#ui-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}

.screen {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 10;
  transition: opacity .2s ease;
}

.overlay-only { background: rgba(3, 4, 7, 0.82); backdrop-filter: blur(6px); }

/* Screen Stacking Order */
#hud { z-index: 5; }
#touch-controls { z-index: 6; }
#voice-widget { z-index: 8; }
#screen-boot, #screen-menu { z-index: 10; }
#screen-worlds, #screen-missions { z-index: 14; }
#screen-garage { z-index: 16; }
#screen-gameover { z-index: 20; }
#screen-countdown { z-index: 24; }
#screen-pause { z-index: 28; }
#screen-howto, #screen-leaderboard, #modal-recap-preview { z-index: 35; }

/* ---------------- Atmospheric Backdrops (Outside The Game) ---------------- */
#screen-boot, #screen-menu, #screen-garage, #screen-worlds, #screen-missions {
  background:
    radial-gradient(ellipse 950px 550px at 50% -5%, rgba(63, 227, 224, 0.10), transparent 60%),
    radial-gradient(ellipse 800px 550px at 100% 105%, rgba(138, 107, 255, 0.08), transparent 60%),
    linear-gradient(180deg, rgba(8, 10, 16, 0.94), rgba(4, 5, 8, 0.98));
}

/* ---------------- Branding & Typography ---------------- */
.logo-block { text-align: center; margin-bottom: 22px; }
.logo-block.small { margin-bottom: 12px; }

.logo {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: clamp(2.8rem, 8.5vw, 4.8rem);
  letter-spacing: 0.05em;
  margin: 0;
  line-height: 1;
  color: var(--text-hi);
  text-shadow: 0 0 30px rgba(63, 227, 224, 0.45);
}
.logo .slash { color: var(--cyan); font-weight: 700; }

.tagline {
  margin: 8px 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.32em;
  color: var(--text-lo);
  font-weight: 600;
  text-transform: uppercase;
}

.menu-driver-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(350px, 88vw);
  margin: 0 auto 16px;
  padding: 10px 16px;
  background: rgba(14, 17, 26, 0.85);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  backdrop-filter: blur(8px);
}

.driver-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.driver-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.60rem;
  background: rgba(63, 227, 224, 0.15);
  color: var(--cyan);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
}
.menu-driver {
  margin: 0;
  font-family: 'Space Mono', monospace;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-hi);
}

.wallet-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--coin);
  background: rgba(255, 207, 92, 0.08);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 207, 92, 0.25);
}

/* ---------------- Panels & Buttons ---------------- */
.panel {
  width: min(370px, 86vw);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-m);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.panel-label {
  margin: 0 0 12px;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--text-lo);
  font-weight: 600;
  text-transform: uppercase;
}

.return-name {
  margin: 0 0 16px;
  font-size: 1.85rem;
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.name-input {
  flex: 1;
  background: #090b12;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  color: var(--text-hi);
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  padding: 13px 14px;
  letter-spacing: 0.06em;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.name-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(63, 227, 224, 0.28);
}
.name-input::placeholder { color: #3a4054; }

.btn-rnd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  color: #fff;
  font-size: 1.25rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}
.btn-rnd:hover { background: rgba(63, 227, 224, 0.15); border-color: var(--cyan); }

.name-error {
  min-height: 18px;
  margin: 8px 2px 0;
  font-size: 0.8rem;
  color: var(--danger);
}

.btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px 18px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  pointer-events: auto;
  text-transform: uppercase;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--cyan);
  color: #041017;
  box-shadow: 0 0 24px rgba(63, 227, 224, 0.32);
}
.btn-primary:hover { filter: brightness(1.15); box-shadow: 0 0 32px rgba(63, 227, 224, 0.5); }

.pulse-glow { animation: btnPulse 2s infinite ease-in-out; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(63, 227, 224, 0.3); }
  50% { box-shadow: 0 0 32px rgba(63, 227, 224, 0.65); transform: translateY(-1px); }
}

.btn-secondary {
  background: rgba(14, 17, 26, 0.85);
  border-color: var(--panel-line);
  color: var(--text-hi);
}
.btn-secondary:hover { border-color: var(--cyan); color: var(--cyan); }

.btn-accent {
  background: linear-gradient(90deg, #ff9020, #ffb84d);
  color: #120902;
  box-shadow: 0 0 22px rgba(255, 184, 77, 0.3);
}
.btn-accent:hover { filter: brightness(1.12); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-lo);
  font-size: 0.85rem;
}
.btn-ghost:hover { color: var(--text-hi); }

.btn-lg { padding: 16px 20px; font-size: 1.15rem; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; margin-top: 0; }

.menu-nav { width: min(350px, 88vw); margin: 0 auto; }

/* ---------------- FLOATING VOICE ASSISTANT WIDGET ---------------- */
.voice-widget {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: 14px;
  pointer-events: auto;
  z-index: 50;
}

.voice-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(10, 12, 18, 0.88);
  border: 1px solid var(--panel-line);
  border-radius: 22px;
  color: var(--text-hi);
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all .2s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.voice-pill:hover { border-color: var(--cyan); }

.voice-pill .mic-icon { font-size: 1.1rem; line-height: 1; }
.voice-labels { display: flex; flex-direction: column; text-align: left; }
.voice-status-text {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.05em;
}
.voice-transcript {
  font-size: 0.60rem;
  color: var(--text-lo);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-pill.state-listening {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(63, 227, 224, 0.45);
  animation: micPulse 1.4s infinite ease-in-out;
}
.voice-pill.state-listening .voice-status-text { color: var(--cyan); }
.voice-pill.state-processing { border-color: var(--amber); box-shadow: 0 0 16px rgba(255, 184, 77, 0.4); }
.voice-pill.state-processing .voice-status-text { color: var(--amber); }
.voice-pill.state-speaking { border-color: var(--nitro); box-shadow: 0 0 20px rgba(255, 95, 162, 0.45); }
.voice-pill.state-speaking .voice-status-text { color: var(--nitro); }
.voice-pill.state-denied, .voice-pill.state-unsupported { border-color: rgba(255, 77, 77, 0.45); opacity: 0.75; }

@keyframes micPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px rgba(63, 227, 224, 0.25); }
  50% { transform: scale(1.04); box-shadow: 0 0 24px rgba(63, 227, 224, 0.6); }
}

/* ---------------- GARAGE & TUNING SCREEN ---------------- */
.garage-wrap { width: min(980px, 95vw); max-height: 94vh; overflow-y: auto; padding-bottom: 20px; }
.garage-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.garage-title { margin: 0; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: 0.08em; }
.garage-title span { color: var(--cyan); }
.garage-head-actions { display: flex; align-items: center; gap: 12px; }
.garage-back { min-width: 100px; }

.garage-card {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: stretch;
  background: linear-gradient(145deg, rgba(16, 20, 30, 0.98), rgba(7, 9, 14, 0.98));
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-l);
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.garage-main {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr);
  min-width: 0;
}

.garage-arrow {
  border: 0;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-hi);
  font-size: 3.2rem;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.garage-arrow:hover { background: rgba(63, 227, 224, 0.12); color: var(--cyan); }
.garage-arrow:active { transform: scale(0.92); }

/* Showroom Podium */
.garage-preview {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(63, 227, 224, 0.12), transparent 58%), linear-gradient(180deg, #0b0e16, #06070a);
}

.showroom-podium {
  position: absolute;
  width: 220px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(63, 227, 224, 0.22), transparent 70%);
  border: 1px solid rgba(63, 227, 224, 0.35);
  bottom: 35px;
  filter: blur(1px);
}

.garage-car {
  width: 190px;
  height: 335px;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 28px 24px rgba(0, 0, 0, 0.8));
  transition: transform .25s ease;
}
.garage-preview:hover .garage-car { transform: translateY(-8px) scale(1.03); }

.garage-car .garage-car-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(1.1) contrast(1.04);
}

.underglow-preview {
  position: absolute;
  width: 200px;
  height: 70px;
  border-radius: 50%;
  bottom: 45px;
  z-index: 1;
  filter: blur(14px);
  opacity: 0.65;
  transition: background .2s ease;
}

.garage-preview.locked .garage-car {
  filter: grayscale(1) brightness(0.35) drop-shadow(0 20px 20px rgba(0, 0, 0, 0.8)) !important;
}

.garage-copy {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.garage-car-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.garage-copy h3 {
  font-size: clamp(2rem, 3.8vw, 3rem);
  margin: 4px 0 2px;
  letter-spacing: 0.08em;
}

.garage-unlock {
  font-family: 'Space Mono', monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.12em;
}

.garage-status {
  display: inline-flex;
  border: 1px solid var(--panel-line);
  padding: 3px 8px;
  border-radius: var(--radius-s);
  font-family: 'Space Mono', monospace;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-lo);
}

.garage-stats { display: grid; gap: 7px; margin: 10px 0 14px; }
.garage-stat {
  display: grid;
  grid-template-columns: 85px 1fr;
  gap: 10px;
  align-items: center;
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-lo);
}

.garage-bar {
  height: 6px;
  background: #181d2a;
  border-radius: 10px;
  overflow: hidden;
}
.garage-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: 10px;
  transition: width .2s ease;
}

/* Tuning Rack & Underglow Swatches */
.tuning-rack {
  background: rgba(10, 13, 20, 0.75);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.tuning-title {
  margin: 0 0 10px;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.tuning-modules {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}
.tune-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 22, 34, 0.7);
  padding: 6px 10px;
  border-radius: 4px;
}
.tune-label {
  display: flex;
  flex-direction: column;
}
.tune-label span:first-child { font-size: 0.85rem; font-weight: 600; }
.tune-level { font-family: 'Space Mono', monospace; font-size: 0.65rem; color: var(--cyan); }

.underglow-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}
.underglow-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-lo);
  font-weight: 700;
}
.swatch-list { display: flex; gap: 7px; }
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.color-swatch:hover { transform: scale(1.18); }
.color-swatch.active { border-color: #ffffff; box-shadow: 0 0 12px #fff; transform: scale(1.22); }
.swatch-cyan { background: #3fe3e0; }
.swatch-magenta { background: #ff4d8d; }
.swatch-gold { background: #ffb84d; }
.swatch-blue { background: #59d0ff; }
.swatch-green { background: #57e08a; }
.swatch-purple { background: #c94dff; }
.swatch-red { background: #ff4d4d; }

.garage-progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--text-lo);
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.garage-progress {
  height: 6px;
  background: #181d2a;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.garage-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width .25s ease;
}
.garage-progress i.done { background: var(--green); }

.garage-actions { display: flex; gap: 8px; }
.garage-actions .btn { flex: 1; margin-top: 0; }
.garage-actions .btn:disabled { opacity: 0.35; cursor: not-allowed; }

.garage-hint { text-align: center; color: var(--text-lo); font-size: 0.8rem; margin: 12px 0 0; }

/* ---------------- FULL-SCREEN WORLDS SHOWROOM ---------------- */
.worlds-wrap, .missions-wrap {
  width: min(1040px, 95vw);
  max-height: 94vh;
  overflow-y: auto;
  padding: 18px 24px 28px;
}

.worlds-head, .missions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.worlds-title, .missions-title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 0.08em;
}
.worlds-title span, .missions-title span { color: var(--cyan); }
.worlds-subtitle {
  color: var(--text-lo);
  font-size: 0.95rem;
  margin: 0 0 20px;
  line-height: 1.4;
}

.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}

.world-card {
  position: relative;
  background: rgba(13, 16, 26, 0.88);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-m);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  overflow: hidden;
}
.world-card:hover { border-color: var(--cyan); transform: translateY(-3px); }
.world-card.selected {
  border-color: var(--cyan);
  background: linear-gradient(145deg, rgba(63, 227, 224, 0.14), rgba(13, 16, 26, 0.95));
  box-shadow: 0 0 26px rgba(63, 227, 224, 0.22);
}
.world-card.locked { filter: grayscale(0.85) opacity(0.65); }

.world-badge {
  align-self: flex-start;
  font-family: 'Space Mono', monospace;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(63, 227, 224, 0.12);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.world-card.selected .world-badge { color: var(--green); background: rgba(87, 224, 138, 0.15); }

.world-card h3 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  letter-spacing: 0.05em;
}
.world-tag {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--cyan);
  font-weight: 600;
}
.world-desc {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--text-lo);
  line-height: 1.4;
  flex: 1;
}

/* ---------------- FULL-SCREEN MISSIONS HEADQUARTERS ---------------- */
.missions-section { margin-bottom: 24px; }
.section-title {
  font-family: 'Space Mono', monospace;
  font-size: 0.82rem;
  color: var(--cyan);
  letter-spacing: 0.15em;
  margin: 0 0 12px;
}
.section-subtitle {
  font-size: 0.84rem;
  color: var(--text-lo);
  margin: -6px 0 14px;
  line-height: 1.4;
}

.daily-missions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mission-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 18, 28, 0.85);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  padding: 12px 18px;
  gap: 12px;
}
.mission-item.completed {
  border-color: rgba(87, 224, 138, 0.5);
  background: rgba(87, 224, 138, 0.08);
}
.mission-item .m-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.m-title { font-size: 0.95rem; font-weight: 700; color: var(--text-hi); }
.m-prog-wrap { display: flex; align-items: center; gap: 8px; }
.m-prog-bar { flex: 1; height: 5px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; max-width: 140px; }
.m-prog-fill { height: 100%; background: var(--cyan); border-radius: 3px; }
.m-prog { font-family: 'Space Mono', monospace; font-size: 0.74rem; color: var(--text-lo); }

.m-reward-block {
  display: flex;
  align-items: center;
  gap: 10px;
}
.m-reward-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.m-reward-currency {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffcf5c;
}
.m-reward-score {
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--cyan);
}
.btn-claim-mission {
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.45);
  animation: pulseNeon 1.6s infinite ease-in-out;
}
.btn-claim-mission:hover {
  transform: scale(1.05);
}
.m-claimed-badge {
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 4px;
  padding: 4px 8px;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.ach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14, 18, 28, 0.85);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  padding: 12px 14px;
}
.ach-card.unlocked {
  border-color: rgba(255, 207, 92, 0.45);
  background: rgba(255, 207, 92, 0.08);
}
.ach-card.locked { opacity: 0.6; }
.ach-badge { font-size: 1.4rem; }
.ach-content h4 { margin: 0; font-size: 0.95rem; letter-spacing: 0.04em; }
.ach-content p { margin: 3px 0 0; font-size: 0.74rem; color: var(--text-lo); }

/* ---------------- RECAP IMAGE PREVIEW MODAL ---------------- */
.recap-img-container {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.recap-img-container canvas, .recap-img-container img {
  max-width: 100%;
  max-height: 58vh;
  border-radius: var(--radius-m);
  border: 1px solid var(--cyan);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.recap-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.recap-actions .btn { width: auto; min-width: 180px; }

/* ---------------- HUD (PORTRAIT-FIRST RACING) ---------------- */
.hud { position: absolute; inset: 0; pointer-events: none; }

.hud-top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.hud-block {
  display: flex;
  flex-direction: column;
  background: rgba(10, 13, 20, 0.60);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-s);
  padding: 6px 10px;
  backdrop-filter: blur(6px);
  min-width: 90px;
}
.hud-center { align-items: center; min-width: 110px; }
.hud-right { align-items: flex-end; min-width: 100px; }

.hud-label {
  font-size: 0.60rem;
  letter-spacing: 0.18em;
  color: var(--text-lo);
  font-weight: 600;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.hud-value { font-size: 1.05rem; font-weight: 700; color: var(--text-hi); }
.hud-value.big {
  font-size: 1.65rem;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(63, 227, 224, 0.4);
  line-height: 1.1;
}

.hud-world-tag {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.combo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 22px;
  justify-content: center;
}
.combo-wrap .hud-combo.hidden {
  display: inline-block !important;
  visibility: hidden !important;
  opacity: 0 !important;
}
.hud-combo {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--nitro);
}
.hud-combo-meter {
  width: 60px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}
.hud-combo-fill {
  height: 100%;
  width: 0%;
  background: var(--nitro);
  transition: width .08s linear;
}

.hud-resource-head {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 4px;
}
.meter {
  width: 105px;
  height: 8px;
  background: #12141d;
  border: 1px solid var(--panel-line);
  border-radius: 5px;
  overflow: hidden;
}
.meter-fill { height: 100%; width: 100%; transition: width .12s linear; }
.petrol-fill { background: linear-gradient(90deg, #2f9e5a, var(--petrol)); }
.petrol-fill.low {
  background: linear-gradient(90deg, #a13030, var(--danger));
  animation: petrolWarn .6s infinite;
}
@keyframes petrolWarn { 50% { opacity: 0.45; } }

.nitro-fill { background: linear-gradient(90deg, #7a2d55, var(--nitro)); }
.nitro-fill.full { box-shadow: 0 0 12px var(--nitro); }

.hud-bottom {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.hud-resources { display: flex; gap: 14px; }
.resource {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Space Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
}
.ico { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.ico.coin { background: var(--coin); border-radius: 50%; }
.ico.diamond { background: var(--diamond); transform: rotate(45deg); border-radius: 2px; }

.hud-nitro { display: flex; flex-direction: column; align-items: flex-end; }

/* In-Run Popup Floaters */
.popup-layer { position: absolute; inset: 0; pointer-events: none; }
.popup {
  position: absolute;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  transform: translate(-50%, -50%);
  animation: popupFloat 0.95s ease-out forwards;
  white-space: nowrap;
}
@keyframes popupFloat {
  0% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-48px); }
}

.pause-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 17, 25, 0.85);
  border: 1px solid var(--panel-line);
  color: var(--text-lo);
  font-size: 0.72rem;
  pointer-events: auto;
  cursor: pointer;
}

/* ---------------- TOUCH CONTROLS ---------------- */
.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 0 16px max(18px, env(safe-area-inset-bottom, 0px));
}

.touch-right {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}
.touch-btn {
  border-radius: 50%;
  border: 2px solid var(--panel-line);
  background: rgba(15, 17, 25, 0.85);
  color: var(--text-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.touch-brake {
  width: 78px;
  height: 60px;
  border-radius: var(--radius-l);
  font-size: 0.72rem;
  font-weight: 700;
}
.touch-nitro {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border-color: var(--nitro);
  color: var(--nitro);
  font-weight: 700;
  font-size: 0.74rem;
  box-shadow: 0 0 18px rgba(255, 95, 162, 0.25);
}
.touch-nitro:active { background: rgba(255, 95, 162, 0.35); }

/* ---------------- GAME OVER ---------------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
}
.stat.full-width { grid-column: span 2; }
.stat-label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  color: var(--text-lo);
  margin-bottom: 4px;
  text-transform: uppercase;
}
.stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-hi);
}

.badges { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.badge {
  font-size: 0.70rem;
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 4px;
}
.badge.best { background: rgba(255, 184, 77, 0.16); color: var(--amber); border: 1px solid rgba(255, 184, 77, 0.4); }
.badge.rank { background: rgba(63, 227, 224, 0.16); color: var(--cyan); border: 1px solid rgba(63, 227, 224, 0.4); }

.go-actions { display: flex; flex-direction: column; gap: 8px; }
.go-actions .btn { margin-top: 0; }

/* ---------------- COUNTDOWN ---------------- */
#screen-countdown { background: rgba(4, 5, 8, 0.45); }
.countdown-number {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: clamp(6.5rem, 24vw, 12rem);
  color: var(--text-hi);
  text-shadow: 0 0 45px rgba(63, 227, 224, 0.55);
  animation: countPulse .5s ease-out;
}
@keyframes countPulse {
  0% { transform: scale(1.6); opacity: 0; }
  60% { transform: scale(0.96); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.stage-banner {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 1.15rem;
  letter-spacing: 0.35em;
  font-weight: 700;
  color: var(--pink);
  opacity: 0;
  pointer-events: none;
}
.stage-banner.show { animation: stageIn 1.6s ease-out forwards; }
@keyframes stageIn {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

.stage-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  opacity: 0;
  pointer-events: none;
}
.stage-flash.flash { animation: whiteFlash .18s ease-out; }
@keyframes whiteFlash { 0% { opacity: 0.55; } 100% { opacity: 0; } }

/* Critical Fuel Alert (Ensured default hidden) */
.fuel-warning {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -50%);
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: #fff;
  padding: 7px 12px;
  border: 1px solid rgba(255, 77, 77, 0.6);
  background: rgba(120, 15, 22, 0.65);
  box-shadow: 0 0 24px rgba(255, 77, 77, 0.3);
  pointer-events: none;
  display: none !important;
}
.fuel-warning.show {
  display: block !important;
  animation: fuelPulse .75s infinite;
}
@keyframes fuelPulse {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.98); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
}

/* ---------------- LEADERBOARD & HOW TO PLAY MODALS ---------------- */
.modal-wrap {
  width: min(450px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-m);
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}
.modal-wrap.wide { width: min(600px, 94vw); }
.modal-wrap.narrow { width: min(320px, 84vw); text-align: center; }

.modal-title { margin: 0 0 12px; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.04em; }
.modal-title.alert { color: var(--pink); }

.lb-status { font-size: 0.8rem; color: var(--text-lo); margin-bottom: 10px; min-height: 16px; }
.lb-table { margin-bottom: 16px; }
.lb-row {
  display: grid;
  grid-template-columns: 42px 1fr 90px 80px;
  gap: 8px;
  align-items: center;
  padding: 9px 6px;
  border-bottom: 1px solid var(--panel-line);
  font-size: 0.88rem;
}
.lb-head {
  color: var(--text-lo);
  font-size: 0.70rem;
  letter-spacing: 0.14em;
  border-bottom: 1px solid var(--panel-line);
}
.lb-body { max-height: 52vh; overflow-y: auto; overscroll-behavior: contain; }
.lb-rank { font-family: 'Space Mono', monospace; color: var(--text-lo); }
.lb-score, .lb-dist { font-family: 'Space Mono', monospace; text-align: right; }
.lb-row.is-you { background: rgba(63, 227, 224, 0.09); border-radius: var(--radius-s); }
.lb-row.rank-1 .lb-rank { color: var(--coin); }
.lb-row.rank-2 .lb-rank { color: #cfd6e6; }
.lb-row.rank-3 .lb-rank { color: #d99a5b; }

.lb-you {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-lo);
  margin-bottom: 16px;
}
.lb-you b { color: var(--text-hi); font-family: 'Space Mono', monospace; }

.howto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.howto-item {
  background: var(--bg-2);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  padding: 9px 11px;
}
.howto-item .key {
  display: inline-block;
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  background: #171a24;
  border: 1px solid var(--panel-line);
  border-radius: 3px;
  padding: 2px 5px;
  margin: 0 3px 3px 0;
  color: var(--cyan);
}
.howto-item p { margin: 5px 0 0; font-size: 0.82rem; color: var(--text-lo); }

.voice-howto-box {
  background: rgba(63, 227, 224, 0.07);
  border: 1px solid rgba(63, 227, 224, 0.25);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  margin-bottom: 16px;
}
.voice-howto-box h4 { margin: 0 0 4px; font-size: 0.88rem; color: var(--cyan); }
.voice-howto-box p { margin: 0; font-size: 0.80rem; color: var(--text-lo); }

.howto-list { list-style: none; margin: 0 0 18px; padding: 0; }
.howto-list li {
  font-size: 0.86rem;
  color: var(--text-hi);
  padding: 7px 0;
  border-bottom: 1px solid var(--panel-line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.howto-list li:last-child { border-bottom: none; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.coin { background: var(--coin); }
.dot.near-miss { background: var(--cyan); }
.dot.petrol { background: var(--petrol); }
.dot.nitro { background: var(--nitro); }

/* ---------------- RESPONSIVE BREAKPOINTS ---------------- */
@media (max-width: 780px) {
  .worlds-grid { grid-template-columns: 1fr; }
  .achievements-grid { grid-template-columns: 1fr; }
  .garage-wrap { width: 96vw; }
  .garage-card { grid-template-columns: 42px 1fr 42px; }
  .garage-main { grid-template-columns: 1fr; }
  .garage-preview { min-height: 250px; }
  .garage-car { width: 155px !important; height: 270px !important; }
  .garage-copy { padding: 18px 20px; }
  .garage-copy h3 { font-size: 2rem; }
  .garage-stats { grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .garage-stat { grid-template-columns: 70px 1fr; font-size: 0.60rem; }
  .garage-arrow { font-size: 2.2rem; }
  .worlds-wrap, .missions-wrap { width: 96vw; padding: 14px; }
}

@media (max-width: 520px) {
  .voice-widget { top: max(8px, env(safe-area-inset-top, 0px)); right: 8px; }
  .voice-transcript { display: none; }
  .hud-top { left: 8px; right: 8px; gap: 5px; }
  .hud-block { padding: 4px 6px; min-width: 0; }
  .hud-value { font-size: 0.82rem; }
  .hud-value.big { font-size: 1.25rem; }
  .meter { width: 85px; height: 7px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .swatch-list { gap: 4px; }
  .color-swatch { width: 16px; height: 16px; }
}

/* ---------------- RUN RECAP MODAL & POSTER PREVIEW ---------------- */
.recap-img-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 14px 0 18px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-m);
  border: 1px solid rgba(63, 227, 224, 0.25);
  padding: 10px;
  max-height: 58vh;
  overflow: hidden;
}
.recap-img-container img {
  max-width: 100%;
  max-height: 52vh;
  height: auto;
  border-radius: var(--radius-s);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(63, 227, 224, 0.25);
  display: block;
  object-fit: contain;
}
.recap-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}
.btn-pulse {
  position: relative;
  overflow: hidden;
  animation: pulseNeon 2s infinite ease-in-out;
}
@keyframes pulseNeon {
  0%, 100% {
    box-shadow: 0 0 16px rgba(255, 95, 162, 0.35);
  }
  50% {
    box-shadow: 0 0 28px rgba(255, 95, 162, 0.7), 0 0 12px rgba(63, 227, 224, 0.4);
  }
}

/* ---------------- SOCIAL SHARING & LINK ACTIONS ---------------- */
.go-share-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 2px 0 4px;
}
.share-link-box {
  display: flex;
  gap: 8px;
  margin: 14px 0 12px;
  background: rgba(10, 13, 20, 0.85);
  border: 1px solid rgba(63, 227, 224, 0.3);
  border-radius: var(--radius-s);
  padding: 6px 8px;
  align-items: center;
}
.share-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--cyan);
  font-size: 0.78rem;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.social-share-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}
.btn-social {
  padding: 9px 18px;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: var(--radius-s);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-whatsapp {
  background: #25D366;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}
.btn-whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.55);
}
.btn-instagram {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(220, 39, 67, 0.35);
}
.btn-instagram:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 39, 67, 0.55);
}

.wallet-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-lo);
  letter-spacing: 0.08em;
  margin-right: 2px;
}
.currency-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: #ffcf5c;
  margin-left: 2px;
}

/* Garage Selection Button Active State */
#btn-garage-select.selected {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
  color: #10b981;
  font-weight: 800;
  cursor: default;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
  pointer-events: none;
}

/* Share Race Summary Card */
.share-summary-card {
  background: rgba(14, 18, 28, 0.9);
  border: 1px solid rgba(63, 227, 224, 0.35);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  margin: 14px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.ssc-top {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}
.ssc-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #fff;
}
.ssc-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-lo);
}
.ssc-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
}
.ssc-score {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(63, 227, 224, 0.5);
  letter-spacing: 0.04em;
}
.ssc-bottom {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 6px;
  font-size: 0.82rem;
  color: var(--text-lo);
}
.ssc-bottom b {
  color: var(--text-hi);
}


