:root {
  --bg: #0b0e13;
  --panel: rgba(12, 17, 25, 0.92);
  --panel-solid: #111923;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e7ebf3;
  --muted: #8a94a6;
  --faint: #8190a3;
  --accent: #4cc2ff;
  --good: #57d27f;
  --warn: #f2b84b;
  --bad: #ff6b6b;
  --radius: 14px;
  --gap: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas#view.orbit-dragging { cursor: grabbing; }
.orbit-toolbar, .orbit-actions { display: flex; align-items: center; gap: 6px; }
.orbit-toolbar { margin-top: 8px; }
#camera-orbit[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #4cc2ff0c; }
.camera-help { margin: 6px 0 0; font-size: 10px; line-height: 1.5; color: var(--muted); }

/* Loading */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #142130, var(--bg) 70%); z-index: 20; }
.overlay .card { text-align: center; }
.overlay h1 { margin: 18px 0 10px; font-size: 22px; font-weight: 750; letter-spacing: 0.14em; }
.overlay h1 small { font-size: 10px; color: var(--muted); font-weight: 500; letter-spacing: 0.12em; margin-left: 6px; }
.overlay p { color: var(--muted); margin: 0; font-family: var(--mono); font-size: 12px; }
.overlay .card { max-width: min(480px, calc(100vw - 48px)); }
.overlay p { overflow-wrap: anywhere; }
#retry-start { margin-top: 18px; }
.loading-mark { width: 38px; height: 38px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(76, 194, 255, 0.15); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* HUD frame: two side columns and a centred instrument cluster */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud .panel { pointer-events: auto; }
.hud-column { position: absolute; top: var(--gap); bottom: var(--gap); display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.hud-left { left: var(--gap); width: 300px; justify-content: space-between; overflow-y: auto; pointer-events: auto; }
.hud-right { right: var(--gap); width: 238px; overflow-y: auto; pointer-events: auto; }
.hud-right > .panel { flex-shrink: 0; }
.hud-top-left { padding: 14px; flex: 0 0 auto; }
.hud-top-right { padding: 8px; }
.label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.muted { color: var(--muted); }

.world-heading { display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 15px; letter-spacing: 0.14em; font-weight: 750; }
.brand small { font-size: 9px; color: var(--muted); font-weight: 500; letter-spacing: 0.1em; margin-left: 5px; }
.current-city { color: var(--muted); font-size: 11px; margin: 2px 0 12px; }

.nav-card { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; background: linear-gradient(135deg, rgba(76, 194, 255, 0.2), rgba(76, 194, 255, 0.06)); border: 1px solid rgba(76, 194, 255, 0.35); }
.nav-card.idle { background: rgba(255, 255, 255, 0.04); border-color: var(--border); }
.nav-card.arrived { background: rgba(87, 210, 127, 0.14); border-color: rgba(87, 210, 127, 0.4); }
.nav-arrow { flex: 0 0 38px; height: 38px; display: grid; place-items: center; font-size: 24px; line-height: 1; border-radius: 9px; background: var(--accent); color: #04131d; font-weight: 700; }
.nav-card.idle .nav-arrow { background: rgba(255, 255, 255, 0.07); color: var(--muted); font-size: 18px; }
.nav-card.arrived .nav-arrow { background: var(--good); }
.nav-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nav-text strong { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.nav-card.idle .nav-text strong { font-size: 14px; }
.nav-text strong small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.nav-text span { font-size: 11.5px; color: #b9c9da; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.street-line { display: flex; gap: 8px; align-items: baseline; margin: 10px 2px 0; font-size: 13px; min-width: 0; }
.street-line #street { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pilot-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; }
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); }
.segmented button { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 5px 13px; cursor: pointer; }
.segmented button[aria-checked="true"] { color: var(--text); background: rgba(255, 255, 255, 0.12); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.segmented button.unavailable { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.3); }
.switch { font: inherit; font-size: 12px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; }
.switch i { position: relative; width: 30px; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #cfd8e3; transition: transform 0.2s; }
.switch[aria-checked="true"] { color: var(--accent); border-color: rgba(76, 194, 255, 0.5); background: rgba(76, 194, 255, 0.12); }
.switch[aria-checked="true"] i { background: var(--accent); }
.switch[aria-checked="true"] i::after { transform: translateX(12px); background: #fff; }

.toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 30px; gap: 6px; margin-top: 10px; }
.tool, .chip-button, select, .toggle { font: inherit; font-size: 11.5px; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.tool { min-width: 0; padding-inline: 5px; white-space: normal; }
.tool:last-child { flex: 0 0 30px; padding: 5px 0; }
.tool:hover, .chip-button:hover, .toggle:hover, select:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--border-strong); }
.tool[aria-expanded="true"], .tool[aria-pressed="true"], .toggle.on { background: rgba(76, 194, 255, 0.16); border-color: rgba(76, 194, 255, 0.55); color: var(--accent); }
.chip-button { font-size: 11px; padding: 3px 9px; border-radius: 999px; color: var(--muted); }
.chip-button:hover { color: var(--text); }
select { appearance: none; -webkit-appearance: none; padding-right: 24px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px; background-repeat: no-repeat; }
select option { background: var(--panel-solid); color: var(--text); }

.settings { display: grid; grid-template-columns: 0.9fr 1.3fr 0.8fr; gap: 8px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
#settings { max-height: min(610px, max(180px, calc(100dvh - 330px))); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding-right: 6px; align-content: start; }
.settings-section-heading { grid-column: 1 / -1; margin: 0 0 3px; font-size: 12px; font-weight: 600; }
.settings > label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.settings select { width: 100%; }
.settings input[type="number"] { width: 100%; min-width: 0; font: inherit; font-size: 11.5px; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-radius: 8px; padding: 5px 7px; }
.world-conditions { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 10px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.world-conditions .chip-button { flex-shrink: 0; font-size: 10px; }
.world-conditions .chip-button[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); }
.world-settings-footer { grid-column: 1 / -1; position: sticky; bottom: 0; z-index: 1; padding: 10px 0 2px; border-top: 1px solid var(--border); background: var(--panel-solid); display: flex; flex-direction: column; gap: 8px; font-size: 10px; line-height: 1.5; color: var(--muted); }
.world-settings-footer .toggle { align-self: flex-start; }
/* Garage choices fit the HUD settings and expand naturally inside a larger dialog. */
.vehicle-garage { grid-column: 1 / -1; min-width: 0; padding-top: 14px; margin-top: 3px; border-top: 1px solid var(--border); }
.garage-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.garage-heading h3 { font-size: 12px; font-weight: 600; margin: 0; }
.garage-heading > span { font-size: 9px; color: var(--muted); }
.vehicle-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; --vehicle-paint: #1f5fd6; }
.vehicle-option { display: flex; flex-direction: column; align-items: flex-start; position: relative; min-width: 0; padding: 8px 10px 10px; color: var(--text); background: #ffffff03; border: 1px solid var(--border); border-radius: 9px; text-align: left; font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.vehicle-option:hover { background: #ffffff08; border-color: var(--border-strong); }
.vehicle-option[aria-pressed="true"] { border-color: var(--accent); background: #4cc2ff0c; box-shadow: inset 0 0 0 1px #4cc2ff20; }
.vehicle-option[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 5px; right: 7px; font-size: 10px; color: var(--accent); }
.vehicle-option strong { font-size: 11px; font-weight: 600; line-height: 1.5; }
.vehicle-option > span { font-size: 9px; line-height: 1.5; color: var(--muted); margin-top: 3px; }
.vehicle-silhouette { display: block; width: 100%; height: 39px; margin: 1px 0 5px; overflow: visible; }
.vehicle-shadow { fill: #0005; }
.vehicle-body { fill: var(--vehicle-paint); stroke: #ffffff24; stroke-width: 1; stroke-linejoin: round; }
.vehicle-glass { fill: #a0c2d0; opacity: .7; }
.vehicle-trim { fill: none; stroke: #182f45; stroke-width: 1.5; }
.vehicle-tire { fill: #0a1018; stroke: #667383; stroke-width: 1; }
.vehicle-rim { fill: #a9b6c5; }
.garage-paint { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; }
.paint-options { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.paint-option { position: relative; width: 28px; height: 28px; flex: 0 0 28px; padding: 3px; border: 1px solid transparent; border-radius: 50%; background: none; cursor: pointer; }
.paint-option::before { content: ""; display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--paint); border: 1px solid #ffffff30; box-shadow: inset 0 1px 2px #ffffff30, 0 2px 4px #0003; }
.paint-option:hover { border-color: var(--border-strong); }
.paint-option[aria-pressed="true"] { border-color: var(--accent); }
.paint-option[aria-pressed="true"]::after { content: ""; position: absolute; inset: 10px; border: 1px solid #ffffffcc; border-radius: 50%; background: #0006; }
.vehicle-spec { font-size: 10px; line-height: 1.6; color: var(--muted); margin: 11px 0 0; min-height: 32px; }
@media (min-width: 700px) {
  dialog .vehicle-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  dialog .vehicle-option { padding: 12px 14px; }
  dialog .vehicle-option strong { font-size: 12px; }
  dialog .vehicle-option > span { font-size: 10px; }
  dialog .vehicle-silhouette { height: 48px; }
}
@media (max-width: 360px) {
  .garage-paint { align-items: flex-start; flex-direction: column; }
}
.settings-checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 14px; }
.settings-inspect { display: none; }
.check { font-size: 11.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }

#minimap { display: block; width: 220px; height: 220px; border-radius: 9px; background: #11151c; cursor: crosshair; }
.note { color: var(--faint); font-size: 10px; line-height: 1.45; margin: 6px 2px 0; }
.note .warn-text { color: var(--warn); }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.decision-card { padding: 12px 12px 10px; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.source-tag { font-family: var(--mono); font-size: 10px; color: var(--muted); padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.source-tag.fallback { color: var(--warn); background: rgba(242, 184, 75, 0.12); }
.source-tag.live { color: var(--good); background: rgba(87, 210, 127, 0.12); }
.decision-motion { font-size: 15px; font-weight: 600; margin: 8px 0 8px; }
.decision-motion.stop { color: var(--warn); }
.decision-motion.off { color: var(--muted); font-weight: 500; font-size: 13px; }
.decision-options { display: flex; flex-direction: column; gap: 5px; min-height: 0; overflow: hidden; }
.decision-options p { margin: 0; font-size: 11px; line-height: 1.5; }
.option { position: relative; display: flex; justify-content: space-between; gap: 8px; padding: 4px 7px; border-radius: 6px; font-size: 11px; color: #b9c9da; overflow: hidden; }
.option > i { position: absolute; inset: 0 auto 0 0; background: rgba(76, 194, 255, 0.14); border-radius: 6px; transition: width 0.3s; }
.option.chosen { color: var(--text); }
.option.chosen > i { background: rgba(87, 210, 127, 0.26); }
.option span, .option b { position: relative; }
.option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option b { font-weight: 500; font-variant-numeric: tabular-nums; }
.option-note { font-size: 10px; color: var(--faint); margin-top: 2px; }
.telemetry { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-variant-numeric: tabular-nums; font-size: 12px; }
.stat span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .label { font-size: 9px; }
.inspect { align-self: flex-start; margin-top: 10px; }
.incidents { margin-top: auto; padding: 10px 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 4px; text-align: center; }
.incident { display: flex; flex-direction: column; gap: 1px; }
.incident span { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--faint); }
.incident small { font-size: 9px; color: var(--muted); letter-spacing: 0.02em; }
.incident.hit span { color: var(--warn); }
.incident.bad span { color: var(--bad); }

/* Instrument cluster */
.cluster { position: absolute; bottom: var(--gap); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-radius: 22px; }
.limit-sign { width: 44px; padding: 4px 0 3px; display: flex; flex-direction: column; align-items: center; border-radius: 6px; background: #f4f5f2; color: #111; border: 2px solid #111; box-shadow: 0 0 0 1.5px #f4f5f2; }
.limit-sign small { font-size: 6.5px; font-weight: 700; letter-spacing: 0.04em; }
.limit-sign b { font-size: 19px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.limit-sign.none { opacity: 0.35; }
.speed { display: flex; align-items: baseline; gap: 5px; min-width: 104px; justify-content: center; font-size: 46px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -0.03em; transition: color 0.2s; }
.speed small { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; font-weight: 500; }
.speed.speeding { color: var(--warn); }
.cluster.speeding .limit-sign { box-shadow: 0 0 0 1.5px #f4f5f2, 0 0 14px 4px rgba(242, 184, 75, 0.7); }

.cluster-mode { display: flex; flex-direction: column; gap: 3px; min-width: 96px; font-size: 10px; letter-spacing: 0.1em; font-weight: 600; }
#drive-mode { color: #c5d6e6; }
#drive-mode.auto { color: var(--accent); }
#drive-mode.paused { color: var(--warn); }
#speed-warning { color: var(--warn); letter-spacing: 0.06em; font-weight: 500; }
.indicator { color: #2c3a33; font-size: 15px; transition: color 0.1s; }
.indicator.active { color: #71e69e; text-shadow: 0 0 12px #71e69e88; }

/* Toasts */
.badge { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; max-width: min(560px, calc(100vw - 600px)); padding: 9px 16px 9px 12px; border-radius: 999px; font-weight: 600; letter-spacing: 0.04em; font-size: 12.5px; color: var(--text); background: rgba(12, 17, 25, 0.88); border: 1px solid var(--border-strong); backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); animation: toast-in 0.18s ease-out; }
.badge::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.badge.safety::before { background: var(--warn); }
.badge.safety { border-color: rgba(242, 184, 75, 0.5); }
.badge.stop::before { background: var(--good); }
.badge.stop { border-color: rgba(87, 210, 127, 0.5); }
.badge.alert { background: rgba(120, 18, 24, 0.9); border-color: rgba(255, 107, 107, 0.7); }
.badge.alert::before { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -6px); } }

/* Keyboard help */
.keys-help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow-y: auto; z-index: 13; padding: 16px 18px; background: rgba(12, 17, 25, 0.92); }
.keys-help dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; margin: 14px 0 0; font-size: 12px; align-items: center; }
.keys-help dt { display: flex; gap: 3px; }
.keys-help dd { margin: 0; color: #b9c9da; }
kbd { font-family: var(--mono); font-size: 10.5px; min-width: 20px; text-align: center; padding: 2px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border-strong); border-bottom-width: 2px; }

/* "What Jev sees" drawer */
.drawer { position: fixed; top: var(--gap); right: calc(238px + var(--gap) * 2); bottom: 96px; width: 440px; z-index: 12; display: flex; flex-direction: column; overflow: hidden; background: rgba(12, 17, 25, 0.92); }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.drawer header strong { flex: 0 0 auto; font-size: 13px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 1px solid transparent; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.tabs button.active { color: var(--text); border-color: var(--border); background: rgba(255,255,255,0.05); }
.drawer .actions { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.drawer .body { flex: 1; overflow: auto; padding: 10px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.45; }
.drawer pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.bar { display: grid; grid-template-columns: 150px 1fr 48px; gap: 8px; align-items: center; margin: 3px 0; }
.bar .track { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); }
.bar.chosen .fill { background: var(--good); }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; }
.kv .label { align-self: center; }
.flash { position: fixed; inset: 0; background: radial-gradient(circle, transparent 40%, rgba(255, 60, 60, 0.45)); pointer-events: none; z-index: 15; animation: fade 0.6s forwards; }
@keyframes fade { to { opacity: 0; } }

.drive-card { padding: 14px; flex: 0 0 auto; }
.drive-heading, .drive-score-row, .drive-actions, .dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.text-button { font: inherit; font-size: 11px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 2px; }
.drive-score-row { justify-content: flex-start; margin: 12px 0; }
.cluster, .incidents, .drive-card { background: var(--panel-solid); }
.drive-number { font-size: 44px; line-height: 1; color: var(--good); font-variant-numeric: tabular-nums; }
.drive-number:not([data-qualified="true"]) { color: var(--faint); }
.drive-number[data-grade="E"], .drive-number[data-grade="D"] { color: var(--warn); }
.drive-score-row > div { min-width: 0; }
.drive-title { font-size: 13px; font-weight: 600; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-score-row .muted { font-size: 11px; margin-top: 5px; }
.score-category { display: grid; grid-template-columns: 78px 1fr 26px; gap: 10px; align-items: center; font-size: 11px; margin: 7px 0; }
.score-category > span { color: var(--muted); }
.score-category b { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.score-track { height: 4px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,0.08); }
.score-track i { display: block; height: 100%; transition: width 0.3s; }
.drive-coach { color: var(--muted); font-size: 12px; line-height: 1.5; min-height: 36px; }
.drive-actions .toggle { font-size: 11px; }
button:disabled { opacity: 0.4; cursor: default; }
.drive-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; padding: 26px; background: #111923; color: var(--text); border: 1px solid rgba(255,255,255,.16); border-radius: 20px; box-shadow: 0 30px 120px #0009; }
.drive-dialog::backdrop { background: #050c14b3; backdrop-filter: blur(5px); }
.drive-dialog h2 { font-size: 25px; margin: 22px 0 8px; letter-spacing: -0.03em; }
.drive-dialog h3 { margin-top: 22px; font-size: 14px; }
.drive-dialog p { font-size: 13px; line-height: 1.6; }
.report-score { display: flex; gap: 16px; align-items: center; margin: 20px 0; }
.report-score strong { font-size: 72px; color: var(--good); line-height: 1; letter-spacing: -0.06em; }
.report-score span { color: var(--muted); font-size: 13px; }
.report-metrics { display: flex; justify-content: space-between; padding: 14px 0; font-size: 13px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.report-categories { margin-top: 20px; }
.report-categories .score-category { font-size: 13px; grid-template-columns: 90px 1fr 30px; margin: 12px 0; }
.report-tips, .report-events { padding-left: 20px; color: #b7c7d9; font-size: 13px; line-height: 1.7; }
.report-tips li { margin: 8px 0; }
.drive-dialog summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.drive-dialog .score-explanation { font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 16px; }
.dialog-footer { font-size: 11px; margin-top: 18px; }
.history-list { display: grid; gap: 8px; margin-top: 24px; }
.history-entry { display: flex; align-items: center; gap: 18px; padding: 16px; text-align: left; color: var(--text); background: #ffffff05; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.history-entry strong { min-width: 70px; color: var(--good); }
.history-entry span { font-size: 13px; }
.history-entry small { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; }
.empty-state { padding: 30px 0; }
/* World explorer: controls persist while asynchronous results update. */
.explorer-dialog { width: min(1100px, calc(100vw - 36px)); padding: 28px; scrollbar-gutter: stable; }
.explorer-dialog h2 { font-size: 30px; margin: 0 0 8px; }
.explorer-intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 26px 0; }
.explorer-intro p { margin: 0; }
.explorer-location { flex: 0 0 auto; max-width: 260px; padding: 12px 16px; background: #ffffff04; border: 1px solid var(--border); border-radius: 10px; }
.explorer-location .label { display: block; margin-bottom: 6px; font-size: 9px; color: var(--good); }
.explorer-location strong { display: block; font-size: 12px; font-weight: 500; line-height: 1.5; }
.explorer-catalog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.explorer-catalog-heading h3 { margin: 0; font-size: 14px; }
.explorer-summary { font-size: 11px; color: var(--muted); text-align: right; }
.explorer-filters { display: grid; grid-template-columns: minmax(240px, 1.6fr) minmax(140px, 1fr) minmax(140px, 1fr); gap: 12px; margin-top: 16px; }
.explorer-filters label { min-width: 0; }
.explorer-filters label > span { display: block; font-size: 10px; color: var(--muted); margin-bottom: 7px; }
.explorer-filters input, .explorer-filters select { box-sizing: border-box; width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #0d141d; color: var(--text); font: inherit; font-size: 12px; color-scheme: dark; }
.explorer-filters input::placeholder { color: var(--faint); }
.explorer-status:empty { display: none; }
.explorer-result-count { display: block; margin-top: 12px; font-size: 10px; color: var(--muted); }
.explorer-loading { color: var(--muted); margin: 16px 0; padding: 12px 16px; background: #ffffff04; border-radius: 8px; }
.explorer-loading::before { content: ""; display: inline-block; vertical-align: middle; margin-right: 9px; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.explorer-error { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 16px 0; padding: 14px 16px; border: 1px solid #f2b86b40; border-radius: 10px; background: #f2b86b09; }
.explorer-error strong { font-size: 12px; color: var(--warn); }
.explorer-error p { font-size: 11px; color: var(--muted); margin: 5px 0 0; overflow-wrap: anywhere; }
.explorer-error .toggle { flex-shrink: 0; }
.explorer-empty { margin: 16px 0; padding: 24px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }
.explorer-empty strong { font-size: 13px; }
.explorer-empty p { font-size: 12px; }
.city-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.city-card { display: flex; flex-direction: column; padding: 0; min-width: 0; text-align: left; overflow: hidden; color: var(--text); border: 1px solid var(--border); border-radius: 12px; background: #0d141d; cursor: pointer; transition: border-color .2s, transform .2s; }
.city-card:hover:not(:disabled) { border-color: var(--city-accent); transform: translateY(-2px); }
.city-card.selected { border-color: var(--city-accent); box-shadow: inset 0 0 0 1px var(--city-accent); }
.city-card:disabled { opacity: .65; }
.city-preview { position: relative; width: 100%; }
.city-card canvas { display: block; width: 100%; height: 86px; object-fit: cover; }
.city-character, .city-current { position: absolute; font-size: 9px; line-height: 1.3; padding: 4px 7px; border-radius: 4px; background: #0a131ee6; }
.city-character { left: 10px; bottom: 9px; color: var(--city-accent); }
.city-current { top: 9px; right: 9px; background: var(--city-accent); color: #102018; font-weight: 600; }
.city-card-body { display: flex; flex-direction: column; flex: 1; padding: 13px; }
.city-eyebrow { font-size: 9px; color: var(--muted); line-height: 1.5; }
.city-card h3 { font-size: 19px; margin: 7px 0 0; letter-spacing: -.03em; line-height: 1.25; }
.city-card p { font-size: 11px; color: var(--muted); line-height: 1.55; margin: 9px 0 12px; }
.city-meta { display: flex; flex-direction: column; gap: 8px; font-size: 10px; color: var(--muted); margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.city-meta b { color: var(--city-accent); font-size: 11px; font-weight: 500; }
.explorer-section { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border); }
.explorer-section h3 { font-size: 15px; margin: 0 0 6px; }
.explorer-section .muted, .explorer-paused { font-size: 10px; }
.explorer-paused { color: var(--muted); text-align: right; }
.explorer-dialog .dialog-footer { flex-wrap: wrap; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.explorer-dialog .dialog-footer a { color: var(--muted); }
.explorer-dialog .dialog-footer .toggle { margin-left: auto; }
.mission-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 26px; }
.mission-card { text-align: left; padding: 18px; color: var(--text); border: 1px solid var(--border); border-radius: 12px; background: #ffffff04; cursor: pointer; }
.mission-card:hover { border-color: var(--accent); background: #4cc2ff09; }
.mission-card h3 { font-size: 16px; margin: 10px 0 8px; letter-spacing: -.02em; }
.mission-card p { color: var(--muted); font-size: 11px; min-height: 36px; }
.mission-difficulty { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.mission-meta { color: var(--muted); font-size: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.mission-start { display: block; margin-top: 14px; color: var(--accent); font-size: 12px; }
.error-note { color: var(--warn); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cockpit { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

@media (max-width: 850px) {
  .city-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mission-grid { grid-template-columns: 1fr; }
  .explorer-intro { align-items: flex-start; gap: 16px; }
  .explorer-location { max-width: 200px; }
  .explorer-dialog h2 { font-size: 26px; }
  .explorer-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explorer-search { grid-column: 1 / -1; }
  .explorer-section { display: block; }
  .explorer-section > span { display: block; text-align: left; margin-top: 10px; }
}
/* Short screens: drop the secondary detail before panels collide */
@media (max-height: 760px) { .drive-bars, .telemetry { display: none; } .decision-options .option:not(.chosen):nth-child(n+4) { display: none; } }
@media (max-height: 620px) { .drive-coach, .current-city { display: none; } #minimap { width: 160px; height: 160px; } .hud-right { width: 178px; } .note { display: none; } }
/* Narrow screens: the cluster moves above the side panels, the right column slims down */
@media (max-width: 1080px) { .cluster { bottom: auto; top: var(--gap); padding: 6px 12px; gap: 10px; } .speed { font-size: 32px; min-width: 76px; } .cluster-mode { display: none; } .hud-right { width: 178px; } #minimap { width: 160px; height: 160px; } .decision-card .telemetry { grid-template-columns: repeat(2, 1fr); } .drawer { right: calc(178px + var(--gap) * 2); width: min(440px, calc(100vw - 230px)); } .badge { max-width: calc(100vw - 40px); top: 70px; } }
@media (max-width: 900px) { .hud-left { width: 262px; } .decision-card, .incidents { display: none; } .settings-inspect { display: inline-block; } .drawer { inset: var(--gap); width: auto; } .badge { top: 84px; } }

@media (max-width: 760px) {
  .cluster { top: auto; bottom: var(--gap); left: auto; right: var(--gap); transform: none; }
  .hud-right { bottom: 86px; }
  .hud-left { justify-content: flex-start; }
  .badge { top: auto; bottom: 82px; max-width: calc(100vw - 28px); }
}
@media (max-width: 540px) {
  .hud-left { width: calc(100vw - 28px); bottom: 182px; }
  .hud-right { top: auto; bottom: var(--gap); width: 150px; }
  #minimap { width: 132px; height: 132px; }
  .hud-right .note { display: none; }
  .cluster { left: var(--gap); right: auto; max-width: calc(100vw - 192px); padding: 6px 8px; gap: 8px; }
  .cluster .indicator { display: none; }
  .speed { min-width: 54px; font-size: 28px; gap: 2px; }
  .speed small { font-size: 9px; }
  .limit-sign { width: 36px; flex-shrink: 0; }
  .drawer header { flex-wrap: wrap; }
  .drawer .tabs { order: 3; flex-basis: 100%; }
  #panel-close { margin-left: auto; }
  .badge { bottom: 172px; }
  .city-grid { grid-template-columns: 1fr; }
  .explorer-dialog { padding: 18px; width: calc(100vw - 20px); max-height: calc(100dvh - 24px); }
  .explorer-intro { display: block; margin: 22px 0; }
  .explorer-location { max-width: none; margin-top: 16px; }
  .explorer-catalog-heading { align-items: flex-start; }
  .explorer-summary { max-width: 135px; line-height: 1.5; }
  .explorer-filters { gap: 10px; }
  .explorer-filters input, .explorer-filters select { font-size: 16px; }
  .city-card canvas { height: 100px; }
  .explorer-error { align-items: flex-start; flex-direction: column; }
  .explorer-dialog .dialog-footer .muted { flex-basis: 100%; line-height: 1.6; }
}
@media (max-height: 460px) { .hud-left { justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
#hud[data-quality="low"] .panel { box-shadow: none; }

/* Photo mode: only the road view and the photo controls remain */
body.photo-mode > :not(#view):not(.photo-panel):not(.photo-reveal) { display: none !important; }
body.photo-mode canvas#view { cursor: grab; }
.photo-panel { position: fixed; right: var(--gap); bottom: var(--gap); z-index: 30; width: 280px; padding: 14px; display: grid; gap: 10px; }
.photo-cameras { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-cameras [aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #4cc2ff0c; }
.photo-slider { display: grid; grid-template-columns: 78px 1fr 48px; align-items: center; gap: 8px; }
.photo-slider input[type="range"] { width: 100%; accent-color: var(--accent); }
.photo-value { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.photo-status { margin: 0; font-size: 11px; color: var(--muted); }
.photo-actions { display: flex; gap: 8px; align-items: center; }
.photo-actions .photo-capture { margin-left: auto; border-color: var(--accent); color: var(--accent); }
.photo-reveal { position: fixed; right: var(--gap); bottom: var(--gap); z-index: 30; background: var(--panel); }
@media (max-width: 520px) { .photo-panel { left: var(--gap); width: auto; } }
