:root {
  --ground: #ece6da;
  --cast: #9a9cc4;
  --shade: #1c2040;
  --shade-2: #262b52;
  --shade-3: #343a6a;
  --ink: #eef0fa;
  --ink-dim: #a9aed0;
  --cool: #4fd1e8;
  --glare: #ff7a1a;
  --sun: #ffc233;
  --radius-sheet: 22px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  font-family: 'Archivo', system-ui, sans-serif;
  font-variation-settings: 'wdth' 100;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ground); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--cool); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

#map { position: fixed; inset: 0; }

:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }

/* Brand */
.brand {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 8px 8px; border-radius: 999px;
  background: var(--shade); box-shadow: 0 6px 20px rgba(28, 32, 64, 0.25);
  z-index: 3;
}
.brand .mark { width: 30px; height: 30px; display: block; }
.brand h1 {
  margin: 0; font-size: 17px; line-height: 1; font-weight: 800;
  font-variation-settings: 'wdth' 118; letter-spacing: 0.01em;
}
.brand p { margin: 3px 0 0; font-size: 12px; line-height: 1; color: var(--ink-dim); }

/* Sheet */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  max-height: 74vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--shade);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 6px 16px max(16px, env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(28, 32, 64, 0.35);
  transition: transform 0.35s var(--ease);
}
@media (max-width: 899px) {
  .sheet.collapsed { max-height: 424px; overflow: hidden; }
  .sheet.collapsed .sun-read, .sheet.collapsed .day { display: none; }
  .time { font-size: 32px; }
  .arc-wrap { height: 100px; margin-top: 6px; }
  .arc { height: 76px; }
  #slider { top: 58px; }
  .ticks { top: 88px; }
  .verdict { margin: 10px 0; }
  .headline { font-size: 18px; }
  .pct { font-size: 36px; margin-bottom: 6px; }
  .route { padding: 10px 11px; }
}
.grip {
  display: block; margin: 0 auto 2px; padding: 8px 30px; background: none; border: 0; cursor: pointer;
}
.grip span { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--shade-3); }

@media (min-width: 900px) {
  .sheet {
    left: 16px; right: auto; top: 76px; bottom: 16px; width: 384px; max-height: none;
    border-radius: var(--radius-sheet); padding: 18px 20px 20px;
  }
  .sheet.collapsed { transform: none; }
  .grip { display: none; }
}

/* Clock */
.clock-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.time {
  font-size: 36px; line-height: 1; font-weight: 850; font-variation-settings: 'wdth' 112;
  letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--sun);
  white-space: nowrap;
}
.day { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.day label { font-size: 13px; color: var(--ink-dim); margin-right: 2px; }
.day input[type='date'] {
  background: var(--shade-2); border: 1px solid var(--shade-3); border-radius: 10px;
  padding: 6px 8px; font-size: 14px; color-scheme: dark; min-width: 0; width: 140px;
}
.chip {
  background: var(--shade-2); border: 1px solid var(--shade-3); border-radius: 999px;
  padding: 6px 11px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--ink-dim); }
.play {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: var(--sun); color: var(--shade); border: 0; border-radius: 10px;
  padding: 8px 12px; font-weight: 700; font-size: 14px; cursor: pointer; flex: none;
}
.play svg { width: 14px; height: 14px; fill: currentColor; }
.play:hover { background: #ffd15e; }

.arc-wrap { position: relative; margin-top: 10px; height: 118px; }
.arc { position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 92px; overflow: visible; }
.arc-path { fill: none; stroke: var(--shade-3); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; }
.arc-lit { fill: none; stroke: var(--sun); stroke-width: 3; stroke-linecap: round; opacity: 0.9; }
.horizon { stroke: var(--shade-3); stroke-width: 1.5; }
.sun { fill: var(--sun); filter: drop-shadow(0 0 10px rgba(255, 194, 51, 0.8)); }
.sun.down { fill: var(--shade-3); filter: none; }

#slider {
  position: absolute; left: -8px; right: -8px; width: calc(100% + 16px); top: 74px; height: 30px;
  margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: grab;
}
#slider::-webkit-slider-runnable-track { height: 30px; background: transparent; }
#slider::-moz-range-track { height: 30px; background: transparent; }
#slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--shade); border: 3px solid var(--sun); margin-top: 0;
}
#slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--shade); border: 3px solid var(--sun); }
#slider:focus-visible { outline: none; }
#slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--ink); }

.ticks {
  position: absolute; left: 0; right: 0; top: 104px; height: 14px;
  font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums;
}
.ticks span { position: absolute; transform: translateX(-50%); }

.sun-read { margin: 6px 0 0; font-size: 13px; color: var(--ink-dim); }

/* Verdict */
.verdict { margin: 14px 0 12px; }
.headline {
  margin: 0; font-size: 21px; line-height: 1.22; font-weight: 700; font-variation-settings: 'wdth' 92;
  text-wrap: balance;
}
.headline b { color: var(--cool); font-weight: 800; }

/* Compare */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.route { background: var(--shade-2); border-radius: 14px; padding: 12px 12px 11px; min-width: 0; }
.route h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-dim); }
.route.shady h2::before, .route.short h2::before {
  content: ''; display: inline-block; width: 16px; height: 4px; border-radius: 2px; margin: 0 6px 2px 0; vertical-align: middle;
}
.route.shady h2::before { background: var(--cool); }
.route.short h2::before { background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 8px); }
.pct {
  margin: 4px 0 8px; font-size: 44px; line-height: 0.95; font-weight: 900;
  font-variation-settings: 'wdth' 112; font-variant-numeric: tabular-nums;
}
.pct small { font-size: 13px; font-weight: 600; margin-left: 3px; font-variation-settings: 'wdth' 100; color: var(--ink-dim); }
.route.shady .pct { color: var(--cool); }
.strip { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--shade-3); }
.strip i { display: block; height: 100%; }
.strip i.s { background: var(--cool); }
.strip i.g { background: var(--glare); }
.meta { margin: 8px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-dim); }
.meta b { color: var(--ink); font-weight: 650; }
.meta .hot { color: var(--glare); font-weight: 650; }

/* Controls */
.controls { margin-top: 14px; display: grid; gap: 10px; }
.detour { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.detour-label { font-size: 13px; color: var(--ink-dim); margin-right: auto; }
.detour button {
  background: var(--shade-2); border: 1px solid var(--shade-3); border-radius: 999px;
  padding: 6px 12px; font-size: 13.5px; font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums;
}
.detour button[aria-checked='true'] { background: var(--ink); color: var(--shade); border-color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost {
  background: none; border: 1px solid var(--shade-3); border-radius: 10px; padding: 7px 11px;
  font-size: 13px; cursor: pointer; color: var(--ink);
}
.ghost:hover, .detour button:hover { border-color: var(--ink-dim); }

.legend { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 7px; font-size: 13px; color: var(--ink-dim); }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend i { flex: none; display: block; width: 26px; height: 12px; border-radius: 3px; }
.legend .k-cast { background: #8f8fb6; }
.legend .k-route { height: 6px; background: linear-gradient(90deg, var(--cool) 0 60%, var(--glare) 60%); }
.legend .k-short { height: 3px; background: repeating-linear-gradient(90deg, var(--ink) 0 5px, transparent 5px 8px); }
.legend .k-guess { background: #e2d9c6; }

.about { margin-top: 14px; border-top: 1px solid var(--shade-3); padding-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-dim); }
.about summary { cursor: pointer; color: var(--ink); font-weight: 600; }
.about p { margin: 8px 0 0; max-width: 62ch; }
.about .credit { font-size: 12px; }

/* Map hint + markers */
.hint {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 3; margin: 0;
  max-width: 220px; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.3;
  background: rgba(255, 255, 255, 0.92); color: var(--shade); box-shadow: 0 6px 20px rgba(28, 32, 64, 0.18);
  transition: opacity 0.4s;
}
.hint.gone { opacity: 0; pointer-events: none; }
@media (max-width: 899px) { .hint { top: 70px; left: 12px; right: auto; } }

.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: grid; place-items: center; cursor: grab; border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(28, 32, 64, 0.4);
}
.pin span { transform: rotate(45deg); font-weight: 900; font-size: 15px; font-variation-settings: 'wdth' 120; }
.pin.a { background: var(--shade); color: var(--sun); }
.pin.b { background: var(--sun); color: var(--shade); }
.pin-label {
  position: absolute; left: 50%; top: -30px; transform: translateX(-50%) rotate(45deg); white-space: nowrap;
}

.maplibregl-ctrl-attrib { font-family: 'Archivo', system-ui, sans-serif; font-size: 11px; }
@media (max-width: 899px) {
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .hint { transition: none; }
}
