:root {
  --bg: #f4f7fa;
  --ink: #102033;
  --muted: #5d6b7a;
  --brand: #0b3a5b;
  --brand2: #1b83c6;
  --ok: #0f8a5f;
  --card: #ffffff;
  --border: #d8e1ea;
  --shadow: 0 14px 30px rgba(16, 32, 51, .12);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; color: #fff; background: linear-gradient(135deg, var(--brand), #0e5d90); position: sticky; top: 0; z-index: 1000; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .1rem; font-size: clamp(1.4rem, 5vw, 2rem); }
h2 { margin-bottom: .6rem; }
.eyebrow { margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: inherit; opacity: .75; font-size: .75rem; }
main { width: min(1100px, 100%); margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 22px; padding: 1rem; box-shadow: var(--shadow); }
.start-panel { display: grid; gap: .75rem; }
label { font-weight: 700; }
select { width: 100%; font-size: 1rem; padding: .85rem; border-radius: 14px; border: 1px solid var(--border); background: #fff; }
.controls { display: flex; flex-wrap: wrap; gap: .6rem; }
.controls.compact { margin-top: .75rem; }
button { border: 0; border-radius: 999px; padding: .85rem 1rem; font-size: 1rem; font-weight: 800; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--brand2); color: white; }
.secondary { background: #e7f1f9; color: var(--brand); }
.ghost { background: transparent; color: inherit; border: 1px solid rgba(16, 32, 51, .25); }
.topbar .ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.status { font-weight: 700; color: var(--brand); }
.safety { color: var(--muted); margin-bottom: 0; }
.map-wrap { height: min(62vh, 560px); min-height: 350px; border-radius: 22px; overflow: hidden; border: 1px solid var(--border); background: #dbe8f2; box-shadow: var(--shadow); position: relative; touch-action: none; }
#map { height: 100%; width: 100%; touch-action: none; }
html, body { touch-action: pan-y; }
.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 2rem; text-align: center; background: #dbe8f2; font-weight: 700; }
.now-playing h2 { color: var(--brand); }
.now-playing p:last-child { margin-bottom: 0; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
#progress { color: var(--muted); font-weight: 800; white-space: nowrap; }
.point-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.point-item { display: grid; grid-template-columns: 34px 1fr auto; gap: .75rem; align-items: center; padding: .75rem; border: 1px solid var(--border); border-radius: 16px; background: #fbfdff; }
.badge { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #dcecf8; color: var(--brand); font-weight: 900; }
.point-item.played .badge { background: #dbf3e9; color: var(--ok); }
.point-item h3 { margin: 0 0 .15rem; font-size: 1rem; }
.point-item p { margin: 0; color: var(--muted); font-size: .9rem; }
.small-btn { padding: .55rem .75rem; font-size: .85rem; }
footer { width: min(1100px, 100%); margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .9rem; }
@media (min-width: 850px) {
  main { grid-template-columns: 380px 1fr; align-items: start; }
  .map-wrap { grid-row: span 3; }
}

.gps-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.gps-stats div { background: #f1f7fc; border: 1px solid var(--border); border-radius: 14px; padding: .65rem; }
.gps-stats span { display: block; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.gps-stats strong { display: block; margin-top: .2rem; font-size: .95rem; color: var(--brand); }
.map-follow { position: absolute; top: .8rem; right: .8rem; z-index: 500; background: rgba(255,255,255,.94); color: var(--brand); border: 1px solid var(--border); box-shadow: 0 8px 20px rgba(16,32,51,.16); padding: .6rem .8rem; font-size: .88rem; }
.map-legend { position: absolute; left: .8rem; bottom: .8rem; z-index: 500; display: flex; gap: .5rem; flex-wrap: wrap; background: rgba(255,255,255,.94); border: 1px solid var(--border); border-radius: 999px; padding: .45rem .65rem; box-shadow: 0 8px 20px rgba(16,32,51,.16); font-size: .84rem; font-weight: 800; color: var(--brand); }
.map-legend span { display: inline-flex; align-items: center; gap: .25rem; }
.map-legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.legend-user { background: #0b3a5b; }
.legend-next { background: #f39c12; }
.legend-point { background: #1b83c6; }
.guide-pin { background: transparent; border: 0; }
.guide-pin span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: white; background: #1b83c6; border: 3px solid white; box-shadow: 0 5px 15px rgba(16,32,51,.32); font-weight: 950; font-size: .9rem; }
.guide-pin.played span { background: #0f8a5f; }
.guide-pin.next span { background: #f39c12; color: #102033; transform: scale(1.14); }
.user-location-icon { background: transparent; border: 0; }
.user-arrow { position: absolute; left: 8px; top: 0; width: 26px; height: 26px; display: grid; place-items: center; transform-origin: 50% 80%; color: #0b3a5b; font-size: 24px; line-height: 1; text-shadow: 0 2px 8px rgba(255,255,255,.9); }
.user-dot { position: absolute; left: 12px; top: 12px; width: 18px; height: 18px; border-radius: 50%; background: #0b3a5b; border: 4px solid white; box-shadow: 0 5px 15px rgba(16,32,51,.35); }
.next-ahead h2 { color: #9a5f00; }
#nextAheadMeta { color: var(--muted); font-weight: 800; margin-bottom: .5rem; }
@media (max-width: 500px) {
  .gps-stats { grid-template-columns: 1fr; }
  .map-legend { border-radius: 16px; }
}
.route-instructions h2 { color: var(--brand); }
.route-instructions p:last-child { margin-bottom: 0; color: var(--muted); font-weight: 700; }
.popup-card { min-width: 170px; color: #102033; }
.popup-card span { color: #5d6b7a; font-weight: 700; }
.popup-play { margin-top: .55rem; width: 100%; padding: .55rem .7rem; border-radius: 999px; background: #1b83c6; color: #fff; font-weight: 900; font-size: .9rem; }
.point-item .small-btn { min-width: 78px; }
