:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: #101a2b;
  --panel-2: #16243b;
  --text: #edf2ff;
  --muted: #9db0cf;
  --accent: #7dd3fc;
  --accent-2: #c084fc;
  --border: #223555;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: linear-gradient(180deg, #09111e 0%, #0d1526 100%);
  color: var(--text);
}
.shell { max-width: 1440px; margin: 0 auto; padding: 20px; }
.hero, .card {
  background: rgba(16, 26, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.hero {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; margin-bottom: 8px; }
h1 { margin: 0 0 10px; font-size: 34px; }
p { margin: 0; color: var(--muted); max-width: 840px; }
.source-link {
  color: #08111f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  text-decoration: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 600;
  white-space: nowrap;
}
.presets, .controls, .sidebar { padding: 18px; }
.presets { margin-bottom: 18px; }
.preset-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.preset-header h2 { margin: 4px 0 0; font-size: 22px; }
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.preset-button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.preset-button.active {
  background: linear-gradient(135deg, rgba(125,211,252,0.18), rgba(192,132,252,0.16));
  border-color: #5b7fb2;
}
.controls { margin-bottom: 18px; }
.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.mode-panel { display: contents; }
.field-wide { grid-column: span 2; }
.group-title { grid-column: 1 / -1; }
.group-title label {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  margin-bottom: 0;
}
.field label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.field select, .field div, .field input {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
}
.field input::placeholder { color: #7f91af; }
.field.stat div { font-weight: 700; }
.hidden { display: none !important; }
.mode-chip {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(125,211,252,0.12);
  color: var(--accent);
  font-size: 12px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 420px);
  gap: 18px;
}
.map-wrap { padding: 10px; position: relative; }
.map-toolbar {
  position: absolute;
  z-index: 500;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.map-pill {
  pointer-events: auto;
  background: rgba(8, 17, 31, 0.82);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
}
.map-pill strong { color: white; }
#map { height: 72vh; border-radius: 16px; overflow: hidden; }
.sidebar h2, .sidebar h3 { margin-top: 0; }
.muted { color: var(--muted); }
#ranking { margin: 14px 0 0; padding-left: 20px; }
#ranking li { margin-bottom: 10px; color: var(--text); }
#ranking .line2 { color: var(--muted); font-size: 13px; }
.legend.inset, .help.inset, .hover.inset {
  margin: 12px 0 18px;
  padding: 14px;
  background: var(--panel-2);
  border-radius: 14px;
  border: 1px solid var(--border);
}
.legend-swatch { display:inline-block; width:16px; height:16px; border-radius:4px; margin-right:8px; vertical-align:middle; border:1px solid rgba(255,255,255,0.15); }
#legendBody > div { color: var(--muted); margin-bottom: 8px; }
#hoverDetails strong { color: var(--text); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0f172a; color: var(--text); }
.popup-title { font-weight: 700; margin-bottom: 6px; }
.popup-muted { color: var(--muted); font-size: 13px; }
@media (max-width: 1000px) {
  .controls-grid, .layout { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .hero, .preset-header { flex-direction: column; }
  .preset-buttons { justify-content: flex-start; }
  #map { height: 56vh; }
}
@media (max-width: 640px) {
  .shell { padding: 12px; }
  .hero, .card { border-radius: 16px; }
  .hero { padding: 18px; }
  h1 { font-size: 28px; }
  .map-toolbar {
    position: static;
    margin: 0 0 10px;
    flex-direction: column;
  }
  #map { height: 52vh; }
  #ranking { padding-left: 18px; }
}
