/* ========================================
   MOTORHEADS: VELOZES E FURIOSOS
   Main Stylesheet
   ======================================== */

:root {
  --bg: #050810;
  --bg2: #0a0f1e;
  --bg3: #0f1628;
  --cyan: #00e5ff;
  --pink: #ff0080;
  --yellow: #ffcc00;
  --green: #00ff88;
  --red: #ff2244;
  --orange: #ff6600;
  --panel: rgba(10,15,30,0.92);
  --border: rgba(0,229,255,0.2);
  --text: #e0eaff;
  --text-dim: #607090;
  --font-display: 'Bebas Neue', sans-serif;
  --font-hud: 'Orbitron', monospace;
  --font-body: 'Rajdhani', sans-serif;
  --neon-glow: 0 0 10px var(--cyan), 0 0 30px rgba(0,229,255,0.3);
  --pink-glow: 0 0 10px var(--pink), 0 0 30px rgba(255,0,128,0.3);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ======= SCREENS ======= */
.screen {
  position: fixed; inset: 0;
  display: none;
  z-index: 10;
}
.screen.active { display: flex; }

/* ======= AUTH SCREEN ======= */
#authScreen {
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.auth-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #050810 0%, #0a0a20 50%, #050810 100%);
}

.auth-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,229,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridScroll 20s linear infinite;
}

@keyframes gridScroll {
  0% { transform: translateY(0); }
  100% { transform: translateY(40px); }
}

.auth-glow {
  position: absolute;
  bottom: -200px; left: 50%; transform: translateX(-50%);
  width: 800px; height: 400px;
  background: radial-gradient(ellipse, rgba(255,0,128,0.2) 0%, transparent 70%);
  animation: glowPulse 4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%,100% { opacity: 0.5; transform: translateX(-50%) scaleX(1); }
  50% { opacity: 1; transform: translateX(-50%) scaleX(1.1); }
}

.auth-container {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
  width: 100%; max-width: 400px;
  padding: 20px;
}

.logo-wrap { text-align: center; }

.game-logo {
  font-family: var(--font-display);
  font-size: clamp(36px, 8vw, 64px);
  line-height: 1;
  color: #fff;
  text-shadow: var(--pink-glow);
  letter-spacing: 4px;
}
.game-logo span { color: var(--cyan); text-shadow: var(--neon-glow); }

.logo-sub {
  font-family: var(--font-hud);
  font-size: clamp(9px, 2vw, 12px);
  color: var(--yellow);
  letter-spacing: 6px;
  margin-top: 4px;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  backdrop-filter: blur(20px);
}
.auth-form.active { display: flex; }
.auth-form h2 {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--cyan);
  letter-spacing: 3px;
  margin-bottom: 4px;
}

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  background: rgba(0,229,255,0.05);
  border: 1px solid rgba(0,229,255,0.15);
  border-radius: 3px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0,229,255,0.1);
}
input::placeholder { color: var(--text-dim); }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300e5ff'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
select option { background: var(--bg2); }

.auth-switch {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}
.auth-switch span {
  color: var(--cyan);
  cursor: pointer;
  font-weight: 700;
  text-decoration: underline;
}

/* ======= PLATE GRID ======= */
.plate-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}
.plate-item {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.plate-item:hover { border-color: var(--cyan); background: rgba(0,229,255,0.05); }
.plate-item.selected { border-color: var(--yellow); background: rgba(255,204,0,0.1); }
.plate-img {
  width: 52px; height: 28px;
  border-radius: 3px;
  object-fit: cover;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-hud);
  font-weight: 900;
  font-size: 9px;
  letter-spacing: 1px;
}
.plate-info { flex: 1; }
.plate-info strong { font-size: 12px; display: block; color: #fff; }
.plate-info small { font-size: 10px; color: var(--cyan); }

/* ======= BUTTONS ======= */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 20px;
  border: none; border-radius: 3px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.18s;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.18s;
}
.btn:hover::after { background: rgba(255,255,255,0.08); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--cyan) 0%, #0099ff 100%);
  color: #000;
  font-weight: 900;
  box-shadow: 0 4px 20px rgba(0,229,255,0.3);
  width: 100%;
}
.btn-danger {
  background: linear-gradient(135deg, var(--red) 0%, #cc0022 100%);
  color: #fff;
  width: 100%;
}
.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}
.btn-gold {
  background: linear-gradient(135deg, var(--yellow) 0%, #ff9900 100%);
  color: #000;
  font-weight: 900;
  width: 100%;
}

.btn-icon {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px; height: 40px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover { background: rgba(0,229,255,0.1); border-color: var(--cyan); }

/* ======= TOP BAR ======= */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(5,8,16,0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 100;
}
.top-logo {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--cyan);
  letter-spacing: 2px;
  text-shadow: var(--neon-glow);
  margin-right: 8px;
}
.top-info {
  display: flex; align-items: center; gap: 10px;
  flex: 1;
}
#menuPlayerName {
  font-family: var(--font-hud);
  font-size: 13px;
  color: #fff;
  font-weight: 700;
}
.plate-badge {
  padding: 3px 8px;
  background: var(--panel);
  border: 1px solid var(--yellow);
  border-radius: 3px;
  font-family: var(--font-hud);
  font-size: 11px;
  color: var(--yellow);
  font-weight: 900;
  letter-spacing: 1px;
}
.money-display {
  font-family: var(--font-hud);
  font-size: 14px;
  color: var(--green);
  font-weight: 700;
}

/* ======= MAIN MENU ======= */
#menuScreen { flex-direction: row; padding-top: 60px; }

.menu-bg {
  position: absolute; inset: 0;
  background: var(--bg);
  overflow: hidden;
}
#menuCarCanvas { position: absolute; bottom: 0; right: 0; width: 60%; height: 70%; opacity: 0.6; }
.menu-scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
}

.menu-left {
  position: relative; z-index: 10;
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 20px 16px;
  width: 220px;
  min-width: 200px;
  border-right: 1px solid var(--border);
  background: rgba(5,8,16,0.7);
  backdrop-filter: blur(10px);
}
.menu-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}
.menu-btn:hover { color: var(--text); border-color: var(--border); background: rgba(0,229,255,0.05); }
.menu-btn.active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(0,229,255,0.08);
  text-shadow: var(--neon-glow);
}
.btn-icon-l { font-size: 18px; }

/* ======= MENU SECTIONS ======= */
.menu-section {
  display: none;
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  position: relative; z-index: 5;
}
.menu-section.active { display: flex; flex-direction: column; }

.section-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 32px);
  letter-spacing: 3px;
  color: #fff;
  margin-bottom: 20px;
  text-shadow: var(--neon-glow);
}

/* ======= MODE CARDS ======= */
.mode-cards {
  display: flex; gap: 16px;
  flex-wrap: wrap;
}
.mode-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 200px;
  flex: 1;
  max-width: 260px;
  backdrop-filter: blur(10px);
}
.mode-card:hover {
  border-color: var(--cyan);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,229,255,0.15);
}
.mode-card .mode-icon { font-size: 36px; margin-bottom: 12px; }
.mode-card h3 { font-family: var(--font-display); font-size: 22px; color: var(--cyan); letter-spacing: 2px; margin-bottom: 8px; }
.mode-card p { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-bottom: 12px; }
.mode-tag {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(0,229,255,0.1);
  border: 1px solid var(--cyan);
  border-radius: 2px;
  font-family: var(--font-hud);
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 2px;
}

/* ======= MAP CARDS ======= */
.map-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.map-card {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.2s;
  min-width: 160px;
}
.map-card:hover { border-color: var(--pink); transform: scale(1.03); }
.map-preview {
  width: 160px; height: 100px;
  background: var(--bg3);
}
.downtown-prev { background: linear-gradient(135deg, #1a1a3e, #2d2d6e); }
.highway-prev { background: linear-gradient(135deg, #1a3a1a, #0a2a0a); }
.port-prev { background: linear-gradient(135deg, #3a1a1a, #2a0a0a); }
.map-card span {
  display: block;
  padding: 8px;
  font-family: var(--font-hud);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text);
  background: var(--panel);
}

/* ======= GARAGE ======= */
.garage-layout {
  display: flex; gap: 16px;
  height: 100%;
  width: 100%;
}
.garage-left { width: 180px; display: flex; flex-direction: column; gap: 8px; }
.garage-center { flex: 1; display: flex; flex-direction: column; align-items: center; }
.garage-right { width: 260px; }

#garageCanvas { border: 1px solid var(--border); border-radius: 4px; background: #080c18; width: 100%; max-width: 600px; }

.cars-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; }
.car-list-item {
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-hud);
  font-size: 12px;
}
.car-list-item:hover, .car-list-item.active { border-color: var(--cyan); color: var(--cyan); }

.car-controls-bar {
  display: flex; align-items: center; gap: 16px;
  margin-top: 10px;
}
.car-controls-bar button {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--cyan);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 16px;
}
#selectedCarName { font-family: var(--font-display); font-size: 20px; color: #fff; letter-spacing: 2px; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab {
  flex: 1;
  padding: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-family: var(--font-hud);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
}
.tab.active { border-color: var(--cyan); color: var(--cyan); background: rgba(0,229,255,0.08); }

/* STAT BARS */
.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.stat-label { font-size: 12px; color: var(--text-dim); font-weight: 600; width: 100px; }
.stat-bar-wrap { flex: 1; background: rgba(255,255,255,0.06); border-radius: 2px; height: 6px; margin: 0 8px; }
.stat-bar { height: 100%; background: var(--cyan); border-radius: 2px; transition: width 0.4s; }
.stat-val { font-family: var(--font-hud); font-size: 11px; color: var(--cyan); width: 30px; text-align: right; }

/* UPGRADE ITEMS */
.upgrade-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: space-between;
}
.upgrade-item:hover { border-color: var(--yellow); }
.upgrade-item.equipped { border-color: var(--green); }
.upgrade-info { flex: 1; }
.upgrade-info strong { font-size: 13px; color: #fff; display: block; }
.upgrade-info span { font-size: 11px; color: var(--cyan); }
.upgrade-price { font-family: var(--font-hud); font-size: 12px; color: var(--yellow); }

/* COLOR PICKERS */
.color-section { margin-bottom: 12px; }
.color-section label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 6px; }
.color-row { display: flex; gap: 6px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.color-swatch:hover, .color-swatch.active { border-color: #fff; transform: scale(1.2); }
.rainbow-swatch {
  animation: rainbowSpin 2s linear infinite;
  border-color: rgba(255,255,255,0.4) !important;
  position: relative;
}
.rainbow-swatch::after {
  content: '🌈';
  position: absolute;
  font-size: 8px;
  bottom: -2px;
  right: -2px;
  line-height: 1;
}
@keyframes rainbowSpin {
  0%   { filter: hue-rotate(0deg) brightness(1.1); }
  100% { filter: hue-rotate(360deg) brightness(1.1); }
}

/* SHOP */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 4px;
}
.shop-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.2s;
}
.shop-card:hover { border-color: var(--cyan); transform: translateY(-2px); }
.shop-card-preview {
  height: 140px;
  background: #080c18;
  display: flex; align-items: center; justify-content: center;
}
.shop-card-info { padding: 12px; }
.shop-card-info h3 { font-family: var(--font-display); font-size: 18px; color: #fff; letter-spacing: 1px; margin-bottom: 4px; }
.shop-card-info .car-specs { display: flex; gap: 8px; margin-bottom: 8px; }
.spec-badge {
  padding: 2px 6px;
  background: rgba(0,229,255,0.1);
  border-radius: 2px;
  font-size: 10px;
  color: var(--cyan);
  font-family: var(--font-hud);
}
.shop-card-info .price { font-family: var(--font-hud); font-size: 16px; color: var(--yellow); font-weight: 700; }

/* ======= LEADERBOARD ======= */
.leaderboard-list { display: flex; flex-direction: column; gap: 6px; max-width: 700px; }
.lb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.lb-rank { font-family: var(--font-hud); font-size: 18px; color: var(--text-dim); width: 30px; text-align: center; }
.lb-rank.gold { color: var(--yellow); }
.lb-rank.silver { color: #aaa; }
.lb-rank.bronze { color: #cd7f32; }
.lb-name { flex: 1; font-weight: 700; font-size: 15px; }
.lb-plate { font-family: var(--font-hud); font-size: 10px; color: var(--yellow); border: 1px solid; padding: 2px 6px; border-radius: 2px; }
.lb-wins { font-family: var(--font-hud); font-size: 14px; color: var(--cyan); }
.lb-money { font-family: var(--font-hud); font-size: 14px; color: var(--green); }

/* ======= LOBBY ======= */
#lobbyScreen {
  display: none;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 100%, rgba(0,229,255,0.05) 0%, transparent 70%);
}
.lobby-container {
  width: 100%; max-width: 700px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(20px);
  text-align: center;
}
.lobby-container h2 { font-family: var(--font-display); font-size: 32px; letter-spacing: 4px; margin-bottom: 8px; }
.neon-text { color: var(--cyan); text-shadow: var(--neon-glow); }

.lobby-player-list {
  list-style: none;
  margin: 16px 0;
  display: flex; flex-direction: column; gap: 6px;
}
.lobby-player-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.lobby-player-item .host-badge {
  font-size: 10px;
  background: var(--yellow);
  color: #000;
  padding: 2px 6px;
  border-radius: 2px;
  font-weight: 700;
}

.lobby-cars-preview {
  display: flex; justify-content: center; gap: 20px;
  flex-wrap: wrap;
  margin: 16px 0;
  min-height: 80px;
}

/* ======= RACE SCREEN ======= */
#raceScreen {
  display: none;
  background: #000;
}

#raceCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* HUD */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 20;
}

#hudTop {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
}

#positionDisplay {
  font-family: var(--font-hud);
  font-size: 48px;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: var(--neon-glow);
  line-height: 1;
}
#positionDisplay sup { font-size: 20px; }

#lapDisplay {
  font-family: var(--font-hud);
  font-size: 16px;
  color: #fff;
  letter-spacing: 2px;
}

#timerDisplay {
  font-family: var(--font-hud);
  font-size: 22px;
  color: var(--yellow);
  font-weight: 700;
}

/* MINIMAP */
#minimap {
  position: absolute; bottom: 140px; left: 16px;
  width: 180px; height: 180px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#minimapCanvas { display: block; border-radius: 50%; }

/* SPEEDOMETER */
#hudBottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 20px 16px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
}

#speedometer { width: 200px; }
.speedo-svg { width: 100%; }

#nitroBar {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding-bottom: 12px;
}
.nitro-label {
  font-family: var(--font-hud);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 2px;
}
.nitro-track {
  width: 120px; height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(0,229,255,0.2);
}
#nitroFill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), #0099ff);
  border-radius: 5px;
  width: 100%;
  transition: width 0.1s;
  box-shadow: 0 0 8px var(--cyan);
}
#nitroPercent {
  font-family: var(--font-hud);
  font-size: 11px;
  color: var(--cyan);
}

.skill-button {
  width: 64px; height: 64px;
  background: rgba(0,0,0,0.7);
  border: 2px solid var(--pink);
  border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
  pointer-events: all;
  margin-bottom: 12px;
  box-shadow: 0 0 10px rgba(255,0,128,0.3);
}
#skillIcon { font-size: 28px; }
.skill-key {
  position: absolute; bottom: 2px; right: 4px;
  font-family: var(--font-hud);
  font-size: 9px;
  color: var(--text-dim);
}
.cooldown-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  border-radius: 6px;
  clip-path: inset(0 0 0 0);
  transition: clip-path 0.05s;
}

/* RACE POSITIONS */
.race-positions {
  position: absolute; top: 70px; right: 16px;
  display: flex; flex-direction: column; gap: 4px;
  max-width: 200px;
}
.race-pos-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.6);
  border-left: 2px solid transparent;
  border-radius: 2px;
  font-family: var(--font-hud);
  font-size: 11px;
}
.race-pos-row.is-me { border-left-color: var(--cyan); color: var(--cyan); }

/* ALERTS */
#raceAlerts {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.race-alert {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 40px);
  letter-spacing: 4px;
  text-shadow: 0 0 20px currentColor;
  animation: alertAnim 3s forwards;
}
@keyframes alertAnim {
  0% { opacity:0; transform: scale(0.8); }
  15% { opacity:1; transform: scale(1.05); }
  70% { opacity:1; transform: scale(1); }
  100% { opacity:0; transform: scale(0.9) translateY(-20px); }
}

/* COUNTDOWN */
.countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 50;
}
#countdownNum {
  font-family: var(--font-display);
  font-size: clamp(80px, 20vw, 160px);
  color: var(--cyan);
  text-shadow: var(--neon-glow), 0 0 60px var(--cyan);
  animation: countPop 0.5s ease-out;
}
@keyframes countPop {
  0% { transform: scale(1.5); opacity:0; }
  100% { transform: scale(1); opacity:1; }
}

/* SPECTATOR */
.spectator-banner {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  padding: 8px 20px;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--yellow);
  border-radius: 4px;
  font-family: var(--font-hud);
  font-size: 14px;
  color: var(--yellow);
  letter-spacing: 2px;
}

/* PODIUM */
#podiumScreen {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
#podiumScreen[style*="flex"] { display: flex !important; }

.podium-container {
  text-align: center;
  padding: 30px;
  max-width: 700px;
  width: 100%;
}
.podium-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 48px);
  color: var(--yellow);
  letter-spacing: 4px;
  margin-bottom: 24px;
  text-shadow: 0 0 20px var(--yellow);
}
.podium-stands {
  display: flex; align-items: flex-end; justify-content: center; gap: 8px;
  margin-bottom: 24px;
}
.podium-stand {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
}
.podium-stand .stand-block {
  width: 120px;
  background: linear-gradient(to top, rgba(255,255,255,0.05), rgba(255,255,255,0.1));
  border: 1px solid;
  border-radius: 4px 4px 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 8px;
  font-family: var(--font-display);
  font-size: 36px;
}
.podium-stand:nth-child(1) .stand-block { height: 100px; border-color: #aaa; }
.podium-stand:nth-child(2) .stand-block { height: 140px; border-color: var(--yellow); }
.podium-stand:nth-child(3) .stand-block { height: 70px; border-color: #cd7f32; }
.podium-name { font-family: var(--font-hud); font-size: 13px; color: #fff; }

.all-positions { display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }
.result-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
}
.result-pos { font-family: var(--font-hud); font-size: 16px; width: 30px; }
.result-name { flex: 1; font-weight: 700; }
.result-time { font-family: var(--font-hud); font-size: 13px; color: var(--text-dim); }
.result-reward { font-family: var(--font-hud); font-size: 13px; color: var(--green); }

.rewards-box {
  padding: 16px;
  background: rgba(0,255,136,0.05);
  border: 1px solid rgba(0,255,136,0.2);
  border-radius: 4px;
  font-family: var(--font-hud);
  font-size: 16px;
  color: var(--green);
}

/* ======= PROFILE MODAL ======= */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  max-width: 500px;
  width: 90%;
  position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
}
.modal-close:hover { color: var(--red); }

.profile-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font-display);
}
.profile-name { font-family: var(--font-display); font-size: 24px; color: #fff; letter-spacing: 2px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-stat {
  padding: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  text-align: center;
}
.profile-stat .val { font-family: var(--font-hud); font-size: 22px; color: var(--cyan); display: block; }
.profile-stat .lbl { font-size: 11px; color: var(--text-dim); }

/* ======= NOTIFICATION ======= */
.notification {
  position: fixed; top: 70px; right: 20px;
  padding: 12px 20px;
  background: var(--panel);
  border-left: 3px solid var(--cyan);
  border-radius: 4px;
  font-family: var(--font-hud);
  font-size: 13px;
  color: #fff;
  z-index: 500;
  transform: translateX(120%);
  transition: transform 0.3s;
  max-width: 300px;
  backdrop-filter: blur(10px);
}
.notification.show { transform: translateX(0); }
.notification.error { border-left-color: var(--red); }
.notification.success { border-left-color: var(--green); }
.notification.warning { border-left-color: var(--yellow); }

/* ======= LOADING ======= */
#loadingScreen {
  justify-content: center;
  align-items: center;
  background: var(--bg);
}
.loading-content { text-align: center; }
.loading-bar-wrap {
  width: 300px; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin: 20px auto;
  overflow: hidden;
}
.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
  animation: loadingShimmer 1.5s infinite;
}
@keyframes loadingShimmer {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}
#loadingText {
  color: var(--text-dim);
  font-family: var(--font-hud);
  font-size: 13px;
  letter-spacing: 2px;
  margin-top: 8px;
}

/* ======= CODE INPUT ======= */
.code-input-wrap {
  display: flex; gap: 10px; margin-top: 16px;
  align-items: center;
}
.code-input-wrap input {
  flex: 1;
  font-family: var(--font-hud);
}
.code-input-wrap .btn { width: auto; padding: 12px 20px; }



/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
  .menu-left { width: 60px; padding: 10px 8px; }
  .menu-btn span:not(.btn-icon-l) { display: none; }
  .menu-btn { padding: 14px 8px; justify-content: center; }
  .garage-layout { flex-direction: column; }
  .garage-right { width: 100%; }
  .mode-cards { flex-direction: column; }
  .mode-card { max-width: 100%; }
  #section-garage { overflow-y: auto; }
}

@media (max-width: 480px) {
  .plate-grid { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: 1fr; }
}

/* ======= SCROLLBAR ======= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,229,255,0.5); }

/* ======= DAMAGE FLASH ======= */
.damage-flash {
  position: fixed; inset: 0;
  background: rgba(255,0,0,0.3);
  pointer-events: none;
  z-index: 200;
  animation: flashOut 0.3s forwards;
}
@keyframes flashOut { 0%{opacity:1} 100%{opacity:0} }

/* ======= NITRO GLOW VFX ======= */
.nitro-active-vfx {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(ellipse at 50% 110%, var(--nitro-color, rgba(0,229,255,0.2)) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.1s;
}
.nitro-active-vfx.on { opacity: 1; }

/* ======= GARAGE 3D ======= */
#garageCanvas {
  width: 100% !important;
  max-width: 640px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #080c18;
  display: block;
  cursor: grab;
}
#garageCanvas:active { cursor: grabbing; }

.garage-tab-content {
  overflow-y: auto;
  max-height: calc(100vh - 260px);
  padding-right: 4px;
}

.shop-section-title {
  color: var(--cyan);
  font-family: var(--font-hud);
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  margin: 12px 0 6px;
  text-transform: uppercase;
}

.upgrade-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.upgrade-item:hover { border-color: var(--yellow); }
.upgrade-item.equipped { border-color: var(--green); background: rgba(0,255,136,0.04); }

.upgrade-img-wrap { flex-shrink: 0; }
.upgrade-info { flex: 1; }
.upgrade-info strong { font-size: 13px; color: #fff; display: block; font-weight: 700; }
.upgrade-info span   { font-size: 11px; color: var(--text-dim); display: block; }
.upgrade-info small  { font-size: 10px; }

.upgrade-action { text-align: right; flex-shrink: 0; }
.upgrade-price { font-family: var(--font-hud); font-size: 12px; color: var(--yellow); font-weight: 700; }
.badge-equipped { font-family: var(--font-hud); font-size: 11px; color: var(--green); }

.stat-bars { margin-bottom: 12px; }

/* ======= ACCESSORIES ======= */
.acc-item { align-items: center; }

.acc-thumb {
  width: 72px; height: 56px;
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.acc-mini-canvas { display: block; border-radius: 3px; }
.acc-thumb-placeholder { font-size: 26px; }

.btn-equip {
  background: rgba(0,229,255,0.1);
  border: 1px solid var(--cyan);
  border-radius: 3px;
  color: var(--cyan);
  font-family: var(--font-hud);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-equip:hover { background: rgba(0,229,255,0.2); }

/* garage canvas responsive height */
#garageCanvas { height: 360px !important; }
@media (max-height: 700px) { #garageCanvas { height: 260px !important; } }

/* ── Engine image in motor tab ── */
.engine-img-wrap {
  width: 56px; height: 44px; flex-shrink: 0;
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* ── Acc thumb sizing ── */
.acc-thumb {
  width: 74px; height: 58px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px; overflow:hidden; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}

/* make garage canvas fill its container properly */
#garageCanvas {
  width: 100% !important;
  height: 360px !important;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: grab;
  display: block;
}
#garageCanvas:active { cursor: grabbing; }
@media (max-height:700px){ #garageCanvas { height: 250px !important; } }

/* ======= GARAGE TABS — Styled ======= */
.tabs {
  display: flex; gap: 3px; margin-bottom: 12px;
  background: rgba(0,0,0,0.4);
  padding: 3px; border-radius: 6px;
  border: 1px solid var(--border);
}
.garage-tab {
  flex: 1; padding: 9px 6px;
  background: transparent;
  border: none; border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-hud);
  font-size: 10px; letter-spacing: 1px;
  cursor: pointer; transition: all 0.18s;
  text-transform: uppercase;
  font-weight: 700;
}
.garage-tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.garage-tab.active {
  background: linear-gradient(135deg, rgba(0,229,255,0.2), rgba(0,150,255,0.1));
  color: var(--cyan);
  border: 1px solid rgba(0,229,255,0.4);
  text-shadow: 0 0 8px var(--cyan);
}

/* ======= MAP CARD SELECTED STATE ======= */
.map-card.selected-map {
  border-color: var(--cyan) !important;
  box-shadow: 0 0 12px rgba(0,229,255,0.3);
}

/* ======= SHOP CARD 3D PREVIEW ======= */
.shop-card-preview canvas {
  display: block;
  width: 100% !important;
  border-radius: 4px;
}

/* ======= UPGRADE ITEM PRICE ======= */
.upgrade-price {
  font-family: var(--font-hud);
  font-size: 13px;
  color: var(--yellow);
  font-weight: 700;
  white-space: nowrap;
}

/* ======= ACC ITEM ======= */
.acc-item { align-items: center; cursor: default; }
.acc-thumb {
  width: 74px; height: 58px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.btn-equip {
  background: rgba(0,229,255,0.1);
  border: 1px solid var(--cyan); border-radius: 3px;
  color: var(--cyan);
  font-family: var(--font-hud); font-size: 10px; letter-spacing: 1px;
  padding: 5px 10px; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-equip:hover { background: rgba(0,229,255,0.2); }

/* ======= GARAGE CANVAS ======= */
#garageCanvas {
  width: 100% !important; height: 360px !important;
  border-radius: 6px; border: 1px solid var(--border);
  cursor: grab; display: block;
}
#garageCanvas:active { cursor: grabbing; }
@media (max-height:700px){ #garageCanvas { height: 250px !important; } }

/* ======= SHOP SECTION TITLE ======= */
.shop-section-title {
  color: var(--cyan); font-family: var(--font-hud); font-size: 11px;
  letter-spacing: 2px; font-weight: 700; margin: 14px 0 8px; text-transform: uppercase;
}
.engine-img-wrap {
  width: 56px; height: 44px; flex-shrink: 0;
  background: rgba(255,255,255,0.03); border-radius: 4px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* ======= BADGE EQUIPPED ======= */
.badge-equipped {
  font-family: var(--font-hud); font-size: 11px; color: var(--green); font-weight: 700;
}

/* ======= STAT BARS ======= */
.stat-bars { margin-bottom: 14px; }
.stat-row { display:flex; align-items:center; gap:6px; margin-bottom:10px; }
.stat-label { font-size:11px; color:var(--text-dim); font-weight:600; width:90px; flex-shrink:0; }
.stat-bar-wrap { flex:1; background:rgba(255,255,255,0.06); border-radius:2px; height:5px; }
.stat-bar { height:100%; border-radius:2px; transition:width 0.4s; }
.stat-val { font-family:var(--font-hud); font-size:11px; color:var(--cyan); width:24px; text-align:right; }

/* ======= COLOR SECTION ======= */
.color-section { margin-bottom: 14px; }
.color-section label {
  font-size: 11px; color: var(--text-dim); font-family: var(--font-hud);
  letter-spacing: 1px; display: block; margin-bottom: 6px; font-weight: 700;
}
.color-row { display: flex; gap: 6px; flex-wrap: wrap; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1); cursor: pointer; transition: all 0.15s;
}
.color-swatch:hover { transform: scale(1.2); border-color: rgba(255,255,255,0.5); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 6px rgba(255,255,255,0.6); transform: scale(1.15); }
/* ======= MOBILE JOYSTICK v2 ======= */
#mobileControls {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 30;
  display: none;
}
@media (pointer: coarse) {
  #mobileControls { display: block; }
}

#joystickZone {
  position: absolute;
  bottom: 30px; left: 24px;
  width: 130px; height: 130px;
  pointer-events: all;
}
#joystickBase {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(0,229,255,0.35);
  backdrop-filter: blur(4px);
}
#joystickKnob {
  position: absolute;
  top: 50%; left: 50%;
  width: 52px; height: 52px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(0,229,255,0.8), rgba(0,100,200,0.5));
  border: 2px solid rgba(0,229,255,0.7);
  box-shadow: 0 0 12px rgba(0,229,255,0.4);
  transition: none;
}
.mobile-actions {
  position: absolute;
  bottom: 20px; right: 16px;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: all;
}
.mob-row {
  display: flex; gap: 6px;
}
.mobile-action-btn {
  width: 62px; height: 62px;
  background: rgba(0,0,0,0.55);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  backdrop-filter: blur(4px);
  transition: transform 0.08s, opacity 0.08s;
}
.mobile-action-btn .icon { font-size: 22px; line-height: 1; }
.mobile-action-btn.pressed {
  transform: scale(0.88);
  opacity: 0.7;
}

/* Contador de lobby */
#lobbyCount {
  font-family: var(--font-hud);
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 8px;
}

/* ================================================================
   MOBILE — full responsive rebuild
   ================================================================ */

/* ── Base touch target ── */
@media (pointer: coarse) {
  button, .btn, .menu-btn, .garage-tab, .upgrade-item, .map-card, .mode-card,
  .color-swatch, .btn-equip, .plate-item { min-height: 44px; }
  .color-swatch { width: 36px; height: 36px; border-radius: 50%; }
}

/* ── Menu layout ── */
@media (max-width: 860px) {
  .menu-left {
    width: 68px; padding: 12px 6px; gap: 4px; overflow: visible;
  }
  .menu-btn span:not(.btn-icon-l) { display: none; }
  .menu-btn { padding: 12px 6px; justify-content: center; border-radius: 8px; }
  .menu-btn .btn-icon-l { font-size: 20px; }
}
@media (max-width: 600px) {
  #menuScreen { flex-direction: column; overflow: hidden; }
  .menu-left {
    width: 100%; flex-direction: row; height: auto; padding: 6px 8px;
    border-right: none; border-bottom: 1px solid var(--border);
    overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px;
    justify-content: flex-start; flex-shrink: 0;
  }
  .menu-btn { padding: 8px 12px; flex-direction: column; gap: 1px; min-width: 50px; border-radius: 8px; }
  .menu-btn span:not(.btn-icon-l) { display: block !important; font-size: 8px; letter-spacing: .3px; }
  .menu-btn .btn-icon-l { font-size: 16px; }
  .menu-content { flex: 1; overflow-y: auto; padding: 10px; min-height: 0; }
  .section-title { font-size: 16px !important; margin-bottom: 10px !important; }

  /* Garage mobile */
  .garage-layout { flex-direction: column; gap: 8px; height: auto; }
  .garage-left { width: 100%; flex-direction: row; height: auto; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .cars-list { display: flex; flex-direction: row; gap: 6px; flex-wrap: nowrap; }
  .car-list-item { white-space: nowrap; padding: 8px 14px; font-size: 12px; }
  .garage-center { width: 100%; flex-shrink: 0; }
  #garageCanvas { width: 100% !important; height: 200px !important; object-fit: cover; }
  .garage-right { width: 100%; flex: none; }
  .tabs { flex-wrap: wrap; gap: 3px; }
  .garage-tab { padding: 5px 8px; font-size: 9px; letter-spacing: .3px; }
  #garageTabContent { max-height: 280px; overflow-y: auto; }

  /* Shop */
  .shop-grid { grid-template-columns: 1fr; gap: 10px; }
  .shop-card { flex-direction: column; }
  .shop-card-preview { width: 100%; height: 130px; }

  /* Play section */
  .mode-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mode-card { padding: 12px 8px; }
  .mode-card .mode-icon { font-size: 24px; }
  .mode-card h3 { font-size: 13px; }
  .mode-card p { font-size: 10px; }
  .map-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .map-card { padding: 8px 6px; }
  .map-preview { height: 44px; }

  /* Online */
  #onlineList { max-height: 250px; }

  /* Leaderboard */
  .lb-plate { display: none; }
  .lb-row { font-size: 11px; padding: 8px; }
  .lb-money { display: none; }

  /* Auth */
  .auth-container { padding: 16px 12px; }
  .plate-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
}

/* ── Lobby screen mobile ── */
@media (max-width: 600px) {
  .lobby-container {
    padding: 16px 12px; max-width: 100%; margin: 0; border-radius: 0;
    height: 100%; overflow-y: auto; box-sizing: border-box;
  }
  .lobby-container h2 { font-size: 22px; letter-spacing: 2px; }
  .neon-text { font-size: 28px !important; letter-spacing: 4px !important; }
  .lobby-player-item { padding: 8px 10px; font-size: 12px; }
  .map-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .map-card { padding: 8px; font-size: 11px; }
  .map-preview { height: 40px; }
  #btnHostStart { font-size: 14px; padding: 12px 20px; }
  #lobbyScreen { align-items: flex-start; }
}

/* ── Race HUD mobile ── */
@media (max-width: 600px) {
  #hudTop { padding: 6px 10px; }
  #positionDisplay { font-size: 28px; }
  #positionDisplay sup { font-size: 13px; }
  #timerDisplay { font-size: 14px; }
  #lapDisplay { font-size: 11px; }
  #minimap { width: 100px; height: 100px; bottom: 100px; left: 8px; border-radius: 50%; }
  #minimapCanvas { width: 100px !important; height: 100px !important; border-radius: 50%; }
  #hudBottom { padding: 0 8px 8px; gap: 6px; flex-wrap: wrap; justify-content: center; }
  #speedometer { width: 120px; flex-shrink: 0; }
  .speedo-svg { width: 120px; }
  #nitroBar { min-width: 70px; }
  .nitro-track { width: 70px; }
  #turboBar { display: none; } /* hide turbo bar on small screens */
  .race-positions { font-size: 9px; max-width: 100px; top: 50px; }
  .race-pos-row { padding: 2px 4px; }
  #raceAlerts { bottom: 110px; }
  .race-alert { font-size: 13px; padding: 6px 14px; }
  #countdown { font-size: 80px; }
  #voidWarning { box-shadow: inset 0 0 40px rgba(255,80,0,0.5); }
}

/* ── Mobile controls in race ── */
@media (max-width: 600px) {
  #mobileControls { display: flex !important; }
}
#mobileControls {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9100;
  pointer-events: none; display: none;
  align-items: flex-end; justify-content: space-between;
  padding: 0 10px 10px;
}
.joy-wrap { width: 120px; height: 120px; position: relative; pointer-events: all; flex-shrink: 0; }
.joy-base { position: absolute; inset: 5px; border-radius: 50%; background: rgba(0,0,0,0.5); border: 2px solid rgba(0,229,255,0.3); }
.joy-knob { position: absolute; width: 48px; height: 48px; border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: radial-gradient(circle at 35% 35%, rgba(0,229,255,0.8), rgba(0,100,200,0.5));
  border: 2px solid rgba(0,229,255,0.7); box-shadow: 0 0 12px rgba(0,229,255,0.4); }
.btns-wrap { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 5px; pointer-events: all; }
.mbtn { width: 56px; height: 56px; border-radius: 12px; border: none; color: #fff; font-size: 8px;
  font-family: var(--font-hud,monospace); font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; cursor: pointer; }
.mbtn .mi { font-size: 20px; line-height: 1; }
.mbtn.pressed { opacity: 0.6; transform: scale(0.9); }
.mb-nitro { background: rgba(0,229,255,0.15); border: 1.5px solid rgba(0,229,255,0.6); }
.mb-turbo { background: rgba(255,170,0,0.15); border: 1.5px solid rgba(255,170,0,0.6); }
.mb-drift { background: rgba(255,0,128,0.15); border: 1.5px solid rgba(255,0,128,0.5); }
.mb-skill { background: rgba(160,0,255,0.15); border: 1.5px solid rgba(160,0,255,0.5); }
.mb-jump  { background: rgba(0,255,100,0.15); border: 1.5px solid rgba(0,255,100,0.5); }
.mb-brake { background: rgba(255,60,0,0.15);  border: 1.5px solid rgba(255,60,0,0.5); }

/* ── Radio player mobile ── */
@media (max-width: 600px) {
  #radioPlayer { height: 60px; padding: 0 10px; gap: 8px; }
  #radioPlayer .rp-center > div:last-child { display: none; } /* hide progress bar row */
  #radioPlayer > div:nth-child(4) { display: none; } /* hide volume */
}

/* ── Stat bars ── */
.stat-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.stat-row { display: flex; align-items: center; gap: 8px; }
.stat-label { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; min-width: 90px; font-family: var(--font-hud); }
.stat-bar-wrap { flex: 1; background: rgba(255,255,255,0.08); border-radius: 3px; height: 7px; overflow: hidden; }
.stat-bar { height: 100%; border-radius: 3px; transition: width .4s; }
.stat-val { font-size: 11px; color: var(--cyan); font-family: var(--font-hud); min-width: 24px; text-align: right; }

/* ── Repair warning ── */
#carRepairWarn {
  font-family: var(--font-hud, monospace); letter-spacing: .5px;
  transition: background .3s, border-color .3s; margin-bottom: 8px; border-radius: 8px;
  padding: 8px 14px; font-size: 12px; font-weight: 700; border: 1px solid; text-align: center;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.25); border-radius: 2px; }

/* ── Upgrade item touch ── */
.upgrade-item { cursor: pointer; }
@media (pointer: coarse) { .upgrade-item { padding: 12px 10px; gap: 10px; } }

/* ── Shop section title ── */
.shop-section-title {
  font-family: var(--font-hud, monospace); font-size: 10px; letter-spacing: 2px;
  color: var(--text-dim); text-transform: uppercase; margin: 12px 0 7px;
  padding-bottom: 5px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
/* ================================================================
   MISSÕES
   ================================================================ */
#section-missions {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}