:root {
  --bg-dark: #090b10;
  --panel-bg: rgba(14, 17, 24, 0.84);
  --panel-border: rgba(255, 255, 255, 0.11);
  --f1-red: #e10600;
  --f1-red-glow: rgba(225, 6, 0, 0.42);
  --accent-cyan: #00e5ff;
  --accent-purple: #c054ff;
  --accent-green: #00e676;
  --accent-amber: #ffab00;
  --text-main: #f3f6fb;
  --text-muted: #949dae;
  --font-display: 'Oxanium', 'Orbitron', system-ui, sans-serif;
  --font-heading: 'Rajdhani', system-ui, sans-serif;
  --font-label: 'Barlow Condensed', system-ui, sans-serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-ui);
}

#game-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.hidden { display: none !important; }
.mono-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.accent-purple { color: var(--accent-purple); }

.hud-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ================= HUD ================= */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: 20px;
}

.timing-tower { position: absolute; top: 20px; left: 20px; width: 230px; overflow: hidden; }
.tower-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid var(--panel-border);
}
.f1-badge {
  background: var(--f1-red); color: #fff; font-family: var(--font-display);
  font-weight: 800; font-size: 10px; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 4px;
}
.lap-counter { font-family: var(--font-heading); font-size: 14px; font-weight: 700; color: var(--text-muted); }
.lap-counter strong { color: #fff; font-size: 16px; }
.leaderboard-list { list-style: none; padding: 6px 8px; }
.lb-row {
  display: grid; grid-template-columns: 24px 5px 1fr auto; align-items: center;
  gap: 8px; padding: 5px 6px; border-radius: 5px; font-size: 13px; font-weight: 600;
}
.lb-row.is-player { background: rgba(255, 255, 255, 0.1); }
.lb-pos { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }
.lb-row.is-player .lb-pos { color: #fff; }
.lb-swatch { width: 4px; height: 14px; border-radius: 2px; }
.lb-code { font-family: var(--font-label); letter-spacing: 0.05em; font-size: 14px; }
.lb-gap { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.event-banner {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 18px;
  background: rgba(14, 16, 22, 0.92); border: 1px solid rgba(255, 255, 255, 0.18);
  border-left: 4px solid var(--f1-red); border-radius: 8px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: slideDown 0.25s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.banner-tag { font-family: var(--font-heading); font-size: 12px; font-weight: 700; color: var(--accent-cyan); }
.banner-msg { font-family: var(--font-display); font-size: 14px; font-weight: 700; }

.hud-top-right { position: absolute; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.timer-panel { width: 220px; padding: 12px 14px; }
.timer-row.main-timer {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--panel-border);
}
.timer-row.main-timer .mono-val { font-size: 18px; font-weight: 800; }
.timer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.timer-cell { display: flex; flex-direction: column; }
.timer-cell .mono-val { font-size: 12px; font-weight: 700; }
.label { font-family: var(--font-heading); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-muted); }
.minimap-panel { padding: 8px; display: flex; justify-content: center; align-items: center; }

.hud-bottom-left { position: absolute; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 7px; pointer-events: auto; }
.cam-selector-bar { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; width: fit-content; }
.cam-status-label { font-family: var(--font-heading); font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.05em; }
.cam-status-label strong { color: var(--accent-cyan); font-family: var(--font-display); }
.cam-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.cam-pill {
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted); font-family: var(--font-heading); font-size: 11px; font-weight: 700;
  padding: 4px 8px; border-radius: 5px; cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: all 0.15s ease;
}
.cam-pill:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.cam-pill.active { background: rgba(225, 6, 0, 0.22); border-color: var(--f1-red); color: #fff; }
.quick-bar { display: flex; gap: 6px; padding: 6px; width: fit-content; }
.hud-chip {
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main); font-family: var(--font-heading); font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.hud-chip:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.25); }
.key-cap { background: rgba(255, 255, 255, 0.16); padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 10px; }
.controls-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: rgba(255, 255, 255, 0.72); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
.controls-legend kbd { background: rgba(16, 18, 24, 0.85); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 3px; padding: 1px 5px; font-family: var(--font-mono); font-size: 10px; color: #fff; }

.telemetry-cluster { position: absolute; bottom: 20px; right: 20px; width: 280px; padding: 14px 16px; }
.rpm-bar-wrap { display: grid; grid-template-columns: repeat(15, 1fr); gap: 4px; margin-bottom: 12px; }
.rpm-led { height: 6px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); }
.rpm-led.on-green { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.rpm-led.on-red { background: var(--f1-red); box-shadow: 0 0 8px var(--f1-red); }
.rpm-led.on-blue { background: var(--accent-cyan); box-shadow: 0 0 10px var(--accent-cyan); }
.telemetry-core { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.gear-box { display: flex; flex-direction: column; align-items: center; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-border); border-radius: 8px; padding: 4px 12px; min-width: 56px; }
.gear-val { font-family: var(--font-display); font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--accent-amber); }
.speed-box { text-align: right; }
.speed-val { font-family: var(--font-display); font-size: 36px; font-weight: 800; line-height: 1; }
.speed-unit { display: block; font-family: var(--font-heading); font-size: 11px; font-weight: 700; color: var(--text-muted); }
.aero-indicators { display: flex; flex-direction: column; gap: 5px; }
.aero-pill { font-family: var(--font-mono); font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); color: var(--text-muted); border: 1px solid rgba(255, 255, 255, 0.08); text-align: center; }
.aero-pill.drs-ready { color: var(--accent-amber); border-color: var(--accent-amber); }
.aero-pill.drs-active { background: var(--accent-green); color: #000; border-color: var(--accent-green); box-shadow: 0 0 12px rgba(0, 230, 118, 0.5); }
.aero-pill.ers-active { background: var(--accent-cyan); color: #000; border-color: var(--accent-cyan); box-shadow: 0 0 12px rgba(0, 229, 255, 0.5); }
.pedal-bars { display: flex; flex-direction: column; gap: 5px; }
.bar-group { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; }
.bar-label { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.bar-track { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; transition: width 0.05s linear; }
.fill-green { background: var(--accent-green); }
.fill-red { background: var(--f1-red); }
.fill-cyan { background: var(--accent-cyan); }

/* ================= START LIGHTS ================= */
#start-lights-overlay { position: fixed; top: 90px; left: 50%; transform: translateX(-50%); z-index: 15; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.gantry-housing { display: flex; gap: 14px; padding: 14px 22px; background: #101218; border: 2px solid rgba(255, 255, 255, 0.15); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7); }
.light-pod { width: 34px; height: 34px; border-radius: 50%; background: #1e1f26; border: 2px solid #2e313d; display: flex; align-items: center; justify-content: center; }
.lamp { width: 24px; height: 24px; border-radius: 50%; background: #351414; }
.lamp.lit { background: #ff1e1e; box-shadow: 0 0 20px #ff1e1e, 0 0 40px rgba(255, 30, 30, 0.8); }
#start-status-text { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.12em; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9); }

/* ================= GARAGE / SELECTION OVERLAY ================= */
.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: radial-gradient(circle at 20% 15%, rgba(225, 6, 0, 0.14), rgba(8, 10, 15, 0.88) 65%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 14px 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.menu-shell {
  width: 100%;
  max-width: 1220px;
  margin: auto;
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.brand-tag {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--f1-red);
  margin-bottom: 2px;
}

.menu-header h1 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
}

.menu-header h1 span { color: var(--f1-red); }
.subtitle { color: #e2e8f2; opacity: 1; font-size: 13.5px; margin-top: 6px; font-weight: 400; line-height: 1.4; }
.menu-bgm-btn { padding: 8px 14px; background: rgba(255, 255, 255, 0.07); flex-shrink: 0; }

.menu-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: 14px;
  align-items: stretch;
}

.menu-card, .modal-card {
  background: rgba(15, 18, 26, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.menu-card h2 {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #cfd6e3;
  margin-bottom: 8px;
}

.panel-head h2 { margin-bottom: 0; }
.panel-hint { font-family: var(--font-mono); font-size: 11px; color: var(--accent-cyan); }

/* Left Panel: 6 Car Cards + 3D Showroom */
.livery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.livery-card {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.livery-card:hover { background: rgba(255, 255, 255, 0.08); transform: translateY(-1px); }
.livery-card.active {
  background: rgba(225, 6, 0, 0.13);
  border-color: var(--f1-red);
  box-shadow: 0 0 0 1px var(--f1-red);
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.livery-info { display: flex; flex-direction: column; min-width: 0; }
.livery-info strong { font-family: var(--font-label); font-size: 14px; font-weight: 700; line-height: 1.15; }
.livery-info small { color: var(--text-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 3D Car Showcase */
.car-showcase {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, rgba(28, 35, 52, 0.7), rgba(10, 12, 18, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  overflow: hidden;
}

.showcase-viewport {
  position: relative;
  flex: 1;
  min-height: 230px;
  cursor: grab;
}

.showcase-viewport:active { cursor: grabbing; }

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

.showcase-badge {
  position: absolute;
  top: 12px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(11, 14, 20, 0.78);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--f1-red);
  box-shadow: 0 0 10px currentColor;
}

.showcase-team { font-family: var(--font-heading); font-size: 12px; font-weight: 700; color: var(--text-muted); line-height: 1; }
.showcase-model { font-family: var(--font-label); font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2; }

.orbit-hint {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(11, 14, 20, 0.65);
  padding: 3px 8px;
  border-radius: 5px;
  pointer-events: none;
}

.car-specs-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 12px 14px;
  background: rgba(10, 12, 18, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.spec-metric { display: flex; flex-direction: column; gap: 5px; }
.spec-label-row { display: flex; justify-content: space-between; font-size: 11px; }
.spec-label-row span { color: var(--text-muted); font-family: var(--font-heading); font-weight: 600; }
.spec-label-row strong { font-family: var(--font-mono); font-size: 11px; color: #fff; }
.spec-track { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.spec-fill { height: 100%; width: 90%; background: linear-gradient(90deg, var(--f1-red), var(--accent-cyan)); transition: width 0.25s ease; }

/* Right Panel: 24-Circuit Catalog + Preview + Config */
.circuit-toolbar {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 9px;
}

.circuit-search {
  width: 100%;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 11, 16, 0.72);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 12px;
  outline: none;
  user-select: text;
}

.circuit-search:focus {
  border-color: var(--accent-cyan);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-pill {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.filter-pill.active {
  background: rgba(0, 229, 255, 0.14);
  border-color: var(--accent-cyan);
  color: #fff;
}

.country-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 11px;
  max-height: 152px;
  overflow-y: auto;
  padding-right: 4px;
}

.country-grid::-webkit-scrollbar { width: 5px; }
.country-grid::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 4px; }

.country-card {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.country-card:hover { background: rgba(255, 255, 255, 0.08); }
.country-card.active {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan);
}
.country-card.is-pending { opacity: 0.78; }

.flag-badge {
  width: 34px; height: 24px; border-radius: 5px; background: rgba(255, 255, 255, 0.1);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
}
.country-info { display: flex; flex-direction: column; min-width: 0; }
.country-info strong { font-family: var(--font-label); font-size: 13px; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-info small { color: var(--text-muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-pill { font-family: var(--font-mono); font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
.tag-pill.night { background: rgba(192, 84, 255, 0.2); color: var(--accent-purple); }
.tag-pill.ready { background: rgba(0, 230, 118, 0.16); color: var(--accent-green); }

.cta-primary:disabled {
  background: #2b3140;
  color: #8f98aa;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Circuit Preview Card */
.circuit-preview-card {
  display: grid;
  grid-template-columns: minmax(165px, 200px) minmax(0, 1fr);
  gap: 12px;
  padding: 11px;
  background: rgba(9, 11, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  margin-bottom: 11px;
  overflow: hidden;
  align-items: stretch;
}

.circuit-map-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 142px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: grab;
}

.circuit-map-wrap:active { cursor: grabbing; }

#circuit-map-canvas,
#circuit-silhouette-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.map-legend {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  z-index: 2;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(9, 11, 16, 0.72);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.dot-drs { display: inline-block; width: 8px; height: 3px; background: var(--accent-green); border-radius: 2px; }

.circuit-meta-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.circuit-env-banner { position: relative; border-radius: 7px; overflow: hidden; height: 64px; border: 1px solid rgba(255, 255, 255, 0.08); }
#circuit-env-canvas { width: 100%; height: 100%; display: block; }
.env-label {
  position: absolute; bottom: 4px; left: 8px; right: 8px;
  font-size: 10px; font-weight: 500; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.circuit-title { font-family: var(--font-label); font-size: 16px; font-weight: 700; color: #fff; line-height: 1.15; }
.circuit-stats-row { display: grid; grid-template-columns: 1.2fr 0.9fr 0.7fr; gap: 6px; }
.circuit-stats-row span { display: flex; flex-direction: column; }
.circuit-stats-row small { font-size: 10px; color: var(--text-muted); }
.circuit-stats-row strong { font-family: var(--font-heading); font-size: 13px; font-weight: 700; color: var(--accent-cyan); }
.circuit-desc { font-size: 11px; color: var(--text-muted); line-height: 1.35; }

/* Session Mode & Lap Distance */
.config-split { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 12px; margin-bottom: 12px; }
.mode-toggle { display: flex; flex-direction: column; gap: 7px; }
.mode-btn {
  padding: 8px 11px; background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px; color: #fff; text-align: left; cursor: pointer; transition: all 0.15s ease;
}
.mode-btn strong { display: block; font-family: var(--font-label); font-size: 14px; font-weight: 700; }
.mode-btn small { color: var(--text-muted); font-size: 11px; }
.mode-btn.active { background: rgba(0, 229, 255, 0.1); border-color: var(--accent-cyan); }

.lap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; transition: opacity 0.16s ease; }
.lap-grid.is-disabled { opacity: 0.42; pointer-events: none; }
.lap-btn {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px; color: #fff; text-align: left; cursor: pointer; transition: all 0.15s ease;
}
.lap-btn:hover { background: rgba(255, 255, 255, 0.08); }
.lap-btn.active { background: rgba(225, 6, 0, 0.14); border-color: var(--f1-red); box-shadow: 0 0 0 1px var(--f1-red); }
.lap-num { font-family: var(--font-mono); font-size: 10px; font-weight: 800; color: var(--accent-cyan); background: rgba(0, 229, 255, 0.1); padding: 3px 5px; border-radius: 4px; }
.lap-info { display: flex; flex-direction: column; }
.lap-info strong { font-family: var(--font-label); font-size: 13px; font-weight: 700; line-height: 1.1; }
.lap-info small { font-family: var(--font-ui); font-size: 10px; color: var(--text-muted); }

.cta-primary {
  width: 100%; padding: 13px 20px; border: none; border-radius: 10px;
  background: var(--f1-red); color: #fff; font-family: var(--font-display);
  font-size: 14px; font-weight: 700; letter-spacing: 0.06em; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 24px var(--f1-red-glow); transition: transform 0.15s ease, background 0.15s ease;
}
.cta-primary:hover { background: #ff1710; transform: translateY(-1px); }
.cta-secondary { width: 100%; padding: 12px 18px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #fff; font-family: var(--font-display); font-size: 13px; font-weight: 700; cursor: pointer; }
.cta-ghost { width: 100%; padding: 12px 18px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-muted); font-family: var(--font-display); font-size: 12px; font-weight: 700; cursor: pointer; }
.cta-ghost:hover { color: #fff; }

.modal-card { width: 100%; max-width: 420px; text-align: center; margin: auto; }
.modal-card h2 { font-family: var(--font-display); font-size: 24px; margin-bottom: 20px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.finish-card { max-width: 500px; }
.finish-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat-box { background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 10px; padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.stat-box span { font-size: 10px; color: var(--text-muted); }
.stat-box strong { font-size: 15px; }

@media (max-height: 860px), (max-width: 1460px) {
  .overlay-screen { padding: 10px 16px; }
  .menu-header { margin-bottom: 10px; }
  .menu-header h1 { font-size: 31px; }
  .subtitle { font-size: 13px; margin-top: 4px; }
  .menu-grid { gap: 12px; }
  .menu-card { padding: 12px 14px; }
  .livery-grid { gap: 6px; margin-bottom: 9px; }
  .livery-card { padding: 6px 8px; }
  .showcase-viewport { min-height: 180px; }
  .car-specs-bar { padding: 9px 12px; gap: 10px; }
  .circuit-toolbar { gap: 6px; margin-bottom: 7px; }
  .country-grid { max-height: 118px; margin-bottom: 9px; gap: 6px; }
  .circuit-preview-card { padding: 9px; gap: 10px; margin-bottom: 9px; }
  .circuit-map-wrap { min-height: 130px; }
  .circuit-env-banner { height: 52px; }
  .config-split { gap: 10px; margin-bottom: 9px; }
  .cta-primary { padding: 11px 16px; }
}

@media (max-width: 1020px) {
  .menu-grid { grid-template-columns: 1fr; }
  .livery-grid { grid-template-columns: repeat(2, 1fr); }
  .car-specs-bar { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .livery-grid, .country-grid, .circuit-preview-card, .config-split { grid-template-columns: 1fr; }
  .timing-tower, .minimap-panel, .controls-legend { display: none; }
}
