/* Atlas-op-tafel: papierkleurige ondergrond, zachte zee, pastel landen zoals een schoolatlas.
   Bewust één (licht) thema: het moet op de kaart van school lijken. */
:root {
  color-scheme: light;
  --paper: #f3efe4;
  --card: #fffdf7;
  --ink: #1f2b33;
  --ink-soft: #5d6a70;
  --line: #d9d2c0;
  --sea: #bcd9e6;
  --sea-deep: #2f6f8f;
  --land-other: #e7e1d1;
  --border: #ffffff;
  --accent: #ef7d22;
  --accent-soft: #ffe3c7;
  --good: #2e9a57;
  --good-soft: #d6f1df;
  --bad: #d4483f;
  --bad-soft: #fbdcd8;
  --star: #f5b400;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { height: 100%; }
.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
}

/* ---------- Start ---------- */
#home { overflow-y: auto; }
.home-head { padding-block: 48px 24px; max-width: 760px; width: 100%; margin: 0 auto; }
h1 { font-size: clamp(40px, 7vw, 64px); margin: 0; letter-spacing: -0.02em; line-height: 1; }
h1 span { color: var(--sea-deep); }
.sub { margin: 10px 0 0; color: var(--ink-soft); font-size: 20px; }
.set-list { display: grid; gap: 16px; max-width: 760px; width: 100%; margin: 0 auto; padding-bottom: 40px; }
.set-card {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 16px 20px 16px 16px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r);
  text-align: left;
}
.set-card:active { transform: scale(0.99); }
.set-card.current { border-color: var(--sea-deep); box-shadow: 0 6px 0 -2px var(--sea); }
.set-thumb { width: 120px; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--sea); }
.set-thumb svg { width: 100%; height: 100%; display: block; }
.set-info { min-width: 0; }
.set-info b { display: block; font-size: 22px; }
.set-info small { display: block; color: var(--ink-soft); font-size: 16px; margin-top: 4px; }
.tag { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: #9a4a08; font-size: 14px; font-weight: 700; }
.set-go { font-size: 36px; color: var(--sea-deep); }

/* ---------- Balk ---------- */
.bar { display: flex; align-items: center; gap: 14px; padding-block: 12px; }
.bar-title { font-size: 24px; font-weight: 800; min-width: 0; }
.icon-btn {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card);
  font-size: 32px; line-height: 1; padding-bottom: 4px;
}
.icon-btn.small { width: 44px; height: 44px; font-size: 18px; padding: 0; }
.progress { flex: 1; height: 16px; border-radius: 99px; background: var(--line); overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--good); border-radius: 99px; transition: width .4s ease; }
.score { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

/* ---------- Menu ---------- */
.menu-body { flex: 1; overflow-y: auto; max-width: 760px; width: 100%; margin: 0 auto; padding-block: 8px 32px; display: flex; flex-direction: column; gap: 24px; }
.filter { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 18px; border-radius: 99px; border: 2px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 17px;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--card); }
.chip small { opacity: .6; font-weight: 600; margin-left: 4px; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.mode {
  position: relative; text-align: left; padding: 22px 22px 24px; min-height: 130px;
  border-radius: var(--r); border: 2px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; gap: 6px; justify-content: flex-end;
}
.mode b { font-size: 26px; }
.mode span { color: var(--ink-soft); font-size: 17px; }
.mode[data-mode="leer"] { background: var(--sea); border-color: var(--sea); }
.mode[data-mode="typ"] { background: var(--ink); border-color: var(--ink); color: var(--card); }
.mode[data-mode="typ"] span { color: #c9d2d6; }
.mode:active { transform: scale(0.985); }
.stars { position: absolute; top: 16px; right: 18px; font-style: normal; font-size: 22px; letter-spacing: 2px; color: var(--star); }

/* ---------- Spel ---------- */
#game { padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
.play { flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr auto; gap: 12px; }
@media (orientation: landscape) and (min-width: 900px) {
  .play { grid-template-rows: none; grid-template-columns: 1fr 340px; }
}
.map-wrap {
  min-height: 0; min-width: 0; border-radius: var(--r); overflow: hidden;
  background: var(--sea); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.map-wrap { position: relative; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 8px; }
.zoom button { width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-size: 28px; font-weight: 800; line-height: 1; box-shadow: 0 2px 0 var(--line); }
.zoom button:active { transform: translateY(1px); }
.map-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.panel {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; justify-content: center;
}
.prompt { font-size: 26px; font-weight: 700; line-height: 1.2; text-wrap: balance; }
.prompt strong { color: var(--sea-deep); font-weight: 900; }
.prompt .kind { display: inline-block; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 3px 10px; border-radius: 99px; background: var(--paper); color: var(--ink-soft); vertical-align: middle; margin-left: 4px; }
.answers { display: grid; gap: 10px; }
@media (orientation: portrait), (max-width: 899px) { .answers.opts { grid-template-columns: 1fr 1fr; } }
.opt {
  padding: 16px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper);
  font-size: 21px; font-weight: 700; min-height: 64px;
}
.opt.good { background: var(--good-soft); border-color: var(--good); color: #145c31; }
.opt.bad { background: var(--bad-soft); border-color: var(--bad); color: #8a221b; }
.type-row { display: flex; gap: 10px; }
.type-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 24px; font-weight: 700; padding: 14px 16px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--paper); color: var(--ink);
  -webkit-user-select: text; user-select: text;
}
.type-row input.good { border-color: var(--good); background: var(--good-soft); }
.type-row input.bad { border-color: var(--bad); background: var(--bad-soft); }
.btn, .next-btn {
  padding: 16px 22px; border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-weight: 800; font-size: 20px;
}
.btn.primary, .next-btn, .type-row .btn { background: var(--sea-deep); border-color: var(--sea-deep); color: #fff; }
.btn.ghost { background: transparent; }
.feedback { font-size: 21px; font-weight: 700; min-height: 1.3em; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback small { display: block; font-size: 17px; color: var(--ink-soft); font-weight: 600; margin-top: 4px; }

/* ---------- Kaart ---------- */
.sea { fill: var(--sea); }
.land { fill: var(--land-other); stroke: var(--border); stroke-width: 1.2; stroke-linejoin: round; }
.land.q { stroke-width: 1.6; }
.land.q0 { fill: #c9dba8; } .land.q1 { fill: #f0d49a; } .land.q2 { fill: #e9b9a6; }
.land.q3 { fill: #c3c9e6; } .land.q4 { fill: #e2c2dc; } .land.q5 { fill: #b9dbcf; } .land.q6 { fill: #efc98f; }
.land.hl { fill: var(--accent) !important; }
.land.ok { fill: var(--good) !important; }
.land.wrong { fill: var(--bad) !important; }
.lakes { fill: var(--sea); stroke: #9cc3d5; stroke-width: .6; }
.rivers { fill: none; stroke: #8fbcd3; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.qriver { fill: none; stroke: #5f9fc1; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.qriver.hl { stroke: var(--accent); stroke-width: 6; }
.qriver.ok { stroke: var(--good); stroke-width: 6; }
.area { fill: url(#hatch); stroke: none; }
.area.hl { fill: url(#hatch-hl); }
.leader { stroke: var(--ink); stroke-width: 1.4; }
.mk .shape { fill: var(--ink); stroke: #fff; stroke-width: 2.5; }
.mk[data-type="water"] .shape, .mk[data-type="rivier"] .shape { fill: var(--sea-deep); }
.mk .code { font-family: var(--font); font-size: 13px; font-weight: 900; fill: #fff; pointer-events: none; }
.mk[data-type="werelddeel"] .shape { fill: #6b4f8a; }
.code-chip { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; padding-inline: .3em; border-radius: 99px; background: var(--ink); color: #fff; font-size: .85em; font-weight: 900; vertical-align: middle; }
.mk .ring { fill: none; stroke: var(--accent); stroke-width: 5; opacity: 0; }
.mk.hl .ring { opacity: 1; animation: pulse 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.mk.hl .shape { fill: var(--accent); }
.mk.ok .shape { fill: var(--good); }
.mk.wrong .shape { fill: var(--bad); }
.mk.seen .shape { fill: var(--sea-deep); }
.lbl {
  font-family: var(--font); font-size: 17px; font-weight: 800; fill: var(--ink);
  paint-order: stroke; stroke: #fff; stroke-width: 5px; stroke-linejoin: round;
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.lbl.show { opacity: 1; }
.lbl.good { fill: #145c31; } .lbl.bad { fill: #8a221b; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shake { animation: shake .3s; }

/* ---------- Leren ---------- */
.learn-toggle { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Resultaat ---------- */
.result {
  position: fixed; inset: 0; background: rgba(31, 43, 51, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10;
}
.result-card {
  background: var(--card); border-radius: 26px; padding: 32px 28px; width: min(520px, 100%);
  text-align: center; display: flex; flex-direction: column; gap: 10px; max-height: 100%; overflow-y: auto;
}
.result-stars { font-size: 64px; letter-spacing: 6px; color: var(--star); line-height: 1; }
.result-stars .off { color: var(--line); }
.result-card h2 { margin: 6px 0 0; font-size: 32px; }
.result-card p { margin: 0; color: var(--ink-soft); font-size: 20px; }
.mistakes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-block: 8px; }
.mistakes span { padding: 6px 12px; border-radius: 99px; background: var(--bad-soft); color: #8a221b; font-weight: 700; font-size: 16px; }
.result-actions { display: grid; gap: 10px; margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  .mk.hl .ring { animation: none; }
  .shake { animation: none; }
  #progress-fill { transition: none; }
}
@media (max-width: 520px) {
  .set-card { grid-template-columns: 84px 1fr auto; gap: 14px; }
  .set-thumb { width: 84px; }
  .prompt { font-size: 22px; }
}
