@font-face { font-family: "Anita"; src: url(fonts/anita.ttf) format("truetype"); font-display: swap; }

:root {
  /* 0x tokens (launcher/src/theme.rs, x1-design/mockups/x1.css), dark */
  --lime: #b9e611; --lime-hi: #d4f55a; --lime-deep: #485515;
  --near-black: #181717; --charcoal: #2b2929; --charcoal-hi: #3a3737;
  --warm-white: #fffafa; --white: #fff; --cool-gray: #97a3b9; --electric: #4f8cff;
  --bg: #0d0c0c; --surface: #0d0c0c; --card: #141313; --card-hi: #1d1c1c;
  --line: #2b2929; --line-strong: #3a3737;
  --heading: var(--white); --text: var(--warm-white); --dim: var(--cool-gray); --faint: #7c8596;
  --src-peers: var(--lime); --src-edge: #4f8cff; --src-relay: #b18cff; --src-origin: #8b8580;
  --warn: #f2b84b; --danger: #ff6b5e;
  --font: ui-sans-serif, "Noto Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --display: "Anita", var(--font);
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: #6fa1ff; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .92em; color: var(--text); }
button { font: inherit; color: inherit; }

/* top bar */
.top { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--line); position: relative; z-index: 3; background: var(--bg); }
.brand img { height: 28px; width: auto; display: block; }
.wordmark { font: 400 22px/1 var(--display); letter-spacing: .04em; margin: 0; color: var(--heading); }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on .dot { background: var(--lime); box-shadow: 0 0 0 0 rgb(185 230 17 / .6); animation: pulse 2s infinite; }
.live.off .dot { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(185 230 17 / .55); } 70% { box-shadow: 0 0 0 8px rgb(185 230 17 / 0); } 100% { box-shadow: 0 0 0 0 rgb(185 230 17 / 0); } }
.top nav { margin-left: auto; display: flex; gap: 18px; font-size: 14px; }
.top nav a { color: var(--dim); }
.top nav a:hover { color: var(--text); text-decoration: none; }

/* the map */
.stage { position: relative; height: min(72vh, 760px); min-height: 460px; overflow: hidden; border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse 60% 55% at 50% 50%, rgb(79 140 255 / .07), transparent 70%),
    radial-gradient(circle at 1px 1px, rgb(151 163 185 / .09) 1px, transparent 1.5px) 0 0 / 28px 28px,
    var(--surface); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }
#map.over { cursor: pointer; }

.hero { position: absolute; top: 22px; left: 24px; pointer-events: none; max-width: 340px; }
.hero-label { font-size: 13px; color: var(--dim); }
.hero-value { font: 600 64px/1.05 var(--font); color: var(--heading); letter-spacing: -.02em; margin: 2px 0; }
.hero-sub { font-size: 13px; color: var(--dim); }
.counts { position: absolute; top: 24px; right: 24px; text-align: right; font-size: 13px; color: var(--dim); pointer-events: none; line-height: 1.7; }
.counts b { color: var(--text); font-weight: 600; }

.legend { position: absolute; left: 24px; bottom: 18px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--dim); max-width: calc(100% - 160px); pointer-events: none; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.k { display: inline-block; width: 12px; height: 12px; }
.k-player { width: 9px; height: 9px; border-radius: 50%; background: var(--src-peers); box-shadow: 0 0 0 2px var(--surface), 0 0 10px rgb(185 230 17 / .5); }
.k-server { border-radius: 3px; border: 2px solid var(--src-edge); background: #10182a; }
.k-turn { width: 13px; height: 12px; background: var(--src-relay); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.k-origin { border: 2px solid var(--src-origin); background: #1c1a19; }
.f { display: inline-block; width: 18px; height: 2px; border-radius: 2px; }
.f-peer { background: var(--src-peers); }
.f-server { background: var(--src-edge); }

.tip { position: absolute; z-index: 4; min-width: 170px; max-width: 260px; padding: 10px 12px; border-radius: var(--r); background: rgb(20 19 19 / .96); border: 1px solid var(--line-strong); box-shadow: 0 8px 30px rgb(0 0 0 / .5); font-size: 13px; pointer-events: none; }
.tip .t-title { font-weight: 600; color: var(--heading); }
.tip .t-sub { color: var(--dim); }
.tip .t-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip .t-row b { color: var(--heading); font-weight: 600; }

.ghost { background: transparent; border: 1px solid var(--line-strong); color: var(--dim); border-radius: var(--r-sm); padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.ghost:hover, .ghost[aria-expanded=true], .ghost[aria-pressed=true] { color: var(--text); border-color: var(--cool-gray); }
#list-toggle { position: absolute; right: 24px; bottom: 16px; z-index: 3; }
.node-list { position: absolute; right: 24px; bottom: 52px; z-index: 3; width: min(420px, calc(100% - 48px)); max-height: 60%; overflow: auto; background: rgb(20 19 19 / .97); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 6px 0; }

/* filter row */
.filters { display: flex; align-items: center; gap: 12px; padding: 18px 24px 4px; max-width: 1360px; margin: 0 auto; flex-wrap: wrap; }
.filter-label { font-size: 13px; color: var(--dim); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 5px 12px; font-size: 13px; color: var(--dim); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed=true] { background: var(--lime); color: var(--near-black); font-weight: 600; }
.filter-note { font-size: 12.5px; color: var(--faint); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; padding: 12px 24px; max-width: 1360px; margin: 0 auto; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px 10px; min-width: 0; }
.tile .label { font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value { font: 600 28px/1.2 var(--font); color: var(--heading); margin-top: 2px; }
.tile .sub { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile svg { display: block; width: 100%; height: 30px; margin-top: 6px; }

/* charts */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 24px 12px; max-width: 1360px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; min-width: 0; position: relative; }
.card.wide { grid-column: 1 / -1; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0; color: var(--heading); }
.chart { position: relative; }
.chart svg, .multiples svg { display: block; width: 100%; overflow: visible; }
.chart.stale, .multiples.stale { opacity: .55; transition: opacity .2s; }
.axis text { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--dim); margin-top: 6px; }
.legend-row span { display: inline-flex; align-items: center; gap: 7px; }
.legend-row i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.crosshair { stroke: var(--cool-gray); stroke-width: 1; }
.ctip { position: absolute; z-index: 2; pointer-events: none; background: rgb(20 19 19 / .97); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 8px 10px; font-size: 12.5px; min-width: 170px; box-shadow: 0 8px 24px rgb(0 0 0 / .45); }
.ctip .when { color: var(--dim); margin-bottom: 4px; }
.ctip .row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.ctip .row i { height: 2px; border-radius: 2px; }
.ctip .row b { color: var(--heading); font-weight: 600; }
.ctip .row span { color: var(--dim); }
.multiples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.mini h3 { font-size: 12.5px; font-weight: 500; color: var(--dim); margin: 0 0 2px; display: flex; justify-content: space-between; }
.mini h3 b { color: var(--heading); font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { font-size: 13px; color: var(--faint); padding: 26px 0; text-align: center; }

.table-wrap { max-height: 280px; overflow: auto; margin-top: 8px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--dim); font-weight: 500; position: sticky; top: 0; background: var(--card); }

/* explainer */
.explain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 24px; max-width: 1360px; margin: 0 auto; }
.explain h3 { font: 400 16px/1.3 var(--display); letter-spacing: .03em; color: var(--heading); margin: 0 0 6px; }
.explain p { margin: 0; color: var(--dim); font-size: 14px; }
.foot { border-top: 1px solid var(--line); padding: 18px 24px 28px; text-align: center; font-size: 13px; color: var(--faint); }
.foot a { color: var(--dim); }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .explain { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .top { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .top nav { gap: 12px; font-size: 13px; }
  .stage { height: 92vh; min-height: 640px; }
  .counts { display: none; }
  .tile .sub { white-space: normal; }
  .hero { top: 14px; left: 16px; }
  .hero-value { font-size: 46px; }
  .legend { left: 16px; bottom: 14px; max-width: calc(100% - 120px); gap: 4px 10px; font-size: 12px; }
  #list-toggle { right: 16px; bottom: 14px; }
  .filters, .tiles, .charts, .explain { padding-left: 16px; padding-right: 16px; }
  .tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .multiples { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .live.on .dot { animation: none; } }
