:root {
  --bg: #1f1813; --bg2: #2a211a; --card: #f3e9d4; --card2: #e9dbbd; --ink: #2b2118; --muted: #8a7a66;
  --gold: #d7a24c; --gold2: #b8862f; --red: #a8342c; --green: #3f7d4e; --line: rgba(43,33,24,.18);
  --text: #f3e9d4; --text2: #c9b896; --radius: 14px;
  --serif: "EB Garamond", Georgia, serif; --sans: Inter, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.2rem; }
p { margin: .4em 0; }
.wrap > * { scroll-margin-top: 150px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }
.muted { color: var(--text2); }
.small { font-size: .86rem; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hide { display: none !important; }

/* kaarten */
.card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.card .muted, .card.muted { color: #6f604d; }
.card h2, .card h3 { color: var(--ink); }
.card.dark { background: var(--bg2); color: var(--text); border: 1px solid rgba(215,162,76,.25); }
.card.dark h2, .card.dark h3 { color: var(--text); }
.card.gold { border: 2px solid var(--gold); }
.card.struck { opacity: .55; }
.card.struck .claim { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.story { font-family: var(--serif); font-size: 1.12rem; white-space: pre-line; }
.quote { font-family: var(--serif); font-style: italic; font-size: 1.1rem; }
.photo { width: 100%; border-radius: 10px; display: block; margin: 8px 0; max-height: 240px; object-fit: cover; }
.chip { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--ink); margin: 2px 4px 2px 0; border: 1px solid var(--line); }
.chip b { text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; color: #6f604d; }
.tag { display: inline-block; font: 700 .72rem var(--sans); letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: var(--gold); color: var(--ink); }
.tag.red { background: var(--red); color: #fff; } .tag.green { background: var(--green); color: #fff; } .tag.grey { background: #8a7a66; color: #fff; }

/* knoppen */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 18px; background: var(--gold); color: var(--ink); font-weight: 700; min-height: 46px; }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; color: inherit; border: 1.5px solid currentColor; }
.btn.dark { background: var(--bg2); color: var(--text); border: 1px solid rgba(215,162,76,.4); }
.btn.red { background: var(--red); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fffaf0; color: var(--ink); font-size: 1.05rem; margin: 6px 0 10px; }
.field.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; font-size: 1.4rem; }
label { font-weight: 600; font-size: .9rem; }

/* kop en navigatie */
.top { position: sticky; top: 0; z-index: 20; background: rgba(31,24,19,.96); border-bottom: 1px solid rgba(215,162,76,.2); padding: max(8px, env(safe-area-inset-top)) 16px 8px; }
.top .row { max-width: 640px; margin: 0 auto; flex-wrap: nowrap; }
.clock { font: 700 1.25rem var(--sans); font-variant-numeric: tabular-nums; color: var(--gold); }
.clock.warn { color: #ff9c6b; } .clock.paused { color: var(--text2); }
.banner { max-width: 640px; margin: 6px auto 0; padding: 8px 12px; border-radius: 10px; background: var(--red); color: #fff; font-size: .9rem; font-weight: 600; }
.banner.gold { background: var(--gold); color: var(--ink); }
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 30; display: flex; gap: 4px; padding: 6px; border-radius: 999px; background: rgba(42,33,26,.97); border: 1px solid rgba(215,162,76,.35); box-shadow: 0 8px 24px rgba(0,0,0,.45); max-width: calc(100vw - 24px); }
.nav button { border: 0; background: transparent; color: var(--text2); border-radius: 999px; padding: 8px 12px; font-size: .78rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; min-width: 64px; position: relative; }
.nav button span { font-size: 1.25rem; line-height: 1.1; }
.nav button.on { background: var(--gold); color: var(--ink); }
.nav .dot { position: absolute; top: 4px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
.subtabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.subtabs button { flex: none; border: 1px solid rgba(215,162,76,.4); background: transparent; color: var(--text2); padding: 7px 12px; border-radius: 999px; font-size: .88rem; font-weight: 600; }
.subtabs button.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }

/* kaart */
#lmap { height: 46vh; min-height: 280px; border-radius: var(--radius); margin: 8px 0; background: #d9cfb8; }
.loclist .loc { display: flex; gap: 10px; align-items: center; }
.seal { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font: 700 1rem var(--serif); background: var(--card2); color: var(--ink); border: 2px solid var(--gold2); flex: none; }
.seal.done { background: var(--green); color: #fff; border-color: var(--green); }
.seal.hub { background: var(--gold); }
.leaflet-container { font: inherit; }
.mk { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 14px var(--serif); background: #f3e9d4; border: 2px solid #b8862f; color: #2b2118; }
.mk.done { background: #3f7d4e; color: #fff; border-color: #fff; }
.mk.me { width: 16px; height: 16px; background: #2f6fd6; border: 3px solid #fff; }

/* puzzels */
.puzzle h3 { margin-top: 4px; }
.mats { display: grid; gap: 10px; margin: 10px 0; }
.mat { background: #fffaf0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); }
.mat .glyph { font-size: 1.6rem; margin-right: 6px; vertical-align: middle; }
.counter { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.counter button { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--gold2); background: var(--card); font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.counter b { font-size: 1.4rem; min-width: 2ch; text-align: center; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.tbl td, table.tbl th { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6f604d; }
.lock { background: linear-gradient(#4a3826, #2e2218); border-radius: 16px; padding: 14px; margin: 14px 0; color: var(--text); border: 2px solid var(--gold2); }
.lock .title { font: 700 1.05rem var(--serif); text-align: center; margin-bottom: 10px; color: var(--gold); }
.wheels { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.wheel { display: flex; flex-direction: column; align-items: center; background: #1b140f; border-radius: 12px; padding: 4px; min-width: 76px; border: 1px solid rgba(215,162,76,.35); }
.wheel small { font-size: .72rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin: 2px 0; text-align: center; max-width: 92px; }
.wheel button { background: transparent; border: 0; color: var(--gold); font-size: 1.2rem; width: 100%; padding: 6px 0; }
.wheel .val { font: 700 1.5rem var(--serif); min-height: 2.1rem; display: flex; align-items: center; justify-content: center; padding: 0 6px; background: var(--card); color: var(--ink); border-radius: 6px; min-width: 60px; text-align: center; line-height: 1.1; }
.wheel .val.txt { font-size: 1rem; }
.feedback { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(168,52,44,.25); border: 1px solid var(--red); font-size: .95rem; }
.solved { border: 2px solid var(--green); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles button { padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 1; position: relative; }
.tiles button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tiles button.tapped { border-color: var(--gold); }
.tiles button .n { position: absolute; top: 4px; left: 4px; background: var(--gold); color: var(--ink); font-weight: 700; border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; font-size: .85rem; }
.taps { display: flex; gap: 6px; margin: 8px 0; }
.taps img, .taps .empty { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; border: 2px solid var(--gold2); background: rgba(0,0,0,.15); }
.timeline { display: grid; gap: 6px; margin: 8px 0; }
.slot { display: flex; gap: 8px; align-items: stretch; }
.slot .no { flex: none; width: 30px; display: grid; place-items: center; font-weight: 700; background: var(--gold); color: var(--ink); border-radius: 8px; }
.slot .body { flex: 1; min-height: 44px; border: 1.5px dashed var(--gold2); border-radius: 8px; padding: 6px 8px; background: #fffaf0; color: var(--ink); font-size: .92rem; }
.slot .body.filled { border-style: solid; }
.slot .body.target { background: #fff1c9; border-color: var(--gold); }
.cards { display: grid; gap: 6px; }
.tcard { text-align: left; border: 1.5px solid var(--gold2); background: var(--card); color: var(--ink); border-radius: 10px; padding: 8px 10px; font-size: .95rem; }
.tcard.sel { background: #ffe39a; border-color: var(--ink); }
.tcard .lab { display: block; font-size: .78rem; font-weight: 700; color: #6f604d; }
.tcard.placed { opacity: .5; }
.jig { display: grid; gap: 2px; background: #2b2118; border-radius: 8px; overflow: hidden; position: relative; }
.jig button { padding: 0; border: 0; aspect-ratio: 390 / 506; background-repeat: no-repeat; outline: 3px solid transparent; outline-offset: -3px; }
.jig button.sel { outline-color: var(--gold); }
.mapdone { position: relative; }
.mapdone img { width: 100%; display: block; border-radius: 8px; }
.mapdone svg { position: absolute; inset: 0; width: 100%; height: 100%; }
canvas.ink { width: 100%; max-width: 360px; touch-action: none; border-radius: 6px; display: block; margin: 6px auto; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.disc { width: 100%; max-width: 320px; display: block; margin: 0 auto; }
.reading { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 8px 0; }
.reading div { background: #fffaf0; border: 1px solid var(--line); border-radius: 6px; text-align: center; padding: 3px 0; font-size: .95rem; color: var(--ink); }
.reading div i { display: block; font-style: normal; font-size: .8rem; font-weight: 700; color: #8a6a3a; }
.reading div b { display: block; border-top: 1px solid var(--line); margin-top: 2px; padding-top: 2px; }
.letter { font: 1.6rem var(--serif); background: #efe1bf; color: var(--ink); padding: 12px; border-radius: 6px; line-height: 1.6; text-align: center; }
.letter sub { font: 700 .85rem var(--sans); color: #8a6a3a; margin-left: 2px; }
.calc { display: flex; gap: 6px; }
.calc input { flex: 1; }
.hintbox { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 10px; }
.hint { background: #fff4d6; border-left: 4px solid var(--gold); padding: 8px 10px; border-radius: 6px; margin: 6px 0; color: var(--ink); }

/* weegschaal en kist */
.pick { display: grid; gap: 6px; }
.pick button { text-align: left; border: 1.5px solid var(--line); background: #fffaf0; color: var(--ink); border-radius: 10px; padding: 8px 10px; font-size: .93rem; }
.pick button.sel { border-color: var(--ink); background: #ffe39a; }
.pick button[disabled] { opacity: .45; }
.fields { display: flex; flex-wrap: wrap; gap: 6px; }
.fields button { border: 1.5px solid var(--gold2); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.fields button.sel { background: var(--ink); color: var(--card); }
.result { padding: 10px 12px; border-radius: 10px; margin: 8px 0; font-weight: 600; }
.result.ok { background: rgba(63,125,78,.18); border: 1.5px solid var(--green); }
.result.no { background: rgba(168,52,44,.12); border: 1.5px solid var(--red); }
.score td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.score tr.total td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--ink); }
.players li { margin: 4px 0; }
.log { font-size: .88rem; }
.log div { padding: 4px 0; border-bottom: 1px solid rgba(215,162,76,.15); }
.ob { display: grid; gap: 10px; }
.ob .card { display: flex; gap: 12px; align-items: flex-start; margin: 0; }
.ob .ic { font-size: 1.7rem; line-height: 1; }

/* toast en modal */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 60; background: var(--ink); color: var(--card); border: 1px solid var(--gold); padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px); display: none; font-size: .95rem; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.modal .sheet { background: var(--card); color: var(--ink); width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px max(20px, env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .modal .sheet { border-radius: 18px; } }
