/* r3dv2/style.css — cinematic 3D route replay (Mapbox Standard + terrain)
 * Layout: full-bleed map, story-style bottom stack, sheet for load/share. */

:root {
  --accent: #fb923c;
  --accent-rgb: 251, 146, 60;
  --ink: #f8fafc;
  --muted: rgba(248, 250, 252, 0.62);
  --dim: rgba(248, 250, 252, 0.38);
  --glass: rgba(8, 12, 20, 0.30);
  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.07);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue",
          "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; height: 100dvh;
  overflow: hidden; background: #05070a; color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: #0a0e17; }

/* ── cinematic grade ─────────────────────────────────────── */
.map-tint {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    linear-gradient(180deg, rgba(4, 7, 12, 0.5) 0%, rgba(4, 7, 12, 0) 24%,
                    rgba(4, 7, 12, 0) 50%, rgba(4, 7, 12, 0.7) 100%);
  opacity: 0.95;
}
.cinematic-vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  box-shadow: inset 0 0 160px 24px rgba(0, 0, 0, 0.45);
}
.cinematic-grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 4; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
.accent-light-line {
  position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 30;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.85; transition: background 0.6s var(--ease);
}

/* ── top bar ─────────────────────────────────────────────── */
.top-bar {
  position: absolute; z-index: 20;
  top: calc(var(--safe-t) + 14px);
  left: calc(var(--safe-l) + 14px);
  right: calc(var(--safe-r) + 14px);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
.top-bar-left, .top-bar-right { display: flex; align-items: center; gap: 8px; pointer-events: auto; min-width: 0; }
.top-bar-left { flex: 1 1 auto; }

.top-link {
  display: inline-flex; align-items: center; gap: 3px;
  height: 34px; padding: 0 11px 0 7px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--glass); backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; white-space: nowrap; flex: 0 1 auto; overflow: hidden;
}
.top-link span { overflow: hidden; text-overflow: ellipsis; }
.top-link:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.28); }

.rec-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-soft); background: rgba(6, 10, 16, 0.4);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden;
}
.rec-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  animation: pulse-dot 1.8s infinite ease-in-out;
}
.rec-time { font-family: var(--mono); font-weight: 600; letter-spacing: 0.01em; color: var(--ink); font-size: 11px; text-transform: none; }
.rec-phase { color: var(--accent); }

.icon-btn {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--glass); color: var(--ink);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  cursor: pointer; text-decoration: none;
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
  font-family: var(--mono);
  transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── stats: story stack ─────────────────────────────────── */
.stats-overlay {
  position: absolute; z-index: 16;
  left: calc(var(--safe-l) + 20px);
  top: calc(var(--safe-t) + 64px);
  display: flex; flex-direction: column;
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.stat-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 3px 0; min-width: 126px;
}
.stat-item.hidden { display: none; }
.stat-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--dim); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}
.stat-value {
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink); line-height: 1.15; text-shadow: 0 1px 14px rgba(0, 0, 0, 0.6);
}
.stat-main { padding-bottom: 7px; margin-bottom: 5px; border-bottom: 1px solid var(--line-soft); }
.stat-main .stat-label { color: var(--muted); }
.stat-main .stat-value { font-size: 34px; font-weight: 800; letter-spacing: -0.035em; }
.stat-main .stat-value .stat-unit { font-size: 11px; margin-left: 4px; letter-spacing: 0.12em; color: var(--muted); }
.stat-unit { font-size: 10px; font-weight: 600; color: var(--dim); margin-left: 3px; letter-spacing: 0.06em; }

/* ── bottom stack ───────────────────────────────────────── */
.bottom-container {
  position: absolute; z-index: 18; left: 0; right: 0; bottom: 0;
  padding: 0 calc(var(--safe-r) + 14px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 14px);
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, rgba(3, 6, 10, 0) 0%, rgba(3, 6, 10, 0.5) 55%, rgba(3, 6, 10, 0.8) 100%);
  pointer-events: none;
}
.timeline-wrap {
  position: relative; height: 68px; width: 100%; cursor: pointer;
  pointer-events: auto; touch-action: none;
}
.elevation-canvas { position: absolute; left: 0; right: 0; top: 0; height: 42px; width: 100%; display: block; }
.metric-canvas { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; width: 100%; display: block; opacity: 0.9; }
.plot-label {
  position: absolute; font-family: var(--mono); font-size: 8px;
  letter-spacing: 0.16em; text-transform: uppercase; pointer-events: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.plot-label::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.plot-pace { left: 0; top: -2px; color: #38bdf8; }
.plot-hr { right: 0; bottom: 24px; color: #fb7185; }
.timeline-progress-bar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0), rgba(var(--accent-rgb), 0.09));
  pointer-events: none;
}
.timeline-scrubber-handle {
  position: absolute; top: 3px; bottom: 3px; left: 0; width: 2px;
  background: var(--accent); box-shadow: 0 0 14px var(--accent);
  border-radius: 2px; transform: translateX(-1px); pointer-events: none;
}
.timeline-scrubber-handle::after {
  content: ''; position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}

.bottom-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px 6px 6px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}
.toolbar-group { display: flex; align-items: center; gap: 6px; min-width: 0; }

.play-button {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  border: 0; background: #fff; color: #05070a;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform 0.2s var(--ease);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}
.play-button:hover { transform: scale(1.04); }
.play-button:active { transform: scale(0.95); }
.play-button svg { width: 15px; height: 15px; fill: currentColor; }
.play-button svg#playIcon { margin-left: 2px; }

.time-display {
  display: flex; align-items: baseline; gap: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.time-display #elapsedTime { color: var(--ink); }
.time-sep { opacity: 0.4; }

.speed-chips { display: flex; align-items: center; gap: 1px; }
.chip-btn {
  border: 0; background: transparent; color: var(--dim);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 6px 6px; border-radius: 999px; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.chip-btn:hover { color: var(--ink); }
.chip-btn.active { color: #05070a; background: var(--accent); }

.cam-chip-btn {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  color: var(--ink); font-family: var(--mono);
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  padding: 7px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.cam-chip-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* ── phase chips (sheet) ────────────────────────────────── */
.phase-chips { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.phase-chip, .phase-auto {
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.05);
  color: var(--muted); font-size: 11px; font-weight: 600; font-family: var(--font);
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.phase-auto { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; }
.phase-chip:hover { color: var(--ink); }
.phase-chip.active { background: var(--accent); border-color: transparent; color: #05070a; }
.phase-auto.active { background: rgba(255, 255, 255, 0.9); color: #05070a; border-color: transparent; }
.phase-chips.auto-lock .phase-chip { opacity: 0.45; pointer-events: none; }

/* ── intro / summary ────────────────────────────────────── */
.intro-modal, .summary-modal {
  position: absolute; inset: 0; z-index: 24;
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: calc(var(--safe-t) + 70px) calc(var(--safe-r) + 20px) calc(var(--safe-b) + 156px) calc(var(--safe-l) + 22px);
  background: linear-gradient(180deg, rgba(3, 6, 11, 0.35) 0%, rgba(3, 6, 11, 0.12) 32%, rgba(3, 6, 11, 0.72) 72%, rgba(3, 6, 11, 0.93) 100%);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 1; transition: opacity 0.5s var(--ease), visibility 0.5s;
}
.intro-modal.dismissed, .intro-modal.loading, .summary-modal:not(.active) { opacity: 0; visibility: hidden; pointer-events: none; }
.summary-modal { align-items: center; justify-content: center; padding: 24px; background: rgba(4, 7, 12, 0.76); backdrop-filter: blur(10px); }

.intro-card { width: min(620px, 100%); display: flex; flex-direction: column; align-items: flex-start; }
.summary-card { width: min(480px, 100%); align-items: stretch; background: rgba(10, 15, 24, 0.72); border: 1px solid var(--line); border-radius: 26px; padding: 26px 24px; backdrop-filter: blur(24px); }

.intro-header-kicker {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 12px;
}
.intro-title {
  margin: 0 0 10px; font-size: clamp(30px, 8vw, 58px); line-height: 0.98;
  font-weight: 800; letter-spacing: -0.035em; text-wrap: balance;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
}
.intro-sub { font-size: 12px; color: var(--muted); margin-bottom: 24px; letter-spacing: 0.02em; }

.intro-stats-row {
  display: flex; align-items: flex-start; gap: clamp(20px, 7vw, 52px);
  padding: 16px 0 22px; border-top: 1px solid var(--line-soft);
  width: 100%;
}
.intro-stat-col { display: flex; flex-direction: column; gap: 6px; }
.intro-stat-num {
  font-size: clamp(21px, 5.4vw, 30px); font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.intro-stat-num small { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--dim); margin-left: 3px; }
.intro-stat-lbl { font-size: 9px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }

.intro-actions { display: flex; align-items: center; gap: 10px; width: 100%; flex-wrap: wrap; }
.pill-btn-primary {
  border: 0; background: #fff; color: #05070a;
  font-family: var(--font); font-size: 13.5px; font-weight: 700;
  padding: 14px 22px; border-radius: 999px; cursor: pointer;
  transition: transform 0.2s var(--ease);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}
.pill-btn-primary:hover { transform: translateY(-1px); }
.pill-btn-primary:active { transform: scale(0.98); }
.pill-btn-secondary {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  color: var(--ink); font-family: var(--font); font-size: 13.5px; font-weight: 600;
  padding: 14px 20px; border-radius: 999px; cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: background 0.2s, border-color 0.2s;
}
.pill-btn-secondary:hover { background: rgba(255, 255, 255, 0.14); }

/* ── sheet ──────────────────────────────────────────────── */
.side-sheet {
  position: absolute; z-index: 26; right: 0; bottom: 0; left: 0;
  max-height: 86vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 18px calc(var(--safe-b) + 22px);
  background: rgba(8, 12, 18, 0.9);
  border-top: 1px solid var(--line);
  border-radius: 26px 26px 0 0;
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.55);
  transform: translateY(102%); transition: transform 0.42s var(--ease);
}
.side-sheet.open { transform: translateY(0); }
.sheet-grabber { width: 38px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); margin: 2px auto 12px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-title { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.sheet-section { padding: 14px 0; border-top: 1px solid var(--line-soft); }
.sheet-section:first-of-type { border-top: 0; }
.sheet-section-title { font-size: 9px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim); margin-bottom: 9px; }

.file-drop-target {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 18px 14px; border: 1px dashed rgba(255, 255, 255, 0.22); border-radius: 16px;
  background: rgba(255, 255, 255, 0.04); cursor: pointer; text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.file-drop-target:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.07); }
.file-drop-target input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-drop-icon { font-size: 17px; color: var(--muted); line-height: 1; }
.file-drop-text { font-size: 13px; font-weight: 600; }
.file-drop-sub { font-size: 10.5px; color: var(--dim); }

.input-row { display: flex; gap: 8px; }
.text-input, .select-input {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); color: var(--ink);
  font-family: var(--font); font-size: 13px; padding: 11px 12px;
  outline: none; appearance: none;
}
.text-input::placeholder { color: var(--dim); }
.text-input:focus, .select-input:focus { border-color: var(--accent); }
.btn-small {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.10); color: var(--ink);
  border-radius: 12px; padding: 0 16px; font-size: 12.5px; font-weight: 700;
  font-family: var(--font); cursor: pointer; white-space: nowrap;
}
.btn-small:hover { background: rgba(255, 255, 255, 0.18); }

.strava-box { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.strava-item {
  text-align: left; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.04);
  color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 12.5px;
  font-family: var(--font); cursor: pointer;
}
.strava-item:hover { background: rgba(255, 255, 255, 0.1); }

.fine-print { font-size: 10.5px; line-height: 1.6; color: var(--dim); padding-top: 14px; border-top: 1px solid var(--line-soft); }

/* ── toast ──────────────────────────────────────────────── */
.toast {
  position: absolute; z-index: 40; left: 50%; bottom: calc(var(--safe-b) + 136px);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: min(86vw, 420px);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(8, 12, 18, 0.92); border: 1px solid var(--line);
  color: var(--ink); font-size: 12px; font-weight: 600; text-align: center;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(248, 113, 113, 0.55); }
.toast.ok { border-color: rgba(var(--accent-rgb), 0.6); }

/* ── markers ────────────────────────────────────────────── */
.marker-runner-outer { position: relative; width: 26px; height: 26px; }
.marker-runner-core {
  position: absolute; left: 50%; top: 50%; width: 13px; height: 13px;
  margin: -6.5px 0 0 -6.5px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 0 16px rgba(var(--accent-rgb), 0.9), 0 2px 8px rgba(0, 0, 0, 0.5);
}
.marker-runner-pulse1, .marker-runner-pulse2 {
  position: absolute; left: 50%; top: 50%; width: 26px; height: 26px;
  margin: -13px 0 0 -13px; border-radius: 50%;
  border: 1px solid rgba(var(--accent-rgb), 0.85);
  animation: runner-ripple 2.6s infinite ease-out;
}
.marker-runner-pulse2 { animation-delay: 1.3s; }

.marker-term {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(6, 10, 16, 0.72); border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff; font-size: 8px; line-height: 1;
}
.marker-km {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity 0.3s;
}
#map.show-km .marker-km { opacity: 0.85; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes runner-ripple {
  0% { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* ── responsive ─────────────────────────────────────────── */
@media (min-width: 900px) {
  .stats-overlay { top: calc(var(--safe-t) + 70px); left: calc(var(--safe-l) + 28px); }
  .stat-item { min-width: 196px; }
  .stat-main .stat-value { font-size: 40px; }
  .bottom-container { padding-left: calc(var(--safe-l) + 24px); padding-right: calc(var(--safe-r) + 24px); }
  .intro-modal { align-items: center; padding-left: calc(var(--safe-l) + 72px); }
  .side-sheet {
    left: auto; right: 18px; bottom: 18px; top: auto;
    width: 392px; max-height: min(760px, calc(100vh - 36px));
    border-radius: 24px; border: 1px solid var(--line);
    padding: 12px 20px 22px;
    transform: translateX(calc(100% + 30px));
  }
  .side-sheet.open { transform: translateX(0); }
  .sheet-grabber { display: none; }
  .sheet-header { margin-bottom: 10px; }
  .toast { bottom: auto; top: calc(var(--safe-t) + 66px); }
}

@media (max-width: 520px) {
  .top-link span { display: none; }
  .top-link { padding: 0; width: 34px; justify-content: center; }
  .rec-chip { padding: 0 10px; letter-spacing: 0.1em; gap: 6px; }
  .rec-time { font-size: 10px; }
  .stat-main .stat-value { font-size: 28px; }
  .stat-item { min-width: 132px; }
  .bottom-toolbar { padding: 5px 8px 5px 5px; gap: 5px; }
  .play-button { width: 40px; height: 40px; flex-basis: 40px; }
  .chip-btn { padding: 6px 4px; font-size: 9px; }
  .cam-chip-btn { font-size: 8px; padding: 6px 7px; letter-spacing: 0.06em; }
  .time-display { font-size: 9.5px; gap: 2px; }
  .intro-stats-row { gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* the title card owns the screen until the replay starts */
body.intro-open .stats-overlay,
body.intro-open .bottom-container { opacity: 0; pointer-events: none; }
.stats-overlay, .bottom-container { transition: opacity 0.4s var(--ease); }

/* ── boot splash ────────────────────────────────────────── */
.boot-splash {
  position: absolute; inset: 0; z-index: 35;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(180deg, #060a11 0%, #0a1018 100%);
  transition: opacity 0.6s var(--ease), visibility 0.6s;
}
.boot-splash.done { opacity: 0; visibility: hidden; }
.boot-ring {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.25); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.boot-text { font-family: var(--mono); font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.uat-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 6px; background: rgba(var(--accent-rgb), 0.18);
  border: 1px solid rgba(var(--accent-rgb), 0.5); color: var(--accent);
  font-family: var(--mono); font-size: 8.5px; font-weight: 800; letter-spacing: 0.14em;
  margin-right: 2px;
}
@media (max-width: 520px) { .uat-badge { display: none; } }

/* ── start picker ───────────────────────────────────────── */
.picker-backdrop {
  position: absolute; inset: 0; z-index: 45;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 16px);
  background: linear-gradient(180deg, rgba(3, 6, 11, 0.72), rgba(3, 6, 11, 0.9));
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  transition: opacity 0.28s var(--ease), visibility 0.28s;
}
.picker-backdrop.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.picker-card {
  width: min(460px, 100%); max-height: 100%;
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px 18px 16px;
  background: rgba(10, 15, 24, 0.82);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.picker-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.picker-title { margin: 0; font-size: clamp(20px, 5.6vw, 26px); font-weight: 800; letter-spacing: -0.02em; }
.picker-sub { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.picker-list {
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-height: 42vh; padding-right: 2px;
  border-top: 1px solid var(--line-soft); padding-top: 12px;
}
.picker-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-soft);
  color: var(--ink); font-family: var(--font); text-align: left; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.picker-row:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); }
.picker-row:active { transform: scale(0.985); }
.picker-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.picker-row-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-row-meta { font-size: 10px; color: var(--dim); }
.picker-row-badge {
  flex: 0 0 auto; font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  padding: 3px 8px; border-radius: 999px; text-transform: uppercase;
  background: rgba(var(--accent-rgb), 0.12); color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
}
.picker-row-badge.is-demo { background: rgba(255, 255, 255, 0.06); color: var(--muted); border-color: var(--line); }
.picker-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.picker-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 10px 11px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, 0.045); border: 1px solid var(--line-soft);
  color: var(--ink); font-family: var(--font); text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.picker-action:hover { background: rgba(255, 255, 255, 0.09); }
.picker-action.hidden { display: none; }
.picker-action-icon { font-size: 13px; color: var(--accent); line-height: 1; }
.picker-action strong { font-size: 11.5px; font-weight: 700; }
.picker-action small { font-size: 9px; color: var(--dim); }
.picker-note { margin: 0; font-size: 10px; color: var(--dim); text-align: center; }

/* ── drone distance ─────────────────────────────────────── */
.drone-row { display: flex; align-items: center; gap: 12px; }
.drone-row input[type="range"] {
  flex: 1 1 auto; -webkit-appearance: none; appearance: none;
  height: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); outline: none;
}
.drone-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0a0f18; cursor: pointer;
}
.drone-row input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border: 2px solid #0a0f18; border-radius: 50%; background: var(--accent);
}
.drone-row b { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--ink); min-width: 52px; text-align: right; }
#droneDistSection.hidden, #droneDistChip.hidden { display: none !important; }

/* ── strava rows ────────────────────────────────────────── */
.strava-item { display: flex; flex-direction: column; gap: 2px; }
.strava-name { font-size: 12.5px; font-weight: 600; }
.strava-meta { font-size: 10px; color: var(--dim); }
.strava-item.loading { opacity: 0.65; pointer-events: none; }
.strava-empty { font-size: 11px; color: var(--dim); padding: 6px 0; }
.mini-spin {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; vertical-align: -1px;
}

/* inside your own head you cannot see the avatar */
#map.fp-mode .marker-runner-outer { display: none !important; }

.summary-card { position: relative; }
.summary-close {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  color: var(--ink); font-size: 11px; cursor: pointer;
}
.summary-close:hover { background: rgba(255, 255, 255, 0.14); }
.summary-card .intro-actions { flex-wrap: wrap; gap: 8px; }

/* ── checkpoint markers + km bubble ─────────────────────── */
.marker-cp { display: flex; align-items: center; gap: 5px; pointer-events: none; }
.marker-cp .cp-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #ffe08a; box-shadow: 0 0 8px rgba(255, 224, 138, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.45);
}
.marker-cp .cp-name {
  display: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 9.5px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}
#map.show-cp .marker-cp .cp-name { display: inline; }

.km-bubble .mapboxgl-popup-content {
  background: rgba(8, 12, 18, 0.92); color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 12px;
  padding: 7px 11px; font-size: 11.5px; letter-spacing: 0.02em;
  backdrop-filter: blur(16px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.km-bubble .mapboxgl-popup-tip { border-top-color: rgba(8, 12, 18, 0.92); }
.km-bubble b { color: var(--accent); }

@media (max-width: 900px) {
  .uat-badge { display: none; }
  .top-link span { display: none; }
  .top-link { width: 34px; padding: 0; justify-content: center; }
}
