:root {
  --bg: #0d1412;
  --bg-2: #151c1a;
  --card: #1b2321;
  --card-2: #232c29;
  --line: rgba(232, 220, 196, 0.12);
  --text: #f3ece0;
  --muted: #b7b0a3;
  --mint: #3ee0b0;
  --mint-dim: #1a8f72;
  --coral: #ff7a55;
  --gold: #e8c56b;
  --danger: #ff6b7a;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Sora", "Segoe UI", system-ui, sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; }
a { color: var(--mint); }
img { max-width: 100%; display: block; }
button, select, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.site-nav {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
}
.site-nav a.is-current {
  background: var(--mint);
  color: #06231b;
  border-color: transparent;
  font-weight: 600;
}
.contents { margin: 6px 0 0; font-size: 0.8rem; color: var(--text); line-height: 1.4; }
.req { margin: 4px 0 0; font-size: 0.75rem; color: var(--gold); }
.badge-type {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mint);
  font-weight: 600;
}
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 14px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.kicker {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: var(--mint);
}
h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.tag { margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; max-width: 38rem; }

.view-toggle {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.view-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  min-height: 40px;
  cursor: pointer;
}
.view-toggle button.is-on {
  background: var(--mint);
  color: #06231b;
  font-weight: 600;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.search input, select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 44px;
  outline: none;
}
.search input:focus, select:focus, button:focus-visible {
  box-shadow: 0 0 0 2px var(--mint);
}
.toggles { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.88rem; min-height: 40px; }
.check input { width: 18px; height: 18px; accent-color: var(--mint); }

.status { margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; }

.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 12px;
}
.map-wrap {
  position: relative;
  height: 42vh;
  min-height: 260px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #1a2a28;
  box-shadow: var(--shadow);
}
#map { height: 100%; width: 100%; background: #14211f; isolation: isolate; z-index: 0; }
.map-wrap { isolation: isolate; }
.list-wrap { min-height: 0; }
.list { display: flex; flex-direction: column; gap: 8px; }

.workspace[data-view="list"] .map-wrap { display: none; }
.workspace[data-view="map"] .list-wrap { display: none; }
.workspace[data-view="map"] .map-wrap {
  height: min(70vh, 640px);
  min-height: 360px;
}

.car {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px 8px 8px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.car:hover { background: var(--card-2); }
.car.is-selected { border-color: var(--mint); box-shadow: 0 0 0 1px var(--mint); }
.thumb {
  width: 112px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: #101816;
  flex-shrink: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
  padding: 6px;
  background: repeating-linear-gradient(-45deg, #141c1a, #141c1a 6px, #1a2421 6px, #1a2421 12px);
}
.meta h2 { margin: 0 0 2px; font-size: 0.98rem; font-weight: 600; line-height: 1.25; }
.meta .sub { margin: 0; color: var(--muted); font-size: 0.78rem; }
.nums {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}
.nums b { color: var(--text); font-weight: 600; }
.profit.pos { color: var(--mint); }
.profit.neg { color: var(--danger); }
.profit.zero { color: var(--gold); }
.pin-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 500;
}

.map-card {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 500;
  background: rgba(17, 24, 22, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 10px;
  align-items: start;
  box-shadow: var(--shadow);
  max-height: 46%;
  overflow: auto;
}
.map-card .detail { min-width: 0; }
.map-card .detail p { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.map-card img, .map-card .placeholder {
  width: 120px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}
.map-card h3 { margin: 0 0 2px; font-size: 0.95rem; }
.map-card p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.map-card .close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

/* Leaflet tweaks */
.leaflet-container { background: #14211f; font-family: var(--font); }
.leaflet-control-attribution {
  background: rgba(13, 20, 18, 0.85) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
  max-width: 70vw;
}
.map-wrap.has-card .leaflet-control-attribution {
  margin-bottom: 92px;
}
.leaflet-control-attribution a { color: var(--mint) !important; }
.leaflet-bar a { background: var(--card) !important; color: var(--text) !important; border: 0 !important; }
.leaflet-bar { border: 1px solid var(--line) !important; }

.pin {
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -22px;
}
.pin i {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  background: var(--coral);
  border: 2px solid #fff6e8;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.pin.is-on i {
  background: var(--mint);
  width: 20px;
  height: 20px;
}

.info {
  margin-top: 18px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 14px;
}
.info summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.info-body { color: var(--muted); font-size: 0.92rem; padding-bottom: 12px; line-height: 1.55; }
.info-body p, .info-body ol { margin: 0 0 10px; }
.foot { margin-top: 18px; color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.foot p { margin: 0 0 8px; }
.sources-label { font-weight: 600; color: var(--text); margin-top: 10px !important; }
.sources { margin: 0; padding-left: 18px; }
.empty { color: var(--muted); padding: 24px 8px; }

@media (min-width: 860px) {
  .controls { grid-template-columns: 1.4fr 0.8fr 0.8fr; align-items: center; }
  .toggles { grid-column: 1 / -1; }
  .workspace[data-view="split"] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    align-items: stretch;
    min-height: 70vh;
  }
  .workspace[data-view="split"] .map-wrap {
    height: 100%;
    min-height: 70vh;
    position: sticky;
    top: 12px;
  }
  /* Map-only: give .map-wrap an explicit height. height:100% on a wrap whose
     parent has no definite height made #map compute to 0px, so tiles and
     county names vanished in the full Map view. */
  .workspace[data-view="map"] {
    min-height: 70vh;
  }
  .workspace[data-view="map"] .map-wrap {
    height: 70vh;
    min-height: 70vh;
    position: sticky;
    top: 12px;
  }
  .list-wrap { overflow: auto; max-height: 75vh; padding-right: 4px; }
}

@media (max-width: 859px) {
  .map-card { grid-template-columns: 96px 1fr auto; }
  .map-card img, .map-card .placeholder { width: 96px; height: 48px; }
}

/* ---- Map UX: mobile sheet, clusters, selected pin ---- */
.sheet-handle {
  display: none;
}
.sheet-tools {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  grid-column: 3;
  grid-row: 1;
  min-width: 0;
}
.sheet-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nearby-btn {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2, var(--card));
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.nearby-btn:disabled,
.nearby-btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: default;
}
.sheet-body {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 12px;
  align-items: start;
  grid-column: 1 / 3;
  grid-row: 1;
  min-width: 0;
}
@media (min-width: 860px) {
  .map-card { grid-template-columns: 120px 1fr minmax(108px, auto); }
}
.pin-cluster { margin: 0; }

.pin.is-dim {
  opacity: 0.34;
  filter: saturate(0.55);
}
.pin.is-on {
  z-index: 600 !important;
}
.pin-cluster {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
  border: 2px solid #fff6e8;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
  cursor: pointer;
}
.pin-cluster span { line-height: 1; }

@media (prefers-reduced-motion: no-preference) {
  .pin.is-on i {
    animation: pin-pulse 1.7s ease-out infinite;
  }
}
@keyframes pin-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 227, 211, 0.65), 0 2px 6px rgba(0,0,0,0.45); }
  70% { box-shadow: 0 0 0 12px rgba(34, 227, 211, 0), 0 2px 6px rgba(0,0,0,0.45); }
  100% { box-shadow: 0 0 0 0 rgba(34, 227, 211, 0), 0 2px 6px rgba(0,0,0,0.45); }
}
@media (prefers-reduced-motion: reduce) {
  .pin.is-on i { animation: none; }
}

@media (max-width: 859px) {
  .pin.is-touch i {
    width: 20px;
    height: 20px;
    margin-top: 8px;
  }
  .pin.is-touch.is-on i {
    width: 24px;
    height: 24px;
    margin-top: 6px;
  }
  .pin.is-touch.t-Collectible i {
    width: 14px;
    height: 14px;
    margin-top: 8px;
    border-radius: 50%;
    transform: none;
  }

  body.has-sheet { overflow: hidden; }
  body.has-sheet .to-top { display: none !important; }

  body.has-sheet .map-wrap {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--sheet-nav-top, 56px);
    bottom: 0;
    height: auto !important;
    min-height: 0 !important;
    z-index: 1100;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  .map-card.is-sheet {
    --safe-b: env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--sheet-h, 58dvh) !important;
    max-height: var(--sheet-h, 85dvh) !important;
    border-radius: 18px 18px 0 0;
    padding: 0 12px calc(12px + var(--safe-b, 0px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    grid-template-columns: none;
    gap: 0;
    z-index: 1200;
    pointer-events: auto;
    touch-action: manipulation;
  }
  .map-card.is-sheet .sheet-handle {
    display: grid;
    place-items: center;
    flex: 0 0 24px;
    cursor: grab;
    touch-action: none;
  }
  .map-card.is-sheet .sheet-handle span {
    display: block;
    width: 42px;
    height: 5px;
    border-radius: 99px;
    background: rgba(255,255,255,0.35);
  }
  .map-card.is-sheet .sheet-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding-bottom: 6px;
  }
  .map-card.is-sheet .sheet-nav { flex: 1; order: 0; flex-direction: row; }
  .map-card.is-sheet .nearby-btn { min-height: 44px; font-size: 0.85rem; flex: 1; }
  .map-card.is-sheet .close { align-self: center; }
  .map-card.is-sheet .close { flex: 0 0 44px; }
  .map-card.is-sheet .sheet-body {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px;
    align-items: start;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    pointer-events: auto;
    min-height: 0;
    flex: 1 1 auto;
    padding-bottom: 8px;
  }
  .map-card.is-sheet .sheet-body > img,
  .map-card.is-sheet .sheet-body > .placeholder {
    width: 96px;
    height: 64px;
  }
  .map-card.is-sheet.is-expanded .sheet-body > img,
  .map-card.is-sheet.is-expanded .sheet-body > .placeholder {
    width: 100%;
    height: 120px;
    grid-column: 1 / -1;
  }
  .map-card.is-sheet.is-expanded .sheet-body .detail,
  .map-card.is-sheet.is-expanded .sheet-body > div {
    grid-column: 1 / -1;
  }
  .map-card.is-sheet.is-expanded .detail p,
  .map-card.is-sheet .detail p,
  .map-card.is-sheet .sheet-body p,
  .map-card.is-sheet .sheet-body .tip {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
  }
  .map-card.is-sheet .close { align-self: center; }

  body.has-sheet .map-wrap.has-card .leaflet-control-attribution {
    margin-bottom: 0 !important;
  }
  body.has-sheet .map-wrap.has-card .leaflet-bottom,
  body.page-loot.has-sheet .map-wrap.has-card .leaflet-bottom.leaflet-right {
    top: 8px;
    bottom: auto !important;
  }
}

/* real-life alias hit on result cards (search) */
.meta .alias-hit { margin: 2px 0 0; font-size: 0.74rem; color: var(--mint, #5ef2c8); font-weight: 600; }

/* 1-source pins (owner rule 2026-12-01) */
.unverified-flag { color: var(--gold, #e0b84a); font-weight: 600; white-space: nowrap; }
.map-card .approx.unverified a { color: inherit; text-decoration: underline; }
