:root {
  --brand: #0a2540;
  --brand-ink: #ffffff;
  --accent: #f5a623;
  --danger: #c8102e;
  --bg: #ffffff;
  --ink: #0a1a2b;
  --muted: #5b6b7c;
  --line: #e1e7ee;
  --cam: #37474f;
  --route: #1565c0;
  --route-alt: #9aa8b8;
  --shadow: 0 4px 18px rgba(0, 0, 0, .16);
  --radius: 14px;
  --primary: #0a2540;     /* main action button */
  --link: #1565c0;        /* text links, focus ring */
  --danger-ink: #c8102e;  /* red text */
  --warn-ink: #8a5a00;    /* amber text (prices) */
  --good-ink: #1b7f3b;    /* green text (scores, climbing) */
  --credit-bg: rgba(255, 255, 255, .75); --credit-ink: #333;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a26; --ink: #eef3f8; --muted: #9fb0c2; --line: #233244; --cam: #b0bec5;
    --route-alt: #5d6e80; --shadow: 0 4px 18px rgba(0, 0, 0, .5); color-scheme: dark;
    --primary: #1565c0; --link: #7cb6f5; --danger-ink: #ff7a7a; --warn-ink: #f2b84b; --good-ink: #5fd38a; --credit-bg: rgba(15, 26, 38, .75); --credit-ink: #c9d4df;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1a26; --ink: #eef3f8; --muted: #9fb0c2; --line: #233244; --cam: #b0bec5;
  --route-alt: #5d6e80; --shadow: 0 4px 18px rgba(0, 0, 0, .5); color-scheme: dark;
  --primary: #1565c0; --link: #7cb6f5; --danger-ink: #ff7a7a; --warn-ink: #f2b84b; --good-ink: #5fd38a; --credit-bg: rgba(15, 26, 38, .75); --credit-ink: #c9d4df;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); -webkit-tap-highlight-color: transparent;
}
#map { position: absolute; inset: 0; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
button:active { filter: brightness(.92); }
@media (hover: hover) { button:hover { filter: brightness(.95); } }

.panel {
  position: absolute; left: 12px; right: 12px; z-index: 5;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 520px; margin: 0 auto;
}
.panel.top { top: calc(12px + env(safe-area-inset-top)); padding: 10px 12px 12px; }
.panel.bottom { bottom: calc(12px + env(safe-area-inset-bottom)); padding: 14px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; margin-bottom: 8px; }
.brand .chip { margin-left: auto; }
.logo { width: 24px; height: 24px; display: block; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 2px 10px; font-size: 13px;
}
select.chip { appearance: none; -webkit-appearance: none; background-color: var(--bg); color: var(--ink);
  padding: 4px 26px 4px 12px; font: inherit; font-size: 13px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 12px center, right 8px center; background-size: 4px 4px; background-repeat: no-repeat; }

.field { position: relative; margin-top: 6px; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 16px; background: var(--bg); color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--route); box-shadow: 0 0 0 3px rgba(21, 101, 192, .2); }
.results { list-style: none; margin: 4px 0 0; padding: 0; max-height: 46vh; overflow: auto; overscroll-behavior: contain; }
.results li { border-bottom: 1px solid var(--line); }
.results .result { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: 10px 6px; }
.results .name, .results .meta { display: block; overflow-wrap: anywhere; }
.results li:last-child { border-bottom: 0; }
.results .name { font-weight: 600; }
.results .meta { color: var(--muted); font-size: 13px; }
.results .empty { color: var(--muted); padding: 10px 6px; }

.route-options { display: grid; gap: 8px; }
.route-opt {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer;
  background: transparent; color: var(--ink); text-align: left; width: 100%;
}
.route-opt.selected { border-color: var(--route); }
.route-opt .dur { font-size: 20px; font-weight: 700; }
.route-opt .sub { color: var(--muted); font-size: 13px; }
.route-opt > .sub { white-space: nowrap; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.btn { border: 0; border-radius: 10px; padding: 12px 14px; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; flex: 1; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.wide { width: 100%; margin-top: 10px; }
.privacy { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.nav.top { background: var(--brand); color: var(--brand-ink); padding: 14px; }
.maneuver { display: flex; gap: 12px; align-items: center; }
#manIcon { width: 48px; height: 48px; flex: none; fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.maneuver > div { min-width: 0; }
.man-dist { font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.man-dist:empty { display: none; }
.man-text { font-size: 17px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.man-then { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .25); font-size: 14px; opacity: .9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav.bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.trip strong { font-size: 30px; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; }
.trip span:empty { display: none; }
.trip { font-variant-numeric: tabular-nums; }
.trip span { color: var(--muted); margin-left: 6px; }
.trip div + div { color: var(--muted); }

.fab {
  position: absolute; z-index: 4; right: 12px; border: 0; border-radius: 999px;
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 6px; padding: 12px;
}
.fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fab.locate { bottom: calc(150px + env(safe-area-inset-bottom)); }
.fab.report { bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--accent); color: #1d1600; padding: 12px 16px; font-weight: 700; }
body.navigating .fab.locate { bottom: calc(110px + env(safe-area-inset-bottom)); }
body.navigating .fab.report { bottom: calc(170px + env(safe-area-inset-bottom)); }
.fab.share { bottom: calc(210px + env(safe-area-inset-bottom)); }
body.navigating .fab.share { display: none; } /* no camera or share menu while driving */
.fab.compass { bottom: calc(270px + env(safe-area-inset-bottom)); }
.fab.compass .n { fill: var(--danger); stroke: var(--danger); }
#compassNeedle { transform-box: view-box; transform-origin: 12px 12px; }
body.navigating .fab.locate { display: none; }
body.navigating .fab.overview { bottom: calc(230px + env(safe-area-inset-bottom)); }
body.navigating .fab.mute { bottom: calc(290px + env(safe-area-inset-bottom)); }
body.navigating .fab.compass { bottom: calc(350px + env(safe-area-inset-bottom)); }
.fab.mute .cross, .fab.mute.muted .wave { display: none; }
.fab.mute.muted .cross { display: inline; }
.fab.mute.muted { color: var(--danger-ink); }
#stopBtn.confirm { outline: 3px solid #fff; outline-offset: -6px; }
.recenter {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 20px; background: var(--route); color: #fff;
  font-weight: 700; box-shadow: var(--shadow);
}
.recenter svg { width: 20px; height: 20px; fill: #fff; }

#reportSheet { overscroll-behavior: contain; }
#reportSheet h2 { margin: 0 0 12px; font-size: 17px; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.report-grid button {
  border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink);
  padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px;
}
.kind-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; }

.report-marker { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; cursor: pointer; }
.k-accident { background: #c8102e; } .k-police { background: #1f4fd1; } .k-jam { background: #e86a00; }
.k-flood { background: #0a8fb3; } .k-hazard { background: #b98900; } .k-closure { background: #333; } .k-camera { background: #37474f; }

/* Speed camera ahead: bottom-left, just above the trip footer (the right-hand buttons sit higher). */
.cam-alert { position: absolute; left: 12px; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 8px 12px 8px 10px;
  background: var(--bg); color: var(--ink); border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.cam-alert[hidden] { display: none; }
.cam-ico { width: 30px; height: 30px; flex: none; fill: var(--cam); }
.cam-ico .lens { fill: var(--bg); }
.cam-alert.redlight .cam-ico { fill: #c8102e; }
.cam-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1 1 auto; }
.cam-text span { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-text strong { font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.limit-sign { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 4px solid #c8102e; background: #fff;
  color: #111; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.limit-sign[hidden] { display: none; }
.cam-speed { flex: none; font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cam-alert.over { background: #c8102e; color: #fff; }
.cam-alert.over .cam-ico { fill: #fff; }
.cam-alert.over .cam-ico .lens { fill: #c8102e; }

.me-marker { width: 22px; height: 22px; border-radius: 50%; background: var(--route); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(21, 101, 192, .25); }
.me-marker.heading { width: 0; height: 0; border-radius: 0; background: none; box-shadow: none;
  border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 30px solid var(--route);
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.dest-marker { width: 18px; height: 18px; border-radius: 50%; background: var(--danger); border: 3px solid #fff; box-shadow: var(--shadow); }

.popup-actions { display: flex; gap: 6px; margin-top: 6px; }
.popup-actions button { flex: 1; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); padding: 8px; min-height: 40px; }
/* Map pop-ups (pin card, hazard reports) follow the light/dark theme */
.maplibregl-popup-content { background: var(--bg); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--bg); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--bg); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--bg); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--bg); }

.toast {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 9;
  bottom: calc(220px + env(safe-area-inset-bottom)); /* JS moves it above the lowest panel */ background: #0a2540; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: env(safe-area-inset-bottom); }

/* ---------- settings, account, perks ---------- */
.icon-btn { position: relative; margin-left: auto; border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.coin-badge { position: absolute; top: -6px; right: -8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #1d1600; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums; }
.sheet { top: calc(12px + env(safe-area-inset-top)); bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 8;
  padding: 14px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.sheet h2 { margin: 0; font-size: 19px; text-wrap: balance; }
.box { border-top: 1px solid var(--line); padding: 12px 0; }
.box:first-of-type { border-top: 0; }
.box h3 { margin: 0 0 8px; font-size: 15px; }
.note { margin: 4px 0 8px; color: var(--muted); font-size: 13px; text-wrap: pretty; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 46px; height: 28px; margin: 0;
  border-radius: 999px; background: var(--line); cursor: pointer; transition: background-color .15s; }
.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,.3); transition: transform .15s; }
.switch:checked { background: var(--route); }
.switch:checked::after { transform: translateX(18px); }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
.account { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account .who { min-width: 0; display: grid; }
.account .who strong, .account .who .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.account .coins { flex: none; background: var(--accent); color: #1d1600; font-weight: 800; border-radius: 999px; padding: 6px 12px;
  font-variant-numeric: tabular-nums; }
.danger-text { color: var(--danger-ink) !important; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pick { border: 2px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink); padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 64px; }
.pick svg { width: 32px; height: 50px; }
.pick.current { border-color: var(--route); }
.pick.locked svg { opacity: .7; }
.pick-name { font-size: 13px; font-weight: 600; }
.pick-state { font-size: 11px; color: var(--muted); }
.pick.locked .pick-state { color: var(--warn-ink); font-weight: 700; }
.field-label { display: grid; gap: 4px; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.field-label input, .field-label select { font: inherit; font-size: 16px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.error { color: var(--danger); font-size: 13px; margin: 0 0 8px; }
.link-btn { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--link); font-weight: 600; padding: 8px; }
.results .add-place { color: var(--link); font-weight: 600; }
.btn:disabled { opacity: .6; }

/* Add a place: pin tip marks the spot (top is set in JS) */
.place-pin { position: absolute; z-index: 4; left: 50%; width: 30px; height: 30px; transform: translate(-50%, -100%) rotate(-45deg);
  transform-origin: center; margin-top: -4px; pointer-events: none;
  background: var(--danger); border: 3px solid #fff; border-radius: 50% 50% 50% 0; box-shadow: var(--shadow); }
#addPlaceSheet h2 { margin: 0 0 4px; font-size: 17px; }

/* Map credit: always visible, tiny; tap for the full list */
.credit { position: absolute; z-index: 3; left: 4px; bottom: calc(1px + env(safe-area-inset-bottom)); border: 0;
  background: var(--credit-bg); color: var(--credit-ink); font-size: 10px; padding: 1px 4px; border-radius: 4px; }

/* Vehicle avatars replace the arrow */
.me-marker.heading.avatar { width: 28px; height: 44px; border: 0; background: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); }
.me-marker.avatar svg { width: 28px; height: 44px; display: block; }
.verify-box { background: rgba(245, 166, 35, .14); border: 1px solid rgba(245, 166, 35, .5); border-radius: 12px; padding: 10px 12px; margin: 4px 0 10px; }
.verify-box p { margin: 0 0 8px; font-size: 13px; }
#authSheet { bottom: auto; max-height: calc(100% - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.field-label input:focus, .field-label select:focus { border-color: var(--link); outline: none; box-shadow: 0 0 0 3px rgba(21, 101, 192, .25); }

/* Search results: fade the last row while more results are below */
.results.more { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent); }

/* Touch targets: at least ~44 px for anything tapped while on the move */
.chip { min-height: 36px; padding: 6px 14px; }
.sheet-head .chip { min-height: 40px; min-width: 64px; }
.icon-btn { width: 42px; height: 42px; }
.link-btn { min-height: 44px; }
a.link-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
select.chip { min-height: 36px; }

/* Nav footer: the arrival time never breaks; End keeps one line in both states */
.trip { min-width: 0; }
.trip strong { white-space: nowrap; }
#stopBtn { flex: none; white-space: nowrap; min-height: 48px; }

/* Saved places and recents (empty search box) */
.results .quick { display: flex; align-items: center; }
.results .quick .result { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.results .qi { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); color: var(--ink); }
.results .qi svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.results .qt { min-width: 0; }
.results .qt .name, .results .qt .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .meta:empty { display: none; }
.results .remove { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 22px; }
.results .quick-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 6px 2px;
  border-bottom: 0; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.link-btn.small { margin: 0; min-height: 32px; padding: 4px 6px; font-size: 13px; text-transform: none; letter-spacing: 0; }

/* Route sheet: where you're going, and a star to save it */
.dest-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 10px; }
.dest-text { min-width: 0; display: grid; }
.dest-text .note { margin: 0; font-size: 12px; }
.dest-text strong { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.save-chip { flex: none; display: flex; align-items: center; gap: 6px; color: var(--ink); }
.save-chip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.save-chip.on { color: var(--warn-ink); border-color: currentColor; }
.save-chip.on svg { fill: currentColor; }
.dest-row .save-chip + .save-chip { margin-left: -4px; }
.icon-chip { padding: 6px 10px; min-width: 40px; min-height: 40px; justify-content: center; }
.icon-chip svg { fill: none; }
.save-chip:first-of-type { margin-left: auto; }

/* Press-and-hold pin */
.drop-pin { width: 30px; height: 38px; display: grid; place-items: start center; }
.drop-pin-shape { width: 26px; height: 26px; margin-top: 2px; transform: rotate(-45deg); background: var(--danger);
  border: 3px solid #fff; border-radius: 50% 50% 50% 0; box-shadow: var(--shadow); }
.pin-card { display: grid; gap: 2px; min-width: 200px; }
.pin-card strong { font-size: 15px; overflow-wrap: anywhere; }
.pin-card .note { margin: 0 0 6px; }
.pin-card .actions { margin-top: 4px; }
.pin-card .btn { padding: 10px 12px; font-size: 14px; }

/* Share my location */
.sheet-title { margin: 0 0 8px; font-size: 17px; }
.share-photo { display: block; width: 100%; height: 38vh; object-fit: contain; background: var(--line); border-radius: 10px; margin-bottom: 8px; }
#sharePlace { margin: 0 0 4px; overflow-wrap: anywhere; }
#shareDestName { margin: -4px 0 10px; overflow-wrap: anywhere; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.share-app { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.share-app:active { background: var(--line); }
.share-app .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.share-app .dot.link { background: var(--route); }
#shareDestSheet .actions .btn { flex: 1; }

/* ---------- Malaysia's food race ---------- */
.race-btn { margin-left: auto; color: var(--warn-ink); }
.race-btn + .icon-btn { margin-left: 0; }
.race-sub { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.race-sub::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #2e9d4f;
  animation: live-pulse 1.6s ease-out infinite; }
@keyframes live-pulse { from { box-shadow: 0 0 0 0 rgba(46, 157, 79, .6); } to { box-shadow: 0 0 0 8px rgba(46, 157, 79, 0); } }
.race-mine { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; font-size: 14px; font-weight: 600; text-wrap: pretty;
  background: rgba(245, 166, 35, .14); border: 1px solid rgba(245, 166, 35, .5); }
.race-mine:empty { display: none; }
.race-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.race-row { position: relative; border: 1px solid var(--line); border-radius: 12px; background-color: var(--bg); }
.race-row.r1 { border-color: #d4a017; background-image: linear-gradient(90deg, rgba(212, 160, 23, .16), transparent 75%); }
.race-row.mine { outline: 2px solid var(--route); outline-offset: -1px; }
.race-row.flash { animation: row-flash 1.4s ease-out; }
@keyframes row-flash { from { background-color: rgba(245, 166, 35, .4); } }
.race-line { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.race-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 58px;
  border: 0; background: none; color: inherit; text-align: left; padding: 10px 4px 10px 10px; }
.rank { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); color: var(--ink); font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.r1 .rank { background: #d4a017; color: #1d1600; width: 34px; height: 34px; font-size: 16px; }
.r2 .rank { background: #a7b1bc; color: #14202b; }
.r3 .rank { background: #c27c3a; color: #1d1000; }
.race-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.race-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-weight: 700; }
.race-name .nm { overflow-wrap: anywhere; }
.tag { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag.up { color: var(--good-ink); background: rgba(46, 157, 79, .14); }
.tag.down { color: var(--danger-ink); background: rgba(200, 16, 46, .1); }
.tag.new { color: var(--link); background: rgba(21, 101, 192, .12); }
.tag.hot { color: var(--warn-ink); background: rgba(245, 166, 35, .18); }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; transform-origin: left;
  background: linear-gradient(90deg, #f5a623, #ff6b35); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.r1 .bar i { background: linear-gradient(90deg, #d4a017, #f5c842); }
.votes { flex: none; display: grid; justify-items: end; min-width: 38px; line-height: 1.1; }
.votes b { font-size: 18px; font-variant-numeric: tabular-nums; }
.votes small { font-size: 11px; color: var(--muted); }
.race-vote { flex: none; min-width: 58px; min-height: 40px; padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--route); background: transparent; color: var(--link); font-weight: 700; }
.race-vote[aria-pressed="true"] { background: var(--route); border-color: var(--route); color: #fff; }
.race-stalls { padding: 0 12px 12px; border-top: 1px dashed var(--line); }
.stall-head { margin: 10px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stall-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stall { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.srank { font-weight: 800; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.s1 .srank { color: var(--warn-ink); }
.sbody { min-width: 0; display: grid; }
.sname { font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.smeta { font-size: 12px; color: var(--muted); }
.smeta:empty { display: none; }
.score { min-width: 34px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.score.pos { color: var(--good-ink); } .score.neg { color: var(--danger-ink); } .score.zero { color: var(--muted); }
.sgo { padding: 8px 12px; min-height: 40px; }
.stall-rate { grid-column: 2 / -1; display: flex; gap: 6px; }
.stall-rate .btn { flex: 1; padding: 8px; min-height: 40px; }
.race-stalls .note { margin: 8px 0 0; }
.race-stalls .btn.wide { margin-top: 8px; }
.race-more { margin-top: 12px; }
.race-find { list-style: none; margin: 4px 0 0; padding: 0; }
.race-find li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.race-find li:last-child { border-bottom: 0; }
.race-find .fbody { flex: 1; min-width: 0; display: grid; }
.race-find .fname { font-weight: 600; overflow-wrap: anywhere; }
.race-find .fmeta { font-size: 12px; color: var(--muted); }
.race-find .create { flex: 1; text-align: left; margin: 0; padding: 8px 0; overflow-wrap: anywhere; }
.burst { position: fixed; z-index: 20; pointer-events: none; font-size: 20px; line-height: 1; }
.rate-at { margin: 0 0 2px; }
.food-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: rgba(245, 166, 35, .18);
  color: var(--warn-ink); font-weight: 700; }
.rate-card strong { display: block; font-size: 18px; overflow-wrap: anywhere; }
.rate-card #rateScore { margin: 2px 0 0; }
.rate-btn { flex: 1; min-height: 48px; font-size: 16px; }
.rate-card .link-btn { margin-top: 4px; }
.coin-badge.pop { animation: coin-pop .6s cubic-bezier(.2, .8, .2, 1.4); }
@keyframes coin-pop { 40% { transform: scale(1.6); } }
/* Small phones: give the food name the room */
@media (max-width: 360px) {
  .sheet.race { padding: 12px 10px; }
  .race-main { gap: 8px; padding-left: 8px; }
  .rank { width: 26px; height: 26px; font-size: 13px; }
  .r1 .rank { width: 30px; height: 30px; font-size: 15px; }
  .votes { min-width: 34px; }
  .votes b { font-size: 16px; }
  .race-line { padding-right: 6px; }
  .race-vote { min-width: 50px; padding: 6px 8px; }
  .race-stalls { padding: 0 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .race-sub::before, .race-row.flash, .coin-badge.pop { animation: none; }
  .bar i { transition: none; }
}

/* AI: voice commands, signboard scan, smart search */
.fab.mic { left: 12px; right: auto; justify-content: center; bottom: calc(90px + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
body.navigating .fab.mic { bottom: calc(110px + env(safe-area-inset-bottom)); }
.fab.mic.listening { background: var(--danger); color: #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 30%, transparent); }
@media (prefers-reduced-motion: no-preference) { .fab.mic.listening { animation: mic-pulse 1.2s ease-in-out infinite; } }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--danger) 10%, transparent); } }
.mic-caption { position: absolute; left: 12px; right: 12px; bottom: calc(156px + env(safe-area-inset-bottom)); z-index: 4; pointer-events: none;
  background: var(--bg); color: var(--ink); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow);
  font-size: 15px; overflow-wrap: anywhere; }
body.navigating .mic-caption { bottom: calc(176px + env(safe-area-inset-bottom)); }
.scan-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 4px; }
.scan-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.result.ask-ai .name { color: var(--link, var(--primary)); }
.results li.ai-note { padding: 8px 14px; font-size: 13px; color: var(--muted); }

/* Lane guidance and exit number in the driving banner */
.lanes { display: flex; justify-content: center; gap: 4px; margin: 10px 0 2px; padding: 6px 8px; border-radius: 10px;
  background: rgba(255, 255, 255, .08); overflow: hidden; }
.lanes .lane { flex: 0 1 36px; min-width: 22px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-right: 1px dashed rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .35); }
.lanes .lane:last-child { border-right: 0; }
.lanes .lane.ok { color: #fff; }
.lanes svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.exit-badge { align-self: flex-start; margin-left: auto; padding: 3px 8px; border-radius: 6px; background: #1b8a3a; color: #fff;
  font-weight: 700; font-size: 14px; white-space: nowrap; }
