*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
/* Layout: full-bleed clay globe on a felt backdrop; title top-left, destinations down the right, trip card bottom-left (stacked at the bottom on phones). */
:root {
  --felt: #c4cbe4;
  --felt-deep: #9ea7cd;
  --ink: #282739;
  --ink-soft: #5d5c78;
  --tile: #f6f2ed;
  --tile-edge: #d8cfc5;
  --tile-hi: rgba(255, 255, 255, 0.75);
  --shadow: rgba(30, 28, 60, 0.22);
  --accent: #e2523b;
  --font-display: "Bagel Fat One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --felt: #262b47; --felt-deep: #12152a; --ink: #f2efea; --ink-soft: #a9a8c4;
    --tile: #30355a; --tile-edge: #1a1d36; --tile-hi: rgba(255, 255, 255, 0.10);
    --shadow: rgba(0, 0, 0, 0.45); --accent: #ff7d62; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --felt: #262b47; --felt-deep: #12152a; --ink: #f2efea; --ink-soft: #a9a8c4;
  --tile: #30355a; --tile-edge: #1a1d36; --tile-hi: rgba(255, 255, 255, 0.10);
  --shadow: rgba(0, 0, 0, 0.45); --accent: #ff7d62; color-scheme: dark;
}
html, body { height: 100%; }
body {
  background-color: var(--felt);
  background-image: radial-gradient(120% 95% at 50% 45%, var(--felt) 0%, var(--felt-deep) 100%);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage.is-dragging { cursor: grabbing; }
#stage.is-hover { cursor: pointer; }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pin-label {
  position: absolute; left: 0; top: 0;
  font: 600 12px/1 var(--font-body);
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--tile);
  padding: 4px 9px 5px;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--tile-edge), 0 4px 10px var(--shadow);
  white-space: nowrap;
  will-change: transform, opacity;
}
.pin-label.is-active { font: 400 15px/1 var(--font-display); padding: 6px 12px 7px; letter-spacing: 0.02em; }
.pin-label.is-dim { font-weight: 500; }

/* Layout: title top-left, itinerary down the right, stop card bottom-left, playback timeline across the bottom. */
.hud {
  position: fixed; inset: 0; pointer-events: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "title list" ". list" "card list" "timeline timeline";
  gap: 14px 16px;
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.title { grid-area: title; max-width: 34ch; }
.title h1 {
  margin: 0; font: 400 clamp(28px, 3.6vw, 42px)/0.95 var(--font-display);
  letter-spacing: 0.01em; text-wrap: balance;
  text-shadow: 0 3px 0 var(--tile-edge);
}
.title p { margin: 8px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.45; max-width: 36ch; }

.tile {
  background: var(--tile);
  box-shadow: inset 0 2px 0 var(--tile-hi), 0 5px 0 var(--tile-edge), 0 14px 30px var(--shadow);
}
.eyebrow { font: 600 11px/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }

/* Itinerary */
.list {
  grid-area: list; pointer-events: auto; align-self: start;
  width: 260px; max-height: 100%; min-height: 0;
  display: flex; flex-direction: column;
  border-radius: 20px; padding: 14px 8px 8px;
}
.list header { display: flex; align-items: center; padding: 0 8px 10px; gap: 8px; }
.list header small { font-size: 11px; color: var(--ink-soft); margin-right: auto; }
.play-all {
  appearance: none; border: 0; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--accent); color: #fff; font: 600 12px/1 var(--font-body);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.25), 0 2px 0 var(--tile-edge);
  transition: transform .1s ease;
}
.play-all:active { transform: translateY(1px); box-shadow: inset 0 2px 0 rgba(255,255,255,.25); }
.play-all svg { width: 11px; height: 11px; fill: currentColor; }
.stops { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; display: grid; gap: 2px; }
.stop {
  appearance: none; border: 0; background: none; color: var(--ink); cursor: pointer; text-align: left;
  width: 100%; display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: 10px; row-gap: 3px;
  padding: 8px 8px; border-radius: 12px; font: inherit;
}
.stop:hover { background: var(--tile-edge); }
.stop .dot { grid-row: span 2; align-self: center; width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: inset -2px -2px 0 rgba(0,0,0,.18), inset 2px 2px 0 rgba(255,255,255,.35); }
.stop .when { font: 500 11px/1.2 var(--font-data); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.stop .what { font: 600 14px/1.25 var(--font-body); overflow-wrap: anywhere; }
.stop[aria-current="true"] { background: var(--ink); color: var(--tile); }
.stop[aria-current="true"] .when { color: var(--tile); opacity: .75; }
.stop .event { font-weight: 500; color: var(--ink-soft); }
.stop[aria-current="true"] .event { color: var(--tile); opacity: .7; }
.stop .today { font: 600 10px/1 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-left: 6px; }

/* Stop card */
.card {
  grid-area: card; pointer-events: auto; align-self: end;
  width: min(360px, 100%);
  border-radius: 22px;
  padding: 16px 18px 14px;
  display: grid; gap: 12px;
}
.now { display: grid; gap: 6px; }
.place { font: 400 24px/1.05 var(--font-display); letter-spacing: 0.01em; text-wrap: balance; }
.meta { font-size: 13px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.coords { font-family: var(--font-data); font-size: 12px; font-variant-numeric: tabular-nums; }
.trip { display: grid; gap: 7px; border-top: 2px dashed var(--tile-edge); padding-top: 12px; }
.route { font-weight: 600; font-size: 14px; min-height: 18px; }
.route .km { font-family: var(--font-data); font-weight: 500; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Timeline */
.timeline {
  grid-area: timeline; pointer-events: auto;
  border-radius: 22px; padding: 12px 18px 10px 12px;
  display: flex; align-items: center; gap: 16px;
}
.transport { display: flex; align-items: center; gap: 8px; flex: none; }
.btn {
  appearance: none; border: 0; cursor: pointer; color: var(--ink);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tile);
  box-shadow: inset 0 2px 0 var(--tile-hi), 0 3px 0 var(--tile-edge), 0 4px 10px var(--shadow);
  transition: transform .1s ease;
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 var(--tile-hi), 0 1px 0 var(--tile-edge); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }
.btn.play { width: 50px; height: 50px; background: var(--accent); color: #fff; }
.btn.play svg { width: 20px; height: 20px; }
.btn:focus-visible, .play-all:focus-visible, .stop:focus-visible, .text-btn:focus-visible, .track:focus-visible, .toggle input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.readout { display: grid; gap: 4px; min-width: 170px; padding-left: 6px; }
.date { font: 500 17px/1 var(--font-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.status b { color: var(--accent); font-weight: 700; }
.track-wrap { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; padding-top: 4px; }
.track { position: relative; height: 30px; cursor: pointer; touch-action: none; border-radius: 10px; outline: none; }
.track .rail { position: absolute; left: 0; right: 0; top: 50%; height: 0; border-top: 2px dashed var(--tile-edge); }
.seg { position: absolute; top: 5px; bottom: 5px; border-radius: 6px; background: var(--c); box-shadow: inset 0 2px 0 rgba(255,255,255,.35), inset 0 -2px 0 rgba(0,0,0,.15); min-width: 4px; }
.seg.past { opacity: 1; }
.seg.future { opacity: .55; }
.today-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.today-mark::after { content: "Today"; position: absolute; top: -13px; left: 50%; transform: translateX(-50%); font: 700 9px/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.thumb {
  position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  background: var(--tile); box-shadow: inset 0 2px 0 var(--tile-hi), 0 3px 0 var(--tile-edge), 0 4px 10px var(--shadow);
  border: 3px solid var(--ink); pointer-events: none;
}
.months { position: relative; height: 13px; }
.months span { position: absolute; top: 0; transform: translateX(-1px); font: 500 10.5px/1 var(--font-data); color: var(--ink-soft); white-space: nowrap; padding-left: 4px; border-left: 1px solid var(--tile-edge); }

.controls { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle span.sw { width: 34px; height: 20px; border-radius: 999px; background: var(--tile-edge); position: relative; transition: background .15s; flex: none; }
.toggle span.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--tile); box-shadow: 0 1px 2px var(--shadow); transition: transform .15s; }
.toggle input:checked + span.sw { background: var(--accent); }
.toggle input:checked + span.sw::after { transform: translateX(14px); }
.text-btn { appearance: none; border: 0; background: none; color: var(--ink-soft); font: 600 13px var(--font-body); cursor: pointer; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--ink); }

@media (max-width: 900px) {
  .list { display: none; }
  .hud { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "." "card" "timeline"; grid-template-rows: auto minmax(0, 1fr) auto auto; }
}
@media (max-width: 640px) {
  .hud { gap: 10px; }
  .title p { display: none; }
  .title h1 { font-size: 26px; }
  .card { width: 100%; padding: 12px 14px; gap: 8px; }
  .card .controls { display: none; }
  .place { font-size: 20px; }
  .timeline { flex-wrap: wrap; padding: 10px 12px 8px; gap: 8px 10px; }
  .track-wrap { flex-basis: 100%; }
  .readout { min-width: 0; }
  .date { font-size: 15px; }
}
