:root {
  --bg: #12100f;
  --panel: #1c1917;
  --line: #3a3330;
  --ink: #f5f0ea;
  --dim: #a39a92;
  --hot: #ff6b1a;
  --cold: #5ad1ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; color: inherit; }

#map { background: #0b0a09; }

body[data-view="national"] {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100%;
}

body[data-view="national"] #panel { grid-column: 1; grid-row: 1; }
body[data-view="national"] #map { grid-column: 2; grid-row: 1; min-height: 0; height: 100%; }

#panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 16px 16px 24px;
}

#panel h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

#panel p { margin: 6px 0 0; color: var(--dim); }

#panel a { color: var(--cold); }

.totals { color: var(--ink); font-variant-numeric: tabular-nums; }

.mark { color: var(--hot); }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-top: 14px;
}

.filters label, .filters fieldset {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  color: var(--dim);
}

.filters fieldset {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.filters legend { padding: 0 4px; }

.filters input, .filters select {
  background: #100e0d;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

.filters fieldset label { flex-direction: row; align-items: center; gap: 6px; }

.count { font-variant-numeric: tabular-nums; }

.fire-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.fire {
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}

.fire strong, .fire span { display: block; }

.fire span { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }

.fire:hover, .fire.on, .fire:focus-visible {
  border-color: var(--line);
  background: #262220;
}

.foot { font-size: 13px; }

/* Leaflet writes position:relative inline at startup, which would collapse this map to 0 height. */
body[data-view="event"] #map { position: absolute !important; inset: 0; }

body[data-view="event"] #panel {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 120px);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.stats { margin-top: 10px; }

.stats .k {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}

.stats .k span:first-child { color: var(--dim); }
.stats .k span:last-child { font-weight: 650; }

#legend, #controls {
  position: absolute;
  z-index: 1000;
  background: rgba(28, 25, 23, 0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
}

#legend {
  right: 12px;
  bottom: 92px;
  padding: 10px 12px;
  font-size: 12px;
}

#legend p { margin: 0 0 6px; color: var(--dim); }

#legend i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 6px;
}

#controls {
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  flex-wrap: wrap;
}

#clock { min-width: 180px; font-variant-numeric: tabular-nums; font-weight: 650; }
#clock small { display: block; color: var(--dim); font-weight: 400; }

#controls input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--hot); }

button {
  background: var(--hot);
  color: #160d06;
  border: 0;
  border-radius: 7px;
  padding: 7px 14px;
  font-weight: 650;
  cursor: pointer;
}

button.ghost { background: #2b2523; color: var(--ink); border: 1px solid var(--line); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--cold);
  outline-offset: 2px;
}

.leaflet-top.leaflet-right { z-index: 1001; }

.trail { font-size: 13px; color: var(--dim); }

@media (max-width: 720px) {
  body[data-view="national"] {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(240px, 52vh) minmax(0, 1fr);
  }

  body[data-view="national"] #panel,
  body[data-view="national"] #map { grid-column: 1; }
  body[data-view="national"] #map { grid-row: 1; height: auto; }
  body[data-view="national"] #panel { grid-row: 2; }

  #panel { border-right: 0; border-top: 1px solid var(--line); }

  body[data-view="event"] #panel {
    max-height: 38vh;
  }

  #legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
