:root {
  --bg: #0c0e12;
  --panel: #12151b;
  --panel-2: #171b22;
  --line: #222832;
  --line-2: #2c3340;
  --fg: #e7eaf0;
  --muted: #8c95a5;
  --dim: #5d6574;
  --accent: #ffb22e;
  --blue: #3d8bff;
  --live: #4fd67e;
  --bot: #6b7383;
  --warn: #ff7a59;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --rail: 236px;
  --detail: 440px;
  --top: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
: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); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }


/* --- Header --------------------------------------------------------- */

.top {
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #11141a, var(--bg));
}
.logo {
  font: 800 23px/1 var(--sans);
  letter-spacing: -0.03em;
  color: #fff;
  text-decoration: none;
}
.logo .u { color: var(--blue); }
.totals { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.totals b { color: var(--fg); font-weight: 600; }

/* --- Layout --------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  height: calc(100% - var(--top));
}
body.has-detail .layout { grid-template-columns: var(--rail) minmax(0, 1fr) var(--detail); }

/* --- Game rail ------------------------------------------------------ */

.rail {
  overflow-y: auto;
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rail-sep { height: 1px; background: var(--line); margin: 8px 6px; flex: none; }
.game {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  color: var(--muted);
  flex: none;
}
.game:hover { background: var(--panel-2); color: var(--fg); }
.game.on { background: var(--panel-2); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 6px color-mix(in srgb, var(--c) 50%, transparent); }
/* A game's icon, or a badge in its color for games without one. */
.gi { width: 16px; height: 16px; border-radius: 3px; flex: none; object-fit: contain; }
.gb {
  display: inline-grid; place-items: center; overflow: hidden;
  font-size: 7.5px; font-weight: 700; line-height: 1; letter-spacing: -.02em;
  color: color-mix(in srgb, var(--c) 80%, white);
  background: color-mix(in srgb, var(--c) 28%, #11151b);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
}
.tag .gi { width: 14px; height: 14px; margin: -2px 5px -2px -4px; vertical-align: -3px; }
.tag .gb { display: inline-grid; font-size: 6.5px; }
.gn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--dim); }
.game.on .gc, .game:hover .gc { color: var(--muted); }

/* --- Toolbar -------------------------------------------------------- */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; container-type: inline-size; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 14px 20px 6px; }
.search {
  flex: 1 1 340px;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 8px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 100%; }
.search input::placeholder { color: var(--dim); }
.search input::-webkit-search-cancel-button { filter: invert(.6); }
kbd {
  font: 11px var(--mono);
  color: var(--dim);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 1px 6px;
}
.search:focus-within kbd { display: none; }
.region {
  height: 36px;
  padding: 0 30px 0 12px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238c95a5' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center / 10px 6px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--fg);
  appearance: none;
  cursor: pointer;
}
.region:focus { border-color: var(--accent); outline: none; }
.ver {
  font-size: 11px;
  padding: 1px 5px;
  margin-left: 2px;
  border-radius: 3px;
  border: 1px solid var(--line-2);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.flag { width: 18px; height: 12px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,.08); object-fit: cover; }
.flag.none { display: inline-block; box-shadow: inset 0 0 0 1px var(--line-2); }
.facts .flag { vertical-align: -1px; margin-right: 2px; }
.credits { margin: 0; padding: 18px 20px 24px; font-size: 12px; color: var(--dim); }
.credits a { color: var(--dim); }
.credits a:hover { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 15px;
  background: none;
  color: var(--muted);
  font-size: 13px;
}
.chips button:hover { color: var(--fg); border-color: var(--dim); }
.chips button[aria-pressed="true"] {
  color: #1a1204;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.status { margin: 0; padding: 4px 20px 10px; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.warn { color: var(--warn); }

/* --- Server table --------------------------------------------------- */

.tablewrap { flex: 1; overflow: auto; min-height: 0; border-top: 1px solid var(--line); position: relative; scroll-padding-top: 33px; }
.list { width: 100%; border-collapse: collapse; table-layout: fixed; }
.list thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  user-select: none;
}
.list th[data-sort] { cursor: pointer; }
.list th[data-sort]:hover { color: var(--muted); }
.list th[aria-sort="descending"], .list th[aria-sort="ascending"] { color: var(--fg); }
.list th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.list th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }

.c-fav { width: 40px; }
.row td.c-fav { padding: 0 0 0 10px; text-overflow: clip; }
.c-pl { width: 118px; }
.c-map { width: 15%; }
.c-mode { width: 12%; }
.c-mod { width: 11%; }
.c-game { width: 12%; }
.list.onegame .c-game { display: none; }

.row td {
  padding: 0 10px;
  height: 38px;
  border-bottom: 1px solid #171b22;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.row { cursor: pointer; }
.spacer td { padding: 0; border: 0; }
.row:hover td { background: #13171e; }
.row.cur td { background: #161b23; }
.row.sel td { background: #1a1f29; }
.row.sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.row.empty .c-name, .row.empty .c-map, .row.empty .c-mode, .row.empty .c-mod { opacity: .55; }
.c-map, .c-mode, .c-mod { color: var(--muted); }
.c-map { font-family: var(--mono); font-size: 12.5px; }

.nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lock { width: 12px; height: 12px; flex: none; fill: var(--muted); }
.who { display: flex; gap: 10px; font-size: 12px; margin-top: -3px; padding-bottom: 4px; overflow: hidden; }
.who::before { content: "▸"; color: var(--accent); }
.row:has(.who) td { height: auto; padding-top: 6px; }

.star {
  border: 0;
  background: none;
  color: var(--line-2);
  font-size: 15px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}
.star:hover { color: var(--muted); }
.star.on { color: var(--accent); }
.row .star:not(.on) { opacity: 0; }
.row:hover .star, .row.cur .star, .row.sel .star, .star:focus-visible { opacity: 1; }

.pl { display: flex; flex-direction: column; gap: 3px; font-variant-numeric: tabular-nums; }
.pn { font-size: 13px; }
.pn b { font-weight: 600; color: var(--fg); }
.pn em { font-style: normal; color: var(--bot); margin-left: 2px; font-size: 12px; }
.pn small { color: var(--dim); font-size: 12px; margin-left: 1px; }
.bar { display: flex; width: 84px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { background: var(--live); }
.bar u { background: repeating-linear-gradient(90deg, var(--bot) 0 2px, transparent 2px 4px); }
.pl.full .bar i { background: var(--accent); }
.pl.none .pn b, .pl.botsonly .pn b { color: var(--dim); font-weight: 400; }

.tag {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 4px;
  color: color-mix(in srgb, var(--c) 80%, white);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}

.empty { padding: 60px 20px; text-align: center; color: var(--fg); }
.empty:empty { display: none; }
.empty p { margin: 0 0 6px; }
.btn {
  height: 30px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
}
.btn:hover { border-color: var(--dim); }
.empty .btn { margin-top: 12px; }
.spinner {
  width: 24px; height: 24px; margin: 0 auto;
  border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Detail panel --------------------------------------------------- */

.detail {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  min-height: 0;
}
.d-top {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.d-top .tag { margin-right: auto; }
.d-top .star { color: var(--dim); font-size: 17px; }
.d-top .star.on { color: var(--accent); }
.close {
  border: 0; background: none; color: var(--muted);
  width: 30px; height: 30px; border-radius: 6px; font-size: 15px;
}
.close:hover { background: var(--panel-2); color: var(--fg); }
.d-body { padding: 18px 20px 28px; }
.d-name { margin: 0 0 14px; font-size: 21px; line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }
.connect {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
}
.connect code { flex: 1; font: 13px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px 16px; margin: 18px 0 6px; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.detail section { margin-top: 24px; }
.detail h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }

.players { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.players th { font-size: 11px; color: var(--dim); font-weight: 500; text-align: left; padding: 4px 0 6px; border-bottom: 1px solid var(--line); }
.players td { padding: 6px 0; border-bottom: 1px solid #1b2028; }
.players .num { text-align: right; width: 64px; color: var(--muted); }
.players .p-name { overflow-wrap: anywhere; }
.players tr.bot .p-name { opacity: .6; }
.players tr.hit td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--bot); border: 1px solid var(--line-2); border-radius: 3px; padding: 0 4px; margin-left: 4px;
  vertical-align: 1px;
}

.varfilter {
  width: 100%; height: 30px; padding: 0 10px; margin-bottom: 8px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; outline: none;
}
.varfilter:focus { border-color: var(--accent); }
.vars { margin: 0; font-size: 12.5px; }
.vars div { display: grid; grid-template-columns: 40% 1fr; gap: 10px; padding: 4px 0; border-bottom: 1px solid #1b2028; }
.vars dt { font-family: var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.vars dd { margin: 0; overflow-wrap: anywhere; }

/* --- Small screens -------------------------------------------------- */

/* Columns give way as the list gets narrower, whether from the window or
   from the detail panel opening. */
@container (max-width: 860px) { .c-mod, .c-game { display: none; } }
@container (max-width: 680px) { .c-mode { display: none; } }
@container (max-width: 520px) {
  .c-map { display: none; }
  .row td.c-name { height: auto; padding-top: 6px; padding-bottom: 6px; }
  .sub { display: block; }
}
.sub { display: none; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1180px) {
  :root { --detail: 380px; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout, body.has-detail .layout { display: block; height: auto; }
  .top { position: sticky; top: 0; z-index: 3; }
  .rail {
    position: sticky; top: var(--top); z-index: 2;
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 8px 12px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line);
    background: var(--bg); scrollbar-width: none;
  }
  .rail-sep { display: none; }
  .game { width: auto; padding: 6px 10px; white-space: nowrap; }
  .game.on { box-shadow: inset 0 -2px 0 var(--accent); }
  .gn { overflow: visible; }
  .toolbar { padding: 12px 12px 4px; }
  .status { padding: 4px 12px 8px; }
  .tablewrap { overflow: visible; }
  .list thead th { top: calc(var(--top) + 45px); }
  .detail {
    position: fixed; inset: 0; z-index: 10; border: 0;
  }
  body.has-detail { overflow: hidden; }
}

@media (max-width: 600px) {
  .top { gap: 14px; padding: 0 12px; }
  .totals { font-size: 12px; }
  .c-fav { width: 34px; }
  .row td.c-fav { padding-left: 6px; }
  .c-pl { width: 96px; }
  .bar { width: 64px; }
  .row .star:not(.on) { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

.note svg { width: 13px; height: 13px; fill: currentColor; vertical-align: -2px; margin-right: 4px; }
