:root {
  --bg: #f3eee4;
  --bg2: #fbf8f2;
  --kaart: #ffffff;
  --inkt: #1b2838;
  --zacht: #5d6b7c;
  --lijn: #24334a;
  --pijl: #24334a;
  --rand: #d9d2c4;
  --vak: #fffefb;
  --omschr: #dce8f6;
  --omschr-inkt: #17345a;
  --accent: #0b5cad;
  --accent-diep: #08427d;
  --zon: #ffcd00;
  --woord: #fff0a3;
  --cursor: #ffd23c;
  --omschr-actief: #ffd95a;
  --fout: #d23636;
  --goed: #16824a;
  --onthuld: #0b5cad;
  --schaduw: 0 1px 2px rgba(27, 40, 56, 0.08), 0 8px 24px rgba(27, 40, 56, 0.08);
  --smal: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "sans-serif-condensed", "Helvetica Neue", Arial, sans-serif;
  --gewoon: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cs: 48px;
  color-scheme: light;
}
:root[data-thema="donker"] {
  --bg: #10161d;
  --bg2: #161e27;
  --kaart: #1b242e;
  --inkt: #eef2f6;
  --zacht: #9aa8b8;
  --lijn: #5f7186;
  --pijl: #a9bbcf;
  --rand: #2c3947;
  --vak: #222c37;
  --omschr: #2b405b;
  --omschr-inkt: #d5e4f7;
  --accent: #4a9bea;
  --accent-diep: #0b3a6b;
  --woord: #57501f;
  --cursor: #a88a12;
  --omschr-actief: #8d7410;
  --fout: #ff7a7a;
  --goed: #5fd698;
  --onthuld: #7db9f5;
  --schaduw: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--inkt);
  font-family: var(--gewoon);
  font-size: 16px;
  line-height: 1.4;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }
h1, h2, h3, p { margin: 0; }

/* ══════════ overzicht ══════════ */
#home { max-width: 760px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px 40px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.brand .logo { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 3px 6px rgba(11, 92, 173, 0.25)); }
.brand h1 { font-size: 30px; letter-spacing: 0.14em; font-weight: 800; line-height: 1; }
.brand .tag { color: var(--zacht); font-size: 14px; margin-top: 5px; }
.brand > div { flex: 1; min-width: 0; }

.rond { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--inkt); }
.rond:hover { background: rgba(127, 140, 160, 0.16); }
.rond svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.dagkaart {
  background: linear-gradient(135deg, var(--accent) 0%, #0a4b90 100%);
  color: #fff; border-radius: 18px; padding: 20px; display: flex; gap: 14px; align-items: center; justify-content: space-between;
  box-shadow: var(--schaduw); position: relative; overflow: hidden;
}
.dagkaart::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 150px; height: 150px; opacity: 0.13; pointer-events: none;
  background:
    linear-gradient(#fff, #fff) 0 0 / 100% 2px, linear-gradient(#fff, #fff) 0 50px / 100% 2px, linear-gradient(#fff, #fff) 0 100px / 100% 2px,
    linear-gradient(#fff, #fff) 0 0 / 2px 100%, linear-gradient(#fff, #fff) 50px 0 / 2px 100%, linear-gradient(#fff, #fff) 100px 0 / 2px 100%;
  background-repeat: no-repeat; transform: rotate(12deg);
}
.etiket { display: inline-block; background: var(--zon); color: #2a2200; font-weight: 700; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; }
.dagkaart h2 { font-size: 22px; margin-top: 8px; }
.dagkaart h2::first-letter { text-transform: uppercase; }
.dag-status { opacity: 0.88; font-size: 14px; margin-top: 2px; }
.dag-rechts { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.reeks { display: grid; justify-items: center; line-height: 1.1; }
.reeks .vlam { font-size: 20px; }
.reeks b { font-size: 20px; }
.reeks small { font-size: 11px; opacity: 0.8; }
.reeks.koud .vlam { filter: grayscale(1); opacity: 0.6; }

.knop { border-radius: 12px; padding: 11px 18px; font-weight: 700; background: var(--kaart); color: var(--inkt); border: 1px solid var(--rand); white-space: nowrap; }
.knop:hover { filter: brightness(0.97); }
.knop:active { transform: translateY(1px); }
.knop.primair { background: var(--zon); color: #2a2200; border-color: transparent; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); }
.knop.blauw { background: var(--accent); color: #fff; border-color: transparent; }
.knop.klein { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.knop.gevaar { color: var(--fout); }
.link { color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: none; padding: 6px 2px; }
.link:hover { text-decoration: underline; }
.dag-extra { display: flex; gap: 18px; margin: 8px 4px 0; flex-wrap: wrap; }

.cijfers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0 24px; }
.cijfer { background: var(--kaart); border: 1px solid var(--rand); border-radius: 14px; padding: 12px 8px; text-align: center; }
.cijfer b { display: block; font-size: 22px; line-height: 1.1; }
.cijfer span { color: var(--zacht); font-size: 12px; }

.boek-kop { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.boek-kop h2 { font-size: 22px; }
.tabs { display: flex; background: var(--kaart); border: 1px solid var(--rand); border-radius: 12px; padding: 3px; }
.tabs button { padding: 6px 14px; border-radius: 9px; font-weight: 700; font-size: 14px; display: grid; line-height: 1.15; color: var(--zacht); }
.tabs button small { font-weight: 500; font-size: 11px; opacity: 0.8; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.boek-balk { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; color: var(--zacht); font-size: 14px; gap: 10px; }
.tegels { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.tegel {
  aspect-ratio: 1; border-radius: 12px; background: var(--kaart); border: 1px solid var(--rand); font-weight: 700; font-size: 17px;
  display: grid; place-items: center; position: relative; color: var(--inkt);
}
.tegel:hover { border-color: var(--accent); }
.tegel .st { position: absolute; left: 6px; top: 6px; }
.st { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #58b368; vertical-align: middle; }
.st.st2 { background: #f0a92b; }
.st.st3 { background: #e0593f; }
.tegel.klaar { background: color-mix(in srgb, var(--goed) 14%, var(--kaart)); border-color: color-mix(in srgb, var(--goed) 40%, var(--rand)); }
.tegel.klaar::after { content: "✓"; position: absolute; right: 5px; bottom: 2px; font-size: 12px; color: var(--goed); }
.tegel .ster { position: absolute; left: 0; right: 0; bottom: 3px; font-size: 8px; letter-spacing: 1px; color: #e3a400; text-align: center; }
.tegel.bezig { border-color: var(--zon); box-shadow: inset 0 0 0 2px var(--zon); }
.tegel .balk { position: absolute; left: 8px; right: 8px; bottom: 6px; height: 3px; border-radius: 3px; background: var(--rand); overflow: hidden; }
.tegel .balk i { display: block; height: 100%; background: var(--zon); }
.legenda { color: var(--zacht); font-size: 12px; margin-top: 12px; }
.legenda .vink { color: var(--goed); font-weight: 700; }
.bezig-stip { display: inline-block; width: 9px; height: 9px; border-radius: 3px; box-shadow: inset 0 0 0 2px var(--zon); vertical-align: middle; }
.voet { margin-top: 30px; display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }

/* ══════════ spel ══════════ */
#spel { height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; padding-top: env(safe-area-inset-top); }
.topbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; flex: none; }
.topbar .titel { flex: 1; min-width: 0; display: grid; line-height: 1.15; padding-left: 4px; }
.topbar .titel b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .titel span { font-size: 12px; color: var(--zacht); }
.klok { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; padding: 6px 10px; border-radius: 99px; background: var(--kaart); border: 1px solid var(--rand); min-width: 62px; }

.cluebar { flex: none; display: flex; align-items: stretch; gap: 6px; padding: 0 8px 8px; max-width: 900px; width: 100%; margin: 0 auto; }
.cluebar .pijl { width: 40px; border-radius: 12px; background: var(--kaart); border: 1px solid var(--rand); font-size: 26px; line-height: 1; color: var(--accent); flex: none; }
.clue-mid { flex: 1; min-width: 0; background: var(--omschr-actief); color: #2a2200; border-radius: 12px; padding: 7px 12px; min-height: 54px; display: grid; align-content: center; }
:root[data-thema="donker"] .clue-mid { color: #fff; }
.clue-hoofd { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 18px; line-height: 1.2; }
.clue-hoofd .richting { font-size: 15px; opacity: 0.7; flex: none; }
.clue-hoofd .len { margin-left: auto; font-size: 12px; font-weight: 600; opacity: 0.7; white-space: nowrap; flex: none; }
.clue-kruis { text-align: left; font-size: 12.5px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.clue-kruis:empty { display: none; }

.gridwrap { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 2px 6px 6px; -webkit-overflow-scrolling: touch; }
.gridwrap.zoom { place-items: start; }
.grid {
  display: grid; grid-template-columns: repeat(var(--w), var(--cs)); grid-auto-rows: var(--cs);
  border: 2px solid var(--lijn); background: var(--lijn); gap: 1px; border-radius: 4px; overflow: hidden; flex: none;
  box-shadow: var(--schaduw); user-select: none; -webkit-user-select: none;
}
.cel { position: relative; background: var(--vak); overflow: hidden; }
.cel.l { cursor: pointer; display: grid; place-items: center; }
.cel.l .ch { font-size: calc(var(--cs) * 0.6); font-weight: 600; line-height: 1; text-transform: uppercase; letter-spacing: -0.02em; }
.cel.l .ch.ij { font-size: calc(var(--cs) * 0.5); letter-spacing: -0.06em; }
.cel.l.inwoord { background: var(--woord); }
.cel.l.cursor { background: var(--cursor); box-shadow: inset 0 0 0 2px var(--accent); }
.cel.l.fout .ch { color: var(--fout); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.cel.l.onthuld .ch { color: var(--onthuld); }
.cel.l.goed .ch { color: var(--goed); }
.cel.l .nr {
  position: absolute; right: 1.5px; bottom: 1px; font-size: max(7px, calc(var(--cs) * 0.2)); line-height: 1; font-weight: 700; color: #2a2200;
  background: var(--zon); opacity: 0.92; border-radius: 50%; min-width: 1.35em; height: 1.35em; display: grid; place-items: center;
}
.cel.l svg.pl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cel.l svg.pl path { fill: none; stroke: var(--pijl); stroke-width: 3.5; }
.cel.l svg.pl polygon { fill: var(--pijl); }
.cel.l.plop .ch { animation: plop 0.16s ease-out; }
@keyframes plop { from { transform: scale(1.35); } to { transform: scale(1); } }
.cel.l.golf { animation: golf 0.5s ease-out; }
@keyframes golf { 30% { background: var(--zon); transform: scale(0.92); } }

.cel.o { background: var(--omschr); color: var(--omschr-inkt); display: flex; flex-direction: column; }
.cel.o .cl {
  flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--smal); line-height: 1.02; padding: 1px 1.5px; cursor: pointer; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; word-break: normal;
}
.cel.o .cl span { display: block; max-width: 100%; }
.cel.o .cl + .cl { border-top: 1px solid var(--lijn); }
.cel.o .cl.actief { background: var(--omschr-actief); color: #2a2200; }
:root[data-thema="donker"] .cel.o .cl.actief { color: #fff; }
.cel.o .cl.af { opacity: 0.5; }

.solstrip { flex: none; display: flex; align-items: center; justify-content: center; gap: 3px; padding: 4px 8px 8px; flex-wrap: wrap; }
.solstrip .lab { font-size: 12px; color: var(--zacht); margin-right: 6px; font-weight: 600; }
.solvak { width: 28px; height: 32px; border-radius: 6px; background: var(--kaart); border: 1.5px solid var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 17px; position: relative; text-transform: uppercase; }
.solvak small { position: absolute; left: 2px; top: 0; font-size: 8px; color: var(--accent); font-weight: 700; }
.solvak.ij { font-size: 13px; letter-spacing: -0.05em; }

.kb { flex: none; padding: 4px 3px max(6px, env(safe-area-inset-bottom)); background: var(--bg2); border-top: 1px solid var(--rand); display: none; user-select: none; -webkit-user-select: none; }
body.touch .kb { display: block; }
.kb .rij { display: flex; justify-content: center; gap: 4px; margin-top: 5px; }
.kb button {
  flex: 1 1 0; max-width: 46px; height: 46px; border-radius: 8px; background: var(--kaart); border: 1px solid var(--rand); font-weight: 600; font-size: 19px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.14); display: grid; place-items: center; touch-action: manipulation;
}
.kb button:active, .kb button.druk { background: var(--zon); color: #2a2200; transform: translateY(1px); }
.kb button.breed { flex: 1.5 1 0; max-width: 70px; font-size: 16px; }
.kb button.ijk { background: var(--omschr); color: var(--omschr-inkt); }
.kb button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.pauze { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: grid; place-items: center; z-index: 5; }
.pauze-kaart { text-align: center; display: grid; gap: 10px; justify-items: center; }

/* ══════════ vensters ══════════ */
.sluier { position: fixed; inset: 0; background: rgba(10, 18, 28, 0.55); display: grid; place-items: center; padding: 16px; z-index: 20; animation: in 0.15s ease-out; }
@keyframes in { from { opacity: 0; } }
.venster { background: var(--kaart); border-radius: 20px; padding: 22px; width: min(460px, 100%); max-height: min(88dvh, 720px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); animation: op 0.2s ease-out; }
@keyframes op { from { transform: translateY(14px) scale(0.98); opacity: 0; } }
.venster h2 { font-size: 22px; margin-bottom: 4px; }
.venster .sub { color: var(--zacht); font-size: 14px; margin-bottom: 14px; }
.venster .rijen { display: grid; gap: 8px; }
.venster .actie { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--rand); background: var(--bg2); }
.venster .actie:hover { border-color: var(--accent); }
.venster .actie b { display: block; }
.venster .actie small { color: var(--zacht); display: block; }
.venster .actie .straf { margin-left: auto; font-size: 12px; color: var(--zacht); white-space: nowrap; }
.venster .actie .ic { font-size: 20px; width: 26px; text-align: center; flex: none; }
.venster .kopje { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--zacht); font-weight: 700; margin: 14px 0 6px; }
.venster .onder { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.venster .onder .knop { flex: 1; text-align: center; }
.schuif { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--rand); }
.schuif small { color: var(--zacht); display: block; }
.schuif input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--rand); position: relative; flex: none; transition: background 0.15s; cursor: pointer; margin: 0; }
.schuif input[type="checkbox"]::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.schuif input[type="checkbox"]:checked { background: var(--accent); }
.schuif input[type="checkbox"]:checked::after { transform: translateX(18px); }
.schuif select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--rand); background: var(--bg2); color: var(--inkt); }

.uitslag { text-align: center; }
.uitslag .sterren { font-size: 38px; letter-spacing: 6px; color: #e3a400; margin: 4px 0; }
.uitslag .sterren i { font-style: normal; color: var(--rand); }
.uitslag .tijd { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.uitslag .solwoord { display: inline-flex; gap: 3px; margin: 12px 0 4px; flex-wrap: wrap; justify-content: center; }
.uitslag .solwoord span { width: 30px; height: 36px; display: grid; place-items: center; border-radius: 7px; background: var(--zon); color: #2a2200; font-weight: 800; font-size: 19px; animation: op 0.3s ease-out backwards; }
.naamrij { display: flex; gap: 8px; margin-top: 10px; }
.naamrij input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--rand); background: var(--bg2); color: var(--inkt); }
.rang { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 8px; }
.rang td { padding: 6px 4px; border-bottom: 1px solid var(--rand); text-align: left; }
.rang td:first-child { width: 34px; color: var(--zacht); font-weight: 700; }
.rang td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.rang tr.ik td { background: color-mix(in srgb, var(--zon) 30%, transparent); }
.archief { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.archief .tegel { aspect-ratio: auto; padding: 8px 4px; font-size: 13px; line-height: 1.2; display: grid; }
.archief .tegel b { font-size: 18px; }
.uitleg p { margin: 8px 0; }
.uitleg .vb { display: inline-grid; grid-template-columns: repeat(4, 42px); grid-auto-rows: 42px; gap: 1px; background: var(--lijn); border: 2px solid var(--lijn); border-radius: 4px; margin: 6px 0; --cs: 42px; }

.toost { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--inkt); color: var(--bg); padding: 11px 18px; border-radius: 99px; font-weight: 600; font-size: 15px; z-index: 30; box-shadow: var(--schaduw); max-width: calc(100vw - 32px); text-align: center; animation: op 0.2s ease-out; }
body.touch .toost { bottom: 250px; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 25; }

@media (max-width: 520px) {
  .cijfers { grid-template-columns: repeat(2, 1fr); }
  .dagkaart { padding: 16px; }
  .dagkaart h2 { font-size: 19px; }
  .clue-hoofd { font-size: 16px; }
  .topbar .rond { width: 36px; height: 36px; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .clue-hoofd { font-size: 20px; }
}

@media print {
  #home, .topbar, .cluebar, .kb, .solstrip .lab, .sluier, .toost, .pauze { display: none !important; }
  body { background: #fff; }
  #spel { display: block !important; height: auto; overflow: visible; }
  .gridwrap { overflow: visible; display: block; }
  .grid { --cs: 15mm !important; box-shadow: none; margin: 0 auto; }
  .cel.l .ch { visibility: hidden; }
  .cel.l, .cel.l.inwoord, .cel.l.cursor { background: #fff !important; box-shadow: none !important; }
  .cel.o { background: #e6e6e6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cel.o .cl.actief { background: transparent !important; }
  .solstrip { margin-top: 8mm; }
  .solvak { color: transparent; }
}
