:root {
  --bg: #d8eef8;
  --panel: rgba(255, 252, 248, 0.94);
  --red: #e8233a;
  --blue: #1a8fff;
  --amber: #f0a020;
  --green: #12c86a;
  --text: #1a2433;
  --muted: #5a6a7e;
  --line: rgba(26, 36, 51, 0.12);
  --font-display: "Orbitron", sans-serif;
  --font-ui: "Rajdhani", sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #3a5060;
  color: var(--text);
  font-family: var(--font-ui);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}
#game-wrap { position: absolute; inset: 0; }
#game { display: block; width: 100%; height: 100%; }

/* Mobile / narrow screens — block access */
#mobile-block {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(180, 220, 245, 0.7), rgba(255, 210, 160, 0.55)),
    radial-gradient(circle at 30% 20%, rgba(255, 90, 100, 0.2), transparent 40%),
    #c8e4f5;
}

.mobile-block-panel {
  width: min(420px, 100%);
  padding: 36px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(40, 90, 140, 0.22);
}

.mobile-block-panel h2 {
  color: var(--red);
  font-size: clamp(1.4rem, 6vw, 1.8rem);
}

.mobile-block-panel .tagline {
  margin-bottom: 0;
  font-size: 1.05rem;
}

#split-divider {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 3px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.35), transparent);
  pointer-events: none;
  z-index: 4;
}

#split-labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

.split-label {
  position: absolute;
  top: 12px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 252, 248, 0.88);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(30, 60, 100, 0.12);
}

.split-label.left { left: 14px; color: var(--red); border-color: rgba(255, 59, 74, 0.4); }
.split-label.right { left: calc(50% + 14px); color: var(--blue); border-color: rgba(59, 167, 255, 0.4); }

/*
  Top HUD bands (no overlap):
  1) 12px  — split labels · WANTED · garage/settings
  2) 56px  — damage bars (clear of play-controls on the right)
  3) 104px — cash / speed / heat cards
*/
#damage-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  z-index: 7;
}

.dmg-panel {
  position: absolute;
  top: 56px;
  width: min(34%, 240px);
}

.dmg-panel.left { left: 18px; }
/* Keep clear of #play-controls (~148px wide + padding) */
.dmg-panel.right {
  right: 178px;
  text-align: right;
}

.dmg-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
  color: var(--muted);
  text-shadow: none;
}

.dmg-panel.left .dmg-label { color: var(--red); }
.dmg-panel.right .dmg-label { color: var(--blue); }

.dmg-track {
  height: 12px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(26, 36, 51, 0.18);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(40, 80, 120, 0.15);
}

.dmg-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #3dff8a, #ffc14a, #ff3b4a);
  background-size: 280px 100%;
  transition: width 0.12s linear;
  box-shadow: 0 0 10px rgba(255, 80, 60, 0.35);
}

.dmg-fill.critical {
  animation: dmgFlash 0.45s ease-in-out infinite;
}

@keyframes dmgFlash {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.45); }
}

#wanted-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.35em;
  color: #fff;
  background: linear-gradient(90deg, transparent, rgba(220, 30, 40, 0.85), transparent);
  padding: 8px 36px;
  max-width: min(42vw, 320px);
  text-align: center;
  pointer-events: none;
  animation: wantedPulse 0.8s ease-in-out infinite;
}

@keyframes wantedPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#zone-toast {
  position: absolute;
  bottom: 16%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--text);
  background: rgba(255, 252, 248, 0.92);
  border: 1px solid var(--line);
  padding: 10px 22px;
  border-radius: 8px;
  pointer-events: none;
  transition: opacity 0.25s ease;
  box-shadow: 0 8px 24px rgba(40, 80, 120, 0.15);
}

#zone-toast.gas { border-color: rgba(255, 140, 60, 0.65); color: #d06010; }
#zone-toast.hospital { border-color: rgba(40, 120, 200, 0.45); color: #1a6aaa; }
#zone-toast.nightclub { border-color: rgba(255, 70, 180, 0.65); color: #c02088; }
#zone-toast.precinct { border-color: rgba(70, 140, 255, 0.7); color: #1a5ecc; }
#zone-toast.bank { border-color: rgba(220, 160, 40, 0.7); color: #b07810; }

#car-alert {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 640px);
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.12em;
  line-height: 1.35;
  text-align: left;
  color: #5a2a00;
  background: rgba(255, 236, 180, 0.95);
  border: 2px solid rgba(220, 120, 20, 0.85);
  padding: 12px 22px;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(180, 80, 20, 0.28);
  animation: carAlertPulse 0.7s ease-in-out infinite;
}

#car-alert.fuel {
  color: #5a2a00;
  border-color: rgba(220, 120, 20, 0.85);
  background: rgba(255, 236, 180, 0.95);
}

#car-alert.heat {
  color: #6a1010;
  border-color: rgba(220, 40, 40, 0.9);
  background: rgba(255, 210, 200, 0.96);
}

.car-alert-icon {
  font-size: 1.45rem;
  line-height: 1;
  animation: carAlertIcon 0.55s ease-in-out infinite;
}

@keyframes carAlertPulse {
  0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.82; transform: translateX(-50%) scale(1.02); }
}

@keyframes carAlertIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.car-gameover-panel .car-gameover-icon {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: 8px;
  color: #c03020;
}

.car-gameover-panel .eyebrow {
  color: #c03020;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(180, 220, 245, 0.55), rgba(255, 210, 160, 0.45)),
    radial-gradient(circle at 30% 20%, rgba(255, 90, 100, 0.18), transparent 40%),
    radial-gradient(circle at 75% 70%, rgba(40, 160, 255, 0.2), transparent 42%);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.overlay.hidden, .hidden { display: none !important; }

.panel {
  width: min(780px, 94vw);
  padding: clamp(22px, 3.2vh, 36px) clamp(22px, 3vw, 40px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(40, 90, 140, 0.22);
  max-height: min(94vh, 94dvh);
  overflow-y: auto;
}

.panel.compact {
  width: min(400px, 90vw);
  padding: clamp(24px, 3.5vh, 36px) clamp(22px, 3vw, 32px);
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  color: var(--amber);
  margin-bottom: 12px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.2rem, 5.5vw, 3.4rem);
  letter-spacing: 0.04em;
  line-height: 1;
  margin-bottom: 10px;
}

h1 span { color: var(--red); }

h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.tagline {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 22px;
}

.mission-hint { color: var(--green); margin-bottom: 16px; }

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  padding: 12px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mode-btn:hover {
  transform: translateY(-1px);
  color: var(--text);
  border-color: rgba(26, 36, 51, 0.28);
}

.mode-btn.active {
  color: #fff;
  border-color: rgba(232, 35, 58, 0.55);
  background: linear-gradient(135deg, rgba(232, 35, 58, 0.9), rgba(255, 122, 59, 0.85));
  box-shadow: 0 6px 22px rgba(232, 35, 58, 0.28);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

body.mode-1p .controls-grid {
  grid-template-columns: 1fr;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

body.mode-1p #p2-controls { display: none; }

body.mode-1p .split-label.right,
body.mode-1p #split-divider,
body.mode-1p .dmg-panel.right,
body.mode-1p .p2-hud {
  display: none !important;
}

body.mode-1p .dmg-panel.left {
  left: 18px;
  transform: none;
  width: min(42%, 280px);
  text-align: left;
}

/* Keep P1 card on the left so the guide arrow above the car stays visible */
body.mode-1p #hud {
  justify-content: space-between;
}
body.mode-1p .hud-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
body.mode-1p .p1-hud {
  margin-right: auto;
}

.control-card {
  text-align: left;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
}

.control-card.p1 { border-color: rgba(255, 59, 74, 0.35); }
.control-card.p2 { border-color: rgba(59, 167, 255, 0.35); }

.car-badge {
  width: 88px;
  height: 40px;
  margin-bottom: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: none;
  border-radius: 0;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}
.car-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  display: block;
  pointer-events: none;
  user-select: none;
}
.car-badge.red {
  filter: drop-shadow(0 3px 12px rgba(255, 59, 74, 0.55));
}
.car-badge.blue {
  filter: drop-shadow(0 3px 12px rgba(59, 167, 255, 0.55));
}

.control-card h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.control-card .keys { color: var(--muted); margin-bottom: 10px; }
.control-card ul { list-style: none; color: var(--muted); font-size: 0.95rem; }
.control-card li { margin: 4px 0; }

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid rgba(26, 36, 51, 0.16);
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--font-display);
  font-size: 0.68rem;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.92rem;
  padding: 14px 28px;
  border-radius: 999px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--red), #ff7a3b);
  color: white;
  box-shadow: 0 8px 28px rgba(255, 59, 74, 0.35);
  margin-bottom: 10px;
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(255, 59, 74, 0.45);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  margin-top: 8px;
  display: block;
  width: 100%;
}

.btn.ghost:hover {
  color: var(--text);
  border-color: rgba(26, 36, 51, 0.28);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-row .btn.ghost {
  margin-top: 0;
  flex: 1;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 8px 0 22px;
  text-align: left;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  user-select: none;
}

.settings-row:hover {
  border-color: rgba(26, 36, 51, 0.28);
}

.settings-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-label strong {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text);
}

.settings-label small {
  color: var(--muted);
  font-size: 0.92rem;
}

.settings-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-switch {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(26, 36, 51, 0.18);
  border: 1px solid rgba(26, 36, 51, 0.12);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.settings-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(30, 60, 100, 0.22);
  transition: transform 0.18s ease;
}

.settings-row input:checked + .settings-switch {
  background: linear-gradient(135deg, var(--red), #ff7a3b);
  border-color: transparent;
}

.settings-row input:checked + .settings-switch::after {
  transform: translateX(20px);
}

.settings-row input:focus-visible + .settings-switch {
  outline: 2px solid rgba(26, 143, 255, 0.55);
  outline-offset: 2px;
}

.hint { color: var(--muted); font-size: 0.95rem; }

.auth-panel h2 { margin-bottom: 8px; }

.auth-form {
  display: grid;
  gap: 14px;
  text-align: left;
  margin: 8px 0 16px;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-field span {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.auth-field input {
  appearance: none;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  border-color: rgba(232, 35, 58, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 35, 58, 0.12);
}

.auth-error {
  color: var(--red);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  text-align: center;
}

.auth-form .btn.primary {
  margin-bottom: 0;
  width: 100%;
}

.auth-form .btn.ghost {
  margin-top: 0;
}

.profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  text-align: left;
}

.profile-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.profile-email {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-summary {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.ghost.profile-logout {
  width: auto;
  margin-top: 0;
  padding: 10px 14px;
  font-size: 0.68rem;
  flex-shrink: 0;
  white-space: nowrap;
}

#hud {
  position: absolute;
  top: 104px;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 18px;
  pointer-events: none;
  z-index: 5;
}

#play-controls {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.play-ctrl-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 148px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 248, 0.9);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(40, 80, 120, 0.12);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.play-ctrl-btn:hover {
  border-color: rgba(240, 160, 32, 0.55);
  background: #fff;
  transform: translateY(-1px);
}

#play-pause-btn:hover {
  border-color: rgba(255, 90, 60, 0.5);
}

.play-ctrl-btn kbd {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}

.hud-card {
  min-width: 168px;
  max-width: min(220px, 28vw);
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 252, 248, 0.82);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(40, 80, 120, 0.12);
}

.p1-hud { border-color: rgba(255, 59, 74, 0.4); }
.p2-hud { border-color: rgba(59, 167, 255, 0.4); text-align: right; }

.hud-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}

.p1-hud .hud-label { color: var(--red); }
.p2-hud .hud-label { color: var(--blue); }

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.98rem;
  line-height: 1.35;
}

.p2-hud .hud-row { flex-direction: row-reverse; }
.hud-row span { color: var(--muted); font-weight: 600; }
.hud-row strong {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.hud-center { text-align: center; padding-top: 4px; }

#race-timer {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

#lap-target {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  margin-top: 2px;
}

#shared-cash {
  margin-top: 8px;
  font-family: var(--font-display);
  color: var(--amber);
  letter-spacing: 0.08em;
  font-size: 1rem;
}

.cash-big {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--amber);
  letter-spacing: 0.06em;
}

/* ——— Garage showroom ——— */
.garage-overlay {
  place-items: stretch;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(190, 225, 248, 0.75), rgba(255, 220, 180, 0.55)),
    radial-gradient(ellipse at 28% 40%, rgba(255, 140, 80, 0.2), transparent 45%),
    radial-gradient(ellipse at 70% 70%, rgba(60, 150, 255, 0.22), transparent 50%),
    #c8e4f5;
  backdrop-filter: blur(4px);
}

.garage-showroom {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 28px 28px;
  min-height: 0;
}

.garage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.garage-brand { text-align: left; }
.garage-brand h2 { margin: 0; text-align: left; }
.garage-brand .eyebrow { margin-bottom: 6px; }

.garage-back {
  width: auto;
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
}

.garage-back .btn-keys {
  display: inline-flex;
  gap: 6px;
}

.garage-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 360px);
  gap: 22px;
  align-items: stretch;
}

.garage-stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(26, 36, 51, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(200, 225, 245, 0.45)),
    #e8f4fc;
  box-shadow:
    inset 0 0 60px rgba(255, 255, 255, 0.35),
    0 18px 50px rgba(40, 90, 140, 0.18);
}

#garage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.garage-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 58px;
  height: 86px;
  border: 1px solid rgba(26, 36, 51, 0.14);
  border-radius: 12px;
  background: rgba(255, 252, 248, 0.88);
  color: var(--text);
  cursor: pointer;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  box-shadow: 0 6px 18px rgba(40, 80, 120, 0.12);
}

.garage-arrow .arrow-glyph {
  font-size: 2.2rem;
  line-height: 1;
}

.garage-arrow kbd {
  font-size: 0.62rem;
  min-width: 1.6em;
  padding: 2px 6px;
  pointer-events: none;
}

.garage-arrow:hover {
  background: #fff;
  border-color: rgba(240, 160, 32, 0.55);
}

.garage-arrow.left { left: 14px; }
.garage-arrow.right { right: 14px; }

.garage-keys-hint {
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 2;
  color: var(--muted);
  font-size: 0.92rem;
  pointer-events: none;
}

.garage-keys-hint kbd {
  margin: 0 2px;
}

.garage-stage-caption {
  position: absolute;
  left: 18px;
  bottom: 16px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.garage-stage-caption span {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.garage-stage-caption strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.garage-stats-card {
  border-radius: 18px;
  border: 1px solid rgba(26, 36, 51, 0.12);
  background:
    linear-gradient(165deg, rgba(255, 252, 248, 0.96), rgba(230, 242, 255, 0.95));
  padding: 28px 26px;
  text-align: left;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(40, 90, 140, 0.16);
}

.garage-stats-eyebrow {
  font-family: var(--font-display);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: var(--amber);
  margin-bottom: 10px;
}

.garage-stats-card h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.garage-status {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 28px;
}

.garage-status.owned { color: var(--green); }
.garage-status.equipped { color: var(--amber); }
.garage-status.locked { color: var(--muted); }

.stat-block {
  margin-bottom: 22px;
}

.stat-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  margin-bottom: 10px;
}

.stat-heading span:last-child {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.stat-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(26, 36, 51, 0.08);
  border: 1px solid rgba(26, 36, 51, 0.1);
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 0.35s ease;
}

.stat-fill.speed {
  background: linear-gradient(90deg, #ff7a3b, var(--amber));
  box-shadow: 0 0 12px rgba(255, 193, 74, 0.35);
}

.stat-fill.armor {
  background: linear-gradient(90deg, #2a6cff, var(--blue));
  box-shadow: 0 0 12px rgba(59, 167, 255, 0.35);
}

#garage-action {
  margin-top: auto;
  width: 100%;
  margin-bottom: 0;
}

.garage-action-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.load-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 8px;
}

#load-fill {
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, var(--red), var(--amber));
  transition: width 0.25s ease;
}

/* ——— Desktop / laptop scaling ——— */
@media (max-width: 1280px) {
  .panel { width: min(720px, 94vw); }
  .garage-body {
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 320px);
    gap: 16px;
  }
  .hud-card { min-width: 150px; padding: 10px 12px; }
  .play-ctrl-btn { min-width: 132px; padding: 9px 12px; font-size: 0.66rem; }
}

@media (max-width: 1100px) {
  #hud { top: 96px; padding: 0 12px; }
  .dmg-panel { top: 52px; width: min(32%, 220px); }
  .dmg-panel.right { right: 160px; }
  .hud-row { font-size: 0.9rem; gap: 10px; }
  .hud-row strong { font-size: 0.72rem; }
  #race-timer { font-size: 0.95rem; }
  #lap-target { font-size: 0.7rem; }
  #wanted-banner { font-size: 0.92rem; padding: 7px 28px; max-width: min(38vw, 280px); }
  .garage-showroom { padding: 16px 18px 18px; }
  .garage-body {
    grid-template-columns: minmax(0, 1.2fr) minmax(240px, 300px);
    gap: 14px;
  }
  #garage-canvas { min-height: 360px; }
  .cash-big { font-size: 1.35rem; }
  .garage-back { padding: 10px 14px; font-size: 0.72rem; }
}

@media (max-width: 980px) {
  .controls-grid { gap: 12px; }
  .control-card { padding: 14px; }
  .control-card ul { font-size: 0.88rem; }
  .tagline { font-size: 1rem; }
  .hint { font-size: 0.88rem; }
  .garage-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 1fr) auto;
  }
  #garage-canvas { min-height: 280px; }
  .garage-stats-card { min-height: auto; }
  .garage-top { flex-wrap: wrap; }
  .garage-arrow { width: 48px; height: 74px; }
  .garage-arrow .arrow-glyph { font-size: 1.8rem; }
  .garage-keys-hint {
    font-size: 0.82rem;
    left: 14px;
    right: 14px;
    text-align: center;
  }
  #hud { top: 90px; }
  .dmg-panel { top: 50px; width: min(30%, 200px); }
  .dmg-panel.right { right: 150px; }
  body.mode-1p .dmg-panel.left { width: min(42%, 240px); }
  .profile-bar {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

/* Short laptop screens */
@media (max-height: 820px) {
  .panel { padding: 20px 28px; }
  .eyebrow { margin-bottom: 8px; }
  h1 { margin-bottom: 6px; }
  .tagline { margin-bottom: 14px; font-size: 1rem; }
  .mode-toggle { margin-bottom: 12px; }
  .controls-grid { margin-bottom: 12px; }
  .control-card { padding: 12px 14px; }
  .control-card li { margin: 2px 0; }
  .btn { padding: 12px 22px; font-size: 0.85rem; }
  .garage-showroom { padding: 12px 16px 16px; }
  .garage-top { margin-bottom: 10px; }
  #garage-canvas { min-height: 240px; }
}

@media (max-height: 700px) {
  h2 { font-size: 1.45rem; }
  .mission-hint { margin-bottom: 10px; }
  .car-badge { width: 72px; height: 32px; margin-bottom: 8px; }
}

/* Mobile screens — hide game, show error */
@media (max-width: 768px) {
  #app { display: none !important; }
  #mobile-block { display: grid; }
}
