:root {
  --bg: #0d0f14;
  --surface: #151922;
  --surface-2: #1c2130;
  --line: #2a3142;
  --text: #e8ecf3;
  --muted: #8b94a7;
  --accent: #e0b04f;
  --accent-ink: #1a1405;
  --danger: #ef6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Kop ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 12px 16px;
  background: rgba(13, 15, 20, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 1.15rem; letter-spacing: .02em; }

.tabs {
  display: flex; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.tabs button {
  border: 0; background: none; color: var(--muted);
  font: inherit; padding: 6px 16px; border-radius: 999px; cursor: pointer;
}
.tabs button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- Layout ---------- */
main { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; display: grid; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }

.back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--text); }

.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0 0 12px; }
.win { color: var(--accent); font-weight: 700; }

/* ---------- Knoppen & velden ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { color: var(--danger); border-color: rgba(239, 107, 107, .4); background: transparent; }
.btn.sm { padding: 4px 10px; font-size: .85rem; font-weight: 500; }

input, select {
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Lijsten ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent;
  color: inherit; text-decoration: none;
}
.list a:hover { border-color: var(--accent); }
.list small { display: block; color: var(--muted); }

.pill {
  font-size: .8rem; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
}

.players { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.players li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--surface-2); border-radius: 10px;
}
.players li.off span { color: var(--muted); text-decoration: line-through; }
.add-player { display: flex; gap: 8px; }
.add-player input { flex: 1; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 500; font-size: .85rem; }
tfoot td { font-weight: 700; border-bottom: 0; }
td input { width: 76px; padding: 6px 8px; text-align: center; }

.game-result { margin: 10px 0 0; }

/* ---------- Dialoog ---------- */
dialog {
  width: min(440px, calc(100% - 32px));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.modal h3 { margin: 0 0 14px; }
.modal label { display: grid; gap: 4px; margin-bottom: 12px; font-size: .9rem; }
.modal fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 10px 12px; }
.modal legend { font-size: .9rem; padding: 0 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 6px; margin: 0; background: var(--surface-2); padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.checks input { width: auto; }

/* ---------- Melding ---------- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
