/* src/ui/style.css — all interface styling. Colours follow the controls diagram:
   driving = blue, transmission = green, lights/signals = orange, other = purple. */
:root { --bg: #0f1115; --panel: rgba(20, 23, 30, 0.92); --line: #2a2f3a; --text: #e8eaf0; --muted: #98a0b3; --accent: #3fb6ff; --minor: #e8a020; --serious: #e04a3a; --dangerous: #ff2b2b; --ok: #3ccf6e;
  --driving: #2196d6; --transmission: #23a866; --signals: #e9a318; --other: #8e55e0; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; width: 100% !important; height: 100% !important; }
button { background: #232834; color: var(--text); border: 1px solid #3a4150; border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #08131c; border-color: transparent; font-weight: 600; }
button:disabled { opacity: 0.45; cursor: default; }
input, select { background: #1b1f27; color: var(--text); border: 1px solid #3a4150; border-radius: 6px; padding: 7px 10px; font: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; }
h1 { font-size: 24px; margin: 0 0 8px; } h2 { font-size: 20px; margin: 0 0 10px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 16px 0 6px; }

/* loading */
#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); z-index: 50; gap: 8px; }
.spinner { width: 28px; height: 28px; border: 3px solid #2a2f3a; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading pre { max-width: 80vw; white-space: pre-wrap; color: #ff8a8a; font-size: 12px; }

/* start screen */
#start { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: none; }
#start.show { display: block; }
.start-layout { display: grid; grid-template-columns: 360px 1fr; grid-template-rows: 100%; height: 100%; }
.start-side { padding: 18px; overflow: auto; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.start-place { color: var(--muted); margin: -6px 0 2px; font-size: 14px; }
.start-map { position: relative; min-height: 0; overflow: hidden; }
.start-map canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#street-search { width: 100%; }
.street-results { display: flex; flex-direction: column; }
.street-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.street-item:hover { background: #1f2430; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { font-size: 12.5px; padding: 6px 10px; }
.start-chosen { background: #171b23; border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 48px; }
.start-actions { display: flex; gap: 8px; }
.start-actions button { flex: 1; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
#hud.show { display: block; }
.hud-top-left { position: absolute; left: 16px; top: 14px; }
.hud-street { background: var(--panel); border-radius: 10px; padding: 8px 14px; font-size: 18px; font-weight: 600; display: flex; flex-direction: column; }
.hud-street #hud-street-uk { font-size: 12px; font-weight: 400; color: var(--muted); }
/* max-width: the junction line can carry a cue after it (tram rails that ask for a stop short of the line), and a
   single line of that runs a third of the way across the screen; it wraps under the street name instead. */
.hud-next { margin-top: 6px; background: var(--panel); border-radius: 8px; padding: 6px 12px; font-size: 13px; color: #d5dbe8; min-height: 16px; max-width: 42ch; }
.hud-next:empty { display: none; }
/* in the flow under the street and the junction line, not at a fixed 96px: the junction line wraps to two when it
   carries the tram-rails cue, and a fixed disc was overlapped by it */
.hud-limit { margin-top: 10px; width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 7px solid #d21e2c; display: flex; align-items: center; justify-content: center; color: #111; font-weight: 800; font-size: 22px; }
.hud-limit.over { box-shadow: 0 0 0 4px rgba(255, 60, 60, 0.6); animation: pulse 0.8s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 0 8px rgba(255, 60, 60, 0.15); } }
.hud-bottom-left { position: absolute; left: 16px; bottom: 16px; background: var(--panel); border-radius: 12px; padding: 12px 16px; min-width: 260px; }
.hud-speed { font-size: 46px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-speed small { font-size: 14px; margin-left: 6px; color: var(--muted); font-weight: 400; }
.hud-rpm { height: 6px; background: #2a2f3a; border-radius: 3px; margin: 8px 0; overflow: hidden; }
.hud-rpm div { height: 100%; width: 0; background: linear-gradient(90deg, #3ccf6e, #ffd24b 70%, #ff3b3b); }
.hud-selector { display: flex; gap: 6px; margin: 6px 0; }
.hud-selector span { width: 30px; height: 30px; border-radius: 6px; background: #1b1f27; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.hud-selector span.on { background: var(--transmission); color: #fff; }
.hud-lamps { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.lamp { font-size: 12px; font-weight: 700; color: #3b4150; padding: 2px 4px; border-radius: 4px; }
.lamp.on { color: #6fdc8c; } .lamp.dipped { color: #7ee36a; } .lamp.warn { color: #ff4d4d; } .lamp.blue { color: #59a8ff; }
.lamp.ind { font-size: 16px; } .lamp.ind.on { color: #6fdc8c; text-shadow: 0 0 8px #6fdc8c; }
.hud-bottom-right { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#hud-minimap { width: 220px; height: 220px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.25); background: #ddd; }
.hud-session { background: var(--panel); border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
.hud-keys { position: absolute; right: 16px; top: 14px; color: var(--muted); font-size: 12px; background: var(--panel); padding: 5px 10px; border-radius: 8px; }
.hud-toasts { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); width: min(560px, 60vw); display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel); border-left: 6px solid var(--minor); border-radius: 10px; padding: 10px 14px; animation: drop 0.25s ease-out; }
.toast.serious { border-left-color: var(--serious); } .toast.dangerous { border-left-color: var(--dangerous); background: rgba(70, 20, 20, 0.92); }
.toast-title { font-weight: 700; font-size: 15px; } .toast-what { color: #d9dde8; font-size: 13px; } .toast-advice { color: #9fd0ff; font-size: 13px; margin-top: 2px; }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } }
.hud-hint { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(30, 60, 90, 0.92); border-radius: 10px; padding: 8px 14px; font-size: 13.5px; max-width: 60vw; opacity: 0; transition: opacity .3s; }
.hud-hint.show { opacity: 1; }
/* The steering strip. A wheel that holds its angle needs its angle shown: the bright mark is the driver's hand,
   the dim bar behind it is how much steering that is actually buying at this speed, and the tick is dead centre. */
.hud-steer { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: 232px; text-align: center; }
.steer-track { position: relative; height: 10px; border-radius: 5px; background: rgba(20, 23, 30, 0.72); border: 1px solid var(--line); overflow: hidden; }
.steer-centre { position: absolute; left: 50%; top: 1px; bottom: 1px; width: 2px; margin-left: -1px; background: rgba(232, 234, 240, 0.5); }
.steer-lock { position: absolute; top: 2px; bottom: 2px; background: rgba(33, 150, 214, 0.5); border-radius: 2px; }
.steer-hand { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: var(--driving); border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.steer-hand.centred { background: var(--ok); }
.steer-note { margin-top: 5px; font-size: 12px; color: var(--muted); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.steer-note:empty { display: none; }
/* the offer that appears when the car is wedged (vehicle/recovery.js); clickable, so the key is never the only way */
.hud-stuck { position: absolute; left: 50%; bottom: 68px; transform: translateX(-50%); display: none; pointer-events: auto;
  background: var(--minor); color: #21160a; border: none; border-radius: 10px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); animation: pulse-stuck 1.4s infinite alternate; }
.hud-stuck.show { display: block; }
.hud-stuck:hover { background: #ffc25a; border: none; }
@keyframes pulse-stuck { to { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 0 0 7px rgba(232, 160, 32, 0.18); } }
#replay-banner { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); background: #4a2a80; padding: 8px 16px; border-radius: 10px; z-index: 12; display: none; }
#replay-banner.show { display: block; }

/* overlays */
#overlay { position: fixed; inset: 0; background: rgba(5, 8, 14, 0.55); z-index: 30; display: none; align-items: center; justify-content: center; padding: 20px; }
#overlay.show { display: flex; }
.panel { background: #141821; border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.menu-panel { width: 420px; }
.menu-buttons { display: flex; flex-direction: column; gap: 8px; }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.settings label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.report-panel { width: min(1000px, 94vw); }
.report-summary { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: 10px; margin: 8px 0 12px; background: #1b2a1f; }
.report-summary.fail { background: #2c1a1a; }
.report-summary .big { font-size: 28px; font-weight: 800; color: var(--ok); }
.report-summary.fail .big { color: var(--serious); }
table.faults { width: 100%; border-collapse: collapse; font-size: 13px; }
table.faults th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.faults td { padding: 8px; border-bottom: 1px solid #1f242e; vertical-align: top; }
table.faults tr.minor .sev { color: var(--minor); } table.faults tr.serious .sev { color: var(--serious); } table.faults tr.dangerous .sev { color: var(--dangerous); }
.report-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* controls diagram */
.controls-panel { width: min(900px, 96vw); }
.keyboard { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.kb-row { display: flex; gap: 5px; }
.key { width: 56px; height: 50px; background: #1c2029; border-radius: 6px; padding: 4px 5px; position: relative; font-size: 10px; color: #6b7387; display: flex; flex-direction: column; justify-content: space-between; }
.key.wide { width: 84px; } .key.space { width: 340px; }
.key-label { font-weight: 700; font-size: 11px; } .key-name { color: #fff; font-size: 10.5px; line-height: 1.15; }
.key.driving { background: var(--driving); color: #e8f4ff; } .key.transmission { background: var(--transmission); color: #eafff2; } .key.signals { background: var(--signals); color: #1a1200; } .key.signals .key-name { color: #1a1200; } .key.other { background: var(--other); color: #f3ecff; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.driving { background: var(--driving); } .sw.transmission { background: var(--transmission); } .sw.signals { background: var(--signals); } .sw.other { background: var(--other); }

/* ---- simple mode: the four-key drive (controls.js SIMPLE_BINDINGS) */
#hud.simple .hud-rpm, #hud.simple #lamp-engine, #hud.simple #lamp-hb, #hud.simple #lamp-lights,
#hud.simple #lamp-high, #hud.simple #lamp-hazard, #hud.simple #lamp-wipers { display: none; }
.mode-pick { display: flex; gap: 8px; }
.mode-pick button { flex: 1; text-align: left; padding: 10px 12px; background: #171b23; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.mode-pick button:hover { background: #1f2430; }
.mode-pick button.on { border-color: var(--accent); background: #1b2536; }
.mode-pick b { font-size: 15px; }
.mode-pick span { font-size: 11.5px; color: var(--muted); line-height: 1.35; font-weight: 400; }
.simple-keys { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.simple-keys div { display: flex; align-items: baseline; gap: 10px; }
.simple-keys b { background: var(--driving); color: #e8f4ff; border-radius: 6px; padding: 4px 9px; font-size: 14px; }
.simple-keys span { color: #d9dde8; font-size: 13.5px; }
.settings label.wide { grid-column: 1 / -1; }

/* the start screen's city picker and the loaded-area line (src/ui/overlays.js renderStartScreen) */
.start-place select { font: inherit; font-weight: 600; color: var(--fg); background: #171b23; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.start-area { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #171b23; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.start-area button { flex: 0 0 auto; }
#flip-dir[hidden] { display: none; }
