:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #17212b;
  --muted: #5f6b77;
  --border: #d9e0e6;
  --accent: #0f766e;
  --accent-soft: #d5efec;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcf3e3;
  --bad: #b91c1c;
  --bad-soft: #fbe2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --ocean: #cfe3ef;
  --land: #f3efe4;
  --land-other: #e2ddd0;
  --border-map: #9aa6ae;
  --target: #e8590c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --surface: #182027;
    --surface-2: #212b33;
    --text: #e6edf2;
    --muted: #94a3af;
    --border: #2d3943;
    --accent: #2dd4bf;
    --accent-soft: #123b37;
    --accent-text: #062522;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --ocean: #10202c;
    --land: #3a4650;
    --land-other: #2c363e;
    --border-map: #6b7882;
    --target: #ff8a3d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }

.topbar {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
}
.brand {
  background: none; border: 0; cursor: pointer;
  font-size: 1.15rem; font-weight: 700; padding: 0;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 8px 0 4px; }
h2 { font-size: 1.35rem; margin: 4px 0 16px; }
h3 { font-size: .95rem; margin: 24px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { color: var(--accent); font-weight: 600; margin: 0; font-size: .9rem; }

.hero { padding: 24px 0 16px; }

/* ---------- Onderdelen ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.module-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.module-card:not([disabled]):hover { transform: translateY(-2px); border-color: var(--accent); }
.module-card[disabled] { cursor: default; opacity: .55; }
.module-icon { font-size: 2rem; }
.module-title { font-weight: 700; font-size: 1.15rem; }
.module-desc { color: var(--muted); font-size: .95rem; }
.badge {
  position: absolute; top: 14px; right: 14px;
  font-size: .75rem; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
}

/* ---------- Paneel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 32px);
  margin-top: 8px;
}

.field h3 { margin-top: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.chip-label { color: var(--muted); font-size: .9rem; min-width: 92px; }
.chip {
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: .95rem;
}
.chip:hover:not([disabled]) { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip[disabled] { opacity: .4; cursor: not-allowed; }
.hint { color: var(--muted); font-size: .875rem; margin: 4px 0 0; }
.click-actions { align-items: center; margin-top: 16px; }
.click-actions { flex-wrap: wrap; }
.click-actions .hint { margin: 0; }
.click-buttons { display: flex; gap: 10px; margin-left: auto; }

[hidden] { display: none !important; }
.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }
.actions.end { justify-content: flex-end; margin-top: 16px; }
.actions.wrap { flex-wrap: wrap; justify-content: flex-end; }

.btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
}
.btn:hover:not([disabled]) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not([disabled]) { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: .875rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn:focus-visible, .chip:focus-visible, .choice:focus-visible, .module-card:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ---------- Quiz ---------- */
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.score-pill { background: var(--surface-2); padding: 3px 12px; border-radius: 99px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; margin: 12px 0 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width .3s; }

.question { text-align: center; padding: 28px 0 24px; }
.prompt { margin: 0; color: var(--muted); font-size: 1.05rem; }
.subject { margin: 4px 0; font-size: clamp(1.7rem, 6vw, 2.6rem); font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.q-mark { color: var(--accent); }
.category { margin: 0; color: var(--muted); font-size: .85rem; }

.choices { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.choices.cols-6 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) {
  .choices, .choices.cols-6 { grid-template-columns: 1fr; }
}
.choice {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  transition: border-color .12s, background .12s;
}
.choice:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.choice[disabled] { cursor: default; }
.choice kbd {
  flex: none;
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--surface-2); color: var(--muted);
  font: 600 .8rem system-ui, sans-serif;
}
.choice.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-bad { border-color: var(--bad); background: var(--bad-soft); }
.choice[disabled]:not(.is-ok):not(.is-bad) { opacity: .55; }

.typed { display: flex; gap: 10px; flex-wrap: wrap; }
.typed input {
  flex: 1 1 240px;
  min-width: 0;
  padding: 12px 16px;
  font-size: 1.15rem;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.typed input:focus { outline: none; border-color: var(--accent); }
.typed input.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.typed input.is-bad { border-color: var(--bad); background: var(--bad-soft); }

.feedback { margin-top: 18px; padding: 12px 16px; border-radius: 10px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback.ok strong { color: var(--ok); }
.feedback.bad strong { color: var(--bad); }
.feedback .note { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ---------- Resultaten ---------- */
.score-hero { display: flex; align-items: center; gap: 24px; margin: 12px 0 8px; flex-wrap: wrap; }
.score-hero h2 { margin: 0 0 4px; }
.score-hero p { margin: 4px 0; }
.record { color: var(--accent); font-weight: 600; }
.ring {
  --size: 128px;
  flex: none;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.ring > span {
  width: calc(var(--size) - 22px); height: calc(var(--size) - 22px);
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 2rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ring small { font-size: 1rem; font-weight: 600; margin-left: 1px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 20px;
}
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-value.ok { color: var(--ok); }
.stat-value.bad { color: var(--bad); }
.stat-label { color: var(--muted); font-size: .85rem; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; font-size: .92rem; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar-val { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
@media (max-width: 480px) {
  .bar-row { grid-template-columns: 90px 1fr; }
  .bar-val { grid-column: 2; text-align: left; }
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }
td.ok { color: var(--ok); font-weight: 600; }
td.bad { color: var(--bad); }

/* ---------- Kaart ---------- */
.question:has(.visual) { padding: 12px 0 18px; }
.question:has(.visual) .prompt { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.map-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.geo-map {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--ocean);
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.geo-map.dragging { cursor: grabbing; }
.geo-map .land {
  fill: var(--land);
  stroke: var(--border-map);
  stroke-width: .6;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.geo-map .land.other { fill: var(--land-other); }
.geo-map.pickable .land:not(.other) { cursor: pointer; }
@media (hover: hover) {
  .geo-map.pickable .land:not(.other):hover { fill: var(--target); fill-opacity: .45; }
}
.geo-map .inset {
  fill: var(--ocean);
  stroke: var(--border-map);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.geo-map .land.target { fill: var(--target); stroke: var(--text); stroke-width: 1.2; }
.geo-map .land.selected,
.geo-map.pickable .land.selected:hover { fill: var(--accent); fill-opacity: .75; stroke: var(--text); stroke-width: 1.6; }
.geo-map .land.wrong { fill: var(--bad); fill-opacity: .55; }
.geo-map .marker {
  fill: none;
  stroke: var(--target);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 6 4;
}
.map-controls {
  position: absolute; right: 10px; top: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.map-controls button {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.map-controls button:hover { border-color: var(--accent); }
@media (max-width: 560px) {
  .geo-map { aspect-ratio: 4 / 3; }
}
