/* ── Basis en gedeelde onderdelen ─────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-bg);
  background-image: var(--sfeer);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 0.4em;
  line-height: 1.15;
}

h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { line-height: 1.55; margin: 0 0 1em; }
a { color: var(--color-primary); }

.gedempt { color: var(--color-text-muted); }
.klein { font-size: 0.83rem; }
.mono { font-family: var(--font-code); }
.midden { text-align: center; }
[hidden] { display: none !important; }

/* ── Knoppen ──────────────────────────────────────────────────────────── */

button, .knop {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  padding: 0.8em 1.2em;
  background: var(--color-surface-2);
  color: var(--color-text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
  min-height: 44px;
}
button:hover:not(:disabled) { background: var(--color-hover); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, .kaart:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 2px;
}

.knop-hoofd {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: var(--color-on-primary);
  box-shadow: var(--schaduw-sm);
}
.knop-hoofd:hover:not(:disabled) { background: var(--color-primary-hover); }

.knop-stil { background: transparent; border: 2px solid var(--color-border); }
.knop-stil:hover:not(:disabled) { background: var(--color-hover); }
.knop-klein { padding: 0.45em 0.8em; font-size: 0.85rem; min-height: 36px; border-radius: var(--radius-sm); }
.knop-rij { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.knop-breed { width: 100%; }

/* ── Formulieren ──────────────────────────────────────────────────────── */

label { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 0.3rem; }

input[type="text"] {
  font: inherit;
  width: 100%;
  padding: 0.75em 0.9em;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 44px;
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-20);
}
input::placeholder { color: var(--color-text-muted); opacity: 0.75; }

.veld { margin-bottom: 0.9rem; }

/* ── Kaarten (het spelmateriaal) ──────────────────────────────────────── */

.kaart {
  position: relative;
  display: block;
  aspect-ratio: 169.075 / 244.64;
  border-radius: 7%;
  background: var(--kaart-bg);
  box-shadow: var(--schaduw-sm);
  border: 1px solid var(--kaart-rand);
  overflow: hidden;
  user-select: none;
  flex: none;
}
.kaart svg { display: none; width: 100%; height: 100%; }
.kaarten-geladen .kaart svg { display: block; }

/* Terugval zolang (of als) de kaartenset niet geladen is: rang en teken. */
.kaart-tekst {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6% 0 0 7%;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 0.95;
  font-size: clamp(0.7rem, 2.6vw, 1.1rem);
  color: var(--kaart-zwart);
}
.kaart-tekst[data-rood="ja"] { color: var(--kaart-rood); }
.kaarten-geladen .kaart-tekst { display: none; }

.kaart-rug { background: var(--kaart-rug); }
.kaart-rug .kaart-tekst { display: none; }
.kaart-rug::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 6%;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 6px, transparent 6px 12px);
}

/* ── Paneel / bottom sheet ────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: vervaag 0.18s ease;
}
@keyframes vervaag { from { opacity: 0; } }

.paneel {
  width: min(100%, 560px);
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-bg);
  background-image: var(--sfeer);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 3px solid var(--color-primary);
  padding: 1rem 1rem calc(1.4rem + env(safe-area-inset-bottom));
  box-shadow: var(--schaduw);
  animation: omhoog 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes omhoog { from { transform: translateY(14%); opacity: 0.4; } }

.paneel-kop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  position: sticky;
  top: -1rem;
  padding: 1rem 0 0.6rem;
  margin-top: -1rem;
  /* Doorlopen in de sfeer eronder, anders krijg je een harde band. */
  background: linear-gradient(var(--color-bg) 72%, transparent);
  z-index: 2;
}
.paneel-kop h2 { margin: 0; }
.paneel-sluit {
  border-radius: 50%;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--color-surface-2);
}

.tabs { display: flex; gap: 0.35rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.tabs button {
  flex: 1 1 auto;
  padding: 0.5em 0.7em;
  min-height: 38px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.tabs button[aria-selected="true"] {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

/* ── Kaartjes en lijsten ──────────────────────────────────────────────── */

.kader {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.8rem;
}

.stand-rij {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.2rem;
  border-bottom: 1px solid var(--color-border);
}
.stand-rij:last-child { border-bottom: none; }
.stand-punt { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.1rem; }

/* Twee fiches naast elkaar hebben meer ruimte nodig dan één. */
.koppel-rij { grid-template-columns: 2.7rem 1fr auto; }
.koppel-fiches { display: flex; }
.koppel-fiches .fiche + .fiche { margin-left: -0.5rem; border: 2px solid var(--color-surface); }
.positief { color: var(--color-succes); }
.negatief { color: var(--color-error); }

.fiche {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #1a1020;
  background: var(--speler-kleur, var(--color-primary));
  flex: none;
}

.label {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--color-surface-2);
  color: var(--color-text);
  white-space: nowrap;
}
.label-goed { background: var(--color-succes-bg); color: var(--color-succes); }
.label-fout { background: var(--color-error-bg); color: var(--color-error); }

.plaagfeitje {
  background: var(--color-surface-2);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.55rem;
  line-height: 1.45;
}

.tabel { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tabel th, .tabel td { padding: 0.45rem 0.4rem; text-align: right; border-bottom: 1px solid var(--color-border); }
.tabel th:first-child, .tabel td:first-child { text-align: left; }
.tabel th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.tabel-schuif { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Meldingen ────────────────────────────────────────────────────────── */

.toast-baan {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
  pointer-events: none;
  width: min(94vw, 460px);
}
.toast {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  box-shadow: var(--schaduw);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
  animation: toast-in 0.18s ease;
}
.toast-fout { background: var(--color-error); color: #fff; border-color: transparent; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.melding {
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  background: var(--color-error-bg);
  color: var(--color-error);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
