*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f172a;
  --surface: rgba(15, 23, 42, 0.85);
  --surface-solid: #1e293b;
  --border: rgba(148, 163, 184, 0.15);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: rgba(56, 189, 248, 0.15);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── Map ── */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.maplibregl-ctrl-attrib {
  font-size: 10px !important;
  background: rgba(0,0,0,0.4) !important;
  color: #94a3b8 !important;
}
.maplibregl-ctrl-attrib a { color: #94a3b8 !important; }

/* ── Particle canvases (on top of map + heatmap) ── */
#wind-canvas,
#swell-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* swell-canvas hidden/shown via JS inline style in SwellRenderer.setVisible() */

/* ── Top bar ── */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #38bdf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.btn-group {
  display: flex;
  background: rgba(30, 41, 59, 0.8);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.ctrl-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ctrl-btn:hover {
  color: var(--text);
  background: rgba(56, 189, 248, 0.08);
}

.ctrl-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.status {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Timeline bar ── */
.timeline-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.play-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.play-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

.timeline-track {
  flex: 1;
  position: relative;
}

.timeline-track input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.timeline-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0f172a;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  cursor: pointer;
}

.timeline-track input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0f172a;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  cursor: pointer;
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  padding: 4px 0 0;
  font-size: 9px;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
  overflow: hidden;
}

.timeline-ticks .tick-major {
  font-weight: 600;
  color: var(--text);
  font-size: 10px;
}

.timeline-ticks .tick-minor {
  opacity: 0.5;
  font-size: 8px;
}

.hour-display {
  text-align: right;
  flex-shrink: 0;
  min-width: 80px;
}

.hour-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.hour-date {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Legend ── */
.legend {
  position: absolute;
  bottom: 70px;
  left: 16px;
  z-index: 10;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  min-width: 200px;
}

.swell-legend {
  bottom: 130px;
}

.legend-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-bar {
  height: 10px;
  border-radius: 5px;
  margin-bottom: 4px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}

.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
}

.close-btn:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}


/* ── Loading overlay ── */
.loading-indicator {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  display: none;
}

.loading-indicator.visible {
  display: block;
}

/* ── Hint text ── */
.hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  white-space: nowrap;
}

/* ── Surf Rating Panel ── */
.rating-panel {
  position: absolute;
  top: 50px;
  right: -400px;
  width: 390px;
  bottom: 56px;
  z-index: 12;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rating-panel.open { right: 0; }
.rating-panel .close-btn { z-index: 2; }

.rp-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148,163,184,0.08);
}
.rp-spot-name { font-size: 17px; font-weight: 700; }
.rp-coords { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.rp-overall {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid rgba(148,163,184,0.08);
}
.rp-score {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: white; flex-shrink: 0;
}
.rp-rating-label { font-size: 20px; font-weight: 700; }
.rp-rating-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.rp-detail {
  padding: 14px 18px;
  display: flex; gap: 14px; align-items: center;
  border-bottom: 1px solid rgba(148,163,184,0.08);
}
.rp-detail-info { flex: 1; }
.rp-detail-time { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.rp-detail-time span { font-weight: 400; color: var(--text-muted); }
.rp-detail-row { display: flex; align-items: baseline; gap: 5px; margin: 4px 0; }
.rp-detail-label { font-size: 9px; color: #64748b; text-transform: uppercase; width: 34px; }
.rp-detail-val { font-size: 15px; font-weight: 700; }
.rp-detail-unit { font-size: 10px; color: var(--text-muted); margin-left: 1px; }
.rp-detail-sub { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

.rp-sec-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); font-weight: 600; margin-bottom: 10px;
}

/* Hourly scroll */
.rp-hourly {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148,163,184,0.08);
}
.rp-hour-scroll {
  display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px;
}
.rp-hc {
  min-width: 48px; padding: 5px 3px; border-radius: 6px;
  background: rgba(30, 41, 59, 0.4); text-align: center; flex-shrink: 0;
  cursor: pointer; transition: background 0.15s;
}
.rp-hc:hover { background: rgba(30, 41, 59, 0.7); }
.rp-hc-sel { background: rgba(56,189,248,0.12) !important; outline: 1px solid rgba(56,189,248,0.25); }
.rp-hc-time { font-size: 8px; color: var(--text-muted); margin-bottom: 2px; }
.rp-hc-ht { font-size: 8px; font-weight: 700; margin-top: 2px; line-height: 1.2; }
.rp-hc-wind { font-size: 8px; color: var(--text-muted); margin-top: 1px; line-height: 1.2; }
.rp-hc-unit { font-size: 7px; color: var(--text-muted); }

/* Daily outlook */
.rp-daily { padding: 14px 18px; }
.rp-day-labels {
  display: grid;
  grid-template-columns: 48px 8px 8px 8px 1fr 34px 34px 34px;
  gap: 4px; padding: 0 4px 4px;
}
.rp-day-col-label {
  font-size: 7px; color: #64748b; text-align: center;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.rp-day {
  display: grid;
  grid-template-columns: 48px 8px 8px 8px 1fr 34px 34px 34px;
  gap: 4px; align-items: center; padding: 8px 4px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.05);
  cursor: pointer; border-radius: 4px; transition: background 0.15s;
}
.rp-day:hover { background: rgba(30, 41, 59, 0.4); }
.rp-day-sel { background: rgba(56,189,248,0.08); }
.rp-day-name { font-size: 12px; font-weight: 600; }
.rp-day-date { font-size: 9px; color: #64748b; }
.rp-mini-dot { width: 7px; height: 7px; border-radius: 50%; }
.rp-bar-bg { height: 5px; background: rgba(148,163,184,0.12); border-radius: 3px; overflow: hidden; }
.rp-bar-fill { height: 100%; border-radius: 3px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .top-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }

  .rating-panel {
    width: 100%;
    right: -100%;
    top: 48px;
  }

  .legend {
    min-width: 160px;
  }
}
