:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel-bg: rgba(10, 14, 26, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e7ecf5;
  --text-dim: #8a93a8;
  --accent: #ffd166;
  --accent-strong: #fff4d6;
  --live: #37e28a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

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

/* Radial spotlight overlay for Ringerike-fokus. Positioned dynamically via JS. */
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 900ms ease;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 180px,
    rgba(3, 4, 10, 0.72) 520px,
    rgba(3, 4, 10, 0.88) 100%
  );
}

#vignette.on { opacity: 1; }

header#brand {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 8px 14px;
  z-index: 5;
}

.bolt {
  font-size: 22px;
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.7));
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; letter-spacing: 0.02em; }
.brand-sub { font-size: 11px; color: var(--text-dim); }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e2574c;
  margin-left: 4px;
  box-shadow: 0 0 6px rgba(226, 87, 76, 0.8);
  transition: background 300ms, box-shadow 300ms;
}
.status-dot.live {
  background: var(--live);
  box-shadow: 0 0 8px rgba(55, 226, 138, 0.85);
}

#panel {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 18px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 10px 18px;
  z-index: 5;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 28px);
  /* #4: panelbakgrunnen skal ikke sluke touch/pinch mot kartet under den —
     bare de faktiske knappene er interaktive. */
  pointer-events: none;
}
#panel button { pointer-events: auto; }

.panel-group { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.panel-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.btn-row { display: flex; gap: 6px; }

button {
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
  white-space: nowrap;
  /* #4: unngå at raske trykk på panelknapper tolkes som dobbelttrykk-zoom av mobilnettleseren */
  touch-action: manipulation;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
button:disabled { opacity: 0.35; cursor: default; }
button.active {
  background: var(--accent);
  color: #2a2000;
  border-color: var(--accent);
  font-weight: 600;
}
button.toggled {
  background: rgba(255, 209, 102, 0.22);
  border-color: var(--accent);
  color: var(--accent-strong);
}

#top-right {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  z-index: 5;
}

#btn-theme {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

#stats {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}
#stats #stat-count { color: var(--text); font-weight: 600; }
#stat-nearest { margin-top: 4px; color: var(--accent-strong); }
#stat-trend { margin-top: 4px; font-weight: 600; cursor: help; }
#stat-trend.approaching { color: #ff6b5e; }
#stat-trend.retreating { color: #7fd1a8; }
#stat-trend.stable { color: var(--text-dim); font-weight: 400; }
#stat-local { margin-top: 4px; color: var(--text-dim); cursor: help; font-size: 11px; }
#stat-local .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; background: var(--live); }
#stat-local.stale .dot { background: #e2574c; }
#stat-local .intensity.moderat { color: #ffd166; font-weight: 600; }
#stat-local .intensity.høy { color: #ff6b5e; font-weight: 700; }
#stat-weather { margin-top: 4px; color: var(--text-dim); cursor: help; font-size: 11px; }
#stat-weather.falling { color: #ff9f6b; }
.hidden { display: none; }

footer#attribution {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  z-index: 4;
}
footer#attribution a { color: rgba(255, 255, 255, 0.5); }

.maplibregl-ctrl-attrib { display: none; }

@media (max-width: 640px) {
  #panel { gap: 10px; padding: 8px 10px; bottom: 8px; }
  header#brand { top: 8px; left: 8px; padding: 6px 10px; }
  #top-right { top: 8px; right: 8px; }
  #stats { padding: 6px 10px; }
  #btn-theme { width: 30px; height: 30px; font-size: 14px; }
  footer#attribution { display: none; }
  /* #4: #panel wrapper til to rader på smale skjermer og dekker MapLibre sine
     +/- knapper visuelt (panelet er øverst i z-index) — løft +/- over panelet. */
  .maplibregl-ctrl-bottom-right { bottom: 140px; }
}
