:root {
  --green: #58CC02; --green-d: #46A302; --green-l: #D7FFB8; --green-ink: #3A8A00;
  --blue: #1CB0F6; --blue-d: #1899D6; --blue-l: #DDF4FF; --blue-ink: #1482BA;
  --orange: #FF9600; --orange-d: #E08600; --orange-l: #FFF0D9; --orange-ink: #C26F00;
  --red: #FF4B4B; --red-d: #EA2B2B; --red-l: #FFDFE0;
  --purple: #CE82FF; --purple-d: #A568CC; --purple-l: #F4E6FF;
  --yellow: #FFC800; --yellow-d: #E5A800;
  --pink: #FF4B8B;
  --ink: #3C3C3C; --ink-2: #4B4B4B; --muted: #777; --line: #E5E5E5; --line-d: #CECECE;
  --bg: #FFFFFF; --bg-2: #F7F7F7;
  --radius: 16px;
  --font: ui-rounded, "Nunito", "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease-out: cubic-bezier(.2, .9, .3, 1.2);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 700;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
.app { max-width: 680px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 16px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 3D-knoppen ---------- */
.btn {
  --c: var(--green); --cd: var(--green-d); --fg: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 24px; border-radius: var(--radius);
  background: var(--c); color: var(--fg); font-weight: 900; font-size: 17px; letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 5px 0 var(--cd); transform: translateY(0); transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 0 0 var(--cd); }
.btn:disabled { --c: var(--line); --cd: var(--line-d); --fg: #AFAFAF; cursor: default; }
.btn-block { width: 100%; }
.btn-xl { min-height: 68px; font-size: 21px; border-radius: 20px; }
.btn-blue { --c: var(--blue); --cd: var(--blue-d); }
.btn-orange { --c: var(--orange); --cd: var(--orange-d); }
.btn-purple { --c: var(--purple); --cd: var(--purple-d); }
.btn-ghost { --c: #fff; --cd: var(--line); --fg: var(--blue); border: 2px solid var(--line); }
.btn-ghost:active:not(:disabled) { box-shadow: 0 0 0 var(--line); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: #AFAFAF; font-size: 26px; }
.icon-btn:active { background: var(--bg-2); }

/* ---------- koppelen ---------- */
.pair { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.pair h1 { font-size: 30px; font-weight: 900; margin: 0; }
.pair p { color: var(--muted); margin: 0; max-width: 360px; }
.code-input {
  width: min(340px, 100%); text-align: center; font-size: 34px; font-weight: 900; letter-spacing: .3em; text-transform: uppercase;
  padding: 14px 12px 14px 22px; border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 18px; outline: none; color: var(--ink); background: var(--bg-2);
}
.code-input:focus { border-color: var(--blue); background: #fff; }
.err { color: var(--red-d); min-height: 22px; }

/* ---------- home ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; font-weight: 900; font-size: 18px; }
.stat .ico { font-size: 22px; line-height: 1; }
.stat.streak { color: var(--orange); }
.stat.streak.off { color: #AFAFAF; filter: grayscale(1); }
.stat.xp { color: var(--blue); }
.spacer { flex: 1; }
.hero { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; margin: 8px 0 0; }
.bubble {
  position: relative; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; font-size: 18px; line-height: 1.35;
}
.bubble::before {
  content: ""; position: absolute; left: -11px; top: 50%; width: 18px; height: 18px; background: #fff;
  border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: translateY(-50%) rotate(45deg); border-radius: 0 0 0 5px;
}
.ring-wrap { display: flex; flex-direction: column; align-items: center; margin: 14px 0 18px; }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); overflow: visible; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--green); transition: stroke-dashoffset .7s var(--ease-out); filter: drop-shadow(0 3px 0 var(--green-d)); }
.ring.full .fill { stroke: var(--yellow); filter: drop-shadow(0 3px 0 var(--yellow-d)); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1; }
.ring-label b { display: block; font-size: 40px; font-weight: 900; color: var(--ink); }
.ring-label small { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.ring-caption { margin-top: 10px; color: var(--muted); font-size: 16px; }
.ring.pop { animation: pop .45s var(--ease-out); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

.section-title { font-size: 20px; font-weight: 900; margin: 26px 0 12px; }
.domains { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.domain {
  --c: var(--blue); --cl: var(--blue-l); --cd: var(--blue-d);
  text-align: left; padding: 14px; border-radius: 18px; background: #fff; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line);
  display: flex; flex-direction: column; gap: 8px; transition: transform .08s, box-shadow .08s;
}
.domain:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.domain .em { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: var(--cl); box-shadow: inset 0 -4px 0 rgba(0,0,0,.07); }
.domain .nm { font-size: 18px; font-weight: 900; }
.domain .lv { height: 12px; border-radius: 99px; background: var(--line); overflow: hidden; }
.domain .lv i { display: block; height: 100%; background: var(--c); border-radius: 99px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.domain .sub { font-size: 13px; color: var(--muted); }
.domain.green { --c: var(--green); --cl: var(--green-l); }
.domain.purple { --c: var(--purple); --cl: var(--purple-l); }
.domain.orange { --c: var(--orange); --cl: var(--orange-l); }
.skills-list { margin-top: 12px; display: grid; gap: 8px; }
.skill-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; }
.skill-row .nm { flex: 1; font-size: 15px; }
.skill-row .nm small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.dots { display: flex; gap: 4px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--yellow); box-shadow: inset 0 -2px 0 var(--yellow-d); }
.link-btn { color: var(--blue); font-weight: 900; text-transform: uppercase; letter-spacing: .05em; font-size: 14px; padding: 12px 0; }

/* ---------- les ---------- */
.lesson { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.lesson-top { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.combo { font-weight: 900; color: var(--orange); font-size: 17px; display: inline-flex; align-items: center; gap: 4px; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .3s var(--ease-out); }
.combo.on { opacity: 1; transform: scale(1); }
.mode-tag { font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; padding: 5px 10px; border-radius: 10px; background: var(--purple-l); color: var(--purple-d); }
.mode-tag.herhaling { background: var(--orange-l); color: var(--orange-ink); }
.lesson-body { flex: 1; display: flex; flex-direction: column; gap: 18px; padding: 8px 0 18px; animation: slideIn .35s var(--ease-out); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
.instruction { font-size: 24px; font-weight: 900; margin: 6px 0 0; line-height: 1.2; }
.prompt { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; }
.prompt .bubble { font-size: 21px; line-height: 1.5; }
.prompt.no-pip { grid-template-columns: 1fr; }
.prompt.no-pip .bubble::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 4px 12px; border-radius: 99px; background: var(--blue-l); color: var(--blue-ink); font-size: 15px; font-weight: 800; }
.gap {
  display: inline-block; min-width: 72px; padding: 0 6px; margin: 0 2px; border-bottom: 3px solid var(--line-d); color: var(--blue-ink);
  text-align: center; transition: border-color .15s; min-height: 1.3em; vertical-align: baseline;
}
.gap.filled { border-color: var(--blue); }
.gap.part { min-width: 36px; }
.hl { background: var(--yellow); background: linear-gradient(transparent 55%, #FFE780 55%); padding: 0 2px; }

.options { display: grid; gap: 12px; }
.options.grid2 { grid-template-columns: 1fr 1fr; }
.opt {
  min-height: 60px; padding: 12px 16px; border-radius: var(--radius); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line);
  background: #fff; font-size: 20px; font-weight: 800; color: var(--ink-2); text-align: center; line-height: 1.25;
  transition: transform .08s, box-shadow .08s, border-color .12s, background .12s;
}
.options.stack .opt { text-align: left; font-size: 18px; }
.opt:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.opt.sel { border-color: var(--blue); background: var(--blue-l); color: var(--blue-ink); box-shadow: 0 4px 0 var(--blue); }
.opt.good { border-color: var(--green); background: var(--green-l); color: var(--green-ink); box-shadow: 0 4px 0 var(--green); }
.opt.bad { border-color: var(--red); background: var(--red-l); color: var(--red-d); box-shadow: 0 4px 0 var(--red); animation: shake .4s; }
.opt.gone { opacity: .35; pointer-events: none; transform: scale(.96); }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

.answer-input {
  width: 100%; font-size: 26px; font-weight: 800; padding: 16px 18px; border-radius: 18px; border: 2px solid var(--line); border-bottom-width: 5px;
  background: var(--bg-2); color: var(--ink); outline: none; text-align: center;
}
.answer-input:focus { border-color: var(--blue); background: #fff; }
.speak-row { display: flex; gap: 12px; justify-content: center; }
.speak-btn { width: 96px; height: 96px; border-radius: 26px; font-size: 44px; }
.speak-btn.slow { width: 64px; height: 64px; font-size: 28px; border-radius: 18px; align-self: flex-end; }

.tokens { display: flex; flex-wrap: wrap; gap: 10px 8px; font-size: 22px; line-height: 1.2; }
.tok {
  padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); background: #fff; font-weight: 800; color: var(--ink-2);
  transition: transform .08s, box-shadow .08s, background .12s, border-color .12s;
}
.tok:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.tok.sel { background: var(--blue-l); border-color: var(--blue); color: var(--blue-ink); box-shadow: 0 4px 0 var(--blue); }
.tok.hint { text-decoration: underline dotted var(--purple-d) 3px; text-underline-offset: 6px; }
.tok.good { background: var(--green-l); border-color: var(--green); color: var(--green-ink); box-shadow: 0 4px 0 var(--green); }
.tok.bad { background: var(--red-l); border-color: var(--red); color: var(--red-d); box-shadow: 0 4px 0 var(--red); animation: shake .4s; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match .col { display: grid; gap: 12px; }
.match .opt { font-size: 18px; min-height: 58px; }

.lesson-foot { position: sticky; bottom: 0; padding: 12px 0 0; background: linear-gradient(transparent, #fff 18%); }

/* ---------- feedback sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; transform: translateY(105%); transition: transform .35s var(--ease-out);
  padding: 18px 16px calc(var(--safe-b) + 18px);
}
.sheet.show { transform: none; }
.sheet .in { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.sheet.good { background: var(--green-l); color: var(--green-ink); }
.sheet.bad { background: var(--orange-l); color: var(--orange-ink); }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 26px; font-weight: 900; flex: 1; }
.sheet .xp-pop { font-weight: 900; color: var(--blue); animation: rise .9s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } 30% { opacity: 1; } to { opacity: 1; transform: none; } }
.sheet .answer-line { font-size: 18px; color: var(--ink-2); }
.sheet .answer-line b { color: var(--ink); }
.sheet .expl { font-size: 17px; line-height: 1.45; color: var(--ink-2); font-weight: 700; }
.sheet .expl b { color: var(--ink); }
.sheet .ai { background: rgba(255,255,255,.7); border-radius: 14px; padding: 10px 12px; font-size: 16px; color: var(--ink-2); display: flex; gap: 8px; align-items: flex-start; }
.sheet .ai .who { font-weight: 900; color: var(--green-ink); white-space: nowrap; }
.sheet .note { font-size: 14px; opacity: .85; }
.dots-loading::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 1.2em; } }
.mini-pip { width: 56px; height: 56px; flex: none; }

/* ---------- tip / level up / klaar / slot ---------- */
.tip-card { border: 2px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: 0 4px 0 var(--line); background: #fff; }
.tip-card h2 { margin: 0 0 6px; font-size: 22px; font-weight: 900; }
.tip-card .lvl { color: var(--purple-d); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; font-weight: 900; }
.tip-card p { font-size: 18px; line-height: 1.5; margin: 8px 0; color: var(--ink-2); }
.tip-card .ex { background: var(--blue-l); color: var(--blue-ink); border-radius: 12px; padding: 10px 12px; font-size: 17px; margin-top: 10px; }
.center-col { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(255,255,255,.96); animation: fade .25s; padding: 24px 16px; }
@keyframes fade { from { opacity: 0; } }
.overlay .box { width: min(440px, 100%); }
.big-title { font-size: 32px; font-weight: 900; margin: 0; line-height: 1.1; }
.big-title.purple { color: var(--purple-d); }
.big-title.gold { color: var(--yellow-d); }
.stars { display: flex; gap: 6px; justify-content: center; font-size: 34px; }
.stars span { filter: grayscale(1) opacity(.3); transition: filter .3s; }
.stars span.on { filter: none; animation: pop .5s var(--ease-out) both; }
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.stat-card { border: 2px solid var(--line); border-radius: 16px; overflow: hidden; }
.stat-card .t { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #fff; padding: 5px; font-weight: 900; }
.stat-card .v { font-size: 24px; font-weight: 900; padding: 10px 4px; }
.stat-card.y .t { background: var(--yellow); } .stat-card.y .v { color: var(--yellow-d); }
.stat-card.g .t { background: var(--green); } .stat-card.g .v { color: var(--green-ink); }
.stat-card.b .t { background: var(--blue); } .stat-card.b .v { color: var(--blue-ink); }
.week { display: flex; gap: 8px; justify-content: center; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.week i { width: 34px; height: 34px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-style: normal; font-size: 18px; }
.week i.on { background: var(--orange); box-shadow: inset 0 -3px 0 var(--orange-d); }
.week i.today { outline: 3px solid var(--blue); outline-offset: 2px; }
.locked .countdown { font-size: 18px; color: var(--muted); }
.locked .countdown b { color: var(--ink); }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translate(-50%, -150%); z-index: 60;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 16px; font-size: 16px; transition: transform .3s var(--ease-out); max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

/* ---------- Pip animaties ---------- */
.pip { display: block; overflow: visible; }
.pip .pip-bob { transform-origin: 100px 186px; animation: bob 2.6s ease-in-out infinite; }
.pip .pip-eyes { transform-origin: 100px 68px; animation: blink 5s infinite; }
.pip--sleep .pip-eyes { animation: none; }
.pip--sleep .pip-bob { animation: breathe 3.6s ease-in-out infinite; }
.pip--cheer .pip-bob, .pip--happy .pip-bob { animation: hop .7s var(--ease-out) 2; }
.pip--oops .pip-bob { animation: wobble .6s ease-in-out 1; }
.pip .pip-sparkles path { transform-box: fill-box; transform-origin: center; animation: twinkle 1.2s ease-in-out infinite; }
.pip .pip-sparkles path:nth-child(2) { animation-delay: .3s; } .pip .pip-sparkles path:nth-child(3) { animation-delay: .6s; }
.pip .pip-zzz text { animation: zzz 2.4s ease-in-out infinite; }
.pip .pip-zzz text:nth-child(2) { animation-delay: .4s; } .pip .pip-zzz text:nth-child(3) { animation-delay: .8s; }
@keyframes bob { 0%,100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-4px) scale(1.01, .99); } }
@keyframes breathe { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.03, .97); } }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
@keyframes hop { 0% { transform: translateY(0) scale(1.05, .92); } 40% { transform: translateY(-22px) scale(.95, 1.06); } 70% { transform: translateY(0) scale(1.06, .93); } 100% { transform: none; } }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes twinkle { 0%,100% { transform: scale(.6); opacity: .5; } 50% { transform: scale(1.1); opacity: 1; } }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -10px); } }

@media (min-width: 700px) {
  .instruction { font-size: 28px; }
  .prompt { grid-template-columns: 130px 1fr; }
  .prompt .bubble { font-size: 24px; }
  .opt { font-size: 22px; min-height: 68px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
