/* CARMA: clean and glanceable, with a little wink.
   Light and dark themes come from the tokens below. <html data-theme="light|dark|system">;
   "system" follows the device. */

:root {
  /* Light */
  --bg: #f5f6f8;
  --bg2: #eceef2;
  --surface: #ffffff;
  --surface2: #f3f4f7;
  --line: #e2e5eb;
  --line2: #d3d8e0;
  --text: #12151b;
  --text2: #3b4250;
  --muted: #6b7382;
  --accent: #e8336f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(232, 51, 111, .1);
  --good: #0f9f6e;
  --warn: #c77700;
  --bad: #d92d3a;
  --info: #2f6fde;
  --epic: #7c4ddb;
  --gold: #c99200;
  --glass: rgba(255, 255, 255, .9);
  --glass-line: rgba(18, 21, 27, .08);
  --shadow: 0 1px 2px rgba(18, 21, 27, .06), 0 6px 20px rgba(18, 21, 27, .07);
  --shadow-lg: 0 10px 40px rgba(18, 21, 27, .16);
  --scrim: rgba(18, 21, 27, .38);
  --plate-bg: #ffd84d;
  --map-bg: #e9edf1;
  color-scheme: light;

  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Plus Jakarta Sans', system-ui, sans-serif;
  --num: 'Space Grotesk', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --bg2: #14171c; --surface: #181b21; --surface2: #20242c; --line: #272b33; --line2: #343944;
    --text: #eef0f4; --text2: #c3c8d2; --muted: #8a92a1;
    --accent: #ff4f8b; --accent-ink: #14060c; --accent-soft: rgba(255, 79, 139, .14);
    --good: #34d399; --warn: #fbbf24; --bad: #f87171; --info: #60a5fa; --epic: #a78bfa; --gold: #facc15;
    --glass: rgba(20, 23, 28, .88); --glass-line: rgba(255, 255, 255, .07);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28); --shadow-lg: 0 14px 44px rgba(0, 0, 0, .5);
    --scrim: rgba(5, 6, 8, .62); --map-bg: #1b1f2a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --bg2: #14171c; --surface: #181b21; --surface2: #20242c; --line: #272b33; --line2: #343944;
  --text: #eef0f4; --text2: #c3c8d2; --muted: #8a92a1;
  --accent: #ff4f8b; --accent-ink: #14060c; --accent-soft: rgba(255, 79, 139, .14);
  --good: #34d399; --warn: #fbbf24; --bad: #f87171; --info: #60a5fa; --epic: #a78bfa; --gold: #facc15;
  --glass: rgba(20, 23, 28, .88); --glass-line: rgba(255, 255, 255, .07);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28); --shadow-lg: 0 14px 44px rgba(0, 0, 0, .5);
  --scrim: rgba(5, 6, 8, .62); --map-bg: #1b1f2a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font: 600 12px var(--font); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 1.8em 0 .8em; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.lead { font-size: 17px; color: var(--text2); }
.big-emoji { font-size: 48px; line-height: 1; margin: 6px 0 16px; }
[hidden] { display: none !important; }

/* The wordmark: lowercase, with a tilted accent square for a dot */
.logo, .drive-top .brand { font: 700 24px var(--display); letter-spacing: -.03em; color: var(--text); margin-bottom: 20px; text-transform: lowercase; display: inline-flex; align-items: baseline; }
.logo::after, .drive-top .brand::after { content: ''; width: .28em; height: .28em; margin-left: .12em; background: var(--accent); border-radius: 2px; transform: rotate(18deg) translateY(-.02em); }

/* ── Buttons & forms ─────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 11px 18px;
  font: 700 15px/1.2 var(--font); cursor: pointer; color: var(--text); background: var(--surface2); text-decoration: none !important;
  transition: transform .12s, background .15s, border-color .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-lg { width: 100%; padding: 15px 20px; font-size: 16px; border-radius: 14px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 6px 18px var(--accent-soft); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: var(--line2); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.btn-danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.stack { display: grid; gap: 10px; margin: 26px 0; }
.form { display: grid; gap: 14px; margin: 10px 0 16px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; color: var(--text2); }
input[type=text], input[type=email], input:not([type]), select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line2); color: var(--text); border-radius: 12px; padding: 12px 14px; font: 16px var(--font); }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.code-input { font: 700 28px var(--num); letter-spacing: .3em; text-transform: uppercase; text-align: center; }
.alert, .notice { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.alert { background: color-mix(in srgb, var(--bad) 9%, transparent); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.notice { background: color-mix(in srgb, var(--good) 9%, transparent); border-color: color-mix(in srgb, var(--good) 30%, transparent); color: var(--good); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--text); }
.toggle small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
/* Switches */
input.switch { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: var(--line2); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
input.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }
input.switch:focus-visible { outline: 3px solid var(--accent-soft); }
.seg { display: inline-flex; flex: 0 0 auto; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-wrap: nowrap; }
.toggle > div:first-child { flex: 1; min-width: 0; }
.seg label { display: block; }
.seg input { display: none; }
.seg span, .seg .btn { display: block; padding: 7px 13px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--text2); }
.seg input:checked + span, .seg .btn-primary { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ── Landing / auth ──────────────────────────── */
.hero { max-width: 480px; margin: 0 auto; padding: calc(48px + var(--safe-t)) 22px 40px; position: relative; text-align: center; }
.hero-glow { position: absolute; inset: 0 0 auto; height: 380px; background: radial-gradient(closest-side, var(--accent-soft), transparent); z-index: -1; }
.hero h1 { font-size: 42px; }
.hero h1::after { content: ''; display: block; width: 46px; height: 4px; margin: 14px auto 0; border-radius: 2px; background: var(--accent); transform: rotate(-3deg); }
.hero-car { margin: 18px auto 0; height: 180px; filter: drop-shadow(0 18px 24px rgba(0,0,0,.18)); }
.hero-car svg { transform: rotate(90deg); }
.feature-list { list-style: none; padding: 0; margin: 28px 0; display: grid; gap: 10px; text-align: left; }
.feature-list li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.feature-list b { display: block; font-family: var(--display); }
.feature-list span { color: var(--muted); font-size: 14px; }
.auth-card { max-width: 440px; margin: 0 auto; padding: calc(48px + var(--safe-t)) 22px 120px; }
.auth-card .btn + .btn { margin-top: 10px; }

/* ── Car-screen pairing ──────────────────────── */
body.pair { min-height: 100vh; display: flex; align-items: center; background: radial-gradient(ellipse at 72% 50%, var(--accent-soft), var(--bg) 58%); }
.pair-wrap { display: grid; grid-template-columns: 1.1fr .9fr; gap: 60px; align-items: center; width: 100%; max-width: 1400px; margin: 0 auto; padding: 40px 60px; }
.pair-left h1 { font-size: 52px; }
.steps { list-style: none; padding: 0; margin: 26px 0; display: grid; gap: 16px; font-size: 21px; }
.steps li { display: flex; gap: 16px; align-items: flex-start; }
.steps span { flex: 0 0 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font: 700 20px/38px var(--num); text-align: center; transform: rotate(-4deg); }
.short-code { font: 700 60px var(--num); letter-spacing: .22em; color: var(--text); margin: 4px 0 18px; }
.pair-right { display: grid; justify-items: center; gap: 22px; }
.qr { background: #fff; border-radius: 24px; padding: 22px; width: min(440px, 38vw); aspect-ratio: 1; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.pair-status { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 12px; }
.pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 900px) {
  .pair-wrap { grid-template-columns: 1fr; padding: 30px 22px; gap: 30px; }
  .pair-left h1 { font-size: 34px; }
  .steps { font-size: 17px; }
  .qr { width: min(320px, 80vw); }
  .short-code { font-size: 42px; }
}

/* ── Drive screen ────────────────────────────── */
body.drive { overflow: hidden; height: 100vh; height: 100dvh; }
body.drive #map { position: fixed; inset: 0; background: var(--map-bg); }
.maplibregl-ctrl-attrib { background: var(--glass) !important; color: var(--muted); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
body.drive .maplibregl-ctrl-bottom-right { right: auto; left: 0; }
.car-marker { will-change: transform; }   /* no position here: MapLibre places markers with position:absolute */
.car-marker .car-rot { display: flex; justify-content: center; will-change: transform; }
.car-marker .car-svg { filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
.car-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--glass); border: 1px solid var(--glass-line);
  color: var(--text); font: 600 11px var(--font); padding: 2px 7px; border-radius: 6px; margin-top: 2px; box-shadow: var(--shadow); }

.drive-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: calc(12px + var(--safe-t)) 16px 12px; z-index: 500; pointer-events: none; }
.drive-top .brand { font-size: 20px; margin: 0; background: var(--glass); padding: 3px 12px 5px; border-radius: 10px; border: 1px solid var(--glass-line); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 999px; padding: 5px 11px;
  font: 600 12px var(--font); color: var(--text2); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.chip.good { color: var(--good); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.sim { color: var(--info); }
.chip.rec i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.rec.on i { background: var(--bad); animation: blink 1.6s infinite; }
.chip.rec.warn i { background: var(--warn); }
@keyframes blink { 50% { opacity: .3; } }

.recenter { position: fixed; z-index: 500; left: 16px; bottom: 24px; width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--glass-line);
  background: var(--glass); color: var(--text); cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow); }

.hud { position: fixed; z-index: 600; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; background: var(--glass); backdrop-filter: blur(14px);
  border-left: 1px solid var(--glass-line); box-shadow: var(--shadow-lg); color: var(--text); }
.speed-block { text-align: center; }
.speed { font: 700 96px/.9 var(--num); letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.speed-unit { font: 600 12px var(--font); color: var(--muted); letter-spacing: .18em; text-transform: uppercase; }
.hud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hud-grid > div { background: var(--surface2); border-radius: 12px; padding: 7px 10px; transition: background .3s; }
.hud-grid b { display: block; font: 700 22px/1.15 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hud-grid span { color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.hud-grid > div.flash { animation: flashbad 1.2s; }
@keyframes flashbad { 0%, 40% { background: color-mix(in srgb, var(--bad) 22%, var(--surface2)); } }
.nearby { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.nearby-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.nearby-head b { background: var(--surface2); color: var(--text); border-radius: 999px; padding: 0 8px; font: 700 12px var(--num); }
.nearby-list { overflow: auto; display: grid; gap: 6px; align-content: start; }
.near-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px; }
.near-row b { display: block; font-size: 13px; font-weight: 700; }
.near-row span { color: var(--muted); font-size: 12px; }
.near-row em { font: 600 12px/1.2 var(--num); font-style: normal; text-align: right; color: var(--text2); }
.near-car { display: flex; justify-content: center; }
.met { font-size: 12px; font-weight: 600; color: var(--good); }
.hud-actions { display: grid; gap: 6px; }
.btn-end { width: 100%; padding: 12px; font-size: 15px; background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); border-radius: 12px; }
.btn-end.armed { background: var(--bad); color: #fff; }
.hud.viewing .btn-end { display: none; }

/* Car screen: slim side panel, the map gets the rest */
body.drive.is-car { --hud-w: clamp(230px, 22vw, 290px); }
body.drive.is-car .hud { width: var(--hud-w); padding: calc(16px + var(--safe-t)) 14px 14px; gap: 10px; }
body.drive.is-car .speed { font-size: clamp(60px, 7vw, 92px); }
body.drive.is-car .drive-top { right: var(--hud-w); }
@media (max-height: 700px) {
  body.drive.is-car .hud { gap: 8px; }
  body.drive.is-car .speed { font-size: 60px; }
  body.drive.is-car .hud-grid b { font-size: 19px; }
}
@media (max-height: 520px) {
  body.drive.is-car .hud { gap: 6px; padding-top: 10px; }
  body.drive.is-car .speed { font-size: 50px; }
  body.drive.is-car .hud-grid > div { padding: 4px 8px; }
  body.drive.is-car .hud-grid b { font-size: 17px; }
  body.drive.is-car .btn-end { padding: 9px; }
  body.drive.is-car .met { display: none; }
}

/* Phone: compact bottom panel, most of the screen is map */
body.drive.is-phone .hud { top: auto; left: 0; width: auto; border-left: 0; border-top: 1px solid var(--glass-line); border-radius: 18px 18px 0 0;
  display: grid; grid-template-columns: auto 1fr; align-items: center; padding: 8px 10px calc(8px + var(--safe-b)); gap: 6px 8px; }
body.drive.is-phone .speed-block { display: flex; flex-direction: column; align-items: center; padding-right: 2px; }
body.drive.is-phone .speed { font-size: 44px; }
body.drive.is-phone .speed-unit { font-size: 9px; letter-spacing: .14em; }
body.drive.is-phone .hud-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
body.drive.is-phone .hud-grid > div { padding: 5px 6px; border-radius: 10px; }
body.drive.is-phone .hud-grid b { font-size: 17px; }
body.drive.is-phone .hud-grid span { font-size: 8.5px; letter-spacing: .05em; }
body.drive.is-phone .nearby { grid-column: 1 / -1; gap: 0; }
body.drive.is-phone .nearby-head, body.drive.is-phone .met { display: none; }
body.drive.is-phone .nearby-list { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
body.drive.is-phone .nearby-list::-webkit-scrollbar { display: none; }
body.drive.is-phone .nearby-list p { margin: 0; font-size: 11px; }
body.drive.is-phone .near-row { flex: 0 0 auto; grid-template-columns: 16px auto auto; gap: 6px; padding: 4px 8px; }
body.drive.is-phone .near-row .near-car svg { width: 14px; height: 28px; }
body.drive.is-phone .near-row b { font-size: 12px; white-space: nowrap; }
body.drive.is-phone .near-row span { display: none; }
body.drive.is-phone .near-row em { font-size: 10px; line-height: 1.15; }
body.drive.is-phone .hud-actions { grid-column: 1 / -1; grid-template-columns: 1fr auto; }
body.drive.is-phone .btn-end { padding: 9px; font-size: 14px; }
body.drive.is-phone .hud-actions .btn-sm { padding: 8px 10px; font-size: 12px; }
body.drive.is-phone .recenter { left: auto; right: 10px; bottom: calc(var(--hud-h, 170px) + 10px); width: 44px; height: 44px; border-radius: 12px; }
body.drive.is-phone .drive-top { padding: calc(8px + var(--safe-t)) 10px 8px; gap: 8px; }
body.drive.is-phone .drive-top .brand { font-size: 17px; padding: 2px 10px 4px; }

/* ── Alerts ──────────────────────────────────────
   Plain cards with a coloured edge. Passing alerts top right; rewards and confirmations top left. */
.toasts, .pickups { position: fixed; z-index: 800; display: grid; gap: 8px; pointer-events: none; top: calc(64px + var(--safe-t)); }
.toasts { right: 16px; width: min(330px, 40vw); }
body.drive.is-car .toasts { right: calc(var(--hud-w) + 16px); }
.pickups { left: 16px; max-width: min(260px, 34vw); }
.toast { --edge: var(--accent); display: flex; gap: 10px; align-items: center; background: var(--glass); color: var(--text); border: 1px solid var(--glass-line);
  border-left: 4px solid var(--edge); border-radius: 12px; padding: 9px 12px; box-shadow: var(--shadow-lg); backdrop-filter: blur(12px);
  overflow: hidden; animation: slidein .22s ease-out; }
.toast.out { opacity: 0; transform: translateX(12px); transition: .35s ease-in; }
.toast.kind-passed { --edge: var(--accent); }
.toast.kind-passed_by { --edge: var(--warn); }
.toast.kind-oncoming, .toast.kind-crossed { --edge: var(--info); }
.toast.kind-convoy, .toast.kind-comm { --edge: var(--good); }
.toast-car { flex: 0 0 auto; display: flex; }
.toast-car svg { width: 18px; height: 36px; }
.toast-body { flex: 1; min-width: 0; }
.toast-kind { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.toast-name { font: 700 16px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-sub, .toast-greet { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-greet { color: var(--muted); font-style: italic; }
.comm-emoji { font-size: 26px; line-height: 1; }
.plate { display: inline-block; background: var(--plate-bg); color: #15130a; font: 700 10px/1.5 var(--num); letter-spacing: .08em; padding: 0 5px; border-radius: 3px; margin-left: 3px; vertical-align: 1px; }
@keyframes slidein { from { opacity: 0; transform: translateX(14px); } }

.pickup { --edge: var(--warn); display: flex; align-items: center; gap: 8px; background: var(--glass); color: var(--text); border: 1px solid var(--glass-line);
  border-left: 4px solid var(--edge); border-radius: 12px; padding: 6px 12px 6px 8px; box-shadow: var(--shadow-lg); backdrop-filter: blur(12px); animation: slideinl .22s ease-out; }
.pickup.r-uncommon { --edge: var(--good); }
.pickup.r-rare { --edge: var(--info); }
.pickup.r-epic { --edge: var(--epic); }
.pickup.r-legendary { --edge: var(--gold); }
.pickup.sent { --edge: var(--good); padding: 8px 12px; }
.pickup.out { opacity: 0; transform: translateX(-12px); transition: .35s ease-in; }
.pk-emoji { font-size: 26px; line-height: 1; }
.pk-pts { font: 700 18px/1 var(--num); }
.pk-name { font-size: 11px; font-weight: 600; color: var(--muted); }
.pickup.sent .pk-name { font-size: 13px; color: var(--text); }
@keyframes slideinl { from { opacity: 0; transform: translateX(-14px); } }
body.drive.is-phone .toasts { right: 8px; width: min(58vw, 240px); top: calc(52px + var(--safe-t)); gap: 6px; }
body.drive.is-phone .pickups { left: 8px; max-width: 40vw; top: calc(52px + var(--safe-t)); gap: 6px; }
body.drive.is-phone .toast { padding: 6px 9px; gap: 8px; border-left-width: 3px; }
body.drive.is-phone .toast-name { font-size: 14px; }
body.drive.is-phone .toast-sub, body.drive.is-phone .toast-greet { font-size: 10.5px; }
body.drive.is-phone .toast-car svg { width: 14px; height: 28px; }
body.drive.is-phone .comm-emoji { font-size: 22px; }
body.drive.is-phone .pickup { padding: 4px 9px 4px 6px; gap: 6px; border-left-width: 3px; }
body.drive.is-phone .pk-emoji { font-size: 22px; }
body.drive.is-phone .pk-pts { font-size: 15px; }
body.drive.is-phone .pk-name { font-size: 10px; }

.viewer-banner { position: fixed; z-index: 700; left: 12px; right: 12px; top: calc(60px + var(--safe-t)); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 14px; padding: 10px 12px; font-size: 14px; box-shadow: var(--shadow-lg); }

/* End-of-drive sheet */
.overlay { position: fixed; inset: 0; z-index: 1000; background: var(--scrim); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; overflow: auto; }
.sheet { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 22px; padding: 28px; width: min(620px, 100%); text-align: center; box-shadow: var(--shadow-lg); }
.summary { text-align: left; }
.sum-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; }
.route-label { color: var(--muted); margin: 0; }
.score-ring { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 5px solid var(--good); }
.score-ring.ok { border-color: var(--warn); }
.score-ring.low { border-color: var(--bad); }
.score-ring b { font: 700 36px/1 var(--num); }
.score-ring span { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.sum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 14px; }
.sum-grid > div { background: var(--surface2); border-radius: 12px; padding: 10px; text-align: center; }
.sum-grid b { display: block; font: 700 26px/1.1 var(--num); letter-spacing: -.02em; }
.sum-grid span { color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.xp-line { font: 700 18px var(--num); color: var(--good); margin-bottom: 6px; }
.badges-new { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 14px 0; }
.badge-new { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 12px; padding: 10px; text-align: center; }
.badge-new span { font-size: 26px; display: block; }
.badge-new small { display: block; color: var(--muted); font-size: 12px; }
.enc-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.enc-list li { display: flex; align-items: center; gap: 12px; background: var(--surface2); border-radius: 10px; padding: 6px 12px; }
.mini-car { display: inline-flex; width: 26px; justify-content: center; }
.sum-actions { display: grid; gap: 8px; margin-top: 20px; }
body.drive.is-phone .sum-grid { grid-template-columns: repeat(2, 1fr); }
body.drive.is-phone .sheet { padding: 20px; }

/* ── Road prizes (the map markers stay playful) ── */
.prize { pointer-events: none; width: max-content; text-align: center; }   /* no position here, or markers stack and drift off their spot */
.prize-emoji { font-size: 34px; line-height: 1; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
body.drive.is-car .prize-emoji { font-size: 44px; }
.prize-pts { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 2px; white-space: nowrap; background: var(--glass); color: var(--text);
  font: 700 11px/1 var(--num); padding: 3px 6px; border-radius: 999px; border: 1px solid var(--glass-line); box-shadow: var(--shadow); }
.prize::before { content: ''; position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; z-index: -1; background: radial-gradient(circle, rgba(255,255,255,.35), transparent 70%); }
.prize.r-uncommon::before { background: radial-gradient(circle, color-mix(in srgb, var(--good) 45%, transparent), transparent 70%); }
.prize.r-rare::before { background: radial-gradient(circle, color-mix(in srgb, var(--info) 55%, transparent), transparent 70%); }
.prize.r-epic::before { background: radial-gradient(circle, color-mix(in srgb, var(--epic) 60%, transparent), transparent 70%); width: 64px; height: 64px; margin: -32px 0 0 -32px; }
.prize.r-legendary::before { background: radial-gradient(circle, color-mix(in srgb, var(--gold) 70%, transparent), transparent 70%); width: 76px; height: 76px; margin: -38px 0 0 -38px; }
.prize.r-legendary .prize-emoji { font-size: 44px; }
body.drive.is-car .prize.r-legendary .prize-emoji { font-size: 56px; }
.prize.r-rare .prize-pts { background: var(--info); color: #fff; border-color: transparent; }
.prize.r-epic .prize-pts { background: var(--epic); color: #fff; border-color: transparent; }
.prize.r-legendary .prize-pts { background: var(--gold); color: #1a1405; border-color: transparent; }
.prize.popping .prize-emoji { animation: pop .6s ease-out forwards; }
.prize.popping .prize-pts, .prize.popping::before { opacity: 0; transition: opacity .2s; }
@keyframes pop { 30% { transform: translateY(-20px) scale(1.4); } 100% { transform: translateY(-60px) scale(.5); opacity: 0; } }

.prize-count { display: inline-flex; align-items: baseline; gap: 4px; margin-top: 6px; background: var(--surface2); color: var(--muted); font: 600 12px var(--font); padding: 3px 10px; border-radius: 999px; }
.prize-count b { color: var(--text); font: 700 15px var(--num); }
.prize-count.bump { animation: bump .45s; }
@keyframes bump { 40% { transform: scale(1.15); } }
body.drive.is-phone .prize-count { font-size: 10px; padding: 1px 7px; margin-top: 3px; }
body.drive.is-phone .prize-count b { font-size: 12px; }

.prize-haul { display: flex; flex-wrap: wrap; gap: 6px; }
.haul { position: relative; display: grid; justify-items: center; min-width: 54px; background: var(--surface2); border-radius: 12px; padding: 6px 8px; font-size: 24px; line-height: 1.1; border: 1px solid var(--line); }
.haul b { font: 700 12px var(--num); color: var(--text2); }
.haul i { position: absolute; top: 2px; right: 5px; font: 700 10px var(--num); font-style: normal; color: var(--muted); }
.haul.r-uncommon { border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.haul.r-rare { border-color: color-mix(in srgb, var(--info) 55%, transparent); }
.haul.r-epic { border-color: color-mix(in srgb, var(--epic) 60%, transparent); }
.haul.r-legendary { border-color: var(--gold); }

/* ── Quick comms ─────────────────────────────── */
.tappable { cursor: pointer; }
.car-marker.tappable { pointer-events: auto; }
.near-row.tappable:active { background: var(--accent-soft); }
.comms { position: fixed; z-index: 950; left: 16px; bottom: 16px; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-lg); animation: slideup .2s ease-out; }
body.drive.is-car .comms { width: min(520px, calc(100vw - var(--hud-w) - 32px)); }
.comms-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.comms-car svg { width: 20px; height: 40px; }
.comms-to { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.comms-name { font: 700 19px var(--display); }
.comms-close { margin-left: auto; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-size: 18px; cursor: pointer; }
.comms-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.comm-btn { display: grid; justify-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2);
  color: var(--text2); font: 600 12px var(--font); cursor: pointer; }
.comm-btn span { font-size: 30px; line-height: 1; }
.comm-btn:active { transform: scale(.96); background: var(--accent-soft); border-color: var(--accent); }
@keyframes slideup { from { opacity: 0; transform: translateY(12px); } }
body.drive.is-phone .comms { left: 8px; right: 8px; width: auto; bottom: 8px; padding: 12px; }
body.drive.is-phone .comm-btn span { font-size: 26px; }
body.drive.is-phone .comm-btn { font-size: 11px; padding: 8px 2px; }

/* Keep-awake status (phone drive screen) */
.awake-chip { pointer-events: auto; cursor: pointer; }
.awake-chip.on { color: var(--good); }
.awake-chip.off, .awake-chip.unsupported { color: var(--warn); animation: blink 1.6s 3; }

/* ── Companion app ───────────────────────────── */
body.app { padding-bottom: calc(86px + var(--safe-b)); }
.page { max-width: 640px; margin: 0 auto; padding: calc(22px + var(--safe-t)) 16px 22px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 28px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; background: var(--surface2); color: var(--text); display: grid; place-items: center; font: 700 16px var(--display); border: 1px solid var(--line); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card-link { display: block; color: inherit; text-decoration: none !important; transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--line2); transform: translateY(-1px); }
.profile-card { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; position: relative; overflow: hidden; }
.profile-card::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 34px; background: var(--accent-soft); transform: rotate(18deg); }
.profile-card .car-hold svg { transform: rotate(90deg); margin: -20px 6px; }
.level { font: 600 11px var(--font); color: var(--accent); letter-spacing: .14em; text-transform: uppercase; }
.xpbar { height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.xpbar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font: 700 26px/1.1 var(--num); letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.stat.hl b { color: var(--good); }
.cta-drive { display: flex; align-items: center; justify-content: center; gap: 10px; }
.live-card { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 6%, var(--surface)); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; animation: blink 1.4s infinite; }
.drive-row { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; align-items: center; padding: 12px; }
.drive-row .thumb { width: 84px; height: 66px; background: var(--surface2); border-radius: 10px; overflow: hidden; }
.drive-row h4 { margin: 0 0 2px; font: 700 15px var(--display); }
.drive-row p { margin: 0; color: var(--muted); font-size: 12.5px; }
.drive-row .score { font: 700 24px var(--num); text-align: right; }
.drive-row .score small { display: block; font: 600 9px var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.score.great { color: var(--good); } .score.ok { color: var(--warn); } .score.low { color: var(--bad); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.badge { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; font-size: 11.5px; font-weight: 600; color: var(--text2); }
.badge span { display: block; font-size: 26px; margin-bottom: 2px; }
.badge.locked { opacity: .4; filter: grayscale(1); }
.pill { display: inline-block; background: var(--surface2); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.empty { text-align: center; padding: 30px 18px; color: var(--muted); }

.detail-map { position: relative; z-index: 0; height: 46vh; min-height: 300px; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; border: 1px solid var(--line); background: var(--map-bg); }
.chart { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.garage-preview { display: grid; place-items: center; height: 220px; background: radial-gradient(circle at 50% 60%, var(--accent-soft), transparent 65%), var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.garage-preview svg { transform: rotate(90deg); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches label { display: block; }
.swatches input { display: none; }
.swatches span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; transition: transform .12s; }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.08); }
.bodies { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.bodies label { display: block; }
.bodies input { display: none; }
.bodies span { display: grid; justify-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 4px; font-size: 11px; font-weight: 700; cursor: pointer; color: var(--text2); }
.bodies input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.rank-row { display: grid; grid-template-columns: 34px 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row .pos { font: 700 18px var(--num); color: var(--muted); text-align: center; }
.rank-row.me { background: var(--accent-soft); border-radius: 10px; }
.rank-row .val { font: 700 18px var(--num); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text2); font-weight: 700; font-size: 13px; white-space: nowrap; text-decoration: none; }
.tabs a.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.device-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }

.tabbar { position: fixed; z-index: 900; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--glass);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); backdrop-filter: blur(14px); }
.tabbar a { display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; text-decoration: none; padding: 4px 0; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg { color: var(--accent); }
.tabbar a.go svg { width: 46px; height: 46px; padding: 11px; margin-top: -20px; border-radius: 15px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px var(--accent-soft); transform: rotate(-6deg); }
.tabbar a.go { color: var(--text); }
@media (min-width: 700px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}

/* ── Messages ────────────────────────────────── */
.icon-btn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none !important; font-size: 18px; }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 700 11px/19px var(--font); text-align: center; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.convo { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none !important; }
.convo:last-child { border-bottom: 0; }
.convo p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo .unread { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.convo.has-unread p { color: var(--text); font-weight: 600; }
.thread { display: flex; flex-direction: column; gap: 6px; padding-bottom: 100px; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; word-wrap: break-word; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.bubble.quick { font-size: 20px; background: transparent; }
.bubble small { display: block; font-size: 10.5px; opacity: .7; margin-top: 2px; }
.day-sep { text-align: center; color: var(--muted); font-size: 11px; margin: 10px 0; text-transform: uppercase; letter-spacing: .1em; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(66px + var(--safe-b)); z-index: 800; background: var(--glass); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 10px 12px; }
.composer form { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.composer input { flex: 1; }
.quick-row { max-width: 640px; margin: 0 auto 8px; display: flex; gap: 6px; overflow-x: auto; }
.quick-row button { flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 18px; cursor: pointer; }
.btn-msg { padding: 5px 10px; font-size: 12px; border-radius: 9px; margin-left: auto; }
