:root {
  --bg: #0b1220;
  --card: rgba(13, 20, 36, 0.9);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8eef8;
  --muted: #9aa8c0;
  --accent: #4fc3f7;
  --fair: #34d399;
  --foul: #f87171;
  --cross: #fbbf24;
  --radius: 12px;
  --timebar-h: 76px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0 0 var(--timebar-h) 0; background: #0b1220; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.card-title { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

.btn { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; }
.btn:hover { background: rgba(255,255,255,.16); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 20px; cursor: pointer; line-height: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(255,255,255,.07); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip:hover, .chip.active { background: rgba(79,195,247,.22); border-color: var(--accent); }
.chips.compact .chip { padding: 3px 8px; font-size: 12px; }

/* gates */
.gates { position: fixed; top: 12px; left: 12px; z-index: 1000; padding: 10px 12px; max-width: 340px; }

/* legend */
.legend { position: fixed; left: 12px; bottom: calc(var(--timebar-h) + 12px); z-index: 1000; padding: 8px 10px; width: 190px; }
.legend-bar { height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #253494 0%, #2c7fb8 12.5%, #41b6c4 25%, #7fcd78 37.5%, #ffd600 50%, #fd8d3c 62.5%, #e31a1c 75%, #ae017e 100%); }
.legend-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }

/* banner */
.banner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1100;
  background: #7f1d1d; color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 600;
  max-width: min(560px, 90vw); text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.banner.warn { background: #78350f; }

/* point panel */
.panel { position: fixed; top: 12px; right: 12px; z-index: 1000; width: 380px;
  max-height: calc(100% - var(--timebar-h) - 24px); overflow-y: auto; padding: 14px 16px 16px; }
.panel .close { position: absolute; top: 8px; right: 10px; font-size: 24px; color: var(--muted); }
.panel-title { font-size: 17px; font-weight: 650; padding-right: 30px; }
.panel-sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }

.readout { display: flex; align-items: center; gap: 14px; }
.arrow { width: 58px; height: 58px; flex: none; }
.arrow-ring { fill: rgba(255,255,255,.04); stroke: var(--line); }
.arrow-head { fill: var(--accent); transition: transform .15s linear; }
.speed { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.dir { color: var(--muted); }
.relation { margin: 10px 0 12px; padding: 8px 10px; border-radius: 8px; font-weight: 600;
  background: rgba(255,255,255,.06); border-left: 4px solid var(--muted); }
.relation.fair { border-color: var(--fair); color: var(--fair); background: rgba(52,211,153,.1); }
.relation.foul { border-color: var(--foul); color: var(--foul); background: rgba(248,113,113,.1); }
.relation.cross { border-color: var(--cross); color: var(--cross); background: rgba(251,191,36,.1); }
.relation.hint { font-weight: 400; color: var(--muted); }

.course { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.course label { color: var(--muted); }
.course input { width: 72px; background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 16px; }

.day-nav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 4px; }
.chart-title { font-weight: 600; }
.chart svg { display: block; width: 100%; cursor: crosshair; touch-action: none; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: rgba(255,255,255,.08); }
.chart .zero { stroke: rgba(255,255,255,.35); }
.chart .turn { stroke: rgba(255,255,255,.45); stroke-dasharray: 3 3; }
.chart .turn-label { fill: var(--text); font-size: 10px; font-weight: 600; }
.chart .cursor { stroke: #fff; stroke-width: 1.5; }
.chart .now { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .dirarrow { fill: var(--muted); }

.windows { margin-top: 8px; display: grid; gap: 4px; }
.win { display: grid; grid-template-columns: 12px 92px 1fr; align-items: center; gap: 8px; padding: 5px 8px;
  border-radius: 8px; background: rgba(255,255,255,.04); cursor: pointer; }
.win:hover { background: rgba(255,255,255,.09); }
.win .dot { width: 10px; height: 10px; border-radius: 50%; }
.win .when { font-variant-numeric: tabular-nums; font-weight: 600; }
.win .what { color: var(--muted); }
.win.fair .dot { background: var(--fair); } .win.fair .what b { color: var(--fair); }
.win.foul .dot { background: var(--foul); } .win.foul .what b { color: var(--foul); }
.win.weak .dot { background: var(--muted); }
.win.axis .dot { background: var(--accent); }
.tides { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* time bar */
.timebar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--timebar-h); z-index: 1000;
  display: flex; align-items: center; gap: 14px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: #0d1424; border-top: 1px solid var(--line); }
.play { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #04202e; font-size: 18px; flex: none; }
.slider-wrap { flex: 1; position: relative; min-width: 0; }
.time-label { font-weight: 650; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.time-label .rel { color: var(--muted); font-weight: 400; margin-left: 8px; }
#slider { width: 100%; margin: 0; accent-color: var(--accent); height: 22px; }
.day-ticks { position: relative; height: 14px; font-size: 11px; color: var(--muted); }
.day-ticks span { position: absolute; transform: translateX(-1px); white-space: nowrap; border-left: 1px solid var(--line); padding-left: 3px; }

.loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 2000; background: var(--bg); color: var(--muted); font-size: 16px; }
.loading[hidden] { display: none; }

.current-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
.sel-marker { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; background: rgba(79,195,247,.5); box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.leaflet-container { background: #0b1220; font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: rgba(13,20,36,.75) !important; color: var(--muted); }
.leaflet-control-attribution a { color: #9cc8e6; }
.leaflet-bar a { background: var(--card); color: var(--text); border-color: var(--line); }
.leaflet-control-layers { background: var(--card); color: var(--text); border: 1px solid var(--line) !important; }

/* phones: panel becomes a bottom sheet */
@media (max-width: 720px) {
  :root { --timebar-h: 72px; }
  .gates { right: 12px; max-width: none; padding: 8px 10px; }
  .gates .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .legend { display: none; }
  .banner { top: 74px; font-size: 12px; padding: 6px 10px; }
  .panel { top: auto; left: 0; right: 0; bottom: var(--timebar-h); width: auto; max-height: 58vh;
    border-radius: 16px 16px 0 0; }
  .leaflet-top.leaflet-right { top: 70px; }
}
