/* ==========================================================================
   Mini Race Manager — light, vibrant management UI
   ========================================================================== */

:root {
  --bg: #eef1f6;
  --bg-2: #f7f9fc;
  --card: #ffffff;
  --line: #e2e7f0;
  --line-soft: #eef1f7;

  --ink: #16203a;
  --ink-2: #4a5773;
  --ink-3: #8592ad;

  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --yellow: #f59e0b;
  --yellow-soft: #fef3c7;
  --violet: #7c3aed;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 32, 58, .06), 0 6px 18px rgba(22, 32, 58, .06);
  --shadow-lg: 0 10px 30px rgba(22, 32, 58, .12);

  --font: "Segoe UI", Inter, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Roboto Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 15% -10%, #ffffff 0%, rgba(255,255,255,0) 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1, h2 { margin: 0; }

/* ============================ Splash screen ============================ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 50% 100%, #1a0f02 0%, transparent 70%),
    #000;
  cursor: pointer;
  transition: opacity .5s ease, visibility .5s ease;
}
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.splash-inner { text-align: center; --amber: #ffb027; }

.splash-logo-box {
  position: relative;
  width: 200px; height: 200px;
  margin: 0 auto 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 176, 39, .28);
  background-image:
    linear-gradient(rgba(255, 176, 39, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 176, 39, .07) 1px, transparent 1px);
  background-size: 20px 20px;
}
.splash-logo-glow {
  position: absolute;
  inset: -50px;
  background: radial-gradient(circle, rgba(255, 170, 20, .32), transparent 68%);
  filter: blur(4px);
  z-index: -1;
}
.splash-logo {
  width: 76%; height: 76%;
  color: var(--amber);
  filter:
    drop-shadow(0 0 5px rgba(255, 176, 39, .95))
    drop-shadow(0 0 16px rgba(255, 140, 0, .55));
  animation: splashPulse 2.6s ease-in-out infinite;
}
@keyframes splashPulse { 0%, 100% { filter: drop-shadow(0 0 5px rgba(255,176,39,.95)) drop-shadow(0 0 16px rgba(255,140,0,.55)); } 50% { filter: drop-shadow(0 0 8px rgba(255,176,39,1)) drop-shadow(0 0 26px rgba(255,140,0,.75)); } }

.splash-title {
  color: var(--amber);
  font-size: 25px;
  font-weight: 800;
  letter-spacing: .28em;
  text-transform: uppercase;
  margin: 0 0 8px;
  text-shadow: 0 0 8px rgba(255, 176, 39, .8), 0 0 22px rgba(255, 120, 0, .45);
}
.splash-tag {
  color: rgba(255, 190, 130, .6);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .32em;
  text-transform: uppercase;
  margin: 0;
}

/* ============================ Top bar ============================ */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .5px;
  box-shadow: 0 6px 14px rgba(37, 99, 235, .35);
}

.brand-text h1 { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.brand-text p { margin: 1px 0 0; font-size: 11.5px; color: var(--ink-3); }

.setup { display: flex; gap: 12px; align-items: flex-end; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

select {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-width: 120px;
  cursor: pointer;
  outline: none;
}
select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }

.btn-accent { background: var(--green); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,.3); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.07); }

.btn-ghost { background: var(--bg-2); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: #fff; color: var(--ink); }

/* ============================ Layout ============================ */

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(420px, 1fr) 340px;
  gap: 14px;
  padding: 14px;
}

.col { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.col-manage { overflow-y: auto; padding-right: 4px; }
.col-timing { min-height: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.card-flush { padding: 0; display: flex; flex-direction: column; min-height: 0; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-flush .card-head { padding: 13px 14px; margin: 0; border-bottom: 1px solid var(--line-soft); }
.card-head h2 { font-size: 13px; font-weight: 800; letter-spacing: .02em; }

.pill {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
}
.pill-muted { background: var(--bg); color: var(--ink-3); }
.pill-live { background: var(--green-soft); color: var(--green); }
.pill-warn { background: var(--yellow-soft); color: #b45309; }
.pill-hot  { background: var(--red-soft); color: var(--red); }

.mini-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 8px;
  cursor: pointer;
}
.mini-btn:hover { color: var(--ink); background: #fff; }

/* ============================ Timing tower ============================ */

.tower-scroll { overflow-y: auto; min-height: 0; flex: 1 1 auto; }

.tower { width: 100%; border-collapse: collapse; font-size: 12px; }
.tower thead th {
  position: sticky; top: 0;
  background: var(--bg-2);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.tower td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tower tbody tr[data-number] { cursor: pointer; }
.tower tbody tr[data-number]:hover td { background: var(--bg-2); }
.tower tr.is-player td { background: #f2f7ff; }
.tower tr.is-player td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.tower tr.is-pitting td { background: var(--yellow-soft); }
.tower tr.is-out td { opacity: .45; }
.tower tr.is-cockpit td { background: #fff7e8; }
.tower tr.is-cockpit td:first-child { box-shadow: inset 3px 0 0 #ffb027; }
.tower .empty td { color: var(--ink-3); text-align: center; padding: 18px; font-style: italic; }

.tower .pos { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tower .car-cell { display: flex; align-items: center; gap: 6px; }
.tower .swatch { width: 9px; height: 15px; border-radius: 3px; flex: 0 0 auto; }
.tower .num { font-weight: 800; font-variant-numeric: tabular-nums; }
.tower .drv { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 78px; }
.tower .gap { font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.ta-r { text-align: right; }

.tyre-dot {
  display: inline-block;
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2.5px solid;
  vertical-align: middle;
}
.tyre-dot.soft { border-color: var(--red); background: var(--red-soft); }
.tyre-dot.medium { border-color: var(--yellow); background: var(--yellow-soft); }
.tyre-dot.hard { border-color: #334155; background: #e2e8f0; }

/* ============================ Status bar ============================ */

.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
}
.status-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.status-block.grow { flex: 1 1 auto; min-width: 0; }
.status-label {
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.status-block strong { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status-block strong.soft { font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }

.flag {
  margin-left: auto;
  font-size: 11px; font-weight: 900; letter-spacing: .08em;
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
}
.flag-none { background: var(--bg); color: var(--ink-3); }
.flag-green { background: var(--green-soft); color: var(--green); }
.flag-yellow { background: var(--yellow-soft); color: #b45309; }
.flag-chequered { background: #16203a; color: #fff; }

/* ============================ Canvas ============================ */

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}
#raceCanvas { display: block; width: 100%; height: 100%; }

.canvas-hint {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.canvas-hint.hidden { display: none; }
.canvas-hint-2 { top: auto; bottom: 14px; left: 50%; transform: translateX(-50%); font-size: 11px; padding: 6px 14px; }

#raceCanvas { cursor: pointer; }

/* ============================ Cockpit view ============================ */

.cockpit-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: transparent;
  pointer-events: none;
  animation: cockpitFadeIn .15s ease;
}
.cockpit-overlay.hidden { display: none; }
@keyframes cockpitFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.cockpit-frame {
  position: fixed;
  pointer-events: auto;
  width: min(30vw, 420px);
  min-width: 300px;
  aspect-ratio: 1180 / 720;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  background: #0d1220;
}
.cockpit-frame.is-dragging { box-shadow: 0 22px 52px rgba(0,0,0,.65); user-select: none; }
#cockpitCanvas { display: block; width: 100%; height: 100%; }

.cockpit-hud { position: absolute; inset: 0; pointer-events: none; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0));
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.hud-top:active { cursor: grabbing; }
.hud-driver { display: flex; align-items: center; gap: 5px; min-width: 0; }
.hud-num {
  background: rgba(255,255,255,.92); color: #16203a;
  font-size: 8.5px; font-weight: 800;
  padding: 2px 5px; border-radius: 999px;
  flex: 0 0 auto;
}
.hud-name {
  color: #fff; font-size: 10px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-pos {
  color: #fff; font-size: 9px; font-weight: 800; letter-spacing: .03em;
  background: rgba(255,255,255,.14); padding: 2px 6px; border-radius: 999px;
  flex: 0 0 auto;
}

.hud-icon-btn {
  pointer-events: auto;
  margin-left: auto;
  width: 19px; height: 19px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.35);
  color: #fff;
  font-size: 9px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.hud-icon-btn:hover { background: rgba(0,0,0,.55); }
.hud-icon-btn.hud-close { margin-left: 5px; }

.hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 7px 9px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.6), rgba(0,0,0,0));
}
.hud-gear { display: flex; flex-direction: column; align-items: center; color: #fff; }
.hud-gear-label { font-size: 6.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.hud-gear strong { font-size: 15px; font-family: var(--mono); font-weight: 800; line-height: 1; }

.hud-pedals { display: flex; flex-direction: column; gap: 3px; }
.hud-pedal {
  font-size: 7px; font-weight: 900; letter-spacing: .05em;
  padding: 2px 6px; border-radius: 4px;
  color: rgba(255,255,255,.4);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  transition: background .08s ease, color .08s ease, box-shadow .08s ease;
}
.hud-pedal.is-active { color: #fff; }
#pedalThrottle.is-active { background: var(--green); box-shadow: 0 0 8px rgba(22,163,74,.7); border-color: transparent; }
#pedalBrake.is-active { background: var(--red); box-shadow: 0 0 8px rgba(220,38,38,.7); border-color: transparent; }

.hud-rev { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rev-bar {
  height: 5px; border-radius: 999px;
  background: rgba(255,255,255,.16);
  overflow: hidden;
}
.rev-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #16a34a, #f59e0b 70%, #dc2626);
  transition: width .06s linear;
}
.hud-rev span { font-family: var(--mono); font-size: 7.5px; color: rgba(255,255,255,.85); }

.hud-speed { display: flex; align-items: baseline; gap: 3px; color: #fff; flex: 0 0 auto; }
.hud-speed strong { font-size: 18px; font-family: var(--mono); font-weight: 800; line-height: 1; }
.hud-speed span { font-size: 7.5px; color: rgba(255,255,255,.7); }

/* ============================ Telemetry ============================ */

.telemetry .card-head h2 { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.telemetry .car-num {
  background: var(--blue); color: #fff;
  padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 800;
}
.telemetry .driver-name { font-weight: 700; }

.tele-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tele-cell {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.tele-cell span { font-size: 9.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.tele-cell strong { font-size: 13px; font-family: var(--mono); font-weight: 700; }
.tele-cell strong.warn { color: #b45309; }

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 52px;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.bar-label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.bar-label em { font-style: normal; font-weight: 800; }
.bar-label em.soft { color: var(--red); }
.bar-label em.medium { color: #b45309; }
.bar-label em.hard { color: #334155; }

.bar {
  height: 9px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.bar-fill { height: 100%; width: 100%; border-radius: 999px; transition: width .3s ease, background .3s ease; }
.bar-fill.tire { background: var(--green); }
.bar-fill.fuel { background: var(--blue); }
.bar-fill.wing { background: var(--violet); }
.bar-fill.warn { background: var(--yellow); }
.bar-fill.crit { background: var(--red); }

.bar-val { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--ink-2); font-weight: 600; }

.mandate { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.chip {
  font-size: 10px; font-weight: 800; letter-spacing: .03em;
  padding: 4px 8px; border-radius: 999px;
  background: var(--bg); color: var(--ink-3);
  border: 1px dashed var(--line);
}
.chip.done { background: var(--green-soft); color: var(--green); border-style: solid; border-color: transparent; }
.chip.count { background: var(--blue-soft); color: var(--blue); border-style: solid; border-color: transparent; }
.chip.crit { background: var(--red-soft); color: var(--red); border-style: solid; border-color: transparent; animation: pulse 1.1s infinite; }
.is-hidden { display: none; }

/* ============================ Radio ============================ */

.radio-log {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 172px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.radio-msg {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 11.5px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border-left: 3px solid var(--ink-3);
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(6px); } to { opacity: 1; transform: none; } }
.radio-msg .who {
  font-size: 9.5px; font-weight: 900; letter-spacing: .05em;
  color: var(--ink-3); white-space: nowrap; flex: 0 0 auto;
}
.radio-msg .txt { color: var(--ink-2); }
.tone-info { border-left-color: var(--blue); background: #f4f8ff; }
.tone-warn { border-left-color: var(--yellow); background: #fffbeb; }
.tone-crit { border-left-color: var(--red); background: #fef2f2; }
.tone-good { border-left-color: var(--green); background: #f0fdf4; }

/* ============================ Pit control ============================ */

.seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.seg-btn {
  flex: 1 1 0;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 6px 4px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg-btn.c-soft.is-active { color: var(--red); }
.seg-btn.c-medium.is-active { color: #b45309; }
.seg-btn.c-hard.is-active { color: #334155; }

.pit-field { margin-top: 12px; }
.pit-field > label {
  display: block;
  font-size: 10px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 5px;
}

.toggle { display: flex; align-items: center; gap: 9px; margin-top: 11px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--line); flex: 0 0 auto;
  position: relative; transition: background .18s ease;
}
.toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s ease;
}
.toggle input:checked + .toggle-track { background: var(--green); }
.toggle input:checked + .toggle-track .toggle-knob { transform: translateX(16px); }
.toggle-text { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.toggle-text em { font-style: normal; color: var(--ink-3); font-weight: 500; }

.toggle-inline { margin-top: 0; padding: 6px 0; }

.sound-control { display: flex; align-items: center; gap: 8px; }
.vol-slider {
  width: 74px;
  accent-color: var(--blue);
  cursor: pointer;
}
.vol-slider:disabled { opacity: .4; cursor: not-allowed; }

.btn-box {
  width: 100%;
  margin-top: 14px;
  background: var(--red);
  color: #fff;
  font-size: 13.5px;
  letter-spacing: .06em;
  padding: 12px;
  box-shadow: 0 4px 14px rgba(220,38,38,.32);
}
.btn-box:hover:not(:disabled) { filter: brightness(1.07); }
.btn-box.is-armed { background: var(--yellow); box-shadow: 0 4px 14px rgba(245,158,11,.35); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .74; } }

.pit-hint { margin: 10px 0 0; font-size: 11px; line-height: 1.45; color: var(--ink-3); }

/* ============================ Grid prep ============================ */

.grid-prep-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 12, 22, 0.6);
  backdrop-filter: blur(3px);
  animation: cockpitFadeIn .15s ease;
}
.grid-prep-overlay.hidden { display: none; }

.grid-prep-card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px;
}

.grid-prep-head h2 { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.grid-prep-head p { margin: 0 0 18px; font-size: 12.5px; color: var(--ink-3); }

.grid-prep-cars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 620px) {
  .grid-prep-cars { grid-template-columns: 1fr; }
}

.prep-car {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.prep-car-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.prep-car-num {
  background: var(--blue); color: #fff;
  padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 800;
}
.prep-car-driver { font-weight: 700; font-size: 13px; }

.prep-field { margin-bottom: 14px; }
.prep-field:last-child { margin-bottom: 0; }
.prep-field > label {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 6px;
}
.prep-field > label span { text-transform: none; font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ink-2); letter-spacing: 0; }

.prep-compound-hint, .prep-fuel-hint {
  margin: 7px 0 0; font-size: 11px; line-height: 1.4; color: var(--ink-3);
}

.prep-fuel-slider { width: 100%; accent-color: var(--blue); cursor: pointer; }

.grid-prep-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================ Footer ============================ */

.footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--ink-3);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.footer a { color: var(--ink-3); text-decoration: none; }
.footer a:hover { color: var(--blue); text-decoration: underline; }
.footer-sep { opacity: .5; }

/* ============================ Scrollbars ============================ */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd7e6; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b6c1d6; }

/* ============================ Responsive ============================ */

@media (max-width: 1280px) {
  .layout { grid-template-columns: 226px minmax(340px, 1fr) 308px; }
  .setup .field:last-child { display: none; }
}
@media (max-width: 1080px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .col-track { min-height: 460px; }
}
