:root {
  --ink: #2d2a4a;
  --ink-soft: #5b5780;
  --card: #ffffff;
  --purple: #6c5ce7;
  --pink: #fd79a8;
  --orange: #fdaa48;
  --yellow: #ffd93d;
  --green: #00b894;
  --green-dark: #00916f;
  --red: #ff6b6b;
  --red-dark: #e04848;
  --blue: #4dabf7;
  --shadow: 0 8px 0 rgba(45, 42, 74, .12), 0 14px 30px rgba(45, 42, 74, .12);
  --radius: 26px;
  font-family: "Fredoka", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  color: var(--ink);
  background: linear-gradient(160deg, #8fd3ff 0%, #a29bfe 45%, #fd9ec4 100%) fixed;
  background-color: #a29bfe;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}
button:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }

/* ---------- Achtergrond ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.float { position: absolute; font-size: 42px; opacity: .55; animation: bob 7s ease-in-out infinite; }
.f1 { top: 6%;  left: 4%;  animation-delay: 0s; }
.f2 { top: 14%; right: 8%; font-size: 70px; animation-duration: 11s; }
.f3 { bottom: 10%; left: 6%; font-size: 64px; animation-delay: -2s; }
.f4 { top: 45%; right: 3%; animation-delay: -4s; }
.f5 { bottom: 18%; right: 12%; animation-delay: -1s; animation-duration: 9s; }
.f6 { top: 60%; left: 2%; font-size: 56px; animation-duration: 13s; }
.f7 { top: 30%; left: 12%; font-size: 36px; animation-delay: -3s; }
.f8 { bottom: 4%; right: 40%; font-size: 30px; animation-delay: -5s; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-22px) rotate(8deg); }
}

.sound-btn {
  position: absolute; top: 12px; right: 12px; z-index: 30;
  width: 52px; height: 52px; border-radius: 50%;
  background: #fff; font-size: 26px; box-shadow: var(--shadow);
}
.sound-btn:active { transform: scale(.92); }

/* ---------- Schermen ---------- */
main { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 16px 16px 40px; }
.screen { display: none; }
.screen.active { display: block; animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop-in { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin: 18px 0;
}
.card h2 { margin: 0 0 14px; font-size: 1.35rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.h-icon {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 14px;
  background: #f1efff; font-size: 24px;
}
.hint { margin: -6px 0 12px; color: var(--ink-soft); font-size: .95rem; }

/* ---------- Hero / mascotte ---------- */
.hero { display: flex; align-items: center; gap: 14px; padding-top: 22px; }
.hero h1 { margin: 0; font-size: clamp(2.6rem, 9vw, 4.2rem); line-height: 1; font-weight: 700; letter-spacing: 1px;
  color: #fff; text-shadow: 0 4px 0 rgba(45,42,74,.25); }
.rainbow { color: var(--yellow); }
.rainbow.r2 { color: #fff; }
.hero-text { flex: 1; min-width: 0; }
.speech {
  position: relative; margin-top: 10px; background: #fff; border-radius: 20px; padding: 12px 16px;
  font-size: 1.1rem; font-weight: 500; box-shadow: var(--shadow); display: inline-block;
}
.speech::before {
  content: ""; position: absolute; left: -12px; top: 18px;
  border: 10px solid transparent; border-right: 14px solid #fff; border-left: 0;
}
.owl-slot { width: 120px; flex-shrink: 0; }
.owl { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 0 rgba(45,42,74,.18)); }
.owl .eyes-happy, .owl .eyes-sad, .owl .tear { display: none; }
[data-mood="happy"] .owl .eyes-open { display: none; }
[data-mood="happy"] .owl .eyes-happy { display: inline; }
[data-mood="sad"] .owl .eyes-open { display: none; }
[data-mood="sad"] .owl .eyes-sad, [data-mood="sad"] .owl .tear { display: inline; }
[data-mood="happy"] .owl { animation: hop .6s ease; }
[data-mood="sad"] .owl { animation: shake .5s ease; }
.hero .owl { animation: wiggle 3s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-18px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- Tafeltegels ---------- */
.tables-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.table-tile {
  --c: var(--purple);
  position: relative; aspect-ratio: 1; border-radius: 22px;
  background: #f3f2f8; color: #b3b0cc;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 4px dashed #d9d6ea;
  transition: transform .15s, background .2s, color .2s, border-color .2s;
}
.table-tile .t-num { font-size: clamp(1.9rem, 7vw, 2.8rem); font-weight: 700; line-height: 1; }
.table-tile .t-emoji { font-size: clamp(1.1rem, 4vw, 1.6rem); filter: grayscale(1); opacity: .5; transition: .2s; }
.table-tile .tick {
  position: absolute; top: -8px; right: -8px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 16px; display: grid; place-items: center;
  transform: scale(0); transition: transform .2s cubic-bezier(.2, 1.6, .4, 1); box-shadow: 0 3px 0 var(--green-dark);
}
.table-tile[aria-pressed="true"] {
  background: var(--c); color: #fff; border: 4px solid rgba(0,0,0,.08);
  box-shadow: 0 6px 0 rgba(0,0,0,.18); transform: translateY(-3px);
}
.table-tile[aria-pressed="true"] .t-emoji { filter: none; opacity: 1; }
.table-tile[aria-pressed="true"] .tick { transform: scale(1); }
.table-tile:active { transform: scale(.94); }

.quick-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.pill {
  background: #f1efff; border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 1rem;
  box-shadow: 0 4px 0 #d9d4ff;
}
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9d4ff; }

/* ---------- Bewerkingen ---------- */
.ops-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.op-tile {
  position: relative; border-radius: 22px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center;
  background: #f3f2f8; color: #b3b0cc; border: 4px dashed #d9d6ea; transition: .2s;
}
.op-symbol { font-size: 3rem; font-weight: 700; line-height: 1; }
.op-name { font-weight: 600; font-size: 1.1rem; }
.op-tile .tick {
  position: absolute; top: -8px; right: -8px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--green); color: #fff; display: grid; place-items: center;
  transform: scale(0); transition: transform .2s cubic-bezier(.2, 1.6, .4, 1); box-shadow: 0 3px 0 var(--green-dark);
}
.op-tile[aria-pressed="true"] { background: var(--orange); color: #fff; border: 4px solid rgba(0,0,0,.06); box-shadow: 0 6px 0 #d9822a; }
.op-tile.div[aria-pressed="true"] { background: var(--blue); box-shadow: 0 6px 0 #2b87d1; }
.op-tile[aria-pressed="true"] .tick { transform: scale(1); }
.op-tile:active { transform: scale(.96); }

/* ---------- Steppers ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #fff8e1; border-radius: 22px; padding: 10px; }
.step {
  width: 58px; height: 58px; border-radius: 50%; font-size: 2rem; font-weight: 700; color: #fff; flex-shrink: 0;
  background: var(--pink); box-shadow: 0 5px 0 #d65c8a;
}
.step.plus { background: var(--green); box-shadow: 0 5px 0 var(--green-dark); }
.step:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.step:disabled { opacity: .35; cursor: default; }
.step-value { text-align: center; display: flex; flex-direction: column; line-height: 1; }
.step-value span { font-size: 2.6rem; font-weight: 700; }
.step-value small { font-size: .95rem; color: var(--ink-soft); font-weight: 500; }

/* ---------- Grote knoppen ---------- */
.big-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 18px 24px; border-radius: 999px; font-size: 1.6rem; font-weight: 700; color: #fff;
  background: var(--green); box-shadow: 0 8px 0 var(--green-dark), 0 14px 30px rgba(0,0,0,.18);
  transition: transform .1s, box-shadow .1s;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--green-dark); }
.big-btn small { font-size: 1rem; font-weight: 500; opacity: .9; }
.big-btn.start { margin: 26px 0 8px; font-size: 2rem; }
.big-btn.start .btn-emoji { display: inline-block; animation: hop 1.4s ease-in-out infinite; }
.big-btn:disabled { background: #b8b5cc; box-shadow: 0 8px 0 #9693ad; cursor: not-allowed; }
.big-btn:disabled .btn-emoji { animation: none; }
.big-btn.again { background: var(--orange); box-shadow: 0 8px 0 #d9822a, 0 14px 30px rgba(0,0,0,.18); }
.big-btn.again:active { box-shadow: 0 2px 0 #d9822a; }
.big-btn.home { background: var(--purple); box-shadow: 0 8px 0 #4b3cc4, 0 14px 30px rgba(0,0,0,.18); }
.big-btn.home:active { box-shadow: 0 2px 0 #4b3cc4; }

/* ---------- Geschiedenis ---------- */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.history-list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 18px; background: #f7f6fd;
}
.history-list .h-stars { font-size: 1.2rem; letter-spacing: -2px; white-space: nowrap; }
.history-list .h-main { flex: 1; min-width: 0; }
.history-list .h-main b { display: block; }
.history-list .h-main small { color: var(--ink-soft); }
.history-list .h-score { font-weight: 700; font-size: 1.2rem; color: var(--purple); white-space: nowrap; }
.link-btn { margin-top: 12px; color: var(--ink-soft); font-size: .95rem; text-decoration: underline; }

/* ---------- Oefenscherm ---------- */
.topbar { display: flex; gap: 10px; align-items: center; padding-right: 60px; }
.chip {
  display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px;
  padding: 8px 16px; font-size: 1.3rem; box-shadow: var(--shadow);
}
.chip b { font-variant-numeric: tabular-nums; }
.chip.clock.low { background: var(--red); color: #fff; animation: pulse 1s infinite; }
.chip.stop { margin-left: auto; font-weight: 600; font-size: 1.05rem; }
.chip.stop:active { transform: scale(.95); }
@keyframes pulse { 50% { transform: scale(1.06); } }

.track { position: relative; height: 22px; margin: 22px 30px 10px 6px; background: rgba(255,255,255,.55); border-radius: 999px; }
.track-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), var(--orange), var(--pink)); transition: width .6s ease; }
.rocket { position: absolute; top: 50%; left: 0; font-size: 34px; transform: translate(-30%, -55%) rotate(45deg); transition: left .6s ease; }
.planet { position: absolute; right: -26px; top: 50%; transform: translateY(-50%); font-size: 40px; }

.play-area {
  display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 18px; justify-items: center;
}
.question-card {
  position: relative; width: 100%; background: #fff; border-radius: 34px; box-shadow: var(--shadow);
  padding: 34px 20px 28px; text-align: center; overflow: hidden;
}
.question { font-size: clamp(3.4rem, 15vw, 6rem); font-weight: 700; line-height: 1.05; color: var(--purple); letter-spacing: 2px; }
.question .op { color: var(--pink); margin: 0 .12em; }
.answer-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; }
.eq { font-size: clamp(2.6rem, 11vw, 4.4rem); font-weight: 700; color: var(--ink-soft); }
.answer-box {
  min-width: 2.6em; height: 1.35em; font-size: clamp(2.6rem, 11vw, 4.4rem); font-weight: 700;
  border-radius: 22px; background: #fff8e1; border: 5px solid var(--yellow);
  display: flex; align-items: center; justify-content: center; padding: 0 .3em; color: var(--ink);
}
.answer-box .caret { display: inline-block; width: 4px; height: .9em; background: var(--orange); margin-left: 4px; border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.answer-box.bump { animation: bump .15s ease; }
@keyframes bump { 50% { transform: scale(1.08); } }

.timer-ring { position: absolute; top: 14px; right: 14px; width: 74px; height: 74px; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: #f1efff; stroke: #e6e3f7; stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--green); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 276.46; stroke-dashoffset: 0; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.6rem; }
.timer-ring.warn .ring-num { color: var(--red); animation: pulse .5s infinite; }

.repeat-badge {
  position: absolute; top: 18px; left: 18px; background: #ffe7ef; color: #c2185b; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; font-size: 1rem;
}

.feedback {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: #fff; padding: 20px; cursor: pointer; animation: pop-in .3s cubic-bezier(.2, 1.6, .4, 1);
}
.feedback[hidden] { display: none; }
.feedback.good { background: radial-gradient(circle at 50% 30%, #55efc4, var(--green)); }
.feedback.bad  { background: radial-gradient(circle at 50% 30%, #ff9a9a, var(--red)); }
.feedback.slow { background: radial-gradient(circle at 50% 30%, #ffd08a, var(--orange)); }
.fb-icon { font-size: 4.5rem; line-height: 1; animation: spin-in .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes spin-in { from { transform: scale(0) rotate(-180deg); } to { transform: none; } }
.fb-title { font-size: clamp(2rem, 8vw, 3rem); font-weight: 700; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
.fb-detail { font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 600; }
.fb-detail .yours { text-decoration: line-through; opacity: .75; margin-right: 8px; }
.fb-detail .right { background: #fff; color: var(--ink); border-radius: 14px; padding: 0 12px; }
.fb-tap { margin-top: 10px; font-size: 1rem; opacity: .9; }

.side-owl { display: none; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 420px; }
.numpad button {
  height: 72px; border-radius: 22px; font-size: 2.2rem; font-weight: 700; color: #fff;
  background: var(--purple); box-shadow: 0 6px 0 #4b3cc4;
}
.numpad button:nth-child(3n+1) { background: var(--blue); box-shadow: 0 6px 0 #2b87d1; }
.numpad button:nth-child(3n+2) { background: var(--pink); box-shadow: 0 6px 0 #d65c8a; }
.numpad button:nth-child(3n)   { background: var(--orange); box-shadow: 0 6px 0 #d9822a; }
.numpad button.back { background: #fff; color: var(--red); box-shadow: 0 6px 0 #ddd; }
.numpad button.ok { background: var(--green); box-shadow: 0 6px 0 var(--green-dark); font-size: 2.4rem; }
.numpad button:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.numpad.locked button { opacity: .5; pointer-events: none; }

/* ---------- Rapport ---------- */
.score-card { text-align: center; position: relative; padding-top: 30px; }
.medal { font-size: 5rem; line-height: 1; animation: hop 1.2s ease-in-out infinite; }
.big-stars { font-size: 3rem; margin: 6px 0; letter-spacing: 4px; }
.big-stars .off { filter: grayscale(1); opacity: .25; }
.big-stars span { display: inline-block; animation: spin-in .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.big-stars span:nth-child(2) { animation-delay: .2s; }
.big-stars span:nth-child(3) { animation-delay: .4s; }
.score-line { font-weight: 700; line-height: 1; }
.score-num { font-size: 4.5rem; color: var(--purple); }
.score-of { font-size: 2rem; color: var(--ink-soft); margin-left: 6px; }
.score-label { font-size: 1.15rem; color: var(--ink-soft); font-weight: 500; }
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 20px; }
.stat { border-radius: 18px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; }
.stat b { font-size: 1.6rem; }
.stat small { color: var(--ink-soft); font-size: .85rem; }
.stat-icon { font-size: 1.6rem; }
.s1 { background: #e3fbf3; } .s2 { background: #eef0ff; } .s3 { background: #ffecec; } .s4 { background: #fff3e0; } .s5 { background: #e7f5ff; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.ex-chip {
  position: relative; padding: 10px 16px; border-radius: 16px; font-weight: 600; font-size: 1.25rem;
  background: #fff3e0; border: 3px solid var(--orange);
}
.ex-chip .count {
  position: absolute; top: -12px; right: -10px; min-width: 28px; height: 28px; border-radius: 14px; padding: 0 6px;
  background: var(--red); color: #fff; font-size: .9rem; display: grid; place-items: center; box-shadow: 0 2px 0 var(--red-dark);
}
.ex-chip.todo { background: #ffecec; border-color: var(--red); }
.ex-chip.hot { background: #ffe3e3; border-color: var(--red-dark); }
.empty-note { color: var(--ink-soft); font-size: 1.05rem; }
.unseen-note { margin: 16px 0 0; padding: 10px 14px; border-radius: 16px; background: #eef0ff; font-weight: 500; }
.hint:empty { display: none; }

.report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 26px; }
.report-actions .big-btn { font-size: 1.3rem; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(45,42,74,.5); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 30px; padding: 26px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); animation: pop-in .3s cubic-bezier(.2, 1.6, .4, 1); }
.modal-icon { font-size: 4rem; }
.modal-card p { font-size: 1.5rem; font-weight: 600; margin: 6px 0 20px; }
.modal-actions { display: grid; gap: 14px; }
.modal-actions .big-btn { font-size: 1.3rem; }

/* ---------- Confetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetto { position: absolute; top: -40px; font-size: 28px; animation: fall linear forwards; }
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Groot scherm: uil naast vraag ---------- */
@media (min-width: 760px) {
  .play-area { grid-template-columns: 1fr 140px; align-items: end; }
  .question-card { grid-column: 1; }
  .side-owl { display: block; grid-column: 2; grid-row: 1; width: 130px; align-self: center; }
  .numpad { grid-column: 1 / -1; }
}

/* ---------- Smal scherm ---------- */
@media (max-width: 560px) {
  .tables-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .table-tile { border-radius: 16px; border-width: 3px; }
  .two-col { grid-template-columns: 1fr; gap: 16px; }
  .owl-slot { width: 86px; }
  .hero { padding-top: 40px; }
  .speech { font-size: 1rem; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .report-actions { grid-template-columns: 1fr; }
  .chip { font-size: 1.1rem; padding: 8px 12px; }
  .chip.stop span { display: none; }
  .numpad button { height: 64px; }
  .timer-ring { width: 60px; height: 60px; top: 10px; right: 10px; }
  .ring-num { font-size: 1.3rem; }
  .question-card { padding-top: 64px; }
  .card { padding: 18px 16px; }
}

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