/* Waar ben ik in Vlaanderen? — mobile-first stijl */
:root {
  --navy: #14213d;
  --navy-2: #24345c;
  --red: #e63946;
  --red-dark: #c92a37;
  --gold: #fca311;
  --bg: #f3f1ea;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2ded2;
  --ok: #2a9d8f;
  --warn: #e9a23b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 33, 61, .12);
  --topbar: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--navy-2); }
h1, h2 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
code { background: #efece3; padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.inline { display: inline; margin: 0; }
.no-scroll { overflow: hidden; }

/* ---------- topbalk ---------- */
.topbar {
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px;
  background: var(--navy); color: #fff;
  position: sticky; top: 0; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-weight: 500; opacity: .75; }
.topbar nav { display: flex; align-items: center; gap: 14px; font-size: .95rem; }
.topbar nav a { color: #fff; text-decoration: none; opacity: .9; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; opacity: .9; }
.linkbtn:hover { text-decoration: underline; }
.card .linkbtn, .dropzone .linkbtn { color: var(--navy-2); text-decoration: underline; opacity: 1; }
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .topbar nav { gap: 10px; font-size: .9rem; }
}

/* ---------- knoppen & formulieren ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--text);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: transform .06s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.btn-primary:disabled { background: #9aa0ad; border-color: #9aa0ad; opacity: 1; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: #f2c1c5; background: #fff; }
.btn-small { min-height: 34px; padding: 5px 14px; font-size: .9rem; }
.topbar .btn-small { background: var(--red); border-color: var(--red); color: #fff; opacity: 1; }
.btn-lg { min-height: 54px; font-size: 1.08rem; border-radius: 13px; }
.btn-block { width: 100%; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(20, 33, 61, .7); color: #fff; font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}

input[type=email], input[type=text], input[type=password], input[type=number], input:not([type]), select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid #cfcabc; border-radius: 10px; background: #fff;
  font: inherit; font-size: 16px; /* 16px voorkomt auto-zoom op iOS */
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid rgba(252, 163, 17, .45); outline-offset: 1px; }
label { font-weight: 600; font-size: .92rem; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; margin-top: 6px; }
.stack { display: grid; gap: 10px; margin: 18px 0; }
.stack-lg { display: grid; gap: 18px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.narrow { max-width: 480px; margin: 28px auto; padding-left: 16px; padding-right: 16px; }
.card.narrow { padding: 26px 22px; }
.page-narrow main.narrow { padding: 0 16px; }
.page-narrow main.card.narrow { margin: 28px 16px; }
@media (min-width: 520px) { .page-narrow main.card.narrow { margin: 40px auto; } }
.big-emoji { font-size: 52px; line-height: 1; margin-bottom: 10px; }

.flash { max-width: 720px; margin: 12px auto; padding: 12px 16px; border-radius: 10px; font-weight: 550; }
.flash-ok { background: #ddf3ee; color: #165c53; }
.flash-error { background: #fde2e4; color: #8a1c26; }
.game .flash { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar) + 8px); z-index: 1200; box-shadow: var(--shadow); animation: fadeout .5s 3s forwards; }
@keyframes fadeout { to { opacity: 0; visibility: hidden; } }
.callout { background: #fff6e0; border-left: 4px solid var(--gold); padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.callout.warn { background: #fff3e0; border-color: var(--warn); }

/* ---------- speelscherm ---------- */
.game { height: 100dvh; overflow: hidden; }
.play {
  position: relative;
  height: calc(100dvh - var(--topbar));
  display: grid;
  grid-template-rows: minmax(180px, 42%) 1fr;  /* mobiel: foto boven, kaart onder */
}
@media (max-width: 899px) {
  .play.resulting { grid-template-rows: minmax(110px, 22%) 1fr; }
  .play.resulting .hud { display: none; }
}
@media (min-width: 900px) {
  .play { grid-template-rows: none; grid-template-columns: 1.15fr 1fr; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .play { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
}

.photo-pane { position: relative; background: #0d1426; overflow: hidden; }
#photo {
  width: 100%; height: 100%; object-fit: contain; display: block;
  opacity: 0; transition: opacity .3s; cursor: zoom-in; user-select: none;
}
#photo.ready { opacity: 1; }
.photo-loading { position: absolute; inset: 0; display: grid; place-items: center; }
.photo-loading[hidden] { display: none; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.photo-zoom { position: absolute; right: 10px; bottom: 10px; }
.hud { position: absolute; left: 10px; top: 10px; right: 60px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.chip {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.94); color: var(--navy); text-decoration: none;
  padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.chip-anon { background: var(--gold); color: #1d1300; }

.map-pane { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe6e9; }
.guess-bar {
  position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 500;
}
@media (min-width: 900px) { .guess-bar { left: 50%; right: auto; transform: translateX(-50%); width: 360px; } }
.guess-bar .btn { box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.leaflet-bottom.leaflet-right { bottom: 72px; }
.leaflet-container { font: inherit; }
.leaflet-touch .leaflet-bar a { width: 38px; height: 38px; line-height: 38px; }

/* pins */
.pin span {
  position: absolute; left: 0; top: 0; width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.pin span::after { content: ""; position: absolute; left: 7px; top: 7px; width: 8px; height: 8px; background: #fff; border-radius: 50%; }
.pin-guess span { background: var(--red); }
.pin-answer span { background: var(--ok); }
.pin-answer { animation: drop .45s cubic-bezier(.2,1.4,.5,1); }
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }

/* resultaat */
.result-sheet {
  position: absolute; z-index: 1100;
  left: 0; right: 0; bottom: 0;
  background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.22);
  padding: 10px 18px calc(16px + var(--safe-b));
  transform: translateY(105%); transition: transform .35s cubic-bezier(.2,.9,.3,1);
  max-height: 70%; overflow: auto;
}
@media (max-width: 899px) { .rs-extra { font-size: .88rem; margin-bottom: 10px; } .result-sheet .btn-lg { min-height: 50px; } }
.result-sheet.open { transform: none; }
.rs-handle { width: 40px; height: 4px; background: #d6d2c6; border-radius: 4px; margin: 0 auto 10px; }
.rs-km { font-size: 1.5rem; font-weight: 850; color: var(--navy); letter-spacing: -.02em; }
.rs-sub { font-size: 1.02rem; margin: 2px 0 6px; }
.rs-title { font-weight: 650; margin-bottom: 6px; }
.rs-title::before { content: "📍 "; }
.rs-extra { font-size: .93rem; margin-bottom: 14px; }
.score-pop { display: inline-block; font-weight: 850; color: var(--red); font-size: 1.15rem; animation: pop .5s cubic-bezier(.2,1.6,.5,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.teaser { background: #fff6e0; border-radius: 9px; padding: 8px 12px; margin-bottom: 8px; }
@media (min-width: 900px) {
  .result-sheet { left: auto; right: 18px; bottom: 18px; width: 380px; border-radius: 18px; }
  .rs-handle { display: none; }
}
.progress { height: 10px; background: #ece8dc; border-radius: 99px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--gold), var(--red)); border-radius: 99px; transition: width .6s; }

.empty-state { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(5, 9, 20, .96); }
.lb-scroll { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; touch-action: pan-x pan-y pinch-zoom; }
.lb-scroll img { max-width: 100vw; max-height: 100dvh; display: block; cursor: zoom-in; }
.lb-scroll img.zoomed { max-width: none; max-height: none; width: 250vw; cursor: zoom-out; }
@media (min-width: 900px) { .lb-scroll img.zoomed { width: 180vw; } }
.lb-close { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 2; }

/* badge-dialoog */
dialog { border: 0; border-radius: 18px; box-shadow: var(--shadow); padding: 0; }
dialog::backdrop { background: rgba(10, 16, 32, .55); }
.badge-dlg { width: min(92vw, 360px); padding: 26px 22px 20px; text-align: center; }
.bd-emoji { font-size: 74px; line-height: 1; animation: pop .6s cubic-bezier(.2,1.6,.5,1); }

/* ---------- profiel ---------- */
.badge-big { font-size: 80px; line-height: 1; margin: 4px 0 10px; }
.badge-big.locked { filter: grayscale(1); opacity: .5; }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
@media (min-width: 480px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat-row > div { background: var(--bg); border-radius: 12px; padding: 10px 6px; }
.stat-row strong { display: block; font-size: 1.25rem; color: var(--navy); }
.stat-row span { font-size: .78rem; color: var(--muted); }
.badge-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.badge-list li { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }
.badge-list li.current { border-color: var(--gold); background: #fff8e8; }
.bl-emoji { font-size: 30px; width: 40px; text-align: center; }
table.hist { width: 100%; border-collapse: collapse; font-size: .92rem; }
.hist th, .hist td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.hist .num { text-align: right; white-space: nowrap; }

/* ---------- admin ---------- */
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.admin-tabs { display: flex; gap: 6px; }
.admin-tabs a { padding: 8px 16px; border-radius: 10px; text-decoration: none; color: var(--navy); font-weight: 650; background: #e8e4d8; }
.admin-tabs a.active { background: var(--navy); color: #fff; }
.dot-warn { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); vertical-align: middle; }
.dropzone {
  border: 2px dashed #c8c2b2; border-radius: 14px; padding: 28px 16px; text-align: center;
  display: grid; gap: 6px; transition: background .15s, border-color .15s; cursor: default;
}
.dropzone.over { background: #fff6e0; border-color: var(--gold); }
.dz-icon { font-size: 34px; }
.upload-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.upload-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: .9rem; padding: 6px 10px; background: var(--bg); border-radius: 8px; }
.upload-list progress { grid-column: 1 / -1; width: 100%; height: 6px; }
.ul-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ul-status.ok { color: var(--ok); }
.ul-status.warn { color: #9a6200; grid-column: 1 / -1; }
.ul-status.err { color: var(--red); grid-column: 1 / -1; }

.tabbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.tab { border: 0; background: #ece8dc; padding: 8px 14px; border-radius: 99px; font: inherit; font-weight: 650; cursor: pointer; }
.tab.active { background: var(--navy); color: #fff; }
.tab .count { background: rgba(0,0,0,.12); border-radius: 99px; padding: 0 7px; font-size: .8rem; margin-left: 4px; }
.tab-stats { margin-left: auto; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.photo-card {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff;
  padding: 0; text-align: left; cursor: pointer; font: inherit; color: inherit;
  transition: transform .12s, box-shadow .12s;
}
.photo-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.photo-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #ddd; }
.pc-meta { padding: 8px 10px 10px; display: grid; gap: 3px; }
.pc-title { font-weight: 650; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-s { justify-self: start; font-size: .72rem; font-weight: 750; padding: 1px 8px; border-radius: 99px; }
.badge-s.ok { background: #ddf3ee; color: #165c53; }
.badge-s.warn { background: #fff0d6; color: #8a5a00; }
.badge-s.info { background: #e1e8fb; color: #233c80; }
.badge-s.muted { background: #ebebeb; color: #555; }

.editor { width: min(1100px, 96vw); max-height: 94dvh; }
.editor-close { position: absolute; right: 10px; top: 10px; z-index: 5; margin: 0; }
.editor-body { display: grid; grid-template-columns: 1fr; }
@media (min-width: 860px) { .editor-body { grid-template-columns: 1.2fr 1fr; } }
.editor-photo { background: #0d1426; display: grid; place-items: center; min-height: 260px; }
.editor-photo img { max-width: 100%; max-height: 80dvh; display: block; }
.editor-side { padding: 16px; display: grid; gap: 8px; align-content: start; overflow: auto; max-height: 94dvh; }
.ed-map { height: 300px; border-radius: 12px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.grid-form { display: grid; grid-template-columns: 1fr; gap: 6px 16px; align-items: center; }
@media (min-width: 680px) { .grid-form { grid-template-columns: 210px 1fr; gap: 12px 16px; } }
.smtp-log pre { background: #10172a; color: #cde; padding: 12px; border-radius: 10px; font-size: .78rem; overflow: auto; max-height: 340px; white-space: pre-wrap; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: .93rem;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 3000; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--ok); }
