:root {
  color-scheme: light dark;

  --bg: #f6f7f7;
  --surface: #ffffff;
  --surface-alt: #eef1f0;
  --text: #1d2326;
  --text-muted: #51606a;
  --border: #d6dddc;

  --accent: #0e7a45;
  --accent-soft: #e3f3e9;
  --on-accent: #ffffff;

  --danger: #b42318;
  --danger-soft: #fdecea;

  --radius: 0.375rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181b;
    --surface: #1d2327;
    --surface-alt: #262e33;
    --text: #e8ecee;
    --text-muted: #a3b1b8;
    --border: #3a4549;

    --accent: #4ade80;
    --accent-soft: rgba(74, 222, 128, 0.15);
    --on-accent: #08240f;

    --danger: #f89c93;
    --danger-soft: rgba(248, 113, 113, 0.12);
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  line-height: 1.5;
}

/* A single, consistent focus indicator for everything */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header */

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.25rem;
  margin: 0;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

header nav strong {
  color: var(--text);
}

header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

header nav ul a {
  display: inline-block;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

header nav ul a:hover {
  background: var(--accent-soft);
}

/* Headings & links */

h2 {
  font-size: 1.4rem;
  margin-top: 0;
}

h3 {
  font-size: 1.1rem;
}

a {
  color: var(--accent);
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

#login-section {
  max-width: 26rem;
  margin: 2rem auto 0;
}

/* Forms */

label {
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
}

form input[type="text"],
form input[type="password"] {
  width: 100%;
  max-width: 20rem;
  margin-top: 0.25rem;
}

form p {
  margin-bottom: 1.25rem;
}

button {
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.5rem 1.25rem;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.1);
}

.flash {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}

[role="alert"] {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
}

/* Group accordions */

details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  overflow-x: auto;
}

details > summary {
  cursor: pointer;
  font-weight: 600;
}

details table {
  margin-top: 0.75rem;
}

/* Tables */

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 48rem;
}

/* Match tables: fixed column widths so the score inputs line up
   across groups regardless of team-name length */

details table {
  table-layout: fixed;
}

details table.with-results {
  min-width: 62rem;
}

th.col-team {
  width: 12rem;
}

th.col-score {
  width: 9.5rem;
}

th.col-result {
  width: 5.5rem;
}

th.col-points {
  width: 5rem;
}

th.col-when {
  width: 9.5rem;
}

caption {
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

thead th {
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: none;
}

tbody th[scope="row"] {
  font-weight: 500;
}

td.score {
  white-space: nowrap;
  text-align: center;
}

td.points-cell {
  text-align: center;
}

.live {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--danger);
}

.points-total {
  font-size: 1.05rem;
}

.points-rules {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.admin-refresh {
  margin-bottom: 1.25rem;
}

/* Dim fully predicted matches so the remaining ones stand out;
   restore on hover/focus so they stay easy to edit and read */

tbody tr.filled {
  opacity: 0.55;
}

tbody tr.filled:hover,
tbody tr.filled:focus-within {
  opacity: 1;
}

input.score-input {
  width: 3rem;
  padding: 0.35rem 0.25rem;
  text-align: center;
}

/* Tabs (radio-driven) */

.tab-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tab-list {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.tab-label {
  cursor: pointer;
  padding: 0.5rem 1rem;
  margin-bottom: -1px;
  border-bottom: 3px solid transparent;
  font-weight: 500;
  color: var(--text-muted);
}

.tab-label:hover {
  color: var(--text);
}

#tab-groep:checked ~ .tab-list label[for="tab-groep"],
#tab-knockout:checked ~ .tab-list label[for="tab-knockout"],
#tab-bonus:checked ~ .tab-list label[for="tab-bonus"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

#tab-groep:focus-visible ~ .tab-list label[for="tab-groep"],
#tab-knockout:focus-visible ~ .tab-list label[for="tab-knockout"],
#tab-bonus:focus-visible ~ .tab-list label[for="tab-bonus"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab-panel {
  display: none;
}

#tab-groep:checked ~ #panel-groep,
#tab-knockout:checked ~ #panel-knockout,
#tab-bonus:checked ~ #panel-bonus {
  display: block;
}

/* Bonus fields (kampioen, runner-up, topscorer) */

#panel-bonus p:has(input, output) {
  max-width: 24rem;
}

#panel-bonus input[type="text"] {
  max-width: 100%;
  width: 100%;
}

output {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.3rem 0.75rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-weight: 600;
}

/* Poule list */

.poule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.poule-list li {
  padding: 0.6rem 0.9rem;
}

.poule-list li + li {
  border-top: 1px solid var(--border);
}

.poule-list em {
  color: var(--text-muted);
}

/* Save status */

#save-status {
  position: sticky;
  bottom: 0.75rem;
  display: inline-block;
  margin-top: 1rem;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

#save-status:empty {
  visibility: hidden;
}

/* Visually hidden */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Footer */

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}
