:root {
  --bg: #fdf8ef;
  --card: #ffffff;
  --ink: #1f2440;
  --muted: #6b7090;
  --line: #e7e2d6;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --accent: #2563eb;
  --a1: #22c55e;   /* anker 1x  */
  --a2: #3b82f6;   /* anker 2x  */
  --a5: #f59e0b;   /* anker 5x  */
  --a10: #8b5cf6;  /* anker 10x */
  --radius: 18px;
  --shadow: 0 4px 0 rgba(31, 36, 64, .08), 0 8px 24px rgba(31, 36, 64, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", "Segoe UI Rounded", "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- kop ---------- */
header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 24px; }
.logo-badge {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a5), #ef4444); color: #fff; font-size: 22px;
}
nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
nav button, .sound-btn {
  border: 2px solid var(--line); background: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: 16px;
}
nav button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.sound-btn { padding: 8px 12px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 16px; }

/* ---------- ankers legenda ---------- */
.anchors { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 0; }
.anchor-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 15px; color: #fff;
}
.c1 { background: var(--a1); } .c2 { background: var(--a2); }
.c5 { background: var(--a5); } .c10 { background: var(--a10); }

/* ---------- keuze-chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-width: 52px; height: 52px; padding: 0 14px;
  border: 3px solid var(--line); background: var(--card);
  border-radius: 14px; font-weight: 900; font-size: 20px;
}
.chip.on { border-color: var(--accent); background: #dbeafe; color: #1e3a8a; }
.chip.small { height: 44px; font-size: 16px; min-width: 0; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.setup-block { margin-bottom: 20px; }
.setup-block h3 { font-size: 18px; margin-bottom: 8px; }

.big-btn {
  border: none; border-radius: 16px; padding: 16px 28px;
  font-weight: 900; font-size: 22px; color: #fff; background: var(--accent);
  box-shadow: 0 4px 0 #1d4ed8;
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1d4ed8; }
.big-btn.green { background: var(--good); box-shadow: 0 4px 0 #15803d; }
.ghost-btn {
  border: 2px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 10px 16px; font-weight: 800;
}

/* ---------- oefenen ---------- */
.practice { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .practice { grid-template-columns: 1fr; } }

.progress { display: flex; gap: 5px; margin-bottom: 14px; flex-wrap: wrap; }
.progress span { flex: 1; min-width: 10px; height: 10px; border-radius: 6px; background: var(--line); }
.progress span.ok { background: var(--good); }
.progress span.help { background: var(--a5); }
.progress span.now { background: var(--accent); }

.topline { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 800; margin-bottom: 6px; }
.streak { color: #ea580c; }

.chain {
  background: #fef3c7; border: 2px dashed var(--a5); color: #92400e;
  border-radius: 14px; padding: 10px 14px; font-weight: 800; margin-bottom: 12px;
  animation: pop .4s ease;
}

.question {
  font-size: clamp(48px, 9vw, 84px); font-weight: 900; text-align: center;
  letter-spacing: 1px; margin: 6px 0 14px;
}
.question .ans-slot {
  display: inline-block; min-width: 1.6em; padding: 0 .2em;
  border-bottom: 6px solid var(--accent); color: var(--accent);
}
.question.good .ans-slot { color: var(--good); border-color: var(--good); }
.question.bad .ans-slot { color: var(--bad); border-color: var(--bad); animation: shake .35s; }

.feedback { min-height: 32px; text-align: center; font-weight: 900; font-size: 22px; margin-bottom: 10px; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

.mc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mc button {
  border: 3px solid var(--line); background: var(--card);
  border-radius: 18px; padding: 18px 0; font-size: 34px; font-weight: 900;
  box-shadow: 0 4px 0 var(--line);
}
.mc button:active { transform: translateY(2px); }
.mc button.good { background: var(--good-bg); border-color: var(--good); }
.mc button.bad { background: var(--bad-bg); border-color: var(--bad); opacity: .7; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 0 auto; }
.numpad button {
  border: none; background: #eef2ff; border-radius: 16px;
  padding: 14px 0; font-size: 30px; font-weight: 900; box-shadow: 0 4px 0 #c7d2fe;
}
.numpad button:active { transform: translateY(2px); box-shadow: 0 2px 0 #c7d2fe; }
.numpad .ok { background: var(--good); color: #fff; box-shadow: 0 4px 0 #15803d; }
.numpad .del { background: #fde68a; box-shadow: 0 4px 0 #f59e0b; }

.help-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.help-btn {
  border: 2px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 10px 18px; font-weight: 800; font-size: 17px;
}
.help-btn:disabled { opacity: .45; cursor: default; }

/* ---------- visueel: strategie + blokjes ---------- */
.strategy {
  border-radius: 16px; padding: 14px 16px; margin-bottom: 12px;
  background: #f8fafc; border: 2px solid var(--line);
}
.strategy .title { font-weight: 900; font-size: 20px; margin-bottom: 4px; }
.strategy .expl { font-size: 18px; }
.strategy .alt { color: var(--muted); font-size: 15px; margin-top: 6px; }

.array { display: flex; flex-direction: column; gap: 4px; --dot: 20px; }
.sum.bad .ans-slot { color: var(--bad) !important; border-color: var(--bad) !important; animation: shake .35s; }
.arow { display: flex; align-items: center; gap: 8px; transition: opacity .3s; }
.arow .dots { display: flex; gap: 4px; }
.arow .dot {
  width: var(--dot, 20px); height: var(--dot, 20px); border-radius: 50%;
  background: #cbd5e1; transition: background .3s, transform .3s;
}
.arow .num { width: 34px; text-align: right; color: var(--muted); font-weight: 800; font-size: 14px; }
.arow.p1 .dot { background: var(--a1); }
.arow.p2 .dot { background: var(--a2); }
.arow.p5 .dot { background: var(--a5); }
.arow.p10 .dot { background: var(--a10); }
.arow.gone .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--bad); }
.arow.gone .dots { position: relative; }
.arow.gone .dots::after {
  content: ""; position: absolute; left: -4px; right: -4px; top: 50%;
  border-top: 3px solid var(--bad); transform: rotate(-2deg);
}
.arow.dim { opacity: .22; }
.arow.flash .dot { animation: pulse .6s ease; }
.arow .glabel {
  font-weight: 900; font-size: 15px; padding: 2px 10px; border-radius: 999px; color: #fff; white-space: nowrap;
}
.gsep { height: 6px; }

/* ---------- tussenstappen ---------- */
.steps { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.step {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-size: 24px; font-weight: 900;
}
.step .nr {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--line); font-size: 16px;
}
.step .tip { font-size: 15px; color: var(--muted); font-weight: 700; width: 100%; padding-left: 44px; }
.step.now { border-color: var(--accent); background: #eff6ff; }
.step.now .nr { background: var(--accent); color: #fff; }
.step.done { border-color: var(--good); background: var(--good-bg); }
.step.done .nr { background: var(--good); color: #fff; }
.step .val { color: var(--accent); min-width: 1.5em; border-bottom: 4px solid currentColor; text-align: center; }
.step.done .val { color: var(--good); border-color: transparent; }
.step.todo { opacity: .45; }

/* ---------- bouw de tafel ---------- */
.build { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .build { grid-template-columns: 1fr; } }

.ladder { display: flex; flex-direction: column; gap: 6px; }
.rung {
  display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-weight: 900; font-size: 22px; transition: all .3s;
}
.rung .lbl { white-space: nowrap; }
.rung .res { color: var(--ink); }
.rung .res.empty { color: #cbd5e1; }
.rung .tag { font-size: 13px; font-weight: 900; padding: 3px 10px; border-radius: 999px; color: #fff; white-space: nowrap; }
.rung.anchor { border-left-width: 10px; }
.rung.anchor.k1 { border-left-color: var(--a1); }
.rung.anchor.k2 { border-left-color: var(--a2); }
.rung.anchor.k5 { border-left-color: var(--a5); }
.rung.anchor.k10 { border-left-color: var(--a10); }
.rung.active { border-color: var(--accent); background: #eff6ff; box-shadow: 0 0 0 4px #bfdbfe; transform: scale(1.02); }
.rung.source { background: #fef9c3; border-color: #facc15; }
.rung.filled .res { animation: pop .35s ease; }

.build-task { text-align: center; }
.build-task .explain { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.build-task .sum { font-size: clamp(38px, 6vw, 56px); font-weight: 900; margin: 8px 0 12px; }
.build-task .arrow-note {
  display: inline-block; font-weight: 900; padding: 6px 14px; border-radius: 999px;
  background: #fef3c7; color: #92400e; margin-bottom: 8px;
}

/* ---------- tafelkaart ---------- */
.grid-wrap { overflow-x: auto; }
table.kaart { border-collapse: separate; border-spacing: 4px; margin: 0 auto; }
.kaart th { font-size: 15px; color: var(--muted); padding: 4px; }
.kaart th.anch { color: var(--ink); }
.kaart td {
  width: 52px; height: 44px; text-align: center; font-weight: 900; font-size: 17px;
  border-radius: 10px; background: #f1f5f9; color: #94a3b8; cursor: pointer; transition: transform .15s;
}
.kaart td.l1 { background: #fee2e2; color: #991b1b; }
.kaart td.l2 { background: #fef3c7; color: #92400e; }
.kaart td.l3 { background: #bbf7d0; color: #166534; }
.kaart td.l4 { background: #22c55e; color: #fff; }
.kaart td.sel, .kaart td.mirror { outline: 4px solid var(--accent); transform: scale(1.08); }
.kaart td.mirror { outline-style: dashed; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 14px 0 6px; font-size: 15px; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 18px; border-radius: 5px; display: inline-block; }
.kaart-info { text-align: center; font-weight: 800; min-height: 28px; margin-top: 8px; }

/* ---------- eindscherm ---------- */
.result { text-align: center; }
.result .stars { font-size: 56px; margin: 6px 0; }
.result .again { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 10px 0 18px; }
.result .again span { background: #fef3c7; border-radius: 10px; padding: 6px 12px; font-weight: 900; }

details.info { margin-top: 18px; }
details.info summary { font-weight: 800; cursor: pointer; color: var(--accent); }
details.info p, details.info li { color: #3f4566; font-size: 16px; }

/* ---------- animaties ---------- */
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 70% { transform: scale(1.1) } 100% { transform: scale(1); opacity: 1 } }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-8px) } 75% { transform: translateX(8px) } }
@keyframes pulse { 50% { transform: scale(1.35) } }

.confetti { position: fixed; top: -20px; width: 12px; height: 16px; z-index: 50; pointer-events: none; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 520px) {
  body { font-size: 16px; }
  header { padding: 10px 14px; gap: 10px; position: static; }
  .sound-btn { margin-left: auto; }
  nav { order: 3; width: 100%; margin-left: 0; flex-wrap: nowrap; }
  nav button { flex: 1; padding: 7px 6px; font-size: 13px; white-space: nowrap; }
  .help-btn { padding: 8px 12px; font-size: 15px; }
  .numpad button { padding: 10px 0; font-size: 26px; }
  .logo { font-size: 20px; }
  .card { padding: 16px; }
  .rung { grid-template-columns: 90px 1fr auto; font-size: 19px; }
  .kaart td { width: 34px; height: 34px; font-size: 13px; }
  .mc button { font-size: 28px; }
  .array { --dot: 13px; }
  .arow .dots { gap: 3px; }
}
@media (max-width: 860px) { .build > .card:last-child { order: -1; } }

/* ---------- tempo & diploma ---------- */
.clock { color: var(--ink); font-variant-numeric: tabular-nums; }
.dip-form { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 18px 0 6px; }
.dip-form label { width: 100%; font-weight: 800; }
.dip-form input {
  font: inherit; font-size: 22px; font-weight: 800; padding: 12px 16px; border-radius: 14px;
  border: 3px solid var(--line); width: min(320px, 100%); text-align: center;
}
.dip-form input:focus { outline: none; border-color: var(--accent); }

#diploma { display: none; }
@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#diploma) { display: none !important; }
  #diploma { display: flex !important; width: 297mm; height: 209mm; align-items: center; justify-content: center; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.dip-inner {
  width: 265mm; height: 180mm; border: 4mm solid var(--a5); border-radius: 10mm;
  outline: 1.5mm solid var(--a2); outline-offset: -8mm;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3mm;
  text-align: center; color: var(--ink); background: #fffdf7;
}
.dip-dots { display: flex; gap: 3mm; }
.dip-dots span { width: 5mm; height: 5mm; border-radius: 50%; display: inline-block; }
.dip-title { font-size: 20mm; font-weight: 900; color: #c2410c; letter-spacing: 1mm; margin-top: 2mm; }
.dip-small { font-size: 6mm; color: var(--muted); }
.dip-name { font-size: 14mm; font-weight: 900; min-width: 150mm; }
.dip-line { width: 150mm; border-top: 0.7mm dashed #cbd5e1; margin-top: -2mm; }
.dip-text { font-size: 8mm; }
.dip-stats { font-size: 5.5mm; color: var(--muted); font-weight: 700; }
.dip-foot { display: flex; align-items: flex-end; justify-content: space-between; width: 210mm; margin: 4mm 0 2mm; font-size: 4.5mm; color: var(--muted); }
.dip-foot > div { width: 70mm; }
.dip-sign, .dip-date { border-bottom: 0.5mm solid var(--ink); height: 10mm; margin-bottom: 1.5mm; font-size: 5mm; color: var(--ink); font-weight: 800; display: flex; align-items: flex-end; justify-content: center; }
.dip-foot > .dip-badge {
  width: 30mm; height: 30mm; border-radius: 50%; background: var(--a5); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11mm; font-weight: 900;
  box-shadow: 0 0 0 2mm #fde68a;
}
.dip-badge small { font-size: 7mm; margin-left: 1mm; }
@media (max-width: 520px) { nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; } nav button { font-size: 14px; } }
