/* The live map's chrome, in the website's look (web/static/site.css): same tokens, fonts, sharp corners and the
   zn-theme light/dark switch. The map itself (canvas and 3D labels) keeps its own colours, tuned for the terrain. */
:root {
  --bg: #e9e8e3;
  --panel: rgb(244 243 239 / .94);
  --panel-solid: #f4f3ef;
  --surface-2: #dcdad3;
  --line: #c4c2ba;
  --text: #19191b;
  --muted: #505056;
  --accent: #b3301d;
  --accent-ink: #fbfaf7;
  --accent-soft: rgb(179 48 29 / .1);
  --good: #2f7a3a;
  --bad: #b3301d;
  --ink-line: #19191b;
  --font: "Barlow", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214; --panel: rgb(26 26 29 / .94); --panel-solid: #1a1a1d; --surface-2: #242428; --line: #313136;
    --text: #ebeae5; --muted: #a3a29d; --accent: #e0553e; --accent-ink: #180b08; --accent-soft: rgb(224 85 62 / .12);
    --good: #5cc06c; --bad: #e0553e; --ink-line: #000; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121214; --panel: rgb(26 26 29 / .94); --panel-solid: #1a1a1d; --surface-2: #242428; --line: #313136;
  --text: #ebeae5; --muted: #a3a29d; --accent: #e0553e; --accent-ink: #180b08; --accent-soft: rgb(224 85 62 / .12);
  --good: #5cc06c; --bad: #e0553e; --ink-line: #000; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { display: grid; grid-template: "top top" auto "stage side" 1fr / 1fr 340px; height: 100dvh; }

/* ---------- Header ---------- */
#top {
  grid-area: top; display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 56px;
  background: var(--panel-solid); border-bottom: 2px solid var(--ink-line); min-width: 0;
}
.brand {
  display: flex; align-items: center; gap: 9px; text-decoration: none; flex: none;
  font: 800 1.2rem/1 var(--display); text-transform: uppercase; letter-spacing: .02em;
}
.brand img { width: 32px; height: 32px; }
.brand:hover { color: var(--accent); }
.live-tag {
  display: inline-flex; align-items: center; gap: 8px; flex: none; padding: 6px 10px; border: 1px solid var(--line);
  font: 700 .9rem/1 var(--display); text-transform: uppercase; letter-spacing: .08em;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.up { background: var(--good); animation: pulse 2.4s infinite; }
.dot.down { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
.stats { display: flex; align-items: center; gap: 16px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 0; }
.stats #s-online { color: var(--text); font-weight: 600; }
.stats .st { display: inline-flex; align-items: center; gap: 5px; }
.stats .st:has(#s-time:empty) { display: none; }
.modes { margin-left: auto; display: flex; border: 2px solid var(--ink-line); flex: none; }
.modes button { padding: 6px 14px; color: var(--muted); font: 700 .95rem/1 var(--display); letter-spacing: .06em; }
.modes button.on { background: var(--accent); color: var(--accent-ink); }
.site-links { display: flex; align-items: center; gap: 2px; flex: none; }
.site-links a {
  text-decoration: none; padding: 8px 10px; color: var(--muted);
  font: 600 1rem/1 var(--display); text-transform: uppercase; letter-spacing: .05em;
}
.site-links a:hover { color: var(--text); }
.site-links .discord { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--ink-line); }
.site-links .discord:hover { color: var(--accent-ink); }
.icon { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); font-size: 1.15rem; flex: none; }
.icon:hover { border-color: var(--text); }
#side-toggle { display: none; }

/* ---------- Map stage ---------- */
#stage { grid-area: stage; position: relative; overflow: hidden; min-width: 0; background: #1a3a56; }
#view, #view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#view canvas { cursor: grab; }
#view canvas.drag { cursor: grabbing; }
.panel {
  position: absolute; background: var(--panel); border: 2px solid var(--ink-line); padding: 10px 12px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 3px 3px 0 rgb(0 0 0 / .35);
}
#layers { top: 14px; left: 14px; display: flex; flex-direction: column; gap: 4px; font-size: .92rem; user-select: none; }
#layers label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
#layers input { accent-color: var(--accent); margin: 0; }
#coords { bottom: 14px; left: 14px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#banner {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 14px;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--ink-line); font-weight: 600;
  font-size: .92rem; max-width: calc(100% - 32px);
}
#tip {
  position: absolute; pointer-events: none; background: var(--panel-solid); border: 2px solid var(--ink-line);
  padding: 7px 10px; font-size: .9rem; max-width: 260px; z-index: 5; box-shadow: 3px 3px 0 rgb(0 0 0 / .35);
}
#tip b { color: var(--accent); font-family: var(--display); font-size: 1.05rem; letter-spacing: .02em; }
#tip .m { color: var(--muted); }

/* ---------- Side panel ---------- */
#side { grid-area: side; display: flex; flex-direction: column; background: var(--panel-solid); border-left: 2px solid var(--ink-line); min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button {
  flex: 1; padding: 13px 4px 11px; color: var(--muted); border-bottom: 2px solid transparent;
  font: 700 1rem/1 var(--display); text-transform: uppercase; letter-spacing: .06em;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs span { color: var(--muted); font-weight: 600; }
.tab { display: none; flex: 1; overflow-y: auto; min-height: 0; }
.tab.on { display: block; }

#feed { list-style: none; margin: 0; padding: 10px 14px; }
#feed li { padding: 4px 0; overflow-wrap: anywhere; }
#feed time { color: var(--muted); font-size: .8rem; margin-right: 6px; font-variant-numeric: tabular-nums; }
#feed .title { color: var(--muted); margin-right: 4px; }
#feed .name { font-weight: 600; cursor: pointer; }
#feed .sys { color: var(--muted); font-style: italic; }
#feed .join .sys { color: var(--good); }
#feed .death .sys { color: var(--accent); }
#feed .empty { color: var(--muted); }

.list { list-style: none; margin: 0; padding: 4px 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; border-left: 3px solid transparent; }
.list li:hover { background: var(--accent-soft); }
.list li.follow { border-left-color: var(--accent); background: var(--accent-soft); }
.list .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.list .main { flex: 1; min-width: 0; }
.list .main div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.list .sub { color: var(--muted); font-size: .82rem; }
.list .grid { color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--display); font-weight: 600; }
.list .empty { color: var(--muted); cursor: default; }

/* 3D labels (CSS2DRenderer): map content, always light on the terrain */
.l3 { font: 600 12px var(--font); color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; }
.l3.mon { font-weight: 500; color: #f1e6c8; }
.l3.ev { color: #ffd27a; }

@media (max-width: 1100px) { .site-links a:not(.discord) { display: none; } .stats #s-fps { display: none; } }
@media (max-width: 760px) {
  #app { grid-template: "top" auto "stage" 1fr / 1fr; }
  #top { gap: 10px; padding: 0 12px; }
  .brand span, .site-links, .stats .st { display: none; }
  .live-tag { padding: 5px 8px; }
  .modes { margin-left: auto; }
  #side-toggle { display: grid; }
  #side {
    position: fixed; left: 0; right: 0; bottom: 0; height: 55dvh; z-index: 10; border-left: 0;
    border-top: 2px solid var(--ink-line); transform: translateY(100%);
    transition: transform .25s cubic-bezier(.16, 1, .3, 1); box-shadow: 0 -8px 24px rgb(0 0 0 / .35);
  }
  #side.open { transform: none; }
  #layers { font-size: .85rem; padding: 8px 10px; }
}
@media (max-width: 420px) { .live-tag { font-size: 0; gap: 0; padding: 8px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
