:root {
  --bg: #06090f;
  --bg2: #0b111d;
  --panel: rgba(17, 25, 42, .82);
  --panel-solid: #111a2b;
  --panel2: #16213a;
  --line: #1f2c47;
  --line2: #2a3b5e;
  --text: #e6edf7;
  --muted: #8a9bb8;
  --dim: #5d6e8c;
  --accent: #22d3ee;
  --accent2: #a855f7;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(34, 211, 238, .16), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(168, 85, 247, .16), transparent 60%),
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; }
h2 { font-size: .95rem; color: var(--muted); }
h3 { font-size: .85rem; color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: .85em; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 24px 16px 60px; }
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 10px 22px;
  background: rgba(6, 9, 15, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: .18em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand b {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand span { font-size: .7rem; color: var(--muted); letter-spacing: .25em; font-weight: 600; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a {
  color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: .9rem;
}
.top nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.top nav a.on { color: var(--text); background: linear-gradient(90deg, rgba(34, 211, 238, .18), rgba(168, 85, 247, .18)); }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--muted); }
.me form { margin: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.section { margin-top: 30px; }
.section > h2 { display: flex; align-items: center; gap: 10px; }
.section > h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line2), transparent); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.card.glow::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head .icon {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(34, 211, 238, .16), rgba(168, 85, 247, .16));
  border: 1px solid var(--line2);
}
.card-head .icon svg { width: 22px; height: 22px; stroke: var(--accent); }
.card-head .title { font-weight: 700; font-size: 1.02rem; }
.card-head .sub { color: var(--muted); font-size: .82rem; }
.card-head .right { margin-left: auto; text-align: right; }

/* ---------- status ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .04em;
  background: var(--panel2); border: 1px solid var(--line2); color: var(--muted); white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.pill.running { color: #bbf7d0; border-color: rgba(34, 197, 94, .4); }
.pill.running::before { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.pill.starting, .pill.stopping, .pill.degraded { color: #fde68a; border-color: rgba(245, 158, 11, .4); }
.pill.starting::before, .pill.stopping::before, .pill.degraded::before { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.pill.failed, .pill.problem { color: #fecaca; border-color: rgba(239, 68, 68, .5); }
.pill.failed::before, .pill.problem::before { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.pill.nodot::before { display: none; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; background: var(--panel2); border: 1px solid var(--line2); color: var(--muted);
}
.badge.admin { color: var(--accent2); border-color: rgba(168, 85, 247, .45); }
.badge.friend { color: var(--accent); border-color: rgba(34, 211, 238, .45); }
.badge.perm { color: #fde68a; border-color: rgba(245, 158, 11, .45); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.stat { background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat .v { font-weight: 700; font-variant-numeric: tabular-nums; }

.meter { margin: 9px 0; }
.meter .row { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); }
.meter .row b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .06); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .6s ease; }
.bar.warn i { background: linear-gradient(90deg, var(--warn), #f97316); }
.bar.bad i { background: linear-gradient(90deg, var(--bad), #b91c1c); }

.players { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.player {
  padding: 3px 10px; border-radius: 8px; font-size: .84rem;
  background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .25);
}
.big { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big small { font-size: .9rem; color: var(--muted); font-weight: 600; }

/* ---------- buttons & forms ---------- */
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
button, .btn {
  font: inherit; font-size: .86rem; font-weight: 700; letter-spacing: .03em;
  padding: 7px 14px; border-radius: 9px; cursor: pointer;
  color: var(--text); background: var(--panel2); border: 1px solid var(--line2);
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary {
  border: 0; color: #041018;
  background: linear-gradient(90deg, var(--accent), #67e8f9);
}
button.primary:hover { filter: brightness(1.08); }
button.danger { color: #fecaca; border-color: rgba(239, 68, 68, .45); }
button.danger:hover { background: rgba(239, 68, 68, .15); border-color: var(--bad); }
button.ghost { background: transparent; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; }

label { display: block; font-size: .8rem; color: var(--muted); margin: 12px 0 4px; font-weight: 600; letter-spacing: .03em; }
input, select {
  width: 100%; font: inherit; color: var(--text);
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line2); border-radius: 9px; padding: 9px 12px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .15); }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }

.msg { padding: 10px 14px; border-radius: 10px; margin: 12px 0; font-size: .9rem; }
.msg.err { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4); color: #fecaca; }
.msg.ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4); color: #bbf7d0; }
.msg.info { background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .3); }

/* ---------- auth pages ---------- */
.auth { max-width: 420px; margin: 9vh auto 0; }
.auth .logo { display: flex; justify-content: center; margin-bottom: 18px; }
.auth .logo .brand { font-size: 1.4rem; }
.auth .logo svg { width: 40px; height: 40px; }
.auth button.primary { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; }
.qr { width: 220px; height: 220px; display: block; margin: 14px auto; border-radius: 10px; }
.secret { text-align: center; word-break: break-all; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: rgba(255, 255, 255, .02); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- logs ---------- */
.logs {
  background: #03060b; border: 1px solid var(--line); border-radius: 10px;
  font: 12.5px/1.5 var(--mono); color: #b6c3d9; padding: 12px; height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.logs .err { color: #fca5a5; }
.logs .warn { color: #fcd34d; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar select, .toolbar input { width: auto; }

/* ---------- charts ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { padding: 5px 11px; font-size: .8rem; }
.tabs button.on { border-color: var(--accent); color: var(--accent); }
.chart { position: relative; height: 220px; margin-top: 8px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart .gridline { stroke: rgba(255, 255, 255, .05); }
.chart text { fill: var(--dim); font-size: 10px; font-family: var(--mono); }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--panel-solid); border: 1px solid var(--line2);
  border-radius: 8px; padding: 6px 9px; font-size: .78rem; white-space: nowrap; z-index: 2;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.empty { color: var(--dim); font-size: .85rem; padding: 30px 0; text-align: center; }

/* ---------- public page ---------- */
.hero { text-align: center; padding: 70px 16px 30px; }
.hero svg.mark { width: 74px; height: 74px; filter: drop-shadow(0 0 24px rgba(34, 211, 238, .45)); }
.hero h1 {
  font-size: clamp(2.4rem, 7vw, 4.4rem); letter-spacing: .22em; margin: 14px 0 6px; font-weight: 900;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); letter-spacing: .3em; text-transform: uppercase; font-size: .82rem; margin: 0; }
.public-grid { max-width: 1060px; margin: 20px auto 0; padding: 0 16px; }
.game { text-align: left; }
.game .count { margin-top: 14px; }
.game .since { font-size: .82rem; color: var(--muted); margin-top: 6px; }
footer.pub { text-align: center; color: var(--dim); font-size: .8rem; padding: 40px 16px; }

@media (max-width: 640px) {
  .top { padding: 10px 14px; gap: 10px; }
  .me { margin-left: 0; width: 100%; justify-content: space-between; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .logs { height: 400px; }
}
