@font-face {
  font-family: 'Fredoka';
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/fredoka-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fredoka';
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/fredoka-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #2b2d42;
  --paper: #fffaf2;
  --accent: #ff7a59;
  --accent-dark: #d95b3b;
  --good: #2fb36b;
  --bad: #ef476f;
  --font: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --kw: clamp(30px, 4.4vw, 54px);
  /* Stickerstijl: één donkere contour om alle figuren, plus een harde schaduw eronder */
  --line: #2b2d42;
  --outline:
    drop-shadow(1.6px 0 0 var(--line)) drop-shadow(-1.6px 0 0 var(--line))
    drop-shadow(0 1.6px 0 var(--line)) drop-shadow(0 -1.6px 0 var(--line))
    drop-shadow(0 4px 0 rgba(43, 45, 66, .18));
}
.hero-svg, .friend, .decor-svg, .wind-svg, .book-svg { filter: var(--outline); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #bde0fe;
  user-select: none;
  -webkit-user-select: none;
}

button { font-family: inherit; cursor: pointer; color: inherit; }

.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 6px 0 var(--accent-dark);
  transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--accent-dark); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--ink); box-shadow: 0 6px 0 #cfd6e4; }

.round {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .85);
  font-size: 20px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}
.round .ico { width: 26px; height: 26px; vertical-align: middle; }
.round.dim { opacity: .55; }
/* Pictogrammen uit icons.js: schalen mee met de tekst eromheen */
.ico { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.25em; overflow: visible; }
.btn .ico { width: 1.1em; height: 1.1em; }
.pc-icon .ico { width: 40px; height: 40px; }
.link { background: none; border: none; text-decoration: underline; opacity: .6; font-size: 15px; margin-top: 18px; }
.hint { opacity: .6; font-size: 15px; margin: 8px 0 0; }

/* ---------- Wolken ---------- */
.cloud {
  position: absolute;
  width: 130px; height: 42px;
  background: #fff;
  border-radius: 40px;
  opacity: .95;
  filter: drop-shadow(1.5px 0 0 var(--line)) drop-shadow(-1.5px 0 0 var(--line)) drop-shadow(0 1.5px 0 var(--line)) drop-shadow(0 -1.5px 0 var(--line));
  box-shadow: inset 0 -8px 0 #dbe4ff;
  animation: drift 60s linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 64px; height: 64px; top: -32px; left: 18px; }
.cloud::after { width: 46px; height: 46px; top: -22px; left: 64px; }
.cloud.c1 { top: 12%; animation-duration: 55s; animation-delay: -10s; }
.cloud.c2 { top: 28%; transform: scale(.7); animation-duration: 75s; animation-delay: -40s; }
.cloud.c3 { top: 6%; transform: scale(.5); animation-duration: 90s; animation-delay: -70s; opacity: .7; }
@keyframes drift { from { left: -180px; } to { left: 110%; } }

/* ---------- Titel ---------- */
#title {
  align-items: center; justify-content: center;
  background: linear-gradient(#8fd3ff, #e8f7ff 70%, #b7e4a7 70%, #9bd770);
  overflow: hidden;
}
.title-wrap { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; }
.title-parade { display: flex; gap: 6px; margin-bottom: 6px; }
.title-parade span {
  width: clamp(70px, 9vw, 110px);
  animation: paradeIn .6s cubic-bezier(.2, .9, .3, 1.3) backwards, float 2.6s ease-in-out infinite;
  animation-delay: var(--d, 0ms), var(--f, 0s);
}
/* Om de beurt maakt een dier een sprongetje */
.title-parade .hero-svg { transform-origin: bottom center; animation: heroHop 4.8s cubic-bezier(.3, 0, .3, 1) infinite; animation-delay: var(--h, 0s); }
.title-parade span:hover .hero-svg { animation: hop .45s ease-out; }
@keyframes paradeIn { from { transform: translateY(60px) scale(.5) rotate(-12deg); opacity: 0; } }
.who-plays { font-size: 26px; font-weight: 500; margin: 0 0 14px; }
.player-list { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; max-width: 900px; padding: 0 16px; }
.player-card {
  position: relative;
  width: 170px;
  padding: 14px 10px 16px;
  border: 4px solid #fff;
  border-radius: 26px;
  background: rgba(255, 255, 255, .92);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .1);
  transition: transform .15s;
}
.player-card:hover { transform: translateY(-4px) rotate(-1deg); border-color: #ffd43b; }
.pc-hero { width: 110px; }
.pc-name { font-size: 24px; }
.pc-info { font-size: 15px; opacity: .7; }
.pc-key {
  position: absolute; top: -10px; left: -10px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 15px;
  display: grid; place-items: center;
}
.player-card.add { background: rgba(255, 255, 255, .55); border-style: dashed; justify-content: center; min-height: 190px; }
.pc-plus { font-size: 56px; line-height: 1; color: var(--accent); }

/* ---------- Speler instellen ---------- */
#setup {
  align-items: flex-start; justify-content: center;
  overflow-y: auto;
  padding: 24px 0;
  background: linear-gradient(#8fd3ff, #e8f7ff);
}
.setup-card { text-align: left; width: min(720px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 18px; margin: auto; }
.setup-card h2 { text-align: center; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 20px; font-weight: 600; }
.field small { font-weight: 400; opacity: .6; font-size: 14px; }
.field input {
  font-family: inherit; font-size: 24px;
  padding: 8px 16px;
  border-radius: 16px;
  border: 3px solid #e9ecef;
  outline: none;
}
.field input:focus { border-color: #ffd43b; }
.age-row { display: flex; gap: 8px; flex-wrap: wrap; }
.age-row button, .mode-row button, .hero-pick {
  border: 3px solid #e9ecef;
  background: #fff;
  border-radius: 16px;
  transition: transform .1s, border-color .1s;
}
.age-row button { width: 52px; height: 52px; font-size: 22px; font-weight: 600; }
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-row button { padding: 12px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.mode-row b { font-size: 20px; }
.mode-row small { opacity: .7; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.hero-pick { padding: 8px 6px 6px; display: flex; flex-direction: column; align-items: center; font-size: 16px; font-weight: 600; }
.hero-pick svg { width: 84px; }
.hero-pick:not(.on) .hero-svg * { animation-play-state: paused; }
.hero-pick.picked svg { animation: hop .4s ease-out; }
.age-row button.on, .mode-row button.on, .hero-pick.on { border-color: var(--accent); background: #fff4e6; transform: translateY(-2px); }
.link.danger { color: var(--bad); align-self: center; margin-top: 0; }
h1 {
  margin: 4px 0 26px;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 0 #ff7a59, 0 8px 18px rgba(0, 0, 0, .15);
}
h1 small { font-size: .5em; display: block; margin: 8px 0; color: var(--ink); text-shadow: none; }
h1 span { color: #ffd43b; text-shadow: 0 4px 0 #e67700, 0 8px 18px rgba(0, 0, 0, .15); }
#name-form, #welcome-back { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#name-form label, #welcome-back p { font-size: 26px; font-weight: 500; margin: 0; }
#name-in {
  font-family: inherit;
  font-size: 30px;
  text-align: center;
  padding: 10px 20px;
  width: 300px;
  border-radius: 20px;
  border: 4px solid #fff;
  outline: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .1);
}
#name-in:focus { border-color: #ffd43b; }

/* ---------- Scène ---------- */
.scene {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 110%, transparent 55%, rgba(20, 20, 60, .16)),
    linear-gradient(var(--sky1, #a8e6ff), var(--sky2, #e0f7ff));
  flex: 1;
}
.scene.night .cloud { opacity: .15; }

/* Achtergrondlagen: ver (vaag, zonder lijn) en dichtbij (met contour). Ze schuiven mee met --p. */
.backdrop {
  position: absolute; left: -6%; width: 112%;
  bottom: 18%;
  pointer-events: none;
  transition: transform .8s cubic-bezier(.2, .8, .2, 1);
}
.backdrop.far { height: 54%; color: color-mix(in srgb, var(--ground, #7bd389) 38%, var(--sky2, #e0f7ff)); transform: translateX(calc(var(--p, 0) * -2.5%)); }
.backdrop.near { height: 40%; bottom: 17%; color: color-mix(in srgb, color-mix(in srgb, var(--ground, #7bd389) 80%, #1b3a4b) 85%, var(--sky2, #e0f7ff)); transform: translateX(calc(var(--p, 0) * -5%)); }
.bd-fill { fill: currentColor; }
.backdrop.near .bd-fill { stroke: var(--line); stroke-width: 3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.bd-snow { fill: #fff; opacity: .9; }
.backdrop.far .bd-snow { opacity: .55; }
.ceiling {
  position: absolute; left: -2%; width: 104%; top: 0; height: 26%;
  color: color-mix(in srgb, var(--ground, #5f4b8b) 70%, #000);
  fill: currentColor;
  filter: drop-shadow(0 3px 0 var(--line));
  pointer-events: none;
}

/* Zon met langzaam draaiende stralen */
.sun {
  position: absolute; top: 9%; left: 70%;
  width: 78px; height: 78px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3bf 0 18%, #ffd43b 45%, #fcc419);
  box-shadow: 0 0 0 3px var(--line), 0 0 40px 12px rgba(255, 212, 59, .45);
  isolation: isolate;
}
.sun::before {
  content: '';
  position: absolute; inset: -70px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 236, 153, .45) 0 10deg, transparent 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: spin 40s linear infinite;
  z-index: -1;
}

/* Grond: donkere rand bovenop, lichte rand eronder en wat textuur */
.ground {
  position: absolute; left: -5%; right: -5%; bottom: 0;
  height: 24%;
  background:
    radial-gradient(circle at 30% 40%, rgba(0, 0, 0, .07) 0 5px, transparent 6px) 0 0 / 150px 50px,
    radial-gradient(ellipse 10px 4px at 70% 70%, rgba(255, 255, 255, .16) 0 90%, transparent) 40px 20px / 190px 60px,
    var(--ground, #7bd389);
  border-top: 4px solid var(--line);
  border-radius: 50% 50% 0 0 / 40px 40px 0 0;
  box-shadow: inset 0 10px 0 rgba(255, 255, 255, .22);
}
.decor span {
  position: absolute;
  bottom: 15%;
  width: calc(clamp(52px, 7.5vw, 96px) * var(--s, 1));
  transform: translateX(-50%);
  font-size: clamp(28px, 4.5vw, 54px);
  transform-origin: bottom center;
}
/* Zachte schaduw op de grond, net als onder de held en de bubbel */
.decor span::after, .hero::after {
  content: '';
  position: absolute; left: 12%; right: 12%; bottom: -3px;
  height: 7px;
  border-radius: 50%;
  background: rgba(20, 60, 30, .18);
  z-index: -1;
}
.decor-svg { display: block; width: 100%; overflow: visible; }
.decor .d-sway { animation: sway 3.5s ease-in-out infinite alternate; }
.decor .d-bob .decor-svg { animation: bob 2.8s ease-in-out infinite; animation-delay: inherit; }
.decor .d-float { bottom: 40%; width: calc(clamp(38px, 5.2vw, 66px) * var(--s, 1)); }
.decor .d-float::after { display: none; }
.decor .d-float .decor-svg { animation: floaty 5s ease-in-out infinite; animation-delay: inherit; }
.d-flame { transform-box: fill-box; transform-origin: bottom center; animation: flicker .5s ease-in-out infinite alternate; }
@keyframes sway { from { transform: translateX(-50%) rotate(-3deg); } to { transform: translateX(-50%) rotate(3deg); } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }
@keyframes flicker { from { transform: scale(1, 1); } to { transform: scale(.85, 1.12); } }
.moon {
  position: absolute; top: 10%; right: 12%;
  width: 70px; height: 70px; border-radius: 50%;
  background:
    radial-gradient(circle at 30% 38%, #f5e39a 0 7px, transparent 8px),
    radial-gradient(circle at 62% 64%, #f5e39a 0 10px, transparent 11px),
    radial-gradient(circle at 68% 28%, #f5e39a 0 4px, transparent 5px),
    #fff3bf;
  box-shadow: 0 0 0 3px var(--line), inset -10px -8px 0 #f1d67a, 0 0 50px 14px rgba(255, 243, 191, .4);
}
/* Storm bij de Warrelwind: donkere wolken, regen en af en toe een bliksemflits */
.scene.storm { background: radial-gradient(120% 90% at 50% 110%, transparent 55%, rgba(20, 20, 60, .3)), linear-gradient(#495057, #adb5bd); }
.scene.storm .cloud { background: #868e96; box-shadow: inset 0 -8px 0 #5c636a; opacity: 1; }
.scene.storm .cloud::before, .scene.storm .cloud::after { background: #868e96; }
.rain {
  position: absolute; inset: -20% 0 0;
  background: repeating-linear-gradient(100deg, transparent 0 18px, rgba(255, 255, 255, .28) 18px 20px, transparent 20px 46px);
  animation: rain .5s linear infinite;
  pointer-events: none;
}
@keyframes rain { to { background-position: -30px 120px; } }
.flash-sky { position: absolute; inset: 0; background: #fff; opacity: 0; animation: skyFlash 5s infinite 1.5s; pointer-events: none; }
@keyframes skyFlash { 0%, 100% { opacity: 0; } 2% { opacity: .5; } 4% { opacity: 0; } 6% { opacity: .35; } 10% { opacity: 0; } }
/* Vallende ster, af en toe */
.shoot {
  position: absolute; top: 12%; left: 20%;
  width: 90px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, #fff);
  transform: rotate(-20deg);
  opacity: 0;
  animation: shoot 7s ease-in infinite 2s;
}
@keyframes shoot {
  0% { opacity: 0; translate: 0 0; }
  2% { opacity: 1; }
  9% { opacity: 0; translate: 260px 95px; }
  100% { opacity: 0; translate: 260px 95px; }
}
.stars-bg {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #fff, transparent), radial-gradient(2px 2px at 30% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 50% 30%, #fff, transparent), radial-gradient(2px 2px at 70% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 40%, #fff, transparent), radial-gradient(2px 2px at 20% 45%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 62% 50%, #fff, transparent), radial-gradient(2px 2px at 92% 8%, #fff, transparent);
  animation: twinkle 3s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }
.fireflies i {
  position: absolute;
  width: 7px; height: 7px; border-radius: 50%;
  background: #ffec99;
  box-shadow: 0 0 12px 4px rgba(255, 236, 153, .7);
  animation: firefly 6s ease-in-out infinite alternate;
}
.fireflies i:nth-child(1) { left: 12%; top: 50%; }
.fireflies i:nth-child(2) { left: 28%; top: 35%; animation-delay: -1s; }
.fireflies i:nth-child(3) { left: 45%; top: 55%; animation-delay: -2s; }
.fireflies i:nth-child(4) { left: 60%; top: 30%; animation-delay: -3s; }
.fireflies i:nth-child(5) { left: 74%; top: 48%; animation-delay: -4s; }
.fireflies i:nth-child(6) { left: 88%; top: 60%; animation-delay: -5s; }
@keyframes firefly {
  0% { transform: translate(0, 0); opacity: .2; }
  50% { opacity: 1; }
  100% { transform: translate(40px, -30px); opacity: .3; }
}

/* ---------- Vonk ---------- */
.hero {
  position: absolute;
  left: 3%;
  bottom: 13%;
  width: clamp(110px, 14vw, 170px);
  z-index: 3;
  transition: left .4s cubic-bezier(.16, 1, .3, 1);
}
.hero .inner { animation: float 2.6s ease-in-out infinite; }
.hero.hop .hero-svg { animation: hop .3s ease-out; }
.hero.oops .hero-svg { animation: oops .4s ease-in-out; }
.hero-svg { display: block; width: 100%; overflow: visible; }
.c-wing { transform-box: view-box; animation: flap .5s ease-in-out infinite alternate; }
.c-eyes { transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }
.c-tail { transform-box: view-box; animation: wag 1.6s ease-in-out infinite alternate; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes flap { from { transform: rotate(-8deg); } to { transform: rotate(14deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes wag { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes hop { 0% { transform: none; } 35% { transform: translateY(-14px) rotate(-4deg) scale(1.03); } 70% { transform: translateY(2px) scale(1.04, .96); } 100% { transform: none; } }
@keyframes oops {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}
.talk {
  position: absolute;
  bottom: 100%;
  left: 40%;
  width: max-content;
  max-width: 260px;
  background: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 17px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
  opacity: 0;
  transform: translateY(8px) scale(.9);
  pointer-events: none;
}
.talk.show { animation: talk 5s ease forwards; }
@keyframes talk {
  0% { opacity: 0; transform: translateY(8px) scale(.9); }
  6%, 88% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-4px); }
}

/* ---------- Doel (bubbel) ---------- */
.target {
  position: absolute;
  right: 6%;
  bottom: 18%;
  width: clamp(120px, 15vw, 180px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  z-index: 2;
  animation: bob 3s ease-in-out infinite;
}
.target > * { grid-area: 1 / 1; }
.friends { display: flex; justify-content: center; align-items: flex-end; width: 86%; }
.friend { width: calc(100% / var(--n, 2)); max-width: 62px; overflow: visible; }
.target:not(.free) .friend { animation: worried 1.4s ease-in-out infinite alternate; }
.target.free .friend { animation: jump .6s ease-in-out infinite alternate; }
.target.free .friend:nth-child(2) { animation-delay: .15s; }
.target.free .friend:nth-child(3) { animation-delay: .3s; }
.target.free .friend:nth-child(4) { animation-delay: .45s; }
.skin {
  width: 100%; height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, .95) 0 7%, transparent 8%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .05) 55%, rgba(170, 210, 255, .45) 80%, rgba(255, 190, 240, .5) 100%);
  border: 2px solid rgba(255, 255, 255, .8);
  box-shadow: inset -10px -10px 24px rgba(120, 160, 255, .35);
  animation: wobble 2.4s ease-in-out infinite;
}
.skin.pop { animation: pop .45s ease-out forwards; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes wobble { 0%, 100% { border-radius: 50%; } 33% { border-radius: 48% 52% 50% 50%; } 66% { border-radius: 52% 48% 49% 51%; } }
@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(.88, 1.08); opacity: 1; filter: brightness(1.4); }
  100% { transform: scale(1.8); opacity: 0; filter: blur(6px) brightness(2); }
}
@keyframes worried { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes jump { from { transform: translateY(0); } to { transform: translateY(-22px); } }

.target.boss { width: clamp(150px, 19vw, 230px); right: 5%; bottom: 22%; }
.wind-svg { width: 100%; display: block; }
.w-spin { transform-box: view-box; transform-origin: 80px 80px; animation: spin 2s linear infinite; }
.wind .w-happy { display: none; }
.wind.happy .w-sad { display: none; }
.wind.happy .w-happy { display: inline; }
.wind.happy .w-spin { animation-duration: 8s; }
.w-bolt { animation: bolt 2.2s steps(1) infinite; }
.w-bolt.b2 { animation-delay: -1.1s; }
@keyframes bolt { 0%, 100% { opacity: 1; } 6% { opacity: .15; } 10% { opacity: 1; } 48% { opacity: 1; } 52% { opacity: 0; } 70% { opacity: 0; } 74% { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

.pop-text {
  position: absolute;
  top: 18%; left: 50%;
  transform: translateX(-50%);
  font-size: clamp(38px, 5.6vw, 64px);
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 4px 0 #ff7a59, 0 0 24px rgba(255, 190, 90, .8), 0 8px 20px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.pop-text.show { animation: cheer 1.2s ease forwards; }
@keyframes cheer {
  0% { opacity: 0; transform: translateX(-50%) scale(2.4) skewX(-12deg); filter: blur(8px); }
  14% { opacity: 1; transform: translateX(-50%) scale(.94) skewX(-6deg); filter: blur(0); }
  22% { transform: translateX(-50%) scale(1) skewX(-6deg); }
  75% { opacity: 1; transform: translateX(-50%) scale(1.04) skewX(-6deg); }
  100% { opacity: 0; transform: translateX(-30%) scale(1.04) skewX(-6deg); filter: blur(4px); }
}
/* Schokgolf en flits, voor het knappen van de bubbel */
.shock {
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, .8), inset 0 0 12px rgba(160, 210, 255, .8);
  transform: translate(-50%, -50%);
  animation: shock .6s cubic-bezier(.1, .7, .3, 1) forwards;
}
@keyframes shock { to { width: var(--size, 320px); height: var(--size, 320px); opacity: 0; border-width: 1px; } }
.flash { position: absolute; inset: 0; background: #fff; animation: flash .35s ease-out forwards; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
.scene.impact { animation: impact .35s cubic-bezier(.36, .07, .19, .97); }
@keyframes impact {
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
}

/* ---------- Kaart ---------- */
#map {
  flex-direction: column;
  background: linear-gradient(#a8e6ff, #d8f3dc 30%, #b7e4c7);
}
.map-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
}
.map-hello { font-size: 26px; }
.star-total { margin-left: 12px; background: #fff; padding: 4px 14px; border-radius: 999px; font-size: 20px; }
.toggles { display: flex; gap: 8px; }
.friends-bar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  margin: 0 20px;
  padding: 6px 14px;
  min-height: 56px;
  background: rgba(255, 255, 255, .6);
  border-radius: 18px;
}
.fb-label { font-size: 16px; margin-right: 8px; opacity: .75; }
.fb-friend { width: 38px; display: inline-block; }
.fb-friend svg { width: 100%; display: block; }
.fb-friend:hover { transform: translateY(-4px); transition: transform .15s; }
.map-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0 40px; }
.map-inner { position: relative; max-width: 760px; margin: 0 auto; }
/* Werelden op de kaart: per hoofdstuk een band met de eigen lucht en achtergrond, zacht in elkaar overlopend */
.map-band {
  position: absolute;
  left: calc(50% - 50vw); width: 100vw;
  background: linear-gradient(var(--sky1), var(--sky2));
  -webkit-mask: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  mask: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  pointer-events: none;
  opacity: .85;
  transition: filter .6s, opacity .6s;
}
.map-band .backdrop { position: absolute; left: 0; width: 100%; bottom: 22%; height: 80px; transform: none; }
.map-band.locked { filter: grayscale(.9); opacity: .35; }
.map-band .stars-bg { animation: none; opacity: .8; }
.map-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-path path { fill: none; stroke-linecap: round; }
.p-edge { stroke: #e3cf9a; stroke-width: 32; }
.p-road { stroke: #fff4d6; stroke-width: 24; }
.p-mid { stroke: #ecdcb0; stroke-width: 3; stroke-dasharray: 10 16; }
.p-done { stroke: #ffc933; stroke-width: 12; filter: drop-shadow(0 0 6px rgba(255, 190, 40, .7)); }
.p-grow { stroke-dasharray: var(--len) var(--len); stroke-dashoffset: var(--len); animation: grow 1.1s cubic-bezier(.5, 0, .2, 1) .5s forwards; }
@keyframes grow { to { stroke-dashoffset: 0; } }
.p-flow { stroke: #fff; stroke-width: 4; stroke-dasharray: 2 14; opacity: 0; animation: flow 1s linear infinite, fadeIn .4s 1.6s forwards; }
@keyframes flow { to { stroke-dashoffset: -16; } }
@keyframes fadeIn { to { opacity: .9; } }
.p-comet { fill: #fff; filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 10px #ffd43b); opacity: 0; animation: fadeIn .4s 1.6s forwards; }
.map-decor {
  position: absolute;
  width: 64px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: nodeIn .5s cubic-bezier(.2, .9, .3, 1.4) backwards;
  animation-delay: var(--d, 0ms);
}
.map-decor.locked { filter: grayscale(1); opacity: .45; }
.map-decor .decor-svg { transform-origin: bottom center; animation: mapSway 3.2s ease-in-out infinite alternate; }
@keyframes mapSway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.map-tip { text-align: center; margin: 0; padding: 8px; font-size: 15px; opacity: .7; }

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 92px; height: 92px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: #fff9db;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .12);
  padding: 0;
  display: grid; place-items: center;
  transition: transform .25s cubic-bezier(.2, .9, .3, 1.4);
  animation: nodeIn .5s cubic-bezier(.2, .9, .3, 1.4) backwards;
  animation-delay: var(--d, 0ms);
}
.node:not(.locked):hover { transform: translate(-50%, -50%) scale(1.1) rotate(-4deg); }
/* Overgang van de kaart naar een hoofdstuk */
.warp {
  position: fixed; inset: 0; z-index: 200;
  clip-path: circle(0 at var(--x) var(--y));
  animation: warpIn .52s cubic-bezier(.7, 0, .3, 1) forwards;
  pointer-events: none;
}
.warp.out { clip-path: circle(150% at var(--x) var(--y)); animation: warpOut .4s ease-out forwards; }
@keyframes warpIn { to { clip-path: circle(150% at var(--x) var(--y)); } }
@keyframes warpOut { to { opacity: 0; } }
.node.warping { transform: translate(-50%, -50%) scale(1.25) rotate(-8deg); }
@keyframes nodeIn { from { transform: translate(-50%, -50%) scale(0) rotate(-40deg); opacity: 0; } }
/* Draaiende stippelring om het huidige hoofdstuk */
.node.current::before {
  content: '';
  position: absolute; inset: -14px;
  border-radius: 50%;
  border: 3px dashed var(--accent);
  animation: spin 9s linear infinite;
  pointer-events: none;
}
.node.done { background: #fff3bf; border-color: #ffd43b; }
.node.current { border-color: var(--accent); animation: nodeIn .5s cubic-bezier(.2, .9, .3, 1.4) backwards, glow 1.6s ease-in-out infinite; animation-delay: var(--d, 0ms), 0s; }
.node.locked { background: #dee2e6; cursor: default; filter: grayscale(1); opacity: .75; }
.node.boss:not(.locked) { background: #e7ecf7; }
@keyframes glow { 0%, 100% { box-shadow: 0 6px 0 rgba(0, 0, 0, .12), 0 0 0 0 rgba(255, 122, 89, .5); } 50% { box-shadow: 0 6px 0 rgba(0, 0, 0, .12), 0 0 0 14px rgba(255, 122, 89, 0); } }
.node-icon { font-size: 40px; line-height: 1; width: 56px; display: block; }
.node-icon .decor-svg { filter: var(--outline); }
.node-num {
  position: absolute; top: -8px; left: -8px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 600;
}
.node-label {
  position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  white-space: nowrap;
  font-size: 15px; font-weight: 600;
  background: rgba(255, 255, 255, .85);
  padding: 2px 10px;
  border-radius: 999px;
}
.node-stars { position: absolute; bottom: -38px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 18px; }
.node-stars i { font-style: normal; color: rgba(0, 0, 0, .15); }
.node-stars i.on { color: #fab005; text-shadow: 0 1px 0 #e67700; }
/* Hoeveel quests van een hoofdstuk al af zijn */
.node-quests { position: absolute; top: -10px; right: -14px; display: flex; gap: 3px; padding: 4px 6px; background: #fff; border-radius: 999px; box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.node-quests i { width: 9px; height: 9px; border-radius: 50%; background: #dee2e6; }
.node-quests i.on { background: #40c057; }
.node-hero { position: absolute; width: 70px; left: -78px; top: 4px; animation: heroHop 2.4s cubic-bezier(.3, 0, .3, 1) infinite; }
@keyframes heroHop {
  0%, 60%, 100% { transform: translateY(0) scale(1); }
  68% { transform: translateY(2px) scale(1.08, .92); }
  80% { transform: translateY(-18px) scale(.96, 1.05) rotate(-6deg); }
  92% { transform: translateY(0) scale(1.06, .94); }
}

/* ---------- Verhaal ---------- */
#story { flex-direction: column; }
#story .scene { position: absolute; inset: 0; }
#story .hero { left: 16%; bottom: 20%; width: clamp(140px, 18vw, 220px); }
#story .target { right: 16%; bottom: 24%; }
.dialog {
  position: absolute;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  width: min(900px, calc(100% - 32px));
  display: flex; gap: 18px; align-items: flex-start;
  background: #fff;
  border-radius: 28px;
  padding: 18px 24px 18px 18px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, .08), 0 12px 40px rgba(0, 0, 0, .15);
  z-index: 10;
  cursor: pointer;
}
.portrait {
  flex: 0 0 96px; height: 96px;
  border-radius: 50%;
  background: #e6fcf5;
  display: grid; place-items: center;
  overflow: hidden;
  padding: 8px;
}
.portrait svg { width: 100%; }
.portrait.p-friend { background: #fff0f6; }
.portrait.p-wind { background: #edf2ff; }
.portrait .wind { width: 100%; }
.portrait.talking { animation: talkbob .4s ease; }
@keyframes talkbob { 50% { transform: scale(1.08); } }
.dlg-body { flex: 1; min-width: 0; }
.who { font-weight: 700; color: var(--accent); font-size: 18px; margin-bottom: 4px; }
.text { font-size: clamp(20px, 2.4vw, 27px); line-height: 1.4; min-height: 2.8em; }
.next-hint { align-self: flex-end; font-size: 14px; opacity: .5; white-space: nowrap; animation: nudge 1s ease-in-out infinite alternate; }
@keyframes nudge { to { transform: translateX(4px); opacity: .85; } }
/* Geluid, voorlezen en overslaan rechtsboven in het verhaal en op het hoofdstukpad */
.toggles.corner { position: absolute; top: 16px; right: 16px; z-index: 11; align-items: center; }
.skip {
  height: 44px;
  background: rgba(255, 255, 255, .8);
  border: none; border-radius: 999px;
  padding: 8px 16px; font-size: 16px;
}

/* ---------- Hoofdstukpad ---------- */
#trail { flex-direction: column; --tr-lift: 0px; }
#trail .scene { position: absolute; inset: 0; }
#trail .ground { height: calc(50% + var(--tr-lift)); }
#trail .decor span { bottom: calc(46% + var(--tr-lift)); }
#trail .target { right: 5%; bottom: calc(35% + var(--tr-lift)); }
#trail .hero { transform: translateX(-50%); width: clamp(100px, 12vw, 150px); z-index: 4; transition: left 1.2s ease-in-out, bottom 1.2s ease-in-out; }
#trail .hero.walking .inner { animation: walk .3s ease-in-out infinite alternate; }
@keyframes walk { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-12px) rotate(3deg); } }
.tr-head { position: absolute; top: 16px; left: 16px; z-index: 5; display: flex; align-items: center; gap: 12px; }
.tr-title { font-size: 20px; font-weight: 600; background: rgba(255, 255, 255, .85); padding: 6px 16px; border-radius: 999px; }
.tr-road { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; transform: translateY(calc(-1 * var(--tr-lift))); }
.tr-road path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.tr-road .r-edge { stroke: var(--line); stroke-width: 40px; opacity: .35; }
.tr-road .r-road { stroke: #fff3d6; stroke-width: 32px; }
.tr-road .r-mid { stroke: #e9c46a; stroke-width: 3px; stroke-dasharray: 10 12; }
.tr-road .r-done { stroke: #ffd43b; stroke-width: 12px; opacity: .9; }
.tr-stop {
  position: absolute; z-index: 3;
  width: 68px; height: 68px;
  transform: translate(-50%, 50%);
  display: grid; place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 5px solid #dee2e6;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .15);
}
.tr-ico { width: 40px; height: 40px; display: grid; place-items: center; font-size: 30px; opacity: .45; filter: grayscale(1); }
.tr-ico svg { width: 100%; height: 100%; }
.tr-stop.done { border-color: #51cf66; background: #ebfbee; }
.tr-stop.now { border-color: var(--accent); animation: glow 1.6s ease-in-out infinite; }
.tr-stop.done .tr-ico, .tr-stop.now .tr-ico { opacity: 1; filter: none; }
.tr-check { position: absolute; top: -12px; right: -12px; width: 30px; height: 30px; display: grid; place-items: center; background: #fff; border-radius: 50%; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.tr-check .ico { width: 22px; height: 22px; }
.tr-stop.just .tr-check { animation: slotIn .5s cubic-bezier(.2, .9, .3, 1.4) .2s backwards; }
.tr-stars { position: absolute; bottom: 100%; margin-bottom: 6px; white-space: nowrap; font-size: 22px; }
.tr-stars i { font-style: normal; color: rgba(0, 0, 0, .15); display: inline-block; animation: starIn .5s cubic-bezier(.2, .9, .3, 1.4) backwards; animation-delay: calc(.2s + var(--i) * .25s); }
.tr-stars i.on { color: #fab005; text-shadow: 0 1px 0 #e67700; }
.tr-name {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 8px; width: max-content; max-width: 140px;
  text-align: center; font-size: 14px; font-weight: 600; line-height: 1.2;
  background: rgba(255, 255, 255, .88); padding: 3px 10px; border-radius: 12px;
}
.tr-stop:not(.done):not(.now) .tr-name { opacity: .6; }
#trail .dialog { align-items: center; }
.tr-go { flex: none; white-space: nowrap; }
@media (max-width: 600px) {
  #trail { --tr-lift: 110px; }
  #trail .portrait { display: none; }
  #trail .dialog .text { font-size: 17px; }
  .tr-stop { width: 54px; height: 54px; border-width: 4px; }
  .tr-ico { width: 30px; height: 30px; }
  .tr-name { font-size: 12px; max-width: 96px; }
  #trail .dialog { flex-wrap: wrap; }
  .tr-go { width: 100%; }
}

/* ---------- Spelen ---------- */
#play { flex-direction: column; background: var(--paper); }
.play-head {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .05);
  z-index: 4;
}
.play-title { font-size: 20px; font-weight: 600; white-space: nowrap; }
.progress { flex: 1; height: 18px; background: #edf2f7; border-radius: 999px; overflow: hidden; }
.progress-fill {
  position: relative;
  height: 100%; width: 0;
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .22) 0 10px, transparent 10px 20px),
    linear-gradient(90deg, #ffd43b, #ff922b 70%, #ff5f3b);
  background-size: 40px 100%, 100% 100%;
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(255, 146, 43, .55);
  transition: width .25s cubic-bezier(.2, .8, .2, 1);
  animation: stripes .8s linear infinite;
}
.progress-fill::after {
  content: '';
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 18px;
  border-radius: 999px;
  background: radial-gradient(circle at 70% 50%, #fff 0 25%, transparent 70%);
  opacity: .9;
}
@keyframes stripes { to { background-position: 40px 0, 0 0; } }

/* Reeks-teller */
.combo {
  --heat: #ff922b;
  display: flex; align-items: baseline; gap: 2px;
  min-width: 64px;
  font-size: 22px; font-weight: 700;
  color: var(--heat);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .2s, transform .2s;
}
.combo small { font-size: 13px; font-weight: 600; opacity: .7; }
.combo.on { opacity: 1; transform: none; }
.combo b { display: inline-block; }
.combo.bump b { animation: comboBump .22s cubic-bezier(.2, .8, .2, 1); }
.combo.hot { --heat: #f03e3e; text-shadow: 0 0 10px rgba(240, 62, 62, .45); }
.combo.fire { --heat: #ae3ec9; text-shadow: 0 0 12px rgba(174, 62, 201, .55); }
.combo.drop { animation: comboDrop .45s ease-in forwards; }
@keyframes comboBump { 0% { transform: scale(1.5); filter: brightness(1.6); } }
@keyframes comboDrop { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(14px) rotate(8deg); filter: grayscale(1); } }
.line-count { font-size: 16px; opacity: .6; white-space: nowrap; }
.play-quest { margin-left: 6px; padding: 2px 10px; border-radius: 999px; background: #e6fcf5; color: #087f5b; font-size: 14px; vertical-align: 2px; }
/* Zoek-quest: lege plekjes bovenin de scène die zich vullen met gevonden voorwerpen */
.loot { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; gap: 8px; padding: 6px 12px; background: rgba(255, 255, 255, .75); border-radius: 999px; }
.loot .slot { width: 40px; height: 40px; display: grid; place-items: center; font-size: 30px; filter: grayscale(1); opacity: .3; }
.loot .slot .decor-svg { width: 100%; height: 100%; }
.loot .slot.got { filter: none; opacity: 1; animation: slotIn .5s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes slotIn { 0% { transform: scale(2.2) rotate(-20deg); } }
.rf .decor-svg { width: 100%; animation: jump .6s ease-in-out infinite alternate; }
#play .scene { min-height: 170px; }
#play.klein .hint-row { font-size: 24px; }
#play.klein .line { min-height: 90px; }

.type-panel {
  padding: 16px 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--paper);
}
.line {
  display: flex; flex-wrap: nowrap; gap: 5px; justify-content: center;
  min-height: 72px;
  padding-top: 6px; /* ruimte voor het hoofdletter-toetsje boven de huidige letter */
}
.line.enter .ch:not(.ok):not(.bad) { animation: chIn .38s cubic-bezier(.2, .9, .25, 1) backwards; animation-delay: calc(var(--i, 0) * 18ms); }
.line.leave { animation: lineOut .28s cubic-bezier(.6, 0, .8, .4) forwards; }
@keyframes chIn { from { opacity: 0; transform: translateY(-26px) scale(.7); filter: blur(4px); } }
@keyframes lineOut { to { opacity: 0; transform: translateX(-80px) skewX(-12deg); filter: blur(6px); } }
.ch {
  width: var(--cw, 48px);
  height: calc(var(--cw, 48px) * 1.35);
  display: grid; place-items: center;
  font-size: calc(var(--cw, 48px) * .9);
  font-weight: 600;
  background: #fff;
  border-radius: 12px;
  border-bottom: 4px solid #e9ecef;
  color: #adb5bd;
  position: relative;
  transition: background .15s, color .15s, transform .15s cubic-bezier(.2, .8, .2, 1), box-shadow .2s;
}
.ch.sp { background: transparent; border-bottom-color: transparent; width: calc(var(--cw, 48px) * .5); }
.ch.sp::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #dee2e6; }
.ch.cur {
  color: var(--ink); background: #fff3bf; border-bottom-color: #fab005;
  transform: translateY(-6px) scale(1.06);
  animation: curGlow 1.4s ease-in-out infinite;
  z-index: 1;
}
.ch.sp.cur { width: calc(var(--cw, 48px) * 1.1); background: #fff3bf; }
.ch.sp.cur::after { width: 60%; height: 6px; border-radius: 3px; background: #fab005; }
.ch.ok { color: var(--good); background: #ebfbee; border-bottom-color: #8ce99a; animation: lockIn .32s cubic-bezier(.2, .8, .2, 1); }
.ch.ok::before {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 14px;
  border: 3px solid #51cf66;
  opacity: 0;
  animation: ring .4s ease-out;
  pointer-events: none;
}
.ch.sp.ok::before { display: none; }
/* Lange reeks: de goede letters gaan gloeien */
.line.hot .ch.ok { color: #e8590c; background: #fff4e6; border-bottom-color: #ffa94d; }
.line.hot .ch.ok::before { border-color: #ff922b; }
.line.hot .ch.sp.ok::after { background: #ffa94d; }
.line.fire .ch.ok { color: #9c36b5; background: #f8f0fc; border-bottom-color: #da77f2; box-shadow: 0 0 14px rgba(190, 75, 219, .35); }
.line.fire .ch.sp.ok { box-shadow: none; }
.line.fire .ch.ok::before { border-color: #cc5de8; }
.line.fire .ch.sp.ok::after { background: #da77f2; }
.ch.sp.ok { background: transparent; }
.ch.sp.ok::after { background: #8ce99a; }
.ch.bad { animation: shake .3s cubic-bezier(.36, .07, .19, .97); background: #ffe3e3; border-bottom-color: var(--bad); color: var(--bad); box-shadow: 0 0 0 3px rgba(239, 71, 111, .25); }
/* Deel 1: bij de huidige kleine letter een toetsje met de hoofdletter, zoals hij op het toetsenbord staat.
   Klasse .cap: tot de letter vaak genoeg achter elkaar goed ging (needsCap). */
.ch.cur.cap[data-cap]::after {
  content: attr(data-cap);
  --s: max(20px, calc(var(--cw, 48px) * .5));
  position: absolute; top: calc(var(--s) * -.3); right: calc(var(--s) * -.4);
  width: var(--s); height: var(--s);
  display: grid; place-items: center;
  font-size: calc(var(--s) * .6); line-height: 1;
  border-radius: calc(var(--s) * .25);
  background: color-mix(in srgb, var(--fc) 22%, #fff);
  border: 2px solid var(--ink);
  box-shadow: inset 0 -3px 0 var(--fc), 0 2px 0 var(--ink);
  color: var(--ink);
  animation: capIn .3s cubic-bezier(.2, .9, .3, 1.4) backwards;
}
@keyframes capIn { from { opacity: 0; transform: scale(.4) translateY(6px); } }
@keyframes curGlow {
  0%, 100% { box-shadow: 0 6px 16px rgba(250, 176, 5, .25), 0 0 0 0 rgba(250, 176, 5, .45); }
  50% { box-shadow: 0 6px 16px rgba(250, 176, 5, .35), 0 0 0 7px rgba(250, 176, 5, 0); }
}
@keyframes lockIn {
  0% { transform: translateY(-6px) scale(1.25); filter: brightness(1.15); }
  100% { transform: none; }
}
@keyframes ring {
  0% { opacity: 1; transform: scale(.9); }
  100% { opacity: 0; transform: scale(1.35); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}
.hint-row { font-size: 20px; min-height: 30px; }
.hint-key {
  display: inline-block;
  min-width: 34px;
  padding: 0 8px;
  text-align: center;
  background: var(--fc);
  color: #fff;
  border-radius: 8px;
}
.hint-finger { font-weight: 600; color: var(--fc); filter: brightness(.8); }

/* ---------- Toetsenbord ---------- */
.keyboard {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 8px 16px 20px;
  background: var(--paper);
}
.kb-row { display: flex; gap: 7px; }
.kb-row.r2 { margin-left: calc(var(--kw) * .4); }
.kb-row.r3 { margin-left: calc(var(--kw) * 1.1); }
/* Cijferrij en shift-toetsen alleen in Deel 2 */
.keyboard:not(.full) .kb-row.r0, .keyboard:not(.full) .key.shift { display: none; }
.keyboard.full .kb-row.r0 { margin-right: calc(var(--kw) * .6); }
.keyboard.full .kb-row.r3 { margin-left: calc(var(--kw) * .35); }
.key.shift { width: calc(var(--kw) * 1.6); font-size: calc(var(--kw) * .26); font-weight: 500; }
.keyboard.full { --kw: clamp(28px, 4vw, 48px); }
/* Stickertoetsen: donkere contour en harde schaduw, de vlakke kleur is die van de vinger */
.key {
  width: var(--kw); height: var(--kw);
  display: grid; place-items: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--fc) 22%, #fff);
  border: 2.5px solid var(--ink);
  box-shadow: inset 0 -5px 0 var(--fc), 0 4px 0 var(--ink);
  color: var(--ink);
  font-size: calc(var(--kw) * .42);
  font-weight: 600;
  position: relative;
  transition: transform .1s, background .1s, box-shadow .1s;
}
.key.bump::after { content: ''; position: absolute; bottom: 8px; width: 30%; height: 3px; border-radius: 2px; background: currentColor; opacity: .5; }
.key.space { width: calc(var(--kw) * 6); font-size: calc(var(--kw) * .3); font-weight: 500; }
.key.off { border-color: #ced4da; color: #adb5bd; background: #f8f9fa; box-shadow: inset 0 -4px 0 #e9ecef, 0 3px 0 #ced4da; }
.key.next {
  background: var(--fc); color: #fff;
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--fc) 70%, #000), 0 7px 0 var(--ink);
  transform: translateY(-3px);
  animation: keyPulse 1s ease-in-out infinite;
}
.key.good { animation: keyGood .25s; }
.key.wrong { animation: keyWrong .4s; }
@keyframes keyPulse {
  0%, 100% { outline: 0 solid color-mix(in srgb, var(--fc) 55%, transparent); outline-offset: 2px; }
  60% { outline: 9px solid color-mix(in srgb, var(--fc) 0%, transparent); outline-offset: 4px; }
}
@keyframes keyGood {
  0% { transform: translateY(4px) scale(.95); box-shadow: inset 0 -2px 0 var(--fc), 0 0 0 var(--ink); background: color-mix(in srgb, var(--fc) 45%, #fff); }
  100% { transform: none; }
}
@keyframes keyWrong { 30% { background: var(--bad); color: #fff; transform: translateX(-4px); } 60% { transform: translateX(4px); } }
.keyboard.mini { --kw: 30px; padding: 12px 0 0; align-items: flex-start; background: none; }
.keyboard.mini { gap: 6px; }
.keyboard.mini .kb-row { gap: 4px; }
.keyboard.mini .key { border-radius: 7px; border-width: 2px; box-shadow: inset 0 -3px 0 var(--fc), 0 3px 0 var(--ink); }
.keyboard.mini .key.off { box-shadow: inset 0 -3px 0 #e9ecef, 0 2px 0 #ced4da; }
.keyboard.mini .key.next { -webkit-text-stroke-width: 3px; box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--fc) 70%, #000), 0 5px 0 var(--ink); }
.keyboard.mini .key.next { animation: keyPulse 1s infinite; }

/* ---------- Resultaat ---------- */
#result {
  align-items: center; justify-content: center;
  background: linear-gradient(var(--sky1, #a8e6ff), var(--sky2, #fff));
}
.card {
  background: #fff;
  border-radius: 32px;
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 12px 0 rgba(0, 0, 0, .08), 0 20px 60px rgba(0, 0, 0, .15);
  width: min(560px, calc(100% - 32px));
  animation: cardIn .6s cubic-bezier(.16, 1, .3, 1);
}
@keyframes cardIn { from { transform: perspective(900px) translateY(60px) rotateX(18deg) scale(.92); opacity: 0; filter: blur(6px); } }
.card h2 { margin: 0; font-size: 42px; color: var(--accent); }
.res-stars { font-size: 72px; line-height: 1.1; margin: 8px 0; }
.rs { color: #e9ecef; display: inline-block; }
.rs.on {
  color: transparent;
  background: linear-gradient(110deg, #fab005 35%, #fff9db 50%, #fab005 65%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 4px 0 #e67700) drop-shadow(0 0 14px rgba(250, 176, 5, .5));
  animation-name: starIn, shine;
  animation-duration: .45s, 2.8s;
  animation-timing-function: cubic-bezier(.2, .9, .3, 1.2), ease-in-out;
  animation-iteration-count: 1, infinite;
  animation-fill-mode: backwards, none;
}
@keyframes starIn {
  0% { transform: scale(3) rotate(-30deg); opacity: 0; }
  70% { transform: scale(.9); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes shine { 0%, 60% { background-position: 100% 0; } 100% { background-position: -50% 0; } }
.res-friends { display: flex; justify-content: center; gap: 12px; margin: 6px 0 14px; }
.rf { width: 64px; display: flex; flex-direction: column; align-items: center; font-size: 14px; font-weight: 600; }
.rf svg { width: 100%; animation: jump .6s ease-in-out infinite alternate; }
.rf:nth-child(2) svg { animation-delay: .2s; }
.rf:nth-child(3) svg { animation-delay: .4s; }
.wind.small { width: 110px; }
.stats { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.stats div { background: #f8f9fa; border-radius: 18px; padding: 10px 20px; display: flex; flex-direction: column; min-width: 150px; }
.stats b { font-size: 32px; }
.stats span { font-size: 14px; opacity: .65; }
.res-msg { font-size: 18px; margin: 16px 0; }
.row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- Effecten ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.spark {
  position: absolute;
  width: 3px; height: 14px;
  border-radius: 2px;
  background: var(--c, #ffd43b);
  box-shadow: 0 0 8px var(--c, #ffd43b);
  transform: translate(-50%, -50%) rotate(var(--a)) translateY(-6px);
  animation: spark .42s cubic-bezier(.1, .8, .3, 1) forwards;
}
@keyframes spark { to { transform: translate(-50%, -50%) rotate(var(--a)) translateY(calc(-1 * var(--d, 40px))) scaleY(.2); opacity: 0; } }
.confetti {
  position: absolute; bottom: -20px;
  width: 9px; height: 15px;
  border-radius: 2px;
  animation: blast var(--t, 2.6s) forwards;
}
/* Kanonnen links en rechts onderin: eerst snel omhoog, dan dwarrelen */
@keyframes blast {
  0% { transform: translate(0, 0) rotate(0); animation-timing-function: cubic-bezier(.1, .8, .3, 1); }
  35% { transform: translate(var(--dx), var(--up)) rotate(calc(var(--rot) * .4)); animation-timing-function: cubic-bezier(.5, 0, .9, .6); }
  100% { transform: translate(calc(var(--dx) + var(--drift)), 30px) rotate(var(--rot)); opacity: .8; }
}
input.shake { animation: shake .35s; }

@media (max-height: 720px) {
  :root { --kw: clamp(28px, 4vw, 44px); }
  .type-panel { padding-top: 10px; }
  .keyboard { padding-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Handen ---------- */
.hands {
  position: absolute;
  left: 50%; bottom: 0;
  transform: translate(-50%, 105%);
  padding: 6px 22px 0;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -5px 0 rgba(43, 45, 66, .12);
  transition: transform .35s cubic-bezier(.3, 1.3, .5, 1);
  z-index: 6;
  pointer-events: none;
}
.hands.show { transform: translate(-50%, 0); }
.hand-pair { display: flex; gap: clamp(16px, 5vw, 60px); }
.hand { width: clamp(120px, 15vw, 180px); display: block; overflow: visible; }
#play.klein .hand { width: clamp(140px, 18vw, 210px); }
.hand path, .hand rect { stroke-linejoin: round; stroke-linecap: round; }
.hand .f-shade, .hand .palm-shade { fill: #f6bd93; }
.hand .palm, .hand .palm-cover, .hand .f-skin { fill: #ffd9b8; }
.hand .palm { stroke: var(--ink); stroke-width: 4.5; }
.hand .palm-line, .hand .f-line { fill: none; stroke: var(--ink); stroke-width: 4.5; }
.hand .f-crease, .hand .knuckles { fill: none; stroke: #d9936a; stroke-width: 2.5; }
.hand .nail { fill: var(--fc); stroke: var(--ink); stroke-width: 2.2; transition: opacity .2s; }
.hand .nail-shine { fill: #fff; opacity: .75; }
.hand .sleeve { fill: #74c0fc; stroke: var(--ink); stroke-width: 4.5; }
.hand .sleeve-band { fill: none; stroke: #fff; stroke-width: 5; opacity: .8; }
.hand-r .sleeve { fill: #ffa8a8; }
.hands.has-on .finger:not(.on) .nail { opacity: .35; }
.hands.has-on .finger:not(.on) .nail-shine { opacity: .3; }
.hand .finger.on { animation: fingerTap .9s ease-in-out infinite; }
.hand .finger.on .f-shade { fill: color-mix(in srgb, var(--fc) 72%, #000); }
.hand .finger.on .f-skin { fill: var(--fc); }
.hand .finger.on .f-crease { stroke: color-mix(in srgb, var(--fc) 60%, #000); }
.hand .finger.on .nail { fill: #fff; }
.tip-label { animation: fingerTap .9s ease-in-out infinite; }
.tip-label path { fill: var(--fc); stroke: var(--ink); stroke-width: 3.5; stroke-linejoin: round; }
.tip-label text { fill: #fff; font: 700 21px var(--font); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; paint-order: stroke; }
@keyframes fingerTap { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.story-hands {
  top: 70px; bottom: auto;
  border-radius: 28px;
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 5px 0 rgba(43, 45, 66, .18);
  padding: 8px 22px 4px;
  opacity: 0;
  transform: translate(-50%, -20px);
  transition: opacity .3s, transform .35s cubic-bezier(.3, 1.3, .5, 1);
}
.story-hands.show { opacity: 1; transform: translate(-50%, 0); }

#btn-hands { background: #f1f3f5; opacity: .6; }
#btn-hands.on { background: #fff3bf; opacity: 1; box-shadow: 0 0 0 3px #fab005; }
.story-hands .hand { width: clamp(140px, 19vw, 210px); }

.part-banner {
  position: absolute; left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, #9775fa, #f783ac);
  color: #fff;
  font-size: 20px; font-weight: 600;
  padding: 8px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .12);
  white-space: nowrap;
  z-index: 1;
}
.node.bonus:not(.locked) { background: #f3f0ff; }
.node.bonus.done { border-color: #b197fc; }

.book-svg { width: 100%; display: block; overflow: visible; }
.book .b-open { display: none; }
.book.happy .b-closed { display: none; }
.book.happy .b-open { display: inline; }
.book .b-page { transform-box: fill-box; transform-origin: center; animation: pageFloat 2.4s ease-in-out infinite alternate; }
.book .b-page.p2 { animation-delay: -.8s; }
.book .b-page.p3 { animation-delay: -1.6s; }
@keyframes pageFloat { from { translate: 0 0; } to { translate: 0 -10px; } }
.book .b-rays { transform-box: view-box; transform-origin: 80px 68px; animation: spin 14s linear infinite; }
.book .b-fly { animation: pageFloat 1.6s ease-in-out infinite alternate; }
.book.small { width: 120px; }
.portrait .book { width: 100%; }
.keyboard.mini.full { --kw: 26px; }

/* ---------- Oefenronde ---------- */
.practice-card {
  display: flex; align-items: center; gap: 14px;
  /* Op een breed scherm zo breed als de kaart, zodat de kaart er niet onder wegvalt */
  align-self: center;
  width: calc(100% - 40px); max-width: 760px;
  margin: 10px 0 0;
  padding: 10px 18px;
  border: 3px solid #69db7c;
  border-radius: 18px;
  background: #ebfbee;
  text-align: left;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .08);
  transition: transform .15s;
  animation: cardWiggle 4s ease-in-out infinite;
}
.practice-card:hover { transform: translateY(-2px); }
@keyframes cardWiggle { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-1deg); } 96% { transform: rotate(1deg); } }
.pc-icon { font-size: 34px; }
/* Vandaag is er al een nieuw hoofdstuk gehaald */
.day-card { border-color: #9775fa; background: #f3f0ff; animation: none; }
.day-card .pc-icon .decor-svg { width: 40px; height: 40px; }
.day-card .pc-go { color: #6741d9; }
.node.resting { filter: none; opacity: 1; background: #e5dbff; border-style: dashed; border-color: #9775fa; }
/* Op de kaart zelf, waar het oog al is: dit hoofdstuk gaat morgen open */
.node-soon {
  position: absolute; bottom: calc(100% + 12px); left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 16px; font-weight: 600;
  color: #fff; background: #7950f2;
  padding: 3px 12px;
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .15);
  animation: soonBob 2s ease-in-out infinite;
}
@keyframes soonBob { 50% { transform: translateX(-50%) translateY(-3px); } }
.pc-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pc-text b { font-size: 20px; }
.pc-text small { font-size: 14px; opacity: .7; }
.pc-chips { display: flex; gap: 6px; }
.pc-go { display: flex; flex-direction: column; align-items: flex-end; font-weight: 600; color: #2b8a3e; white-space: nowrap; }
.pc-go small { font-weight: 400; font-size: 12px; opacity: .7; }
.t-chip {
  display: inline-grid; place-items: center;
  min-width: 36px; height: 36px; padding: 0 6px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid var(--fc);
  border-bottom-width: 5px;
  font-size: 20px;
}
.res-letters { margin: 4px 0 8px; }
.res-letters p { margin: 0 0 8px; font-weight: 600; }
.res-letters .rl { display: inline-flex; align-items: center; gap: 8px; margin: 0 10px 6px; }
.practice-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 auto 14px;
  padding: 8px 16px;
  border: 2px solid #69db7c;
  border-radius: 999px;
  background: #ebfbee;
  font-size: 17px; font-weight: 600;
}
.practice-btn.offer { background: #40c057; border-color: #2f9e44; color: #fff; font-size: 19px; padding: 10px 20px; animation: offer-pulse 1.6s ease-in-out infinite; }
@keyframes offer-pulse { 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .practice-btn.offer { animation: none; } }
.practice-btn .t-chip { min-width: 28px; height: 28px; font-size: 16px; border-bottom-width: 3px; }

/* ---------- Schatten ---------- */
/* Een schat verschijnt na --wait: eerst mag het scherm eronder zijn eigen feestje afmaken */
.treasure {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(43, 45, 66, .55);
  animation: tzFade .4s var(--wait, 0s) both;
}
@keyframes tzFade { from { background: rgba(43, 45, 66, 0); } }
.tz-card {
  border: 3px solid var(--ink);
  padding: 22px clamp(18px, 5vw, 36px);
  animation: tzIn .7s cubic-bezier(.3, 1.4, .5, 1) var(--wait, 0s) both;
}
@keyframes tzIn { from { transform: scale(.5) translateY(40px); opacity: 0; } }
.tz-card h2 { font-size: clamp(26px, 6vw, 34px); margin: 4px 0 12px; }
.tz-glow { position: relative; width: 150px; height: 150px; margin: 0 auto; display: grid; place-items: center; }
.tz-rays {
  position: absolute; inset: -28px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 212, 59, .6) 0 12deg, transparent 12deg 30deg);
  -webkit-mask: radial-gradient(closest-side, #000 35%, transparent);
  mask: radial-gradient(closest-side, #000 35%, transparent);
  animation: spin 14s linear infinite;
}
.tz-item { position: relative; width: 118px; animation: tzItem 1s cubic-bezier(.3, 1.5, .5, 1) calc(var(--wait, 0s) + .3s) both; }
.tz-item .decor-svg { filter: var(--outline); animation: floaty 3s ease-in-out 1.4s infinite; }
@keyframes tzItem { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
.tz-talk { display: flex; gap: 14px; align-items: flex-start; text-align: left; margin-bottom: 18px; }
.tz-talk .portrait { flex-basis: 76px; height: 76px; }
.portrait.p-uil { background: #fff4e6; }
.tz-text { font-size: clamp(18px, 2.2vw, 22px); line-height: 1.4; margin: 0; }

/* De schatkist op de kaart */
.chest-btn {
  margin-left: 8px;
  background: #fff; border: none;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 18px; font-weight: 600;
  vertical-align: middle;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .1);
  transition: transform .15s;
}
.chest-btn:hover { transform: translateY(-2px); }
.chest-card { position: relative; width: min(640px, calc(100% - 16px)); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border: 3px solid var(--ink); }
.chest-card h2 { font-size: clamp(28px, 6vw, 38px); }
.chest-sub { margin: 4px 0 14px; opacity: .7; font-size: 17px; }
.chest-close { position: absolute; top: 14px; right: 14px; background: #f1f3f5; }
.chest-list { overflow-y: auto; display: grid; gap: 10px; text-align: left; padding: 2px 4px 6px; }
.chest-item { display: flex; gap: 14px; align-items: center; background: #fff9db; border-radius: 18px; padding: 10px 14px; }
.ci-art { flex: 0 0 60px; }
.ci-art .decor-svg { filter: var(--outline); }
.ci-text { display: flex; flex-direction: column; min-width: 0; }
.ci-text b { font-size: 19px; }
.ci-text small { font-size: 15px; opacity: .8; }
.ci-text .ci-where { font-size: 13px; opacity: .55; margin-top: 2px; }

/* ---------- Zonder toetsenbord ---------- */
.no-kb {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(43, 45, 66, .55);
}
.no-kb-card { padding: clamp(22px, 5vw, 30px) clamp(20px, 6vw, 40px); border: 3px solid var(--ink); }
.no-kb-card h2 { font-size: clamp(26px, 7vw, 38px); margin-top: 6px; }
.no-kb-card p { font-size: 18px; line-height: 1.45; margin: 12px 0 22px; }
.no-kb-card .hint { font-size: 15px; opacity: .6; margin: 14px 0 0; }
.no-kb-icon .ico { width: 110px; height: 110px; animation: noKbBob 2.4s ease-in-out infinite; }
@keyframes noKbBob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(4deg); } }
