:root {
  --bg-0: #070b12;
  --bg-1: #0d1522;
  --panel: rgba(10, 16, 28, 0.72);
  --stroke: rgba(180, 210, 255, 0.14);
  --text: #e8eef8;
  --muted: #8b9bb3;
  --amber: #f0c45a;
  --plasma: #5ce1ff;
  --hot: #ffb020;
  --warn: #ff6b4a;
  --ok: #3dd68c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
}

#map {
  position: absolute;
  inset: 0;
}

.atmosphere {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(92, 225, 255, 0.08), transparent 55%),
    radial-gradient(900px 500px at 90% 10%, rgba(255, 176, 32, 0.07), transparent 50%),
    linear-gradient(180deg, rgba(7, 11, 18, 0.15), rgba(7, 11, 18, 0.55) 70%, rgba(7, 11, 18, 0.78));
}

.brand-bar,
.panel,
.scrubber,
.toast {
  position: absolute;
  z-index: 3;
}

.brand-bar {
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  pointer-events: auto;
  padding: 12px 16px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: rise 0.7s ease both;
}

.brand-mark {
  width: 14px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff6c8, var(--hot) 35%, var(--warn) 70%, transparent);
  box-shadow: 0 0 24px rgba(255, 176, 32, 0.55);
  animation: pulse 2.4s ease-in-out infinite;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.live-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(16px);
  font-size: 0.82rem;
  color: var(--muted);
  animation: rise 0.7s ease 0.08s both;
}

.live-pill.on {
  color: var(--ok);
}

.live-pill.off {
  color: var(--warn);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.5);
}

.live-pill.on .live-dot {
  background: var(--ok);
  animation: ping 1.6s ease infinite;
}

.panel {
  top: 110px;
  left: 18px;
  width: min(380px, calc(100vw - 36px));
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise 0.75s ease 0.12s both;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.controls {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.row.check {
  grid-template-columns: auto 1fr;
}

.row span {
  color: var(--muted);
}

select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.chart-block {
  margin-top: 16px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.chart-block h2,
.legend h2 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

#timelineChart {
  width: 100%;
  height: 110px;
  display: block;
}

.legend {
  margin-top: 14px;
}

.legend-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fff7c2, #ffb020 22%, #ff6b4a 48%, #7a3cff 78%, #2a3550);
  margin: 8px 0 6px;
}

.legend-bar.obcine {
  background: linear-gradient(90deg, rgba(92, 225, 255, 0.12), #5ce1ff 30%, #f0c45a 60%, #ff6b4a 82%, #c0264f);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
}

.obcine-top {
  margin-top: 16px;
}

.top-list {
  list-style: none;
  margin: 8px 0 14px;
  padding: 0;
  display: grid;
  gap: 5px;
}

.top-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}

.top-list li:hover {
  border-color: rgba(92, 225, 255, 0.3);
  cursor: pointer;
}

.top-list .rank {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  width: 1.4em;
  flex-shrink: 0;
}

.top-list .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-list .val {
  font-family: var(--font-mono);
  color: var(--hot);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.attrib {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.archive-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 176, 32, 0.28);
  background: rgba(255, 176, 32, 0.08);
  color: #ffd166;
  font-size: 0.78rem;
  line-height: 1.45;
}

.scrubber {
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: rise 0.8s ease 0.18s both;
}

.play,
.ghost {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 12px;
  height: 42px;
  min-width: 42px;
  cursor: pointer;
  font: inherit;
}

.play:hover,
.ghost:hover {
  border-color: rgba(92, 225, 255, 0.35);
}

.ghost {
  padding: 0 12px;
  white-space: nowrap;
}

.scrubber-main {
  flex: 1;
  min-width: 0;
}

.scrubber-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.range-wrap {
  position: relative;
  height: 28px;
}

.range-wrap input[type="range"] {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  appearance: none;
  background: transparent;
  pointer-events: none;
  height: 28px;
  margin: 0;
}

.range-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--plasma);
  box-shadow: 0 0 0 4px rgba(92, 225, 255, 0.18);
  cursor: grab;
}

.range-wrap input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.range-wrap input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--plasma);
  cursor: grab;
}

.toast {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 22, 36, 0.92);
  border: 1px solid var(--stroke);
  font-size: 0.85rem;
}

.maplibregl-popup-content {
  background: #101826;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.maplibregl-popup-tip {
  border-top-color: #101826 !important;
}

.maplibregl-ctrl-attrib {
  background: transparent !important;
  color: var(--muted) !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.35);
  }
}

@keyframes ping {
  0% {
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(61, 214, 140, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0);
  }
}

@media (max-width: 820px) {
  .panel {
    top: auto;
    bottom: 110px;
    max-height: 38vh;
    width: calc(100vw - 36px);
  }

  .brand h1 {
    font-size: 1.55rem;
  }

  .tagline {
    display: none;
  }

  .scrubber {
    flex-wrap: wrap;
  }
}
