/* ZombieNet survivor registry: a dark, muted "survival dossier" look. No external assets. */
:root {
  --bg: #11140f;
  --bg-2: #171b13;
  --panel: #1c2117;
  --panel-2: #222819;
  --line: #333b29;
  --line-2: #434d36;
  --text: #d9dccd;
  --muted: #8f957f;
  --accent: #8fae5f;
  --accent-2: #6d8a45;
  --online: #7bd65a;
  --amber: #c9a24a;
  --blood: #b2503f;
  --town: #6f7f8f;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--sans);
  color: var(--text);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at top, #1d2416 0%, var(--bg) 60%) fixed;
  background-color: var(--bg);
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, select:focus-visible, .map:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.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;
}

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.9rem clamp(0.75rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1a2014, #141810);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  font-size: 1.7rem; line-height: 1; color: var(--accent);
  text-shadow: 0 0 12px rgba(143, 174, 95, 0.35);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: 1.1rem; }
.brand-sub { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.worldbar { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin: 0; }
.wb-item { display: flex; flex-direction: column; min-width: 0; }
.wb-item dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.wb-item dd { margin: 0; font-family: var(--mono); font-size: 0.88rem; }
#wb-feed.stale { color: var(--amber); cursor: help; }

.banner {
  margin: 0.75rem clamp(0.75rem, 3vw, 2rem) 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid #6b4a2a;
  background: #2a1f14;
  color: #e6c79a;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

/* ── Layout ────────────────────────────────────────────── */
main { padding: 1rem clamp(0.75rem, 3vw, 2rem) 2rem; max-width: 1280px; margin: 0 auto; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; margin: 0.4rem 0 0.8rem; }
.section-title, .panel-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.panel-title { font-size: 0.85rem; margin-bottom: 0.7rem; border-bottom: 1px dashed var(--line-2); padding-bottom: 0.4rem; }
.sort-label { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.5rem; }
select {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 0.25rem 0.5rem;
}
.loading { color: var(--muted); font-style: italic; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 18px rgba(0, 0, 0, 0.25);
  min-width: 0;
}
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 0 1rem; }

/* ── Roster ────────────────────────────────────────────── */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 0.9rem; margin-bottom: 1.5rem; }
.card {
  display: flex; flex-direction: column; gap: 0.55rem;
  padding: 0.85rem 0.95rem;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
  min-width: 0;
}
.card:hover, .card:focus-visible { border-color: var(--accent-2); transform: translateY(-1px); }
.card.is-online { border-left-color: var(--online); }
.card-head { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.card-name { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-ach { font-family: var(--mono); font-size: 0.85rem; color: var(--amber); white-space: nowrap; }
.card-sub { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.2rem 0.8rem; font-size: 0.8rem; color: var(--muted); }
.card-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.metric { display: flex; flex-direction: column; background: rgba(0, 0, 0, 0.18); border-radius: 4px; padding: 0.3rem 0.45rem; min-width: 0; }
.metric-v { font-family: var(--mono); font-size: 1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-l { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; vertical-align: middle; }
.dot.on { background: var(--online); box-shadow: 0 0 0 3px rgba(123, 214, 90, 0.18), 0 0 8px rgba(123, 214, 90, 0.6); }
.dot.off { border: 2px solid var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.76rem; padding: 0.12rem 0.5rem;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: rgba(0, 0, 0, 0.2); color: var(--text);
}
.chip b { font-family: var(--mono); color: var(--accent); }
.chip.trait.positive { border-color: #4f6a35; color: #b9d58f; }
.chip.trait.negative { border-color: #6b3a30; color: #e09a8a; }
.chip.trait.profession { border-color: #6b5a2c; color: #e2c47c; }
.legend { margin: 0.8rem 0 0; color: var(--muted); }

/* ── Dossier ───────────────────────────────────────────── */
.back { display: inline-block; margin: 0.2rem 0 0.8rem; font-family: var(--mono); font-size: 0.85rem; text-decoration: none; }
.back:hover { text-decoration: underline; }
.dossier-head { position: relative; overflow: hidden; }
.dossier-name { margin: 0 0 0.2rem; font-size: clamp(1.4rem, 5vw, 2rem); line-height: 1.2; }
.dossier-sub { margin: 0 0 0.3rem; color: var(--muted); }
.stamp {
  position: absolute; top: 0.9rem; right: 0.9rem;
  font-family: var(--mono); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.2em;
  padding: 0.15rem 0.5rem; border: 2px solid currentColor; border-radius: 3px;
  color: var(--muted); transform: rotate(4deg); opacity: 0.8;
}
.is-online .stamp, .dossier-head .stamp { pointer-events: none; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 0.55rem; }
.stat { display: flex; flex-direction: column; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); border-radius: 4px; padding: 0.5rem 0.6rem; min-width: 0; }
.stat-l { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.stat-v { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; }
.stat-n { font-size: 0.74rem; color: var(--muted); }
.stat.bad { border-color: #6b3a30; }
.stat.bad .stat-v, .stat.bad .stat-n { color: var(--blood); }

.skills { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.skill { display: grid; grid-template-columns: minmax(0, 8.5rem) 1fr 1.6rem; align-items: center; gap: 0.6rem; }
.skill-name { font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-lvl { font-family: var(--mono); text-align: right; color: var(--accent); }
.pips { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; min-width: 0; }
.pip { height: 0.6rem; border-radius: 2px; background: #2a3022; border: 1px solid #343c2b; }
.pip.on { background: linear-gradient(180deg, #a3c46f, var(--accent-2)); border-color: #7d9a50; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0 0 0.8rem; }
.kv dt { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 0.9rem; min-width: 0; }
.btn {
  display: inline-block; padding: 0.4rem 0.8rem; margin-bottom: 0.8rem;
  border: 1px solid var(--accent-2); border-radius: 4px;
  background: rgba(143, 174, 95, 0.1); color: var(--accent);
  text-decoration: none; font-family: var(--mono); font-size: 0.85rem;
}
.btn:hover { background: rgba(143, 174, 95, 0.2); }

.progress { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.prog-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.2rem 0.8rem; }
.prog-name { font-weight: 600; }
.prog-num { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.prog p { margin: 0.2rem 0 0; }
.bar { display: block; height: 0.55rem; margin-top: 0.3rem; border-radius: 3px; background: #262c1f; border: 1px solid #343c2b; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: repeating-linear-gradient(135deg, #8fae5f 0 6px, #7d9a50 6px 12px); }

.ach-summary { margin-bottom: 0.8rem; }
.ach-count { font-family: var(--mono); }
.ach-count b { font-size: 1.3rem; color: var(--amber); }
.ach-cat { margin-top: 1rem; }
.ach-cat-title { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 600; }
.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 0.45rem; }
.badge {
  display: flex; gap: 0.55rem; align-items: flex-start;
  padding: 0.5rem 0.6rem; border-radius: 4px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); min-width: 0;
}
.badge.earned { border-color: #5d5328; background: linear-gradient(180deg, rgba(201, 162, 74, 0.1), rgba(0, 0, 0, 0.15)); }
.badge.locked { opacity: 0.45; filter: grayscale(1); }
.badge-emoji { font-size: 1.35rem; line-height: 1.2; flex: none; }
.badge-body { display: flex; flex-direction: column; min-width: 0; }
.badge-name { font-weight: 600; font-size: 0.86rem; }
.badge-desc { font-size: 0.76rem; color: var(--muted); }
.badge-reward { font-family: var(--mono); font-size: 0.7rem; color: var(--amber); margin-top: 0.15rem; }

/* ── Map ───────────────────────────────────────────────── */
.map-panel { margin-top: 0.5rem; }
.map-wrap { position: relative; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: #0e110c; }
.map { display: block; width: 100%; height: auto; max-height: 78vh; cursor: grab; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.map.zoomed { touch-action: none; }
.map:active { cursor: grabbing; }
.detail-map .map { max-height: 60vh; }
.m-grid line { stroke: #1d2318; }
.m-town rect { fill: rgba(111, 127, 143, 0.12); stroke: var(--town); stroke-dasharray: 6 4; }
.m-town:hover rect { fill: rgba(111, 127, 143, 0.22); }
.m-town-label { fill: #a8b6c3; font-family: var(--mono); font-weight: 700; letter-spacing: 0.06em; }
.m-pin path { fill: var(--amber); stroke: #1a1508; }
.m-pin:hover path { fill: #f0c866; }
.m-pin-label { fill: #e2c47c; font-family: var(--mono); }
.m-player circle { stroke: var(--online); }
.m-player.on circle { fill: var(--online); stroke: #0e110c; }
.m-player.off circle { fill: #0e110c; stroke: #cfd5c0; }
.m-player:hover circle { stroke: #fff; }
.m-player .m-focus-ring { fill: none; stroke: var(--amber); }
.m-player.on .m-focus-ring, .m-player.off .m-focus-ring { fill: none; stroke: var(--amber); }
.m-player-label { fill: #cfd5c0; font-family: var(--sans); font-weight: 600; }
.m-player-label.on { fill: #b7f09c; }
.m-labels text, .m-town-label, .m-scale text {
  paint-order: stroke; stroke: #0e110c; stroke-width: 3px; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; pointer-events: none;
}
.m-scale path { fill: none; stroke: var(--muted); }
.m-scale text { fill: var(--muted); font-family: var(--mono); }
.map-controls { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; }
.map-btn {
  width: 2rem; height: 2rem; font-size: 1.05rem; line-height: 1;
  color: var(--text); background: rgba(28, 33, 23, 0.92);
  border: 1px solid var(--line-2); border-radius: 4px; cursor: pointer;
}
.map-btn:hover { border-color: var(--accent); }
.compass {
  position: absolute; top: 0.5rem; left: 0.5rem;
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--mono); font-size: 0.75rem; line-height: 1; color: var(--muted);
  padding: 0.3rem 0.4rem; background: rgba(14, 17, 12, 0.8); border: 1px solid var(--line); border-radius: 4px;
}
.map-note { margin: 0.5rem 0 0; }
.legend-item { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
.lg { display: inline-block; width: 0.65rem; height: 0.65rem; }
.lg-on { border-radius: 50%; background: var(--online); }
.lg-off { border-radius: 50%; border: 2px solid #cfd5c0; }
.lg-pin { background: var(--amber); transform: rotate(45deg) scale(0.8); }
.lg-town { border: 1px dashed var(--town); background: rgba(111, 127, 143, 0.15); }

.tooltip {
  position: fixed; z-index: 50; max-width: min(280px, 90vw);
  padding: 0.45rem 0.6rem; border-radius: 4px;
  background: rgba(16, 19, 13, 0.97); border: 1px solid var(--line-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  font-size: 0.8rem; pointer-events: none;
  display: flex; flex-direction: column;
}
.tooltip[hidden] { display: none; }
.tooltip strong { color: var(--text); }
.tooltip span { color: var(--muted); font-family: var(--mono); font-size: 0.75rem; }

.footer { padding: 1rem clamp(0.75rem, 3vw, 2rem) 2rem; color: var(--muted); font-size: 0.78rem; text-align: center; border-top: 1px solid var(--line); }

@media (max-width: 520px) {
  body { font-size: 14px; }
  .topbar { position: static; }
  .worldbar { gap: 0.35rem 0.9rem; }
  .skill { grid-template-columns: minmax(0, 6.5rem) 1fr 1.4rem; gap: 0.4rem; }
  .stamp { top: 0.6rem; right: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}
