:root {
  --panel-bg: rgba(18, 24, 31, 0.88);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text-main: #f5f7fa;
  --text-muted: #c7d0da;
  --accent: #ffb347;
  --danger: #ff6b57;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1117;
  color: var(--text-main);
}

body {
  overflow: hidden;
}

#map {
  width: 100vw;
  height: 100vh;
}

.top-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 3;
  width: min(430px, calc(100vw - 32px));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.top-panel h1 {
  margin: 0 0 6px 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.top-panel p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 16px;
  color: #ffffff;
}

.stat span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.disclaimer-panel {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 181, 71, 0.22);
  background: rgba(255, 179, 71, 0.08);
  color: #f2d6b0;
  font-size: 12px;
  line-height: 1.45;
}

.legend {
  position: absolute;
  left: 16px;
  bottom: 18px;
  z-index: 3;
  width: 288px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  font-size: 13px;
}

.legend-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
  color: var(--text-muted);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 14px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.dot-faded {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.28));
}

.maplibregl-popup-content {
  padding: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  min-width: 280px;
  max-width: 340px;
}

.maplibregl-popup-close-button {
  color: #ffffff;
  font-size: 20px;
  padding: 8px 10px;
}

.fire-popup {
  color: #17202a;
  background: #ffffff;
}

.fire-popup-header {
  padding: 14px 16px 12px 16px;
  color: white;
}

.fire-popup-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  padding-right: 22px;
}

.fire-popup-header .subtitle {
  margin-top: 5px;
  font-size: 12px;
  opacity: 0.9;
}

.fire-popup-body {
  padding: 12px 16px 14px 16px;
  font-size: 13px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.popup-metric {
  background: #f3f5f7;
  border-radius: 10px;
  padding: 8px;
}

.popup-metric span {
  display: block;
  font-size: 11px;
  color: #65717e;
  margin-bottom: 2px;
}

.popup-metric strong {
  font-size: 14px;
  color: #17202a;
}

.popup-link {
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
  background: #17202a;
  color: #ffffff;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
  font-size: 13px;
}

.popup-button {
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
  background: #44546a;
  color: #ffffff;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}

.popup-button.secondary {
  background: #6b7280;
}

.map-controls {
  position: absolute;
  top: 16px;
  right: 58px;
  z-index: 4;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin-bottom: 10px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.home-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.14);
}

.popup-button:hover {
  background: #586b84;
}

.popup-button.secondary:hover {
  background: #7b8492;
}

.popup-link:hover {
  background: #2d3a47;
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(340px, calc(100vw - 32px));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.control-group {
  display: grid;
  gap: 6px;
}

.control-group label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.control-group select {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  width: 100%;
}

.control-group option {
  color: #17202a;
}

@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .legend {
    display: none;
  }

  .map-controls {
    top: auto;
    right: 16px;
    bottom: 16px;
    width: min(320px, calc(100vw - 32px));
  }

  .control-panel {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .top-panel {
    width: calc(100vw - 32px);
  }
}
