:root {
  --bg: #04050b;
  --panel: rgba(12, 14, 28, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e9e6f5;
  --muted: #8f8aa8;
  --accent: #ff9d5c;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }

#stars {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(70, 40, 120, 0.25), transparent 60%),
    radial-gradient(1px 1px at 12% 18%, #fff8, transparent),
    radial-gradient(1px 1px at 72% 12%, #fff6, transparent),
    radial-gradient(1px 1px at 88% 64%, #fff7, transparent),
    radial-gradient(1px 1px at 33% 82%, #fff5, transparent),
    radial-gradient(1.5px 1.5px at 56% 30%, #fff9, transparent),
    radial-gradient(1px 1px at 6% 58%, #fff6, transparent),
    radial-gradient(1px 1px at 92% 90%, #fff5, transparent),
    radial-gradient(1px 1px at 44% 6%, #fff6, transparent),
    radial-gradient(1px 1px at 22% 40%, #fff4, transparent),
    radial-gradient(1px 1px at 64% 92%, #fff6, transparent),
    radial-gradient(1px 1px at 80% 38%, #fff4, transparent);
}
#map { position: fixed; inset: 0; background: transparent; }

.panel {
  position: fixed; z-index: 2;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

#brand { top: 16px; left: 16px; width: 300px; padding: 16px 16px 14px; }
h1 {
  margin: 0; font-size: 22px; line-height: 1.15; letter-spacing: 0.01em; font-weight: 750;
  background: linear-gradient(90deg, #ffe7b8, #ff9d5c 45%, #e0479e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin: 2px 0 14px; color: var(--muted); font-size: 13px; }

input[type="search"], select {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--text); background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border); border-radius: 9px; outline: none;
}
input[type="search"]:focus, select:focus { border-color: rgba(255, 157, 92, 0.6); }
select option { background: #15172a; }

.search { position: relative; }
#search-results {
  list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; left: 0; right: 0; z-index: 3;
  background: #121427; border: 1px solid var(--panel-border); border-radius: 9px; max-height: 260px; overflow: auto;
}
#search-results li { padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 14px; }
#search-results li small { color: var(--muted); display: block; font-size: 12px; }
#search-results li:hover, #search-results li[aria-selected="true"] { background: rgba(255, 157, 92, 0.15); }

.field { display: block; margin-top: 12px; font-size: 12px; color: var(--muted); }
.field > span { display: flex; justify-content: space-between; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.06em; }
.field output { color: var(--text); text-transform: none; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 14px; cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }

#country-info { margin-top: 10px; font-size: 13px; line-height: 1.5; color: var(--muted); }
#country-info b { color: var(--text); font-size: 15px; }

#settings { top: 16px; right: 16px; width: 250px; padding: 12px 16px 16px; }
#settings .icon-btn {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 17px; cursor: pointer;
}
#settings .icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
#settings.collapsed { width: 46px; height: 46px; padding: 0; }
#settings.collapsed #settings-body { display: none; }
#settings-body > .field:first-child { margin-top: 4px; }

#legend { left: 16px; bottom: 28px; width: 260px; padding: 12px 14px; font-size: 12px; }
.legend-title { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 7px; }
#legend-bar { height: 8px; border-radius: 4px; }
.legend-scale { display: flex; justify-content: space-between; margin-top: 5px; }
#legend-res { margin-top: 6px; color: var(--muted); }

#tooltip {
  position: fixed; z-index: 4; pointer-events: none; padding: 9px 11px; font-size: 13px; line-height: 1.45;
  background: rgba(10, 11, 22, 0.92); border: 1px solid var(--panel-border); border-radius: 9px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); max-width: 260px;
}
#tooltip b { font-size: 16px; color: #ffd9a8; }
#tooltip .muted { color: var(--muted); }

#loading {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5;
  color: var(--muted); letter-spacing: 0.08em; transition: opacity 0.6s;
}
#loading.done { opacity: 0; pointer-events: none; }

.maplibregl-ctrl-attrib { background: rgba(10, 11, 22, 0.6) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: #b9b3d6 !important; }
.maplibregl-ctrl-group { background: var(--panel) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) opacity(0.8); }

@media (max-width: 720px) {
  #brand { left: 12px; right: 12px; top: 12px; width: auto; padding: 12px; }
  h1 { font-size: 19px; }
  .sub { margin-bottom: 8px; }
  #brand .field { display: inline-block; width: 100%; margin-top: 8px; }
  #settings { top: auto; bottom: 28px; right: 12px; }
  #settings:not(.collapsed) { left: 12px; width: auto; }
  #legend { left: 12px; bottom: 84px; width: 200px; }
}

.range-ends { display: flex; justify-content: space-between; margin-top: 2px; color: var(--muted); text-transform: none; letter-spacing: 0; }

#source {
  position: fixed; z-index: 2; right: 58px; bottom: 40px;
  font-size: 12px; color: var(--muted);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
#source a { color: var(--text); font-weight: 600; text-decoration: none; }
#source a:hover { text-decoration: underline; }
#source span { opacity: 0.7; }
