:root {
  --bg: #0a0a0d;
  --card: #141418;
  --card-2: #1d1d23;
  --ink: #f2f0ea;
  --muted: #9d9a92;
  --line: #2c2c34;
  --accent: #e9e6df;
  --accent-ink: #0a0a0d;
  --pink: #ffffff;
  --warn: #ff6b4a;
  --ok: #4ee08a;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #26262e 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
.top { max-width: 820px; margin: 0 auto; padding: 16px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: block; line-height: 0; }
.brand img { height: 40px; width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chip-btn {
  border: 1px solid rgba(255,255,255,.16); background: rgba(16,16,20,.85); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.chip-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
main { max-width: 820px; margin: 0 auto; padding: 0 16px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 20px; border: 1px solid var(--line); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; overflow-wrap: anywhere; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 2px 0 0; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

/* ---------- Map ---------- */
.map-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
/* Map styles: pick with mapStyle in config.js (or ?map=… to preview). "neon" is the default. */
.map-wrap {
  --sea: #0a0c2a; --land: #241f63; --edge: #3b37a0; --edge-o: .55;
  --b1: #6f63e0; --b2: #7d72ea; --b3: #6257cf; --b4: #8a80f0;
  --park: #2f3488; --tree: #3c46a8; --ave: #9d94ff; --ave-o: .35; --bridge: #4a43b3; --rail: #a69cff;
  --r-done: #ffffff; --r-todo: #e9e6df; --r-glow: #ffffff; --r-glow-o: .16;
}
.map-wrap[data-map="noir"] {
  --sea: #050506; --land: #111114; --edge: #4a4a52; --edge-o: .7;
  --b1: #2a2a31; --b2: #313139; --b3: #24242a; --b4: #3a3a43;
  --park: #16181a; --tree: #22262a; --ave: #b9b5ac; --ave-o: .22; --bridge: #2c2c33; --rail: #c9c5bc;
  --r-done: #f2f0ea; --r-todo: #9d9a92; --r-glow: #ffffff; --r-glow-o: .14;
}
.map-wrap[data-map="night"] {
  --sea: #030c18; --land: #0a1424; --edge: #1f4a7a; --edge-o: .7;
  --b1: #18263d; --b2: #1d2e49; --b3: #142135; --b4: #f0a53a;
  --park: #0b2620; --tree: #12392f; --ave: #ffc857; --ave-o: .22; --bridge: #1b2c47; --rail: #ffc857;
  --r-done: #ffc857; --r-todo: #ffdf9a; --r-glow: #ffb400; --r-glow-o: .22;
}
.map-wrap[data-map="night"] .b4 { opacity: .55; }
.map-wrap[data-map="day"] {
  --sea: #8fd3ff; --land: #efe9dc; --edge: #ffffff; --edge-o: .9;
  --b1: #ffffff; --b2: #f8f5ef; --b3: #e9e3d6; --b4: #dfd8c9;
  --park: #b5e2a2; --tree: #8ccf77; --ave: #ffcf5c; --ave-o: 1; --bridge: #ffcf5c; --rail: #e3ad35;
  --r-done: #1a73e8; --r-todo: #1a73e8; --r-glow: #1a73e8; --r-glow-o: .18;
}
.map-wrap[data-map="blueprint"] {
  --sea: #0a2c52; --land: #0f3f73; --edge: #cfe8ff; --edge-o: .5;
  --b1: #16599a; --b2: #1a63a8; --b3: #134f8a; --b4: #1f6db8;
  --park: #0f4a6e; --tree: #17618c; --ave: #e6f3ff; --ave-o: .45; --bridge: #1a5c99; --rail: #e6f3ff;
  --r-done: #ffffff; --r-todo: #bfe0ff; --r-glow: #ffffff; --r-glow-o: .18;
}
.map-wrap { position: relative; height: min(68vh, 560px); min-height: 380px; background: var(--sea); }
#map { display: block; width: 100%; height: 100%; cursor: grab; user-select: none; -webkit-user-select: none; }
.map-wrap.dragging #map { cursor: grabbing; }
#city rect { shape-rendering: crispEdges; }
.zoom-btns { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
.zoom-btn { width: 38px; height: 38px; padding: 0; font-size: 1.25rem; line-height: 1; display: grid; place-items: center; }
.map-hint {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  background: rgba(10,10,13,.55); opacity: 0; transition: opacity .25s;
}
.map-hint span { background: rgba(14,14,18,.92); border: 1px solid rgba(255,255,255,.16); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.map-wrap.show-hint .map-hint { opacity: 1; }
#sea { fill: var(--sea); }
.land { fill: var(--land); }
.water { fill: var(--sea); }
.water-edge { fill: none; stroke: var(--edge); stroke-width: 3; opacity: var(--edge-o); }
.b1 { fill: var(--b1); } .b2 { fill: var(--b2); } .b3 { fill: var(--b3); } .b4 { fill: var(--b4); }
.park { fill: var(--park); }
.tree { fill: var(--tree); }
.avenue { stroke: var(--ave); stroke-width: 5; opacity: var(--ave-o); fill: none; }
.bridge { fill: var(--bridge); }
.bridge-rail { stroke: var(--rail); stroke-width: 2; opacity: .7; }

.route-glow { fill: none; stroke: var(--r-glow); stroke-width: 16; opacity: var(--r-glow-o); stroke-linecap: round; stroke-linejoin: round; }
.route-todo { fill: none; stroke: var(--r-todo); stroke-width: 5; stroke-dasharray: 2 12; stroke-linecap: round; stroke-linejoin: round; animation: march 1s linear infinite; }
.route-done { fill: none; stroke: var(--r-done); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; filter: url(#glow); }
@keyframes march { to { stroke-dashoffset: -14; } }

.pin .pin-body { filter: url(#pinShadow); }
.pin-label rect { fill: rgba(10,10,13,.88); stroke: rgba(255,255,255,.12); }
.pin-label text { fill: #fff; font: 700 11px system-ui, sans-serif; }
.pin.done .pin-body path { opacity: .85; }
.pin .ring { fill: none; stroke: currentColor; stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; }
.pin.target .ring { animation: ring 1.8s ease-out infinite; }
@keyframes ring { 0% { opacity: .8; transform: scale(.5); } 100% { opacity: 0; transform: scale(1.8); } }
.poi { opacity: .9; }

/* Moped marker */
.moped-pulse { fill: #ffffff; opacity: .3; transform-box: fill-box; transform-origin: center; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .45; } 100% { transform: scale(1.6); opacity: 0; } }
.rider-shadow { fill: #000; opacity: .45; }
.mp-bob { animation: bob .3s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-3px); } }
.map-wrap:not([data-state="riding"]) .mp-bob { animation: none; }
.map-wrap[data-state="problem"] .moped-pulse { fill: var(--warn); }
.map-wrap[data-state="done"] .moped-pulse { fill: var(--ok); animation-duration: 3s; }
.mp-tag rect { fill: var(--accent); }
.mp-tag text { fill: var(--accent-ink); font: 800 11px system-ui, sans-serif; }
.map-wrap[data-state="problem"] .mp-tag rect { fill: var(--warn); }
.map-wrap[data-state="done"] .mp-tag rect { fill: var(--ok); }

/* HUD */
.hud { position: absolute; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { top: 12px; }
.hud-bottom { bottom: 12px; }
.hud-btns { display: flex; gap: 6px; }
.live-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: rgba(16,16,20,.85); border: 1px solid rgba(255,255,255,.16); font-size: .75rem; letter-spacing: .08em; color: var(--ok);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.live-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: live 1.6s infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(78,224,138,.6); } 100% { box-shadow: 0 0 0 10px rgba(78,224,138,0); } }
.live-chip.stale { color: var(--muted); } .live-chip.stale .dot { background: var(--muted); animation: none; }
.hud-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: rgba(14,14,18,.9); border: 1px solid rgba(255,255,255,.16); border-radius: 16px; padding: 10px 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.hud-icon { font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--card-2); flex: none; }
.hud-icon img { width: 40px; height: auto; }
.hud-head { font-weight: 800; line-height: 1.25; }
.hud-sub { font-size: .82rem; color: var(--muted); }

/* Step bar */
.steps { list-style: none; margin: 0; padding: 14px 12px 16px; display: grid; grid-template-columns: repeat(4, 1fr); }
.steps li { position: relative; text-align: center; font-size: .74rem; color: var(--muted); font-weight: 700; padding-top: 24px; line-height: 1.25; }
.steps li::before { content: ""; position: absolute; top: 8px; left: 0; right: 0; height: 4px; background: var(--line); }
.steps li:first-child::before { left: 50%; }
.steps li:last-child::before { right: 50%; }
.steps li::after {
  content: ""; position: absolute; top: 2px; left: 50%; width: 16px; height: 16px; margin-left: -8px;
  border-radius: 50%; background: var(--card); border: 3px solid var(--line); box-sizing: border-box;
}
.steps li.done::before { background: var(--accent); }
.steps li.done::after { background: var(--accent); border-color: var(--accent); }
.steps li.current { color: var(--ink); }
.steps li.current::after { background: var(--pink); border-color: var(--pink); box-shadow: 0 0 0 5px rgba(255,255,255,.22); }
.steps.problem li.current::after { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 0 5px rgba(255,107,74,.25); }
.steps li.leg::before { background: linear-gradient(90deg, var(--accent) 50%, var(--line) 50%); }
.steps li:first-child.leg::before { background: var(--line); }

/* Status */
.status-desc { margin: 8px 0 16px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0; }
.facts div { background: var(--card-2); border-radius: 12px; padding: 10px 14px; }
.facts dt { font-size: .75rem; color: var(--muted); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 700; }
.facts .fact-upd { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.facts .fact-upd-text { background: none; padding: 0; min-width: 0; }
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 8px 14px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: .85rem; font-weight: 800;
}
.refresh-btn:disabled { cursor: default; opacity: .85; }
.refresh-btn.spinning svg { animation: spin .8s linear infinite; }
.refresh-btn.ok { background: var(--ok); }
.refresh-btn.err { background: var(--warn); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.dest { margin-top: 16px; padding: 14px; border-radius: 12px; background: var(--card-2); border-left: 4px solid var(--accent); }
.dest-name { font-weight: 800; font-size: 1.05rem; margin-top: 2px; }
.btn-link { display: inline-block; margin-top: 8px; color: var(--accent); font-weight: 700; text-decoration: none; }

/* History */
.history { list-style: none; margin: 0; padding: 0; }
.history li { position: relative; padding: 0 0 18px 28px; }
.history li::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: -8px; width: 2px; background: var(--line); }
.history li:last-child::before { display: none; }
.history li::after {
  content: ""; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--line); box-sizing: border-box;
}
.history li:first-child::after { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 10px rgba(255,255,255,.5); }
.history .h-title { font-weight: 700; }
.history .h-time { font-size: .8rem; color: var(--muted); }
.history .h-desc { font-size: .9rem; color: var(--muted); margin-top: 2px; }

/* Flavour carousel */
.shop-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.shop-head h2 { margin: 2px 0 0; }
.car-arrows { display: flex; gap: 6px; }
.car-arrow {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
  font-size: 1.4rem; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0 0 3px;
}
.car-arrow:disabled { opacity: .35; cursor: default; }
.carousel {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  margin: 0 -20px; padding: 4px 20px 8px; scrollbar-width: none; outline: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel.single { justify-content: center; }
.flavour {
  flex: 0 0 min(64%, 230px); scroll-snap-align: center; cursor: pointer; text-align: left;
  background: var(--card-2); border: 2px solid transparent; border-radius: 16px; padding: 12px; color: var(--ink); font: inherit;
  transition: border-color .2s, transform .2s, opacity .2s; opacity: .7;
}
.flavour.active { border-color: var(--accent); opacity: 1; transform: translateY(-2px); }
.flavour-img {
  aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #34343d 0%, #16161b 70%);
}
.flavour-img img { width: 86%; height: 86%; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(0,0,0,.6)); }
.flavour-img { container-type: inline-size; }
.tin {
  width: 84%; aspect-ratio: 1; border-radius: 50%; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqw; text-align: center;
  padding: 12%; color: #fff;
  background:
    radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--tint) 75%, transparent) 0%, transparent 60%),
    radial-gradient(circle at 32% 26%, #3b3b45 0%, #111116 62%);
  border: 4px solid var(--rim);
  box-shadow: 0 12px 22px rgba(0,0,0,.6), inset 0 0 0 5px #0c0c10, inset 0 0 0 7px color-mix(in srgb, var(--rim) 40%, transparent);
}
.tin-brand { font-size: 6.5cqw; font-weight: 900; letter-spacing: .14em; color: var(--rim); }
.tin-emoji { font-size: 15cqw; line-height: 1.1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.tin-flavour { font-size: 8.5cqw; font-weight: 900; line-height: 1.05; text-transform: uppercase; letter-spacing: .04em; }
.tin-mg {
  font-size: 5.5cqw; font-weight: 800; padding: .3em .8em; border-radius: 999px;
  background: var(--tint); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.shop-head { flex-wrap: wrap; }
.shop-count { align-self: center; margin-left: auto; margin-right: 4px; }
.shop-filters { display: flex; gap: 6px; overflow-x: auto; margin: 0 -20px 12px; padding: 0 20px; scrollbar-width: none; }
.shop-filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--muted); font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.filter-chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.flavour-name { font-weight: 800; margin-top: 10px; }
.flavour-note { font-size: .82rem; color: var(--muted); }
.car-dots { display: flex; justify-content: center; gap: 6px; margin: 8px 0 14px; }
.car-dots button { width: 8px; height: 8px; border-radius: 4px; border: 0; padding: 0; background: var(--line); cursor: pointer; transition: width .2s, background .2s; }
.car-dots button.on { width: 22px; background: var(--accent); }
.car-dots:empty { display: none; }
.ig-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 14px 18px; border-radius: 14px; text-decoration: none; font-weight: 800; color: #fff;
  background: linear-gradient(90deg, #f58529, #dd2a7b 45%, #8134af 75%, #515bd4);
}
.ig-note { text-align: center; margin: 8px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: .9rem;
  transition: opacity .25s, transform .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: center; font-size: .8rem; margin: 0; }
.err-rider { width: 160px; height: auto; margin: 0 auto 4px; display: block; }
.maker-hero { display: flex; align-items: center; justify-content: center; gap: 8px; margin: -4px 0 12px; }
.maker-logo { width: 120px; height: 120px; }
.maker-rider { width: 190px; height: auto; filter: drop-shadow(0 0 1.5px rgba(242,240,234,.9)) drop-shadow(0 8px 14px rgba(0,0,0,.6)); }

/* Link maker */
.mk-form, .mk-out { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.mk-form input, .mk-out input {
  flex: 1 1 220px; min-width: 0; padding: 12px 14px; font: inherit; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--ink);
}
.mk-form button, .mk-out button {
  padding: 12px 18px; font: inherit; font-weight: 800; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.mk-out .btn-link { align-self: center; margin: 0 4px; }
.demo-bar button { margin: 4px; }

@media (max-width: 520px) {
  .steps li { font-size: .66rem; }
  h1 { font-size: 1.3rem; }
  .hud-btns .chip-btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .route-todo, .mp-bob, .moped-pulse, .pin .ring, .live-chip .dot { animation: none !important; }
}
