:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #f97316;
  --good: #16a34a;
  --bad: #dc2626;
  --bar-bg: #eceef1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --bar-bg: #262a32;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.logo { width: 20px; height: 20px; border-radius: 4px; background: var(--accent); transform: rotate(15deg); }
nav { display: flex; gap: 16px; align-items: center; white-space: nowrap; }
nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
nav a.active { color: var(--text); }
.banner { background: #fef3c7; color: #78350f; text-align: center; padding: 6px; font-size: 13px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stack > * + * { margin-top: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 12px; }
.tile.hero .value { color: var(--accent); }

.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-box { position: relative; height: 300px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.game { display: block; text-decoration: none; transition: border-color .15s; }
.game:hover { border-color: var(--accent); }
.game-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.game-head img { width: 52px; height: 52px; border-radius: 10px; background: var(--bar-bg); flex: none; }
.game-head .name { font-weight: 700; font-size: 16px; }
.live { margin-left: auto; text-align: right; }
.live .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.live .l { font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 4px; }
.dot.off { background: var(--muted); }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 12px; margin-bottom: 12px; }
.mini div { font-size: 12px; color: var(--muted); }
.mini b { display: block; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

.goal .row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar { height: 10px; border-radius: 99px; background: var(--bar-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.goal.done .bar > span { background: var(--good); }
.status { margin-top: 10px; font-size: 12px; color: var(--muted); }
.status.warn { color: var(--bad); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .two { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; }
input {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-width: 0;
}
input.grow { flex: 1 1 260px; }
input.num { width: 90px; }
button.btn {
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 0;
  background: var(--accent); color: #fff; cursor: pointer;
}
button.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.msg { font-size: 13px; margin-top: 8px; min-height: 18px; }
.msg:empty { min-height: 0; margin: 0; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--good); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 260px; }
ol.steps { padding-left: 20px; margin: 0; }
ol.steps li { margin-bottom: 6px; }

.login { max-width: 360px; margin: 60px auto; }
.login input { width: 100%; margin-bottom: 10px; }
.login button { width: 100%; }

.admin-game { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-game img { width: 40px; height: 40px; border-radius: 8px; }
.admin-game .who { flex: 1 1 200px; }
.admin-game label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }

@media (max-width: 520px) {
  .top { padding: 10px 16px; }
  nav { gap: 12px; }
  .brand-text { display: none; }
  .games { grid-template-columns: 1fr; }
  .tile .value { font-size: 20px; }
  .chart-box { height: 240px; }
}
