:root {
  --panel-bg: rgba(22, 26, 34, 0.88);
  --panel-fg: #e8ecf2;
  --panel-muted: #9aa4b2;
  --accent: #3b82f6;
  --radius: 10px;
  font-family: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
}

#map {
  position: fixed;
  inset: 0;
  background: #0d1017;
}

.chrome {
  position: fixed;
  z-index: 1000;
  color: var(--panel-fg);
}

.panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

#titlebar {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-weight: 600;
  white-space: nowrap;
}

#banner {
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  max-width: min(90vw, 480px);
  text-align: center;
  color: #ffd166;
}

.pill {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: var(--panel-fg);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  min-width: 42px;
}

.pill:hover { border-color: rgba(255, 255, 255, 0.55); }

.pill.primary {
  background: var(--accent);
  border-color: var(--accent);
  font-size: 16px;
}

#controls {
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  width: min(92vw, 720px);
  box-sizing: border-box;
  flex-wrap: wrap;
}

#scrubber {
  flex: 1 1 180px;
  accent-color: var(--accent);
  min-width: 120px;
  height: 24px;
}

#clock {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.latest-tag {
  background: #16a34a;
  border-radius: 4px;
  font-size: 11px;
  padding: 1px 6px;
}

#opacityWrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--panel-muted);
}

#opacity {
  width: 80px;
  accent-color: var(--accent);
  height: 20px;
}

#legend {
  right: 10px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  padding: 8px 10px;
  font-size: 11px;
}

.legend-title {
  color: var(--panel-muted);
  margin-bottom: 6px;
  text-align: center;
}

.legend-bar {
  display: flex;
  flex-direction: column-reverse;
}

.legend-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 14px;
}

.legend-cell .swatch {
  width: 22px;
  height: 12px;
  border-radius: 2px;
}

.legend-cell .label {
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.value-popup .leaflet-popup-content-wrapper {
  background: #ffffff;
  color: #111722;
  font-size: 14px;
  font-weight: 600;
}

.value-popup .leaflet-popup-tip {
  background: #ffffff;
}

@media (max-width: 640px) {
  #legend { display: none; }
  #controls { gap: 8px; padding: 8px 10px; }
  #opacityWrap { display: none; }
}
