:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #69716d;
  --line: #e5e3dd;
  --sea: #f3f2ee;
  --land: #e4e2db;
  --state-line: #f3f2ee;
  --dot-empty: #fbfaf7;
  --dot-empty-line: #8c938f;
  --accent: #2f6f4f;
  --accent-soft: #e3efe8;
  --shadow: 0 8px 24px rgb(20 30 25 / 0.16), 0 1px 4px rgb(20 30 25 / 0.1);
  --chips-h: 56px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --surface: #1b1f1d;
    --text: #e8ebe9;
    --muted: #9ba49f;
    --line: #2b302d;
    --sea: #161a18;
    --land: #2a302c;
    --state-line: #161a18;
    --dot-empty: #161a18;
    --dot-empty-line: #7c8580;
    --accent: #7cc39b;
    --accent-soft: #1f3329;
    --shadow: 0 8px 24px rgb(0 0 0 / 0.55), 0 1px 4px rgb(0 0 0 / 0.4);
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.top {
  margin: 0;
  padding: 18px 16px 2px;
  font-size: 1.375rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

/* Member chips: one row that scrolls sideways, pinned to the top */
.chips {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  height: var(--chips-h);
  align-items: center;
  padding: 0 16px;
  overflow-x: auto;
  background: var(--bg);
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.chip .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.chip .sw.all { background: conic-gradient(var(--stops)); }
.chip .ct { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

/* Map: full-bleed on phones, its own pan/zoom surface */
.map-box {
  position: relative;
  height: clamp(300px, 100vw, 72svh);
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--sea);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  scroll-margin-top: calc(var(--chips-h) + 8px);
}
@media (min-width: 640px) {
  .map-wrap { padding: 0 16px; }
  .map-box {
    height: clamp(360px, min(100vw - 32px, 1008px) * 0.74, 78svh);
    border: 1px solid var(--line);
    border-radius: 16px;
  }
}
#map { display: block; width: 100%; height: 100%; cursor: grab; }
.map-box.dragging #map { cursor: grabbing; }
#map .land { fill: var(--land); }
#map .borders {
  fill: none;
  stroke: var(--state-line);
  stroke-width: 1;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.dot { cursor: pointer; }
.dot:focus { outline: none; }
.dot .ring { fill: none; stroke: transparent; stroke-width: 0.45; }
.dot.selected .ring,
.dot:focus-visible .ring { stroke: var(--text); }
.dot.faded { opacity: 0.45; }
.mark-empty { fill: var(--dot-empty); stroke: var(--dot-empty-line); stroke-width: 0.3; }
.mark-edge { fill: none; stroke: var(--sea); stroke-width: 0.2; }

.zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}
.zoom button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
  cursor: pointer;
}
.zoom button[hidden] { display: none; }
.zoom button:disabled { opacity: 0.4; cursor: default; }
.zoom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.territories {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
}
.terr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8125rem;
  cursor: pointer;
}
.terr.selected { border-color: var(--text); }
.terr.faded { opacity: 0.55; }
svg.mini { width: 12px; height: 12px; flex: none; overflow: visible; }

/* Label for the selected park, pinned next to its dot */
.pop {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  width: max-content;
  max-width: min(240px, calc(100% - 16px));
  padding: 9px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  touch-action: auto;
}
.pop[hidden] { display: none; }
.pop h2 { margin: 0 0 4px; font-size: 0.9375rem; line-height: 1.3; }
.pop h2:focus { outline: none; }
.pop ul { margin: 0 0 6px; padding: 0; list-style: none; }
.pop li { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
.pop li .year { margin-left: auto; padding-left: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pop li.none { color: var(--muted); }
.pop a { font-weight: 550; text-decoration: none; }

/* List */
.list-wrap { padding: 20px 16px 0; }
.seg {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 3px;
  border-radius: 999px;
  background: var(--land);
}
.seg button {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}
.list { margin: 0; padding: 0; list-style: none; }
@media (min-width: 760px) {
  .list { columns: 2; column-gap: 32px; }
}
.list li { break-inside: avoid; border-bottom: 1px solid var(--line); }
.row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.row.selected { background: var(--accent-soft); }
.row-text { flex: 1; min-width: 0; }
.row-name { display: block; font-weight: 550; }
.row-meta { display: block; color: var(--muted); font-size: 0.8125rem; }
.row.faded { opacity: 0.45; }
.pips { display: inline-flex; gap: 4px; flex: none; }
.pip { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

.error { margin: 16px; color: var(--muted); }
