* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --inkt: #2b2150;
  --papier: #fdf6e3;
  --geel: #ffd43b;
  --oranje: #f76707;
  --zacht: #fff4c2;
}

html, body { height: 100%; }

body {
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, system-ui, sans-serif;
  background: linear-gradient(180deg, #fff3bf 0%, var(--papier) 50%);
  color: var(--inkt);
  -webkit-tap-highlight-color: transparent;
}

button, .knop-label, input { font: inherit; color: inherit; }

button, .knop-label {
  cursor: pointer;
  border: 3px solid var(--inkt);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 0 var(--inkt);
  transition: transform .08s ease, box-shadow .08s ease;
}
button:active, .knop-label:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--inkt); }
button:disabled { opacity: .4; cursor: default; transform: none; box-shadow: 0 4px 0 var(--inkt); }
button:focus-visible, .knop-label:focus-within, input:focus-visible { outline: 3px solid var(--oranje); outline-offset: 2px; }

.groot { padding: 10px 18px; font-size: 1.1rem; font-weight: 800; background: var(--geel); }
.groot.zacht { background: #fff; }
.klein { padding: 6px 12px; font-size: .95rem; font-weight: 700; }
.knop-label { display: inline-block; }

/* ------------------------------------------------ startscherm */

#kies[hidden] { display: none; }
#kies { max-width: 1000px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 18px; }

.kop { text-align: center; position: relative; padding-top: 8px; }
.terug { position: absolute; left: 0; top: 0; color: var(--inkt); font-weight: 700; text-decoration: none; opacity: .75; }
h1 { font-size: clamp(2rem, 6vw, 3rem); text-shadow: 3px 3px 0 #fff; margin-top: 18px; }
.sub { font-size: 1.1rem; opacity: .85; margin-top: 4px; }
h2 { font-size: 1.25rem; margin-bottom: 10px; }

.blok {
  background: #fff;
  border: 3px solid var(--inkt);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 6px 0 var(--inkt);
}
.blok p { margin-bottom: 12px; opacity: .85; }

.niveaus { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.niveau { display: grid; gap: 2px; padding: 10px; text-align: left; }
.niveau b { font-size: 1.4rem; }
.niveau small { opacity: .75; line-height: 1.25; }
.niveau[aria-pressed="true"] { background: var(--geel); }

.lessen { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.les { display: grid; justify-items: center; gap: 4px; padding: 14px 10px; font-weight: 800; font-size: 1.1rem; background: var(--zacht); }
.les .icoon { font-size: 48px; line-height: 1; }
.les small { font-weight: 600; opacity: .7; }

.rij2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.invoer { display: flex; gap: 10px; flex-wrap: wrap; }
.invoer input { flex: 1 1 200px; min-width: 0; padding: 10px 12px; font-size: 1.1rem; border: 3px solid var(--inkt); border-radius: 14px; }

.foto-keuze { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.foto-keuze[hidden] { display: none; }
.foto-keuze img { width: 160px; height: 160px; object-fit: contain; border: 3px solid var(--inkt); border-radius: 14px; background: #fff; }
.foto-keuze div { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

.galerij { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.galerij figure { text-align: center; font-size: .85rem; }
.galerij img { width: 100%; aspect-ratio: 1; border: 2px solid var(--inkt); border-radius: 10px; background: #fff; }

/* ------------------------------------------------ tekenscherm */

#teken {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}
#teken[hidden] { display: none; }

.balk { display: flex; align-items: center; gap: 10px; }
.balk strong { flex: 1; text-align: center; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.opdracht {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 3px solid var(--inkt);
  border-radius: 18px;
  padding: 8px 12px;
}
#stap-nr { font-weight: 800; background: var(--geel); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
#stap-tekst { flex: 1; font-size: clamp(1rem, 2.4vw, 1.3rem); font-weight: 700; line-height: 1.3; }
.stapknoppen { display: flex; gap: 8px; }

.werkvlak {
  --z: min(calc((100vw - 48px) / 2), calc(100dvh - 270px));
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
@media (orientation: portrait) {
  .werkvlak { --z: min(calc(100vw - 32px), calc((100dvh - 330px) / 2)); flex-direction: column; gap: 10px; }
  .opdracht { flex-wrap: wrap; }
  #stap-tekst { flex-basis: 100%; order: 3; }
  .stapknoppen { margin-left: auto; }
}

.vlak {
  position: relative;
  width: var(--z);
  height: var(--z);
  flex: none;
  background: #fff;
  border: 3px solid var(--inkt);
  border-radius: 12px;
  overflow: hidden;
}
.vlak-naam {
  position: absolute; right: 6px; bottom: 4px;
  font-size: .75rem; font-weight: 700; opacity: .45; pointer-events: none;
}

#voorbeeld-beeld, #voorbeeld-beeld > * { position: absolute; inset: 0; width: 100%; height: 100%; }
#voorbeeld-beeld img { object-fit: contain; }

.raster { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.raster line { stroke: #74c0fc; stroke-width: .35; }
.raster text { fill: #4dabf7; font-size: 3.3px; font-family: sans-serif; font-weight: 700; }
.raster .licht { fill: rgba(255, 212, 59, .35); stroke: var(--oranje); stroke-width: .7; }
.raster .dim { fill: rgba(255, 255, 255, .65); }

#blad-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

/* Stappen in het voorbeeld: eerder = grijs, nu = oranje en dik, later = weg. */
.tekening * { stroke: #222; stroke-width: 1.5px; stroke-linecap: round; stroke-linejoin: round; }
.tekening .eerder, .tekening .eerder * { stroke: #adb5bd; }
.tekening .nu, .tekening .nu * { stroke: var(--oranje); stroke-width: 2.4px; }
.tekening .later { display: none; }

#teken.is-klaar .gereedschap, #teken.is-klaar .stapknoppen { display: none; }
#teken.is-klaar .werkvlak { --z: min(calc((100vw - 48px) / 2), calc(100dvh - 300px)); }
@media (orientation: portrait) {
  #teken.is-klaar .werkvlak { --z: min(calc(100vw - 32px), calc((100dvh - 360px) / 2)); }
}

.gereedschap { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.kleuren { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.kleur { width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 3px 0 var(--inkt); }
.kleur[aria-pressed="true"] { outline: 4px solid var(--oranje); outline-offset: 2px; }
.pennen { display: flex; gap: 6px; }
.pennen button { width: 44px; height: 40px; display: grid; place-items: center; font-size: 1.2rem; }
.pennen i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--inkt); }
.pennen button[aria-pressed="true"] { background: var(--geel); }

.klaar {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center;
  background: var(--zacht); border: 3px solid var(--inkt); border-radius: 18px; padding: 10px;
}
.klaar[hidden] { display: none; }
.tip-ballon { flex-basis: 100%; text-align: center; font-size: 1.15rem; font-weight: 700; }

/* ------------------------------------------------ wachten en meldingen */

.wacht { position: fixed; inset: 0; background: rgba(43, 33, 80, .45); display: grid; place-items: center; z-index: 10; padding: 16px; }
.wacht[hidden] { display: none; }
.wacht-doos { background: #fff; border: 4px solid var(--inkt); border-radius: 24px; padding: 24px 28px; text-align: center; display: grid; gap: 10px; justify-items: center; max-width: 360px; }
.wacht-doos p { font-size: 1.2rem; font-weight: 800; }
.potlood { font-size: 56px; animation: schets 1.2s ease-in-out infinite; }
@keyframes schets {
  0%, 100% { transform: translate(-14px, 0) rotate(-10deg); }
  50% { transform: translate(14px, 6px) rotate(10deg); }
}

.melding {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); background: var(--inkt); color: #fff;
  padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 20;
}
.melding[hidden] { display: none; }
