/* Breukenlab: gedeelde stijl voor alle delen (zelfde huisstijl als de Tafeltrainer) */
:root {
  --bg: #fdf8ef;
  --card: #ffffff;
  --ink: #1f2440;
  --muted: #6b7090;
  --line: #e7e2d6;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --accent: #2563eb;
  --deel: #f97316;      /* kleur van een gekleurd stuk */
  --deel-dark: #c2410c;
  --leeg: #fff4dc;      /* kleur van een leeg stuk */
  --korst: #e0a458;
  --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; }
a { color: var(--accent); }
.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: 22px; text-decoration: none; color: var(--ink); }
.logo-badge {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--deel), #ef4444); color: #fff; font-size: 22px;
}
.logo small { display: block; font-size: 14px; color: var(--muted); font-weight: 800; }
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); }
nav button .check { color: var(--good); }
nav button.active .check { color: #86efac; }
.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; }

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

.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; }

.big-btn {
  border: none; border-radius: 16px; padding: 14px 26px;
  font-weight: 900; font-size: 21px; color: #fff; background: var(--accent);
  box-shadow: 0 4px 0 #1d4ed8; text-decoration: none; display: inline-block;
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1d4ed8; }
.big-btn:disabled { opacity: .4; cursor: default; transform: none; }
.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; text-decoration: none; color: var(--ink); display: inline-block;
}

/* ---------- breuk (boven / streep / onder) ---------- */
.frac {
  display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle;
  font-weight: 900; line-height: 1.05; margin: 0 .12em;
}
.frac > span { padding: 0 .15em; min-width: .8em; text-align: center; }
.frac > span:first-child { border-bottom: .09em solid currentColor; padding-bottom: .04em; }
.frac > span:last-child { padding-top: .04em; }
.frac.big { font-size: 64px; }
.frac.mid { font-size: 38px; }
.frac.small { font-size: 22px; }

/* ---------- vormen ---------- */
.shape { display: block; margin: 0 auto; max-width: 100%; height: auto; touch-action: manipulation; }
.shape .pc { stroke: #fff; stroke-width: 3; transition: fill .2s; }
.shape .pc.leeg { fill: var(--leeg); }
.shape .pc.vol { fill: var(--deel); }
.shape .pc.vol2 { fill: #60a5fa; }
.shape .pc.weg { fill: #fee2e2; stroke-dasharray: 7 5; }
.shape.tap .pc { cursor: pointer; }
.shape.tap .pc:hover { filter: brightness(.96); }
.shape .pc.flash { animation: pulse .6s ease; }
.shape .korst { fill: none; stroke: var(--korst); stroke-width: 10; }
.shape .rand { fill: none; stroke: #b45309; stroke-width: 4; }
.shape .reep .pc { stroke: #92400e; stroke-width: 2.5; }
.shape .lbl { font-weight: 900; font-size: 22px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.shape .lbl.op-vol { fill: #fff; }

.shape .helft-lijn { stroke: var(--ink); stroke-width: 3; stroke-dasharray: 7 6; }
.repen { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.repen-rij { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 470px; }
.repen-lbl { width: 70px; text-align: center; flex: none; }
.repen-rij .shape { flex: 1; min-width: 0; width: 100%; }
.shape.lijn { overflow: visible; }
.lijn .lijn-as { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.lijn .lijn-vul { stroke: var(--deel); stroke-width: 12; stroke-linecap: round; }
.lijn .lijn-streep { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.lijn .lijn-getal { font-weight: 900; font-size: 28px; text-anchor: middle; fill: var(--ink); }
.lijn .lijn-breuk { font-weight: 900; font-size: 17px; text-anchor: middle; fill: var(--muted); }
.lijn .lijn-breukstreep { stroke: var(--muted); stroke-width: 2; }
.lijn .lijn-gekozen { fill: var(--accent); stroke: #fff; stroke-width: 4; }
.lijn .lijn-goed { fill: var(--good); stroke: #fff; stroke-width: 4; }
.lijn .lijn-pijl { fill: var(--deel); }
.lijn .lijn-hit { fill: transparent; cursor: pointer; }
.lijn .lijn-hit:hover { fill: rgba(37, 99, 235, .06); }
.som { font-size: 44px; font-weight: 900; text-align: center; margin: 0 0 16px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.som .frac { font-size: 1em; }
.som .ans-slot { display: inline-block; min-width: 1.2em; border-radius: 10px; background: #eff6ff; outline: 3px solid var(--accent); color: var(--accent); padding: 0 .1em; margin: 2px 0; }
.som.good .ans-slot { background: var(--good-bg); outline-color: var(--good); color: var(--good); }
.som.bad .ans-slot { outline-color: var(--bad); animation: shake .35s; }
.groep .zak-rand { fill: #f8fafc; stroke: #cbd5e1; stroke-width: 3; stroke-dasharray: 8 6; transition: fill .2s; }
.groep .knikker { fill: #60a5fa; stroke: #1d4ed8; stroke-width: 1.5; transition: fill .2s; }
.groep .zak.vol .zak-rand { fill: #ffedd5; stroke: var(--deel); stroke-dasharray: none; }
.groep .zak.vol .knikker { fill: var(--deel); stroke: var(--deel-dark); }
.groep.tap .zak { cursor: pointer; }
.groep .zak-tel { font-weight: 900; font-size: 20px; text-anchor: middle; fill: var(--muted); }
.orden { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.orden button { position: relative; border: 3px solid var(--line); background: var(--card); border-radius: 18px; min-width: 96px; min-height: 96px; font-size: 30px; box-shadow: 0 4px 0 var(--line); }
.orden button .plek { position: absolute; top: -12px; right: -12px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 17px; font-weight: 900; display: grid; place-items: center; }
.orden button.gekozen { border-color: var(--accent); background: #eff6ff; }
.orden-rij { display: flex; gap: 10px; justify-content: center; align-items: center; min-height: 70px; font-size: 26px; font-weight: 900; color: var(--muted); flex-wrap: wrap; }
.orden-rij .frac { color: var(--ink); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pick {
  border: 3px solid var(--line); background: var(--card); border-radius: 18px; padding: 12px;
  font-weight: 900; font-size: 20px; box-shadow: 0 4px 0 var(--line);
}
.pick.good { border-color: var(--good); background: var(--good-bg); }
.pick.bad { border-color: var(--bad); background: var(--bad-bg); }

/* ---------- 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: #f59e0b; }
.progress span.miss { background: var(--bad); }
.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; }

.qtext { font-size: 26px; font-weight: 900; text-align: center; margin: 4px 0 14px; }
.qtext .frac { font-size: 1.3em; }
.feedback { min-height: 32px; text-align: center; font-weight: 900; font-size: 22px; margin: 10px 0; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback .say { display: block; font-size: 17px; color: var(--muted); font-weight: 800; }

.mc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mc button {
  border: 3px solid var(--line); background: var(--card);
  border-radius: 18px; padding: 12px 0; font-size: 30px; font-weight: 900;
  box-shadow: 0 4px 0 var(--line); min-height: 86px;
}
.mc button.word { font-size: 24px; }
.mc button .frac { font-size: 1.2em; }
.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; }

/* breuk-invoer */
.fin { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.fin-frac { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.fin-slot {
  min-width: 84px; height: 72px; border-radius: 14px; border: 3px solid var(--line); background: #fff;
  font-size: 46px; font-weight: 900; display: grid; place-items: center; padding: 0 10px;
}
.fin-slot.on { border-color: var(--accent); background: #eff6ff; box-shadow: 0 0 0 4px #bfdbfe; color: var(--accent); }
.fin-bar { width: 110px; height: 6px; border-radius: 3px; background: var(--ink); }
.fin.good .fin-slot { border-color: var(--good); background: var(--good-bg); color: var(--good); box-shadow: none; }
.fin.bad .fin-frac { animation: shake .35s; }
.fin.bad .fin-slot { border-color: var(--bad); }
.fin-help { font-size: 15px; color: var(--muted); font-weight: 800; text-align: center; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 330px; margin: 0 auto; }
.numpad button {
  border: none; background: #eef2ff; border-radius: 16px;
  padding: 12px 0; font-size: 28px; 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; }

.tipbox {
  border-radius: 16px; padding: 14px 16px; margin-bottom: 12px;
  background: #fef3c7; border: 2px dashed #f59e0b; color: #78350f; font-weight: 800;
}
.tipbox .title { font-weight: 900; font-size: 19px; margin-bottom: 4px; }

.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: 20px; font-weight: 900;
}
.step .nr { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: 16px; flex: none; }
.step > span:last-child { flex: 1; min-width: 0; }
.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.todo { opacity: .45; }

.explain { background: #f8fafc; border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px; font-weight: 700; }
.explain b { color: var(--deel-dark); }

/* ---------- ontdekken ---------- */
.lesson { max-width: 860px; margin: 0 auto; }
.lesson-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.lesson-dots span { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.lesson-dots span.done { background: var(--good); }
.lesson-dots span.now { background: var(--accent); transform: scale(1.3); }
.lesson h2 { text-align: center; }
.lesson .sub { text-align: center; font-size: 20px; color: var(--ink); font-weight: 700; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; }
@media (max-width: 700px) { .split { grid-template-columns: 1fr; } }
.live-frac { display: flex; align-items: center; justify-content: center; gap: 16px; }
.live-frac .side { display: flex; flex-direction: column; justify-content: space-between; height: 150px; font-size: 16px; font-weight: 800; color: var(--muted); max-width: 190px; }
.live-frac .side .top { color: var(--deel-dark); }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 10px 0; }
.names > div { background: #f8fafc; border: 2px solid var(--line); border-radius: 14px; padding: 8px; text-align: center; font-weight: 900; }
.names .frac { font-size: 28px; }
.names svg { width: 70px; height: 70px; display: block; margin: 4px auto; }

/* ---------- eindscherm ---------- */
.result { text-align: center; }
.result .stars { font-size: 56px; margin: 6px 0; }
.result .row { justify-content: center; }
.name-form { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 14px 0; }
.name-form input { font: inherit; font-size: 24px; font-weight: 800; padding: 10px 14px; border: 3px solid var(--line); border-radius: 14px; text-align: center; width: min(360px, 100%); }

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

/* ---------- overzicht ---------- */
.delen { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.deel-kaart { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); position: relative; }
.deel-kaart .nr { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 22px; color: #fff; background: var(--deel); }
.deel-kaart h3 { font-size: 22px; margin: 4px 0 0; }
.deel-kaart .groep { color: var(--muted); font-weight: 800; font-size: 15px; }
.deel-kaart .stat { font-weight: 800; font-size: 15px; }
.deel-kaart.dicht { opacity: .55; }
.deel-kaart.dicht .nr { background: #cbd5e1; }

/* ---------- animaties ---------- */
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.pop { animation: pop .35s ease; }
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 3px; z-index: 50; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ---------- diploma (printen) ---------- */
#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(--deel); border-radius: 10mm;
  outline: 1.5mm solid var(--accent); 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-pizzas { display: flex; gap: 4mm; }
.dip-pizzas svg { width: 12mm; height: 12mm; }
.dip-title { font-size: 18mm; font-weight: 900; color: var(--deel-dark); letter-spacing: 1mm; margin-top: 2mm; }
.dip-deel { font-size: 7mm; font-weight: 900; color: var(--accent); }
.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: 6.5mm; max-width: 225mm; }
.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(--deel); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 5mm; font-weight: 900;
  box-shadow: 0 0 0 2mm #fed7aa; line-height: 1;
}
.dip-badge b { font-size: 13mm; }

@media (max-width: 520px) {
  header { padding: 10px 12px; gap: 10px; }
  .logo { flex: 1; font-size: 19px; }
  .sound-btn { order: 2; }
  nav { order: 3; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; width: 100%; margin-left: 0; }
  nav button { font-size: 13px; padding: 8px 2px; white-space: nowrap; }
  .card { padding: 16px; }
  .qtext { font-size: 22px; }
  .mc button { font-size: 26px; min-height: 76px; }
  .frac.big { font-size: 52px; }
}
