:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1e1e1e;
  --border: #2e2e2e;
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --accent: #f5f5f5;
  --accent-ink: #0a0a0a;
  --danger: #ffffff;
  --warn: #b5b5b5;
  --radius: 0;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  padding: 0 1rem 3rem;
  max-width: min(1700px, 96vw);
  margin-inline: auto;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.75rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.75rem; }

.muted { color: var(--muted); }

.site-header { padding: 2rem 0 1rem; }
.site-header p { margin: 0; }
.site-footer { margin-top: 2rem; font-size: 0.85rem; text-align: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ---------- form ---------- */

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 0.6rem; }

input, textarea, select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.6rem 0.75rem;
  font: inherit;
  width: 100%;
}
select { width: auto; }
textarea { resize: vertical; }

input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button { font: inherit; cursor: pointer; }

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 0;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.55; cursor: progress; }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 0.65rem 1.1rem;
}
button.secondary:hover { background: var(--surface-2); }
button.secondary:disabled { opacity: 0.55; cursor: progress; }

.actions { display: flex; gap: 0.5rem; }

.status { margin-top: 0.75rem; display: grid; gap: 0.35rem; }
.status:empty { margin-top: 0; }
.status p { margin: 0; padding: 0.5rem 0.75rem; border-radius: 0; background: var(--surface-2); font-size: 0.9rem; }
.status .success { border-left: 3px solid var(--accent); }
.status .warning { border-left: 3px solid var(--warn); }
.status .error { border-left: 3px solid var(--danger); }
.status .info { border-left: 3px solid var(--muted); }

.notice { color: var(--muted); }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 0.25rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 0;
  padding: 0.5rem 0.9rem;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 0.55rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
td.muted { text-align: center; }

.sort-btn {
  background: none;
  border: 0;
  color: inherit;
  padding: 0;
  font-weight: inherit;
}
.sort-btn:hover { color: var(--text); }
.sort-btn[data-dir="asc"]::after { content: " \25B2"; font-size: 0.7em; }
.sort-btn[data-dir="desc"]::after { content: " \25BC"; font-size: 0.7em; }

/* ---------- charts ---------- */

.row { margin: 0.5rem 0 0.75rem; }
.chart-box { position: relative; height: 320px; }
.chart-fallback { display: none; color: var(--warn); }
.no-charts .chart-fallback { display: block; }
.no-charts .chart-box canvas { display: none; }

/* ---------- stat cards ---------- */

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; padding: 0.9rem 1rem; display: flex; flex-direction: column; }
.stat-label { color: var(--muted); font-size: 0.8rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .controls-grid { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: 1fr; }
  .chart-box { height: 260px; }
  button.primary, button.secondary { width: 100%; }
}

[hidden] { display: none !important; }

.check { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--muted); }
.check input { width: auto; margin: 0; }

/* ---------- game mode selector ---------- */
.mode-bar { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.mode-btn {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 0; padding: 0.3rem 0.9rem; font: inherit; cursor: pointer;
}
.mode-btn:hover { color: var(--text); }
.mode-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---------- sample notice ---------- */
.sample-note { border-left: 3px solid var(--text); color: var(--muted); margin-bottom: 1rem; }
.sample-note strong { color: var(--text); }
.sample-note a { color: var(--text); }
