:root {
  /* Bestaande tokens — blijven de basis voor kaarten/typografie/spacing.
     Niet vervangen (zou elk scherm tegelijk moeten worden aangepast en
     opnieuw getest); de semantische tokens hieronder zijn er nieuw naast
     gezet en worden per fase op schermen toegepast (zie git-historie voor
     welke fase welk scherm heeft omgezet). */
  --gold: #b8862b;
  --gold-light: #e9c877;
  --gold-soft: #f7ecd2;
  --cream: #fdf8ee;
  --ink: #2b2118;
  --muted: #7a6a55;
  --glow: #ffd257;
  --card: #ffffff;
  --radius: 18px;
  --radius-lg: 28px;
  --success: #dff3e4;
  --success-line: #8fcf9f;
  --oops: #fbe4e2;
  --oops-line: #e3a89f;
  --shadow-card: 0 3px 0 var(--gold-light), 0 10px 24px rgba(120, 80, 20, .14);
  --nav-h: 64px;
  --arabic-hero: clamp(80px, 20vw, 176px);

  /* ---- Alif Ba design system: semantische tokens (referentieafbeelding) ----
     Rolgebaseerd, niet component-gebonden. Elk onderdeel kiest een rol
     (bv. "primaire leeractie" = --color-success), nooit een losse hexcode. */
  --color-background: var(--cream);
  --color-surface: var(--card);
  --color-primary: #2451a3;        /* dieper blauw — belangrijke navigatie/koppen */
  --color-primary-strong: #163b7e;
  --color-secondary: #3a8fd9;      /* helder blauw — interactieve controls/links */
  --color-success: #3fa85c;        /* groen — primaire leeractie ("Verder leren"), goed-antwoord */
  --color-success-strong: #2f7d45;
  --color-reward: var(--gold);     /* sterren/beloningen — bestaand goud hergebruikt */
  --color-reward-strong: #8a6218;
  --color-character-accent: #8452b0; /* paars — character/hero-accentkleur */
  --color-text: var(--ink);
  --color-text-muted: var(--muted);
  --color-locked: #b9ada0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
svg { width: 24px; height: 24px; fill: currentColor; }

/* ---------- Startscherm ---------- */
.home-head {
  position: relative; overflow: hidden; text-align: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px 22px;
  background:
    radial-gradient(120% 140% at 15% -10%, #4a3319, transparent 60%),
    linear-gradient(160deg, #241a0d, #3c2712 55%, #5c3c17 100%);
  border-bottom: 3px solid var(--gold-light);
}
.home-head::before {
  content: ""; position: absolute; inset: 0; opacity: .16; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cg fill='none' stroke='%23e9c877' stroke-width='1'%3E%3Cpath d='M32 2l8 14-8 14-8-14z'/%3E%3Cpath d='M32 34l8 14-8 14-8-14z'/%3E%3Cpath d='M2 32l14-8 14 8-14 8z'/%3E%3Cpath d='M34 32l14-8 14 8-14 8z'/%3E%3Ccircle cx='32' cy='32' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px;
}

.home-title {
  position: relative; max-width: 640px; margin-inline: auto; padding-top: 34px; text-align: center;
}
.home-title h1 { margin: 0; line-height: 1.15; }
.home-title h1 .title-kicker {
  display: block; font-family: "Amiri", serif; font-weight: 700;
  font-size: clamp(14px, 2.6vw, 19px); color: var(--gold-light); opacity: .85; margin-bottom: 2px;
}
.home-title h1 .title-main {
  display: block; font-family: "Amiri", serif; font-weight: 700; color: #fdf6e6;
  font-size: clamp(26px, 7vw, 42px); text-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.home-title h1 .title-main + .title-main { margin-top: -4px; }
.home-title p { margin: 8px 0 0; color: #e4d3b2; }

/* Voortgang over alle lessen */
.home-progress {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 16px auto 0; width: fit-content;
}
.op-ring { width: 32px; height: 32px; transform: rotate(-90deg); flex: none; }
.op-ring-bg, .op-ring-fg { fill: none; stroke-width: 4; }
.op-ring-bg { stroke: rgba(255, 255, 255, .18); }
.op-ring-fg { stroke: var(--glow); stroke-linecap: round; stroke-dasharray: 106.8; stroke-dashoffset: 106.8; transition: stroke-dashoffset .4s; }
.op-text { color: #e4d3b2; font-size: 13px; font-weight: 800; }

.continue {
  position: relative; margin-top: 14px; display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 22px; padding: 8px 16px 8px 12px;
  background: var(--gold); color: #fff; font-weight: 800; box-shadow: 0 3px 0 #8a6218;
}
.continue svg { width: 18px; height: 18px; }
.continue:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6218; }

/* Zoeken */
.home-search {
  position: relative; display: flex; align-items: center; gap: 8px;
  max-width: 420px; margin: 16px auto 0; padding: 0 14px;
  background: rgba(255, 255, 255, .96); border-radius: 22px; height: 44px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
}
.search-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.home-search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none;
  font: inherit; font-size: 15px; color: var(--ink);
}
.home-search input::placeholder { color: #b6a98c; }
.home-search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--gold-soft); color: var(--muted); display: grid; place-items: center;
}
.search-clear svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

.no-results { text-align: center; color: var(--muted); padding: 32px 16px; grid-column: 1 / -1; }

/* ---------- Inhoudsopgave ---------- */
.toc {
  padding: 16px; max-width: 1100px; margin-inline: auto;
  display: grid; gap: 14px; align-items: start;
}
@media (min-width: 820px) { .toc { grid-template-columns: 1fr 1fr; } }

.chapter {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 3px 0 var(--gold-light), 0 6px 14px rgba(120, 80, 20, .1);
}
.chapter > summary {
  list-style: none; cursor: pointer; direction: rtl;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: linear-gradient(90deg, var(--gold-soft), #fff);
}
.chapter > summary::-webkit-details-marker { display: none; }
.ch-num {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--gold);
}
.ch-text { flex: 1; min-width: 0; }
.ch-ar { display: block; font-family: "Amiri", serif; font-size: 21px; font-weight: 700; line-height: 1.3; }
.ch-nl { display: block; color: var(--muted); font-size: 14px; direction: ltr; text-align: right; }
.ch-meta { flex: none; direction: ltr; text-align: center; color: var(--muted); font-size: 13px; font-weight: 800; white-space: nowrap; }
.ch-meta .bar-mini { display: block; width: 56px; height: 6px; border-radius: 3px; background: rgba(184, 134, 43, .18); margin-top: 5px; overflow: hidden; margin-inline: auto; }
.ch-meta .bar-mini i { display: block; height: 100%; background: #5bb974; }
.chev { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; transition: transform .2s; }
.chapter[open] .chev { transform: rotate(180deg); }

.toc-list { list-style: none; margin: 0; padding: 4px 0; }
.toc-item {
  width: 100%; border: 0; background: none; direction: rtl; text-align: right;
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
}
.toc-list li + li .toc-item { border-top: 1px solid var(--gold-soft); }
.toc-item:active { background: var(--gold-soft); }
.toc-item img {
  flex: none; width: 44px; height: 62px; object-fit: cover; object-position: top;
  border-radius: 6px; box-shadow: 0 1px 4px rgba(120, 80, 20, .25);
}
.toc-item .n {
  flex: none; min-width: 30px; height: 30px; border-radius: 15px; padding: 0 6px;
  display: grid; place-items: center; font-weight: 800; color: var(--gold); border: 2px solid var(--gold-light);
}
.toc-item .t { flex: 1; min-width: 0; }
.toc-item .t-ar { display: block; font-family: "Amiri", serif; font-size: 18px; line-height: 1.35; }
.toc-item .t-nl { display: block; color: var(--muted); font-size: 13px; direction: ltr; text-align: right; }
.toc-item .st { flex: none; direction: ltr; width: 30px; text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); }
.toc-item.done .st { font-size: 22px; color: var(--glow); text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.toc-item.last { background: #fff8e3; }
.toc-item.last .n { background: var(--gold); color: #fff; border-color: var(--gold); }

/* ---------- Lesscherm ---------- */
#lesson { display: flex; flex-direction: column; height: 100dvh; }
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--gold-soft); border-bottom: 3px solid var(--gold-light);
}
.bar-title { flex: 1; display: flex; align-items: center; gap: 10px; justify-content: center; min-width: 0; }
.bar-title span:last-child { font-family: "Amiri", serif; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num { background: var(--gold); color: #fff; font-weight: 800; border-radius: 14px; padding: 2px 10px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: #fff; color: var(--gold); display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--gold-light);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gold-light); }
.icon-btn.play { background: var(--gold); color: #fff; box-shadow: 0 3px 0 #8a6218; }
.icon-btn .i-stop { display: none; }
.icon-btn.playing .i-play { display: none; }
.icon-btn.playing .i-stop { display: block; }

.stage-wrap {
  flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start;
  padding: 12px; touch-action: pan-y pinch-zoom;
}
.stage {
  position: relative; width: 100%; max-width: 720px;
  border-radius: 10px; overflow: hidden; box-shadow: 0 8px 24px rgba(120, 80, 20, .18);
  background: #fff;
}
/* Op brede schermen: pagina volledig in beeld */
@media (min-aspect-ratio: 3/4) {
  .stage { width: auto; height: calc(100dvh - 170px); aspect-ratio: 419 / 595; max-width: none; }
}
.stage img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.hotspots { position: absolute; inset: 0; }

.tile {
  position: absolute; border: 0; padding: 0; background: transparent;
  border-radius: 8px; outline: none;
  transition: background .15s, box-shadow .15s, transform .15s;
}
.tile:focus-visible { box-shadow: 0 0 0 3px var(--gold); }
.tile.active {
  background: rgba(255, 210, 87, .28);
  box-shadow: 0 0 0 3px var(--glow), 0 0 18px 4px rgba(255, 196, 40, .6);
  animation: pop .35s ease-out;
}
.tile.heard::after {
  content: ""; position: absolute; top: 5%; left: 5%;
  width: 14%; aspect-ratio: 1; border-radius: 50%; background: #5bb974; opacity: .85;
}
.tile.missing { animation: wobble .4s; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--gold-soft); border-top: 3px solid var(--gold-light);
}
.pg-btn {
  width: 64px; height: 48px; border-radius: 24px; border: 0; background: #fff; color: var(--gold);
  display: grid; place-items: center; box-shadow: 0 3px 0 var(--gold-light);
}
.pg-btn svg { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.pg-btn:disabled { opacity: .35; }
.dots { color: var(--muted); font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 22px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Bewerkmodus (alleen voor de maker, via ?bewerk) ---------- */
body.editing .tile { background: rgba(255, 0, 0, .12); outline: 2px dashed rgba(200, 0, 0, .7); cursor: move; }
body.editing .tile.selected { background: rgba(0, 120, 255, .2); outline: 2px solid #0a6cff; }
body.editing .tile::before {
  content: attr(data-n); position: absolute; top: 2px; right: 4px;
  font: 800 11px/1 Nunito, sans-serif; color: #b00;
}
body.editing .hotspots { cursor: crosshair; }
.draft { position: absolute; border: 2px dashed #0a6cff; background: rgba(0, 120, 255, .12); pointer-events: none; }
.edit-bar {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  padding: 8px 16px; background: #fff3cd; border-top: 1px solid #e0c060; font-size: 14px;
}
.edit-bar button { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--gold); background: #fff; }

/* ---------- Taalkeuze ---------- */
.lang {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); inset-inline-end: 12px;
  display: flex; padding: 3px; gap: 2px; border-radius: 20px;
  background: rgba(255, 255, 255, .92); box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  backdrop-filter: blur(2px);
}
.lang button {
  border: 0; background: none; min-width: 38px; height: 32px; border-radius: 16px;
  font-weight: 800; font-size: 14px; color: var(--muted);
}
.lang button[lang="ar"] { font-family: "Amiri", serif; font-size: 18px; line-height: 1; }
.lang button[aria-pressed="true"] { background: var(--gold); color: #fff; }
.ch-nl:empty, .t-nl:empty { display: none; }
/* Het boek blijft Arabisch: "volgende" altijd links, ook als de bediening Nederlands/Engels is */
.pager { direction: ltr; }
html[dir="rtl"] .home-title p, html[dir="rtl"] .continue { font-family: "Amiri", "Nunito", serif; font-size: 17px; }
.continue { white-space: nowrap; }
html[dir="rtl"] .ch-meta, html[dir="rtl"] .toc-item .st { direction: rtl; }

/* ---------- Hoofdstuk-aanduiding in de les ---------- */
.bar-title { flex-direction: column; gap: 2px; }
.bar-row { display: flex; align-items: center; gap: 10px; max-width: 100%; min-width: 0; }
.bar-title .bar-row span:last-child { font-family: "Amiri", serif; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title span.chapter-line {
  font: 800 12px/1.2 "Nunito", sans-serif; color: var(--gold); letter-spacing: .02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
html[dir="rtl"] .bar-title span.chapter-line { font: 700 15px/1.2 "Amiri", serif; letter-spacing: 0; }

.pager-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.ch-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 60vw; }
.ch-dots i {
  width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--gold-light);
  transition: transform .2s, background .2s;
}
.ch-dots i.done { background: #5bb974; border-color: #5bb974; }
.ch-dots i.here { background: var(--gold); border-color: var(--gold); transform: scale(1.35); }
.dots { font-size: 12px; }

/* ---------- Hoofdstukkaart ---------- */
.splash {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: rgba(43, 33, 24, .45); backdrop-filter: blur(3px);
  animation: fade .2s ease-out;
}
.splash-card {
  width: min(360px, 100%); text-align: center; padding: 28px 24px 24px;
  background: linear-gradient(180deg, var(--gold-soft), #fff 55%);
  border: 3px solid var(--gold-light); border-radius: 28px;
  box-shadow: 0 20px 50px rgba(60, 40, 10, .35);
  animation: rise .35s cubic-bezier(.2, .9, .3, 1.2);
}
.splash-kicker { display: block; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
html[dir="rtl"] .splash-kicker { font-family: "Amiri", serif; font-size: 18px; letter-spacing: 0; text-transform: none; }
.splash-num {
  display: grid; place-items: center; width: 84px; height: 84px; margin: 12px auto;
  border-radius: 50%; background: var(--gold); color: #fff; font: 800 44px/1 "Nunito", sans-serif;
  box-shadow: 0 5px 0 #8a6218, 0 0 0 8px var(--gold-soft);
}
.splash-card h2 { font-family: "Amiri", serif; font-size: 34px; margin: 8px 0 2px; line-height: 1.3; }
.splash-sub { margin: 0; color: var(--muted); font-size: 17px; }
.splash-count { margin: 10px 0 18px; color: var(--muted); font-size: 14px; font-weight: 800; }
.splash .continue { margin: 0; font-size: 17px; padding: 10px 22px 10px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px) scale(.9); opacity: 0; } }

/* =========================================================
   Spelmodus (game.js) — losse schermen, hergebruikt de kleuren
   en lettertypes van de boekmodus hierboven.
   ========================================================= */
.g-entry {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  max-width: 420px; margin: 14px auto 0; height: 44px; border-radius: 22px; text-decoration: none;
  background: linear-gradient(180deg, #ffe08a, var(--glow)); color: #4a2e05; font-weight: 800;
  box-shadow: 0 3px 0 #b9860f;
}
.g-entry:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9860f; }
.g-entry-icon { font-size: 18px; }

.g-screen { min-height: 100dvh; }
.g-icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; flex: none;
  background: rgba(255, 255, 255, .14); color: #fdf6e6; display: grid; place-items: center; font-size: 20px;
}
.g-icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Profielscherm ---------- */
#gProfile {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px 40px;
  background:
    linear-gradient(160deg, rgba(36, 26, 13, .78), rgba(60, 39, 18, .72) 55%, rgba(92, 60, 23, .68) 100%),
    url("assets/backgrounds/general.jpg") center/cover no-repeat, #3c2712;
  color: #fdf6e6; text-align: center;
}
.g-profile-head { width: 100%; max-width: 520px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.g-back-book {
  color: #e4d3b2; text-decoration: none; font-weight: 800; font-size: 14px;
  background: rgba(255, 255, 255, .1); padding: 8px 14px; border-radius: 16px;
}
.g-voice-toggles { display: flex; gap: 8px; }
.g-voice-toggles .g-icon-btn { width: 38px; height: 38px; font-size: 17px; }

.g-lang-pick {
  display: flex; padding: 3px; gap: 2px; border-radius: 20px;
  background: rgba(255, 255, 255, .1);
}
.g-lang-pick button {
  border: 0; background: none; min-width: 34px; height: 30px; border-radius: 16px;
  font-weight: 800; font-size: 13px; color: #e4d3b2;
}
.g-lang-pick button[data-l="ar"] { font-family: "Amiri", serif; font-size: 16px; line-height: 1; }
.g-lang-pick button.sel { background: var(--gold); color: #fff; }
.g-who { font-family: "Amiri", serif; font-size: clamp(22px, 6vw, 30px); margin: 28px 0 20px; }
.g-profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; width: 100%; max-width: 520px; }
.g-profile-card {
  border: 0; border-radius: 20px; padding: 18px 8px; background: rgba(255, 255, 255, .1);
  color: #fdf6e6; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.g-profile-card:active { transform: scale(.96); }
.g-avatar { font-size: 40px; }
.g-pname { font-weight: 800; font-size: 15px; }
.g-add {
  margin-top: 18px; border: 2px dashed rgba(255, 255, 255, .35); background: none; color: #e4d3b2;
  padding: 12px 22px; border-radius: 18px; font-weight: 800;
}
.g-new-form { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 320px; }
.g-avatars { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.g-avatar-pick { width: 48px; height: 48px; border-radius: 50%; border: 2px solid transparent; background: rgba(255, 255, 255, .1); font-size: 24px; }
.g-avatar-pick.sel { border-color: var(--glow); background: rgba(255, 210, 87, .2); }
.g-new-form input {
  width: 100%; height: 46px; border-radius: 23px; border: 0; padding: 0 18px;
  font: inherit; font-size: 16px; text-align: center; background: #fff; color: var(--ink);
}
.g-cta {
  border: 0; border-radius: 22px; padding: 12px 26px; background: var(--gold); color: #fff;
  font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 #8a6218;
}
.g-cta:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a6218; }
.g-cta.ghost { background: rgba(255, 255, 255, .14); box-shadow: none; color: #fdf6e6; }

/* ---------- Werelkaart: sticky kop ---------- */
.g-map-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  color: #fdf6e6; box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.g-theme-oasis { background: linear-gradient(160deg, #1c3326, #2f5138 55%, #c99a3c 130%); }
.g-theme-garden { background: linear-gradient(160deg, #1e3d1a, #3e6b2e 55%, #8fb93c 130%); }
.g-map-title { flex: 1; min-width: 0; }
.g-map-ar { display: block; font-family: "Amiri", serif; font-size: 20px; line-height: 1.2; }
.g-map-sub { display: block; font-size: 12px; color: #e4d3b2; }
.g-stats { display: flex; flex-direction: column; gap: 2px; font-weight: 800; font-size: 12px; text-align: end; white-space: nowrap; }

/* ---------- Werelkaart: het doorlopende landschap ---------- */
/* #gMap vult altijd minstens het volledige scherm tussen header en onder-
   navigatie — .g-scene-wrap rekt mee (flex:1) zodat zijn eigen achtergrond
   (gradient/illustratie) die ruimte vult. Zonder dit ontstond er op lange
   vensters (ingezoomd uit op desktop, of een telefoon met veel verticale
   ruimte) een kaal wit/crème vlak onder de wereld, in plaats van dat de
   thema-achtergrond doorloopt tot aan de taak-/navigatiebalk. */
#gMap.g-screen { min-height: 100dvh; display: flex; flex-direction: column; }
.g-scene-wrap {
  position: relative; overflow-x: hidden; flex: 1; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #cfe6c9 0%, #f3e2ae 34%, #f6d998 66%, #e7c179 100%);
}
.g-scene-wrap[data-theme="garden"] {
  background: linear-gradient(180deg, #dcefc8 0%, #eef3c8 34%, #f5eab3 66%, #e3c88a 100%);
}
/* Geïllustreerde wereld-achtergrond (optioneel): ligt over de CSS-gradient
   hierboven. Ontbreekt het bestand (nog geen illustratie aangeleverd), dan
   verwijdert de onerror-handler in game.js het <img> zelf weer en blijft de
   gradient gewoon zichtbaar — geen kapotte-afbeelding-icoon, geen lege plek. */
.g-scene-bg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center;
  opacity: 0; transition: opacity .25s ease; pointer-events: none; z-index: 0;
}
/* Letter Oase: de knopen zijn opgemeten in de echte pixels van deze
   illustratie (zie OASIS_PATH in game.js) — daarom mag de afbeelding hier
   NIET bijgesneden/uitgerekt worden (geen object-fit:cover). Ze wordt op
   volle breedte getoond en onderaan uitgelijnd (start = onder), exact
   zoals de knoop-coördinaten aannemen. */
/* Moet exact dezelfde breedte/centrering gebruiken als .g-scene hieronder
   (max-width 980px, gecentreerd) — anders klopt de schaal niet meer met de
   knoop-coördinaten uit OASIS_PATH, die uitgaan van diezelfde 980px-brede
   kolom. Zonder deze regel rekte de afbeelding op brede schermen uit tot
   de volle .g-scene-wrap-breedte terwijl de knopen op 980px bleven staan. */
.g-scene-bg--aligned {
  inset: auto 0 0 0; left: 50%; right: auto; width: min(100%, 980px); height: auto;
  transform: translateX(-50%); object-fit: unset; object-position: unset;
}
.g-scene-bg.loaded { opacity: 1; }
.g-scene-wrap .g-scene { position: relative; z-index: 1; }
/* width:100% expliciet nodig: .g-scene-wrap is nu flex (voor de volledige-
   hoogte achtergrond hierboven), en als flex-item met uitsluitend absoluut
   gepositioneerde kinderen heeft .g-scene anders geen eigen intrinsieke
   breedte (komt op 0px uit, dan is ook de achtergrondafbeelding onzichtbaar). */
.g-scene { position: relative; width: 100%; max-width: 980px; margin-inline: auto; overflow: hidden; flex: none; }
.g-route { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.g-route-line {
  fill: none; stroke: #d7ae74; stroke-width: 34; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; opacity: .95; filter: drop-shadow(0 3px 0 rgba(120, 85, 35, .18));
}
.g-route-line-inner {
  fill: none; stroke: #f1dca3; stroke-width: 15; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke; opacity: .9;
}
.g-stone {
  position: absolute; width: 10px; height: 7px; margin: -3px 0 0 -5px; border-radius: 50%;
  background: #c9a877; opacity: .55; z-index: 1;
}

.g-deco { position: absolute; pointer-events: none; z-index: 1; }
.g-deco svg { display: block; width: 100%; height: 100%; overflow: visible; }
.g-deco-xs { width: 34px; height: 34px; }
.g-deco-sm { width: 56px; height: 56px; }
.g-deco-md { width: 90px; height: 126px; }
.g-deco-lg { width: 130px; height: 182px; }
.g-deco-xl { width: 170px; height: 238px; }
.g-deco-oasis { height: 130px; width: 62%; max-width: 420px; }
.g-deco-dune { height: 90px; z-index: 0; }
.g-cloud { position: absolute; width: 160px; opacity: .85; z-index: 1; }
.g-cloud-a { top: 40px; left: -12%; animation: driftCloud 60s linear infinite; }
.g-cloud-b { top: 320px; right: -18%; width: 120px; animation: driftCloud 80s linear infinite reverse; }
@keyframes driftCloud { from { transform: translateX(0); } to { transform: translateX(40px); } }
.sway { transform-origin: 50% 100%; animation: sway 3.5s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.05); } }
.g-gate { position: absolute; left: 50%; transform: translateX(-50%); width: 280px; opacity: .95; z-index: 0; }
/* Zodra een echte geïllustreerde wereld-achtergrond geladen is, bevat die zelf
   al palmen/rotsen/wolken/architectuur — de vlakke CSS/SVG-decoraties zouden
   dan dubbelop en visueel rommelig ogen (twee stijlen palmboom over elkaar).
   .g-scene-bg en .g-scene zijn siblings binnen .g-scene-wrap. */
.g-scene-bg.loaded ~ .g-scene .g-deco,
.g-scene-bg.loaded ~ .g-scene .g-cloud,
.g-scene-bg.loaded ~ .g-scene .g-gate {
  display: none;
}

/* Checkpoint (rustplek na level 5) */
.g-cp {
  position: absolute; transform: translate(-50%, -50%); width: 58px; height: 58px; z-index: 2;
  border: 0; border-radius: 50%; background: #fff8e3; box-shadow: 0 4px 0 #cabfa9; font-size: 26px;
  display: grid; place-items: center;
}
.g-cp svg { width: 38px; }
.g-cp.locked { opacity: .5; }
.g-cp.done { opacity: .75; }
.g-cp:not(.locked):not(.done):active { transform: translate(-50%, -50%) translateY(2px); }
.g-cp:not(.locked):not(.done) { animation: bounceSm 1.6s ease-in-out infinite; }
@keyframes bounceSm { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, -56%); } }

/* Level-node */
.g-node2 { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; z-index: 2; width: 120px; }
.g-node-btn2 {
  position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0;
  display: grid; place-items: center; font-family: "Amiri", serif; transition: width .15s, height .15s;
}
.g-node-btn2.on {
  background: linear-gradient(180deg, #ffe9ad, var(--glow)); color: #4a2e05; box-shadow: 0 5px 0 #b9860f, 0 10px 18px rgba(0, 0, 0, .2);
}
.g-node-btn2.on:active { transform: translateY(3px); box-shadow: 0 2px 0 #b9860f; }
.g-node-btn2.locked {
  position: relative; background: rgba(255, 255, 255, .6); box-shadow: 0 4px 0 rgba(0, 0, 0, .08);
}
.g-node-btn2.locked .g-node-letter, .g-node-btn2.locked .g-node-n-big { opacity: .45; filter: grayscale(.6); }
.g-node-btn2.completed { background: linear-gradient(180deg, #cdeccb, #8fcf9f); box-shadow: 0 5px 0 #5a9c6a, 0 10px 18px rgba(0, 0, 0, .2); }
.g-node-btn2.current {
  width: 100px; height: 100px;
  box-shadow: 0 6px 0 #b9860f, 0 0 0 7px rgba(255, 210, 87, .35), 0 10px 22px rgba(0, 0, 0, .22);
  animation: nodeBounce 1.8s ease-in-out infinite;
}
@keyframes nodeBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.g-node-letter { font-size: 40px; font-weight: 700; line-height: 1; }
.g-node-n-big { font-size: 30px; font-weight: 800; font-family: "Nunito", sans-serif; }
.g-node-btn2.current .g-node-letter { font-size: 46px; }
.g-node-lock {
  position: absolute; bottom: -4px; inset-inline-end: -4px; font-size: 20px;
  background: #fff; border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .25);
}
.g-node-trophy { position: absolute; top: -14px; inset-inline-end: -8px; font-size: 26px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.g-node-sparkle { position: absolute; top: -6px; inset-inline-start: -10px; font-size: 18px; animation: twinkle 1.6s ease-in-out infinite; }
.g-node-pulse {
  position: absolute; inset: -10px; border-radius: 50%; border: 3px solid var(--glow); opacity: .7;
  animation: pulseRing 1.8s ease-out infinite;
}
@keyframes pulseRing { 0% { transform: scale(.85); opacity: .6; } 100% { transform: scale(1.4); opacity: 0; } }
.g-node-num {
  margin-top: 6px; min-width: 24px; padding: 2px 7px; border-radius: 10px; background: rgba(43, 33, 24, .55);
  color: #fff; font-size: 12px; font-weight: 800;
}
.g-node-stars2 { margin-top: 3px; color: var(--glow); font-size: 15px; letter-spacing: 1px; text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.g-node-flag {
  margin-top: 7px; background: var(--color-success); color: #fff; font-size: 14px; font-weight: 800;
  padding: 7px 16px; border-radius: 999px; white-space: nowrap; box-shadow: 0 3px 0 var(--color-success-strong);
}

.g-node2.is-challenge .g-node-btn2 { width: 128px; height: 128px; }
.g-node2.is-challenge .g-node-btn2.current { width: 136px; height: 136px; }
.g-node2.is-challenge .g-node-btn2.on { background: linear-gradient(180deg, #ffcf8a, #f2903f); box-shadow: 0 7px 0 #b1601a, 0 12px 22px rgba(0, 0, 0, .25); }
.g-node2.is-challenge .g-node-letter, .g-node2.is-challenge .g-node-n-big { font-size: 46px; }

/* Letter Oase: knopen staan exact op het getekende pad, dus de onderlinge
   afstand ligt vast (soms maar 40-90px) — flink compacter dan de generieke
   kaart, met het nummer/sterren/label als klein badge i.p.v. eronder
   gestapelde tekst, zodat naburige knopen elkaar niet overlappen. */
/* #gMap-prefix geeft deze regels extra gewicht t.o.v. de generieke
   mobiel-media-query hieronder (zelfde aantal klasses, dus anders zou de
   bronvolgorde die media query laten winnen). */
#gMap .g-node2--aligned { width: auto; }
#gMap .g-node2--aligned .g-node-btn2 { width: 52px; height: 52px; }
/* De current-node blijft hier duidelijk groter dan de rest (net als in de
   generieke kaart), zodat "waar ben ik nu" onmiddellijk duidelijk is. */
#gMap .g-node2--aligned .g-node-btn2.current { width: 78px; height: 78px; box-shadow: 0 6px 0 #b9860f, 0 0 0 6px rgba(255, 210, 87, .4), 0 10px 20px rgba(0, 0, 0, .25); }
#gMap .g-node2--aligned .g-node-letter, #gMap .g-node2--aligned .g-node-n-big { font-size: 22px; }
#gMap .g-node2--aligned .g-node-btn2.current .g-node-letter, #gMap .g-node2--aligned .g-node-btn2.current .g-node-n-big { font-size: 32px; }
#gMap .g-node2--aligned .g-node-num { display: none; }
#gMap .g-node2--aligned .g-node-stars2 {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  margin: 0; font-size: 9px; background: rgba(43, 33, 24, .55); border-radius: 8px; padding: 1px 4px; white-space: nowrap;
}
#gMap .g-node2--aligned .g-node-flag {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  margin: 0; font-size: 13px; padding: 5px 12px; white-space: nowrap; z-index: 3;
}
#gMap .g-node2--aligned .g-node-lock { width: 20px; height: 20px; font-size: 13px; bottom: -2px; }
#gMap .g-node2--aligned.is-challenge .g-node-btn2 { width: 62px; height: 62px; }
#gMap .g-node2--aligned.is-challenge .g-node-btn2.current { width: 84px; height: 84px; }
#gMap .g-node2--aligned.is-challenge .g-node-letter { font-size: 28px; }

/* Mobiel: iets compactere knopen, zoals gevraagd (64-80px) */
@media (max-width: 480px) {
  .g-node2 { width: 100px; }
  .g-node-btn2 { width: 72px; height: 72px; }
  .g-node-letter { font-size: 32px; }
  .g-node-n-big { font-size: 24px; }
  .g-node-btn2.current { width: 84px; height: 84px; }
  .g-node-btn2.current .g-node-letter { font-size: 38px; }
  .g-node2.is-challenge .g-node-btn2 { width: 108px; height: 108px; }
  .g-node2.is-challenge .g-node-btn2.current { width: 114px; height: 114px; }
  .g-node2.is-challenge .g-node-letter, .g-node2.is-challenge .g-node-n-big { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .g-cloud, .sway, .twinkle, .g-cp:not(.locked):not(.done), .g-node-btn2.current, .g-node-pulse, .g-node-sparkle { animation: none; }
}

/* ---------- Level: intro & vragen ---------- */
/* Zelfde algemene achtergrond-illustratie als Home/keuzescherm, met een
   lichte warme wash zodat instructiekaart/antwoordkaarten (wit/opaque)
   dominant en leesbaar blijven. */
#gLevel {
  background:
    linear-gradient(180deg, rgba(255, 249, 236, .88) 0%, rgba(253, 248, 238, .93) 45%, rgba(253, 248, 238, .82) 100%),
    url("assets/backgrounds/general.jpg") center/cover no-repeat, var(--cream);
  min-height: 100dvh; display: flex; flex-direction: column;
}
.g-lvl-head { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 8px; }
.g-lvl-head .g-icon-btn { background: var(--gold-soft); color: var(--gold); flex: none; }
.g-lvl-progress { flex: 1; height: 10px; border-radius: 5px; background: var(--gold-soft); overflow: hidden; }
.g-lvl-progress i { display: block; height: 100%; background: var(--gold); transition: width .3s; }
/* Vraag-voor-vraag voortgang als stippen (referentie: ●●●○○) i.p.v. een balk. */
.g-lvl-dots { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.g-lvl-dots i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--gold-soft); border: 2px solid var(--gold-light);
  transition: transform .2s, background .2s;
}
.g-lvl-dots i.done { background: var(--color-success); border-color: var(--color-success-strong); }
.g-lvl-dots i.cur { background: var(--gold); border-color: var(--gold); transform: scale(1.35); }
.g-lvl-stars {
  flex: none; display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 13px;
  background: var(--gold-soft); color: var(--gold); border-radius: 999px; padding: 6px 10px; white-space: nowrap;
}

/* Tijdslimiet per vraag: dunne balk die leegloopt. */
.g-timer { height: 5px; margin: 0 14px; border-radius: 3px; background: var(--gold-soft); overflow: hidden; }
.g-timer i { display: block; height: 100%; width: 100%; background: var(--gold); }
/* Waarschuwing dat de tijd bijna om is: balk verspringt naar oranje/rood en
   pulseert zachtjes — duidelijk voelbaar, niet fel/eng. */
.g-timer.warn { height: 7px; animation: timerPulse 1s ease-in-out infinite; }
.g-timer.warn i { background: linear-gradient(90deg, #e2762f, #e0503f); }
@keyframes timerPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .g-timer i { transition: none !important; } .g-timer.warn { animation: none; } }

.g-intro, .g-q { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; text-align: center; }
.g-intro-kicker { font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.g-big-letter {
  width: clamp(160px, 46vw, 260px); aspect-ratio: 1; border-radius: 32px; border: 0;
  background: var(--card); box-shadow: var(--shadow-card);
  font-family: "Amiri", serif; font-size: var(--arabic-hero); line-height: 1.3; color: var(--ink);
}
.g-big-letter.playing { animation: pop .4s ease-out; }
.g-intro-hint { color: var(--muted); font-weight: 700; }

/* Instructiekaart: icoon + korte kicker ("Luister") + de eigenlijke vraag —
   vervangt de losse pill van vroeger, zodat de oefening meteen leest als een
   kaart-gebaseerd schermtype i.p.v. een formulierregel. */
.g-instr-card {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 380px; text-align: start;
  background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 14px 18px;
}
.g-instr-icon {
  flex: none; width: 42px; height: 42px; border-radius: 50%; font-size: 19px;
  background: var(--gold-soft); color: var(--gold); display: grid; place-items: center;
}
.g-instr-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.g-instr-kicker { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.g-instr-main { font-size: 15px; font-weight: 800; color: var(--ink); }
.g-play-big {
  width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--gold); color: #fff;
  font-size: 40px; box-shadow: 0 4px 0 #8a6218;
}
.g-play-big:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a6218; }
/* De vraag/referentie (wat er gevraagd wordt) krijgt een gouden accent, duidelijk
   anders dan de witte antwoordkaarten hieronder — zodat "vraag" en "antwoorden"
   niet door elkaar lopen. */
.g-q-ref {
  width: clamp(130px, 34vw, 190px); aspect-ratio: 1; border-radius: 28px;
  background: var(--gold-soft); border: 3px solid var(--gold-light); display: grid; place-items: center;
  font-family: "Amiri", serif; font-size: clamp(64px, 16vw, 100px); line-height: 1.3; color: var(--ink);
  box-shadow: 0 3px 0 var(--gold-light);
}
.g-q-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: 100%; max-width: 380px; }
.g-opt {
  aspect-ratio: 1; min-height: 48px; border-radius: 24px; border: 0; background: var(--card); font-family: "Amiri", serif;
  font-size: clamp(40px, 10vw, 60px); line-height: 1.3; color: var(--ink); box-shadow: 0 3px 0 var(--gold-light);
}
.g-opt:active { transform: translateY(2px); }
.g-opt.correct { background: var(--success); box-shadow: 0 3px 0 var(--success-line); animation: pop .35s ease-out; }
.g-opt.wrong { animation: wobble .4s; background: var(--oops); }

.g-pairs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: 100%; max-width: 320px; }
.g-pair-card {
  aspect-ratio: 1; border-radius: 22px; border: 0; background: linear-gradient(160deg, var(--gold), #8a6218);
  color: #fff; font-family: "Amiri", serif; font-size: 44px; box-shadow: 0 3px 0 #6d4c12;
}
.g-pair-card.flipped, .g-pair-card.matched { background: var(--card); color: var(--ink); box-shadow: 0 3px 0 var(--gold-light); }
.g-pair-card.matched { opacity: .55; }

/* ---------- Level voltooid: volwaardig celebration-scherm ---------- */
/* Warme, stralende achtergrond (geen donkere dialoog-dimmer) — dit moet
   voelen als een bestemming/hoogtepunt, niet als een gesloten modal. */
.g-overlay {
  position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center;
  padding: 24px calc(24px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  overflow-y: auto;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(255, 210, 87, .55), transparent 60%),
    linear-gradient(180deg, #fff4d6 0%, var(--cream) 45%);
}
.g-complete-card {
  width: min(380px, 100%); text-align: center; padding: 34px 26px; border-radius: 32px;
  background: var(--card); box-shadow: 0 20px 50px rgba(60, 40, 10, .22);
  animation: rise .35s cubic-bezier(.2, .9, .3, 1.2);
}
.g-complete-title { font-family: "Amiri", serif; font-size: clamp(24px, 6.5vw, 30px); margin: 0 0 12px; color: var(--ink); }
.g-stars-big { font-size: 48px; letter-spacing: 6px; color: #d8cbb0; }
.g-stars-big .on { color: var(--glow); text-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
.g-complete-hype { font-weight: 800; color: var(--gold); margin: 8px 0 0; font-size: 15px; }
.g-rewards { display: flex; justify-content: center; gap: 16px; font-weight: 800; color: var(--muted); margin: 4px 0 14px; }
.g-badge-earned {
  display: flex; align-items: center; gap: 10px; justify-content: center; text-align: start;
  background: var(--gold-soft); border-radius: 16px; padding: 10px 14px; margin-bottom: 16px; font-weight: 700; font-size: 14px;
}
.g-badge-icon { font-size: 28px; }
/* Grote primaire CTA bovenaan, kleinere secundaire eronder — i.p.v. twee
   gelijkwaardige knoppen naast elkaar. */
.g-complete-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin-top: 4px; }
.g-cta-primary {
  background: var(--color-success); box-shadow: 0 4px 0 var(--color-success-strong);
  font-size: 18px; padding: 15px 26px;
}
.g-cta-primary:active { box-shadow: 0 1px 0 var(--color-success-strong); }
.g-complete-actions .g-cta.ghost { background: none; color: var(--muted); box-shadow: none; font-size: 14px; padding: 8px; }

.g-toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 22px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30;
}
.g-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .g-opt.correct, .g-opt.wrong, .g-big-letter.playing, .g-complete-card { animation: none; }
}

/* ---------- Persoonlijk leermaatje ---------- */
.g-companion {
  position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); inset-inline-end: 14px;
  width: 62px; height: 86px; z-index: 15; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .18));
  animation: charIdle 3.2s ease-in-out infinite;
}
.g-companion svg { width: 100%; height: 100%; display: block; }
.g-companion.enter { animation: charEnter .5s cubic-bezier(.2, .9, .3, 1.2), charIdle 3.2s ease-in-out .5s infinite; }
.g-companion.mood-happy, .g-companion.mood-proud { animation: charHappy .5s ease-in-out; }
.g-companion.mood-celebrate { animation: charHappy .6s ease-in-out 2; }
.g-companion.mood-encouraging, .g-companion.mood-thinking { animation: charThink .5s ease-in-out; }
@keyframes charIdle { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-2deg); } }
@keyframes charEnter { from { transform: translateY(40px) scale(.7); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes charHappy { 0%, 100% { transform: translateY(0) scale(1); } 30% { transform: translateY(-10px) scale(1.06); } 60% { transform: translateY(0) scale(1); } }
@keyframes charThink { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-4deg); } 60% { transform: rotate(3deg); } }

.g-companion-celebrate { width: 76px; height: 104px; margin: 0 auto 4px; animation: charHappy 1s ease-in-out infinite; }
.g-companion-celebrate svg { width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  .g-companion, .g-companion.enter, .g-companion.mood-happy, .g-companion.mood-proud, .g-companion.mood-celebrate,
  .g-companion.mood-encouraging, .g-companion.mood-thinking, .g-companion-celebrate {
    animation: none;
  }
}

/* ---------- App-schil: ruimte boven de onderste navigatie ---------- */
#appHome, #rewards, #profileHub, #home, #gProfile, #gMap {
  padding-bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
}

/* ---------- Onderste navigatie ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(253, 248, 238, .92); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(184, 134, 43, .18); box-shadow: 0 -6px 18px rgba(120, 80, 20, .08);
}
.bottom-nav.hidden { display: none; }
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 800;
}
.bn-icon { font-size: 21px; line-height: 1; filter: grayscale(.35); opacity: .8; }
.bn-item.active { color: var(--gold); }
.bn-item.active .bn-icon { filter: none; opacity: 1; transform: translateY(-1px); }

/* ---------- App-home ---------- */
/* Dezelfde algemene achtergrond-illustratie als het keuzescherm (#gProfile)
   staat hier altijd achter Home — ook het dashboard van een bestaand
   profiel (dat is voor terugkerende kinderen letterlijk "het startscherm").
   Een lichte, warme wash erover houdt de witte kaarten leesbaar/dominant. */
#appHome {
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255, 249, 236, .88) 0%, rgba(253, 248, 238, .93) 55%, rgba(253, 248, 238, .82) 100%),
    url("assets/backgrounds/general.jpg") center/cover no-repeat, var(--cream);
}
/* Startscherm zonder profiel: donkerder scrim, want daar staat witte tekst
   los op de achtergrond (geen kaart eromheen) i.p.v. op een lichte kaart. */
#appHome.is-start {
  background:
    linear-gradient(180deg, rgba(36, 26, 13, .55), rgba(36, 26, 13, .78) 70%),
    url("assets/backgrounds/general.jpg") center/cover no-repeat, #3c2712;
}
.app-home { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.app-home-hero {
  margin: calc(20px + env(safe-area-inset-top)) 0 18px; padding: 20px;
  border-radius: var(--radius-lg); text-align: start; color: var(--ink);
  background: var(--card); box-shadow: var(--shadow-card);
}
.app-home-hero--start {
  text-align: center; color: #fdf6e6; background: rgba(36, 26, 13, .45);
  backdrop-filter: blur(2px); box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
}
.app-home-hero--start .app-home-kicker { color: var(--gold-light); }
.app-home-hero--start .app-home-sub { color: #e4d3b2; }
.app-home-worldcard {
  margin: 6px 0 18px; padding: 20px; border-radius: var(--radius-lg);
  background: var(--card); box-shadow: var(--shadow-card);
}
.app-home-kicker { display: block; font-family: "Amiri", serif; font-size: 14px; color: var(--gold); opacity: .85; margin-bottom: 6px; }
.app-home-title { font-family: "Amiri", serif; font-size: clamp(30px, 8vw, 44px); margin: 0 0 10px; }
.app-home-sub { color: var(--muted); margin: 0 0 18px; font-weight: 700; }
.app-home-avatar { font-size: 40px; display: block; }

/* TOP: identiteitsbalk (kleine avatar + begroeting + sterren/XP-pills). */
.app-home-topbar {
  display: flex; align-items: center; gap: 10px;
  margin: calc(16px + env(safe-area-inset-top)) 0 4px;
}
.ahc-avatar-mini, .ahc-avatar-mini-emoji {
  flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: var(--gold-soft); border: 3px solid var(--gold-light); display: grid; place-items: center;
}
.ahc-avatar-mini-emoji { font-size: 22px; }
.ahc-avatar-mini svg { width: 100%; height: 100%; transform: translateY(14%) scale(1.55); }
.app-home-greet { flex: 1; min-width: 0; font-weight: 800; font-size: clamp(16px, 4.4vw, 19px); margin: 0; }
.app-home-stats { display: flex; gap: 6px; flex: none; }
.ahp-pill {
  display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-size: 13px;
  background: var(--gold-soft); color: var(--gold); border-radius: 999px; padding: 5px 10px;
}

/* HERO: CharacterStage — het personage neemt hier bewust de dominante
   visuele positie in, los van de kaart eronder (net als referentie-Home). */
.app-home-stage {
  height: clamp(190px, 46vw, 260px); display: flex; align-items: flex-end; justify-content: center;
  margin: 6px 0 4px;
}
.app-home-character { width: clamp(150px, 40vw, 210px); height: 100%; animation: charIdle 3.4s ease-in-out infinite; }
.app-home-character svg { width: 100%; height: 100%; }
.app-home-avatar-big { font-size: clamp(72px, 22vw, 110px); line-height: 1; }
.app-home-wardrobe-link { display: block; margin-top: 10px; color: var(--gold); font-weight: 700; font-size: 13px; text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .app-home-character { animation: none; } }

/* CURRENT WORLD: WorldCard met thumbnail-asset-slot + naam/level/voortgang. */
.app-home-current {
  display: flex; align-items: center; gap: 12px;
  background: var(--gold-soft); border-radius: 16px; padding: 12px 16px; margin-bottom: 16px;
}
/* Wereld-thumbnail: asset-slot met vaste afmeting/aspect-ratio (1:1). Nog geen
   illustratie aangeleverd → toont voorlopig een rustige, thema-gekleurde vlak
   (dezelfde --theme-* gradient als de wereldkaart-achtergrond) op exact de
   plek waar later assets/worlds/<theme>/thumbnail.webp 1-op-1 in komt. */
.ahc-world-thumb { flex: none; width: 46px; height: 46px; border-radius: 12px; display: block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.ahc-current-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.ahc-label { font-weight: 700; color: var(--muted); font-size: 13px; }
.ahc-level { font-weight: 800; font-size: 18px; color: var(--ink); }
.ahc-progress { flex-basis: 100%; height: 8px; border-radius: 5px; background: rgba(184, 134, 43, .18); overflow: hidden; margin-top: 6px; }
.ahc-progress i { display: block; height: 100%; background: var(--gold); border-radius: 5px; transition: width .3s; }
.app-cta {
  display: inline-flex; align-items: center; gap: 8px; background: var(--gold); color: #fff; text-decoration: none;
  font-weight: 800; font-size: 17px; padding: 14px 26px; border-radius: 999px; box-shadow: 0 4px 0 #8a6218;
}
.app-cta-full { display: flex; justify-content: center; width: 100%; }
.app-cta:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a6218; }
/* Primaire leeractie ("Verder leren" op Home) volgt de referentie: groen
   i.p.v. goud, zodat goud gereserveerd blijft voor sterren/beloningen. */
.app-home-worldcard .app-cta, .app-home-hero .app-cta {
  background: var(--color-success); box-shadow: 0 4px 0 var(--color-success-strong);
}
.app-home-worldcard .app-cta:active, .app-home-hero .app-cta:active { box-shadow: 0 1px 0 var(--color-success-strong); }
.cta-arrow { display: inline-block; }
[dir="rtl"] .cta-arrow, [dir="rtl"] .book-card-arrow { transform: scaleX(-1); }

.book-card {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
  background: var(--card); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-card);
}
.book-card-icon { font-size: 30px; }
.book-card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.book-card-text strong { font-size: 15px; }
.book-card-text span:last-child { font-size: 13px; color: var(--muted); font-weight: 700; }
.book-card-arrow { font-weight: 800; color: var(--gold); }

/* ---------- Beloningen & Profiel (gedeelde "hub"-opmaak) ---------- */
#rewards, #profileHub { min-height: 100dvh; background: var(--cream); max-width: 560px; margin: 0 auto; padding-inline: 16px; }
.hub-head { padding: calc(20px + env(safe-area-inset-top)) 0 6px; }
.hub-head h1 { margin: 0; font-size: clamp(22px, 6vw, 28px); }
.hub-sub { font-size: 16px; margin: 22px 0 10px; }
.hub-empty { color: var(--muted); font-weight: 700; }

.reward-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.reward-stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 16px 8px; text-align: center; display: flex; flex-direction: column; gap: 4px;
}
.rs-n { font-size: 22px; font-weight: 800; color: var(--gold); }
.rs-l { font-size: 12px; font-weight: 700; color: var(--muted); }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.badge-tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 16px 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.bt-icon { font-size: 32px; }
.bt-name { font-size: 12px; font-weight: 700; color: var(--muted); }

.profile-card-big {
  display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-card); margin-top: 10px;
}
.pcb-avatar { font-size: 40px; }
.pcb-character { width: 40px; height: 54px; display: inline-block; }
.pcb-character svg { width: 100%; height: 100%; }
.pcb-name { font-weight: 800; font-size: 17px; flex: 1; }
.pcb-switch { color: var(--gold); font-weight: 800; text-decoration: none; font-size: 13px; background: var(--gold-soft); padding: 8px 12px; border-radius: 14px; }

.hub-panel { margin-top: 22px; }
.hub-panel h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); }
.lang-picks { display: flex; gap: 8px; }
.lang-pick { border: 2px solid var(--gold-soft); background: var(--card); border-radius: 14px; padding: 10px 16px; font-weight: 800; color: var(--ink); }
.lang-pick.sel { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }

.hub-parents { background: var(--gold-soft); border-radius: var(--radius-lg); padding: 16px; }
.parent-sound { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.parent-toggle { text-align: start; border: 0; background: var(--card); border-radius: 12px; padding: 10px 14px; font-weight: 700; font-size: 14px; }
.parent-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--card); border-radius: 12px; overflow: hidden; }
.parent-table th, .parent-table td { padding: 8px 10px; text-align: start; }
.parent-table thead { background: rgba(184, 134, 43, .12); font-weight: 800; }
.parent-table tbody tr:nth-child(even) { background: rgba(184, 134, 43, .05); }

/* ---------- Nieuwe kleding-melding op het level-voltooid-scherm ---------- */
.g-wardrobe-earned { text-decoration: none; color: var(--ink); cursor: pointer; background: #eef6ec; }

/* ---------- Personage maken (onboarding-wizard) ---------- */
#gCharCreate {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(160deg, #241a0d, #3c2712 55%, #5c3c17 100%);
}
.cc-wrap { width: min(380px, 100%); text-align: center; color: #fdf6e6; }
.cc-preview { width: 140px; height: 190px; margin: 0 auto 18px; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .3)); animation: charIdle 3s ease-in-out infinite; }
.cc-preview svg { width: 100%; height: 100%; }
.cc-wrap h2 { font-family: "Amiri", serif; font-size: clamp(20px, 5.5vw, 26px); margin: 0 0 18px; }
.cc-choices { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.cc-choices-2 .cc-pick { width: 92px; height: 92px; font-size: 46px; border-radius: 26px; border: 0; background: rgba(255, 255, 255, .12); }
.cc-choices-2 .cc-pick.sel { background: var(--gold); }
.cc-labels { display: flex; justify-content: center; gap: 44px; font-weight: 800; margin-bottom: 20px; color: #e4d3b2; }
.cc-swatch { width: 54px; height: 54px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); }
.cc-swatch.sel { border-color: var(--glow); box-shadow: 0 0 0 3px rgba(255, 210, 87, .4); }
.cc-outfits { margin-bottom: 20px; }
.cc-outfit-pick { width: 56px; height: 56px; border-radius: 18px; border: 3px solid rgba(255, 255, 255, .25); }
.cc-outfit-pick.sel { border-color: var(--glow); box-shadow: 0 0 0 3px rgba(255, 210, 87, .4); }
.cc-wrap .g-cta { width: 100%; justify-content: center; margin-top: 6px; }
.cc-wrap .g-cta[disabled] { opacity: .45; pointer-events: none; }

/* ---------- Personage op de wereldkaart ---------- */
/* Het leermaatje staat NAAST de current-level node (niet erop/eronder als
   klein icoontje) — duidelijk het dominante element, alsof het kind zelf
   op het pad staat. Horizontale verschuiving t.o.v. de node-positie via
   transform (px, naast de %-gebaseerde left van de node zelf), voeten
   landen dicht bij het pad-niveau van de node (translateY iets minder dan
   -100% i.p.v. er bovenuit te steken). */
.g-map-character {
  position: absolute; width: 92px; height: 132px; transform: translate(calc(-50% - 74px), -86%); z-index: 6;
  pointer-events: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .3)); animation: charIdle 3.4s ease-in-out infinite;
}
.g-map-character svg { width: 100%; height: 100%; }
@media (min-width: 640px) {
  .g-map-character { width: 122px; height: 175px; transform: translate(calc(-50% - 92px), -86%); }
}

/* WorldMapStage: brede (1672x941) illustratie-wereldkaarten met camera/viewport.
   .g-world-viewport is het venster (overflow:hidden, vult altijd het scherm);
   .g-world-stage is de volledige wereld op ware grootte * zoom, verschoven via
   JS zodat het huidige level gecentreerd staat. Alle knopen/character gebruiken
   dezelfde %-coördinaten (0-1 fractie van de wereldafbeelding) binnen de stage,
   zodat ze nooit los raken van het pad. */
#gMap .g-world-viewport {
  position: relative; overflow: hidden; flex: 1; width: 100%; background: var(--cream);
}
#gMap .g-world-stage {
  position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform;
}
#gMap .g-world-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#gMap .g-wnode { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; z-index: 2; }
#gMap .g-wnode .g-node-btn2 { width: 56px; height: 56px; }
#gMap .g-wnode .g-node-btn2.current { width: 84px; height: 84px; box-shadow: 0 6px 0 var(--color-success-strong), 0 0 0 6px rgba(255, 210, 87, .4), 0 10px 20px rgba(0, 0, 0, .25); }
#gMap .g-wnode .g-node-letter, #gMap .g-wnode .g-node-n-big { font-size: 24px; }
#gMap .g-wnode .g-node-btn2.current .g-node-letter, #gMap .g-wnode .g-node-btn2.current .g-node-n-big { font-size: 34px; }
#gMap .g-wnode .g-node-stars2 { font-size: 14px; }
#gMap .g-wnode .g-node-flag { position: absolute; top: 100%; margin-top: 4px; white-space: nowrap; }
#gMap .g-wnode.is-challenge .g-node-btn2 { width: 66px; height: 66px; }
#gMap .g-wnode.is-challenge .g-node-btn2.current { width: 90px; height: 90px; }
#gMap .g-wchar {
  position: absolute; width: 100px; height: 140px; transform: translate(calc(-50% - 56px), -82%); z-index: 3;
  pointer-events: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .3)); animation: charIdle 3.4s ease-in-out infinite;
}
#gMap .g-wchar svg { width: 100%; height: 100%; }
@media (min-width: 640px) {
  #gMap .g-wchar { width: 130px; height: 178px; transform: translate(calc(-50% - 68px), -82%); }
}
@media (min-width: 1024px) {
  #gMap .g-wchar { width: 150px; height: 205px; transform: translate(calc(-50% - 78px), -82%); }
}
@media (prefers-reduced-motion: reduce) {
  #gMap .g-wchar { animation: none; }
}

/* CharacterRenderer: <span class="char-render"> vult exact dezelfde ruimte
   als de vroegere inline <svg> in elke plek waar het personage getoond wordt
   (companion, app-home, profielkaart, wereldkaart-marker, creator-preview). */
.char-render { display: block; width: 100%; height: 100%; }
.char-render img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---------- Kledingkast ---------- */
#gWardrobe { min-height: 100dvh; background: var(--cream); padding: calc(16px + env(safe-area-inset-top)) 16px calc(90px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
#gWardrobe .g-profile-head { color: var(--ink); }
#gWardrobe .g-back-book { background: var(--gold-soft); color: var(--gold); }
.cc-preview-wardrobe { width: 130px; height: 172px; margin: 12px auto 18px; }
.cc-preview-wardrobe svg { width: 100%; height: 100%; }
.wardrobe-tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 2px; }
.wardrobe-tab { flex: none; border: 2px solid var(--gold-soft); background: var(--card); color: var(--ink); border-radius: 14px; padding: 9px 16px; font-weight: 800; font-size: 13px; }
.wardrobe-tab.sel { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.wardrobe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.wardrobe-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: var(--card);
  border-radius: 18px; padding: 12px 8px; box-shadow: var(--shadow-card);
}
.wardrobe-item.equipped { outline: 3px solid var(--gold); }
.wardrobe-item.locked { opacity: .6; }
.wardrobe-swatch { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; overflow: hidden; }
.wardrobe-swatch-img img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.wardrobe-label { font-size: 12px; font-weight: 700; color: var(--ink); }
.wardrobe-hint { font-size: 10px; color: var(--muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .cc-preview, .g-map-character { animation: none; }
}
