:root {
  --bg: #f4f1ea;
  --bg-2: #fffdf8;
  --ink: #1c1917;
  --muted: #6b645c;
  --line: #d7d0c5;
  --accent: #0f6b5c;
  --accent-ink: #fff;
  --banner: #9a3412;
  --banner-ink: #fff7ed;
  --confirmed: #157a4b;
  --strong: #0f6b5c;
  --possible: #9a6b12;
  --composite: #6d4aa8;
  --unidentified: #5c5854;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 8px 24px rgba(28, 25, 23, 0.06);
  --radius: 10px;
  --header-h: auto;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
[hidden] { display: none !important; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#sample-banner {
  background: var(--banner);
  color: var(--banner-ink);
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  z-index: 20;
}
#sample-banner[hidden] { display: none; }
#sample-banner strong {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "brand nav"
    "tools tools";
  gap: 0.65rem 1.25rem;
  align-items: end;
  padding: 0.8rem 1rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  z-index: 10;
}
.brand { grid-area: brand; }
.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.view-nav {
  grid-area: nav;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem;
}
.view-nav button,
.map-switcher button,
.chips button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}
.view-nav button.active,
.map-switcher button.active,
.chips button.active {
  background: var(--accent);
  color: var(--accent-ink);
}
.toolbar {
  grid-area: tools;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.toolbar input[type="search"],
.toolbar select {
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}
.toolbar input[type="search"] { flex: 1 1 16rem; min-width: 10rem; }
.toolbar select { flex: 0 1 auto; }

.map-view {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 22rem;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "switch sidebar"
    "maps sidebar";
}
.map-switcher {
  grid-area: switch;
  display: none;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
}
.map-switcher button {
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.maps {
  grid-area: maps;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem 0.7rem;
  min-height: 0;
}
.map-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.map-panel h2 {
  margin: 0;
  padding: 0.5rem 0.75rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.map-caption {
  margin: 0;
  padding: 0.15rem 0.75rem 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.map-canvas { flex: 1; min-height: 0; position: relative; background: #d7e4ea; }
.game-map-stack,
.real-map-stack {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
.game-map-stack .map-canvas,
.real-map-stack .map-canvas { flex: 1; }
.map-credit {
  position: absolute;
  left: 0.5rem;
  bottom: 0.45rem;
  z-index: 6;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.3;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
}
.map-empty {
  position: absolute;
  left: 50%;
  bottom: 2.6rem;
  transform: translateX(-50%);
  margin: 0;
  z-index: 5;
  pointer-events: none;
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: calc(100% - 1.5rem);
}

.sidebar {
  grid-area: sidebar;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem 0.35rem;
}
.sidebar-head h2 { margin: 0; font-size: 0.95rem; }
.muted { color: var(--muted); font-size: 0.8rem; margin: 0; }
#feature-list-wrap, #feature-detail {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.feature-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 1rem;
}
.feature-list li { margin: 0; }
.feature-row {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  border-radius: 8px;
  padding: 0.55rem 0.55rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.6rem;
}
.feature-row:hover { background: var(--bg); }
.feature-row.active {
  background: #e7f3ef;
  border-color: #c5ddd6;
}
.feature-row .name { font-size: 0.88rem; font-weight: 600; grid-column: 1; }
.feature-row .meta { font-size: 0.75rem; color: var(--muted); grid-column: 1; }
.feature-row .badge { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.unplotted-note { font-style: italic; }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #ece8e1;
  color: var(--unidentified);
  white-space: nowrap;
}
.badge.confirmed { background: #d8f3e4; color: var(--confirmed); }
.badge.strong { background: #d5efe9; color: var(--strong); }
.badge.possible { background: #f8ebc8; color: var(--possible); }
.badge.composite { background: #ece3f8; color: var(--composite); }
.badge.unidentified { background: #ece8e1; color: var(--unidentified); }

.feature-detail { padding: 0.75rem 1rem 1.5rem; }
.detail-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.back-btn, .share-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.28rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
}
.feature-detail h2 { margin: 0 0 0.15rem; font-size: 1.1rem; line-height: 1.3; }
.feature-detail .id-line { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin: 0 0 0.75rem; }
.feature-detail h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.feature-detail p, .feature-detail li { font-size: 0.88rem; line-height: 1.45; }
.feature-detail ul { margin: 0; padding-left: 1.1rem; }
.kv { display: grid; gap: 0.25rem; }
.kv div { font-size: 0.88rem; }
.kv dt, .k { color: var(--muted); font-size: 0.75rem; }
.candidate {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  margin: 0.45rem 0;
  background: var(--bg);
}
.candidate.chosen { border-color: #b7d4cc; background: #f3faf7; }
.candidate h4 { margin: 0 0 0.25rem; font-size: 0.9rem; }
.ext-link { color: var(--accent); }
.share-toast { font-size: 0.75rem; color: var(--accent); margin-left: 0.35rem; }

.coverage-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.1rem 2rem;
  max-width: 72rem;
}
.coverage-intro h2 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.coverage-intro p { margin: 0 0 1rem; color: var(--muted); max-width: 42rem; font-size: 0.92rem; }
.region-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem 1rem;
  margin: 0 0 0.8rem;
}
.region-card h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.region-card.totals {
  border-color: #c5bbae;
  background: #f6f1e8;
}
.region-card.totals h3 { font-size: 1.05rem; }
.counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}
.count { background: var(--bg); border-radius: 8px; padding: 0.55rem 0.7rem; }
.count .n { display: block; font-size: 1.4rem; font-weight: 650; letter-spacing: -0.03em; }
.count .l { font-size: 0.75rem; color: var(--muted); }
.gap-table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; font-size: 0.85rem; }
.gap-table th, .gap-table td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); }
.gap-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chips button { border: 1px solid var(--line); background: var(--bg-2); font-size: 0.78rem; }
.unmapped { margin-top: 1.2rem; }
.empty { color: var(--muted); padding: 0.75rem 0.9rem; font-size: 0.9rem; }

.load-error {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: #7f1d1d;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  z-index: 50;
  max-width: min(36rem, calc(100% - 2rem));
}
.load-error[hidden] { display: none; }

/* Game map markers */
#game-map svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#game-map svg:active { cursor: grabbing; }
.gm-feat { cursor: pointer; }
.gm-feat .gm-hit { fill: transparent; stroke: transparent; }
.gm-label {
  font-family: var(--sans);
  font-size: 11px;
  fill: #1c1917;
  paint-order: stroke;
  stroke: #f4f1ea;
  stroke-width: 3px;
  pointer-events: none;
}

@media (max-width: 899px) {
  .site-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "nav"
      "tools";
    align-items: start;
  }
  .view-nav { justify-self: start; }
  .map-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1.2fr) minmax(11rem, 0.9fr);
    grid-template-areas:
      "switch"
      "maps"
      "sidebar";
  }
  .map-switcher { display: flex; }
  .maps { grid-template-columns: 1fr; padding-top: 0.4rem; }
  .maps.show-game .real-panel { display: none; }
  .maps.show-real .game-panel { display: none; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); }
  .counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .counts { grid-template-columns: 1fr; }
  .brand h1 { font-size: 1.05rem; }
}

.site-footer {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.35rem 1rem 0.5rem;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
.site-footer p { margin: 0.12rem 0; }
#feature-list-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#feature-list-wrap[hidden], #feature-detail[hidden], #map-view[hidden], #coverage-view[hidden], #examples-view[hidden] {
  display: none !important;
}
body[data-view="benchmark"] .toolbar,
body[data-view="examples"] .toolbar {
  display: none;
}
.feature-list-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}
#feature-list-spacer { position: relative; }
#feature-list-wrap .feature-list {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0 0.5rem;
  will-change: transform;
}
#feature-list-wrap .feature-list li { height: 68px; }
#feature-list-wrap .feature-row {
  height: 64px;
  overflow: hidden;
}
#feature-list-wrap .feature-row .name,
#feature-list-wrap .feature-row .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#unmapped-list .feature-row .name,
#unmapped-list .feature-row .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

blockquote.authority {
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 0.88rem;
  line-height: 1.45;
}
.mark-distinctive {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  background: #d5efe9;
  color: var(--strong);
  vertical-align: middle;
}
.evidence-figure {
  margin: 0.4rem 0 0.6rem;
  padding: 0;
}
.evidence-figure img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.evidence-credit, .credit-line {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.show-more {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  margin: 0.25rem 0.9rem 1rem;
}

#game-map { overflow: hidden; background: #2aa7b8; }
#game-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}
#game-map canvas.gm-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  z-index: 1;
}
#game-map canvas.gm-overlay:active { cursor: grabbing; }
.gm-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: #1c1917;
  color: #fffdf8;
  font-size: 0.72rem;
  line-height: 1.3;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  max-width: 16rem;
  transform: translate(10px, -120%);
  box-shadow: var(--shadow);
}

.maplibregl-ctrl-attrib {
  font-size: 10px;
  background: rgba(255, 253, 248, 0.92) !important;
  color: #1c1917 !important;
}
.maplibregl-ctrl-attrib a { color: #0f6b5c !important; }

.candidate.lead {
  background: #f7f3ea;
  border-style: dashed;
  border-color: #c8b896;
}
.candidate.lead h4 {
  color: #7a5c16;
  font-weight: 650;
}

.page-view { }
.live-coverage { margin: 0 0 1.4rem; }
.live-coverage h3,
.benchmark-section h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}
.cov-block { margin: 0 0 1rem; }
.cov-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.cov-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.cov-table th, .cov-table td {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.cov-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.cov-table tr:last-child td { border-bottom: 0; }
.cov-table a { color: var(--accent); text-decoration: none; }
.cov-table a:hover { text-decoration: underline; }
.cov-table .n { font-variant-numeric: tabular-nums; font-weight: 650; }
.benchmark-section { margin: 1.6rem 0 2rem; }
.benchmark-note {
  max-width: 42rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0 0 0.85rem;
}
.benchmark-md {
  max-width: 48rem;
  font-size: 0.92rem;
  line-height: 1.5;
}
.benchmark-md h1, .benchmark-md h2, .benchmark-md h3, .benchmark-md h4 {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
}
.benchmark-md pre, .benchmark-md code {
  font-family: var(--mono);
  font-size: 0.82rem;
}
.benchmark-md pre {
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}
.benchmark-empty { color: var(--muted); }
.examples-view { }
.example-cards {
  display: grid;
  gap: 1rem;
  max-width: 48rem;
}
.example-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.95rem 1rem 1.1rem;
}
.example-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
}
.example-card .example-kicker {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.example-card h4 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.05rem;
}
.example-card h4 a { color: inherit; text-decoration: none; }
.example-card h4 a:hover { color: var(--accent); text-decoration: underline; }
.example-card .id-line { margin: 0 0 0.5rem; }
.example-card h5 {
  margin: 0.7rem 0 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.example-card .evidence-figure img {
  width: auto;
  max-width: min(100%, 960px);
  max-height: none;
  height: auto;
  object-fit: contain;
}
@media (max-width: 520px) {
  .view-nav button { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
}
