:root {
  --kaas: #f6c945;
  --rood: #c0392b;
  --donker: #1b2a22;
  --paneel: rgba(20, 28, 24, 0.82);
  --tekst: #fdf8ea;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--donker);
  color: var(--tekst);
  font-family: ui-rounded, "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-left {
  position: absolute; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l));
  display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100vw - 170px);
}
.pill {
  background: var(--paneel);
  border: 2px solid rgba(246, 201, 69, 0.35);
  border-radius: 10px;
  padding: 4px 9px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.pill.stars { color: #7d8a85; letter-spacing: 1px; }
.pill.stars.hot { color: #ffd84a; border-color: #ff5a4a; animation: blink 0.6s steps(2) infinite; }
@keyframes blink { 50% { border-color: #3b82f6; } }
.pill.mission {
  position: absolute; top: calc(52px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  background: #4a1f5a; border-color: #ff4fd8; font-size: 15px;
}
.pill.speed {
  position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  font-size: 18px; min-width: 96px; text-align: center;
}
.pill.speed.illegal { background: #7a1d1d; border-color: #ff5a4a; }
.hud-right { position: absolute; top: calc(8px + var(--safe-t)); right: calc(8px + var(--safe-r)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#minimap {
  width: 132px; height: 132px; border-radius: 50%;
  border: 3px solid var(--kaas); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  image-rendering: pixelated; pointer-events: auto; cursor: pointer; background: #2a3a2a;
}
.hud-buttons { display: flex; gap: 6px; pointer-events: auto; }
.hud-buttons button {
  width: 40px; height: 40px; border-radius: 10px; border: 2px solid rgba(246, 201, 69, 0.4);
  background: var(--paneel); font-size: 18px;
}

#street {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%);
  font-size: clamp(22px, 5vw, 40px); font-weight: 900; letter-spacing: 1px;
  color: #fff; text-shadow: 0 3px 0 #000, 0 0 12px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none; z-index: 6; white-space: nowrap;
}
#street.show { animation: streetin 2.6s ease forwards; }
@keyframes streetin {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  12%, 75% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; }
}

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 7; pointer-events: none;
  width: min(92vw, 560px);
}
.toast {
  background: var(--paneel); border: 2px solid var(--kaas); border-radius: 12px; padding: 8px 14px;
  font-weight: 700; font-size: 15px; text-align: center; transition: opacity 0.5s, transform 0.5s;
}
.toast.out { opacity: 0; transform: translateY(-8px); }

#prompt {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(60px + var(--safe-b));
  background: #fff6d6; color: #2b2116; border-radius: 12px; padding: 7px 14px; font-weight: 800; z-index: 6;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4); pointer-events: none;
}
#prompt .key { background: #2b2116; color: #fff6d6; border-radius: 5px; padding: 1px 6px; margin-right: 4px; }

/* ---------- touch ---------- */
#joyzone { position: fixed; left: 0; bottom: 0; width: 50vw; height: 65vh; z-index: 4; display: none; }
#joybase {
  position: fixed; width: 104px; height: 104px; margin: -52px 0 0 -52px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35); background: rgba(0, 0, 0, 0.18); display: none; z-index: 8; pointer-events: none;
}
#joyknob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(246, 201, 69, 0.85); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}
#touchbtns { display: none; }
body.touch #joyzone { display: block; }
body.touch #touchbtns {
  display: grid; position: fixed; right: calc(10px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); z-index: 8;
  grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(2, 62px); gap: 8px;
}
.tb {
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.45); background: rgba(20, 28, 24, 0.7);
  font-size: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  touch-action: none;
}
.tb span { font-size: 10px; font-weight: 800; margin-top: 2px; }
.tb.down { background: rgba(246, 201, 69, 0.85); color: #222; }
.tb.fire { grid-column: 3; grid-row: 1 / span 2; border-radius: 40px; background: rgba(192, 57, 43, 0.8); font-size: 28px; }
.tb.read { grid-column: 1; grid-row: 1; opacity: 0.35; }
body.can-interact .tb.read { opacity: 1; background: rgba(46, 139, 87, 0.85); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.tb.enter { grid-column: 2; grid-row: 1; }
.tb.switch { grid-column: 1; grid-row: 2; }
.tb.horn { grid-column: 2; grid-row: 2; }
.tb.turbo { display: none; }
body.in-vehicle .tb.switch { display: none; }
body.in-vehicle .tb.turbo { display: flex; grid-column: 1; grid-row: 2; }
.tb.radio { display: none; }
body.in-vehicle .tb.radio { display: flex; grid-column: 2; grid-row: 3; }
.tb .drive { display: none; }
body.in-vehicle .tb .drive { display: inline; }
body.in-vehicle .tb .foot { display: none; }
body.touch #prompt { bottom: calc(160px + var(--safe-b)); }
body.touch #toasts { bottom: calc(200px + var(--safe-b)); }
body.touch .pill.speed { bottom: calc(160px + var(--safe-b)); left: 30%; }

/* ---------- modals ---------- */
#modal {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 10, 0.55); backdrop-filter: blur(2px); padding: 12px;
}
#modal[hidden] { display: none; }
#card {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 24px); overflow: auto;
  background: #fbf5e4; color: #2b2116; border-radius: 18px; padding: 18px 18px 14px;
  border: 4px solid #2b2116; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35); user-select: text; -webkit-user-select: text;
  touch-action: pan-y;
}
#card h2 { margin: 0 0 4px; font-size: 22px; }
#card h3 { margin: 14px 0 6px; font-size: 16px; }
#card p { line-height: 1.5; margin: 8px 0; }
#card .close {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid #2b2116; background: #fff; font-weight: 900;
}
.poi-head { display: flex; gap: 12px; align-items: center; padding-right: 36px; }
.poi-head .icon { font-size: 38px; }
.year { font-weight: 800; color: var(--rood); }
.snap { margin: 10px 0 4px; border-radius: 10px; overflow: hidden; border: 3px solid #2b2116; background: #2a3a2a; }
.snapimg { width: 100%; display: block; image-rendering: pixelated; aspect-ratio: 2 / 1; }
.fact { background: #fff0b8; border-radius: 10px; padding: 9px 12px; line-height: 1.45; border-left: 5px solid var(--kaas); }
.quiz { margin-top: 12px; background: #e9f3ea; border-radius: 12px; padding: 10px; }
.quiz.done { font-weight: 800; color: #1e6b3a; }
.quiz .q { font-weight: 800; margin-bottom: 8px; }
.quiz .opt {
  display: block; width: 100%; text-align: left; margin: 6px 0; padding: 10px 12px; border-radius: 10px;
  border: 2px solid #2b2116; background: #fff; font-weight: 700;
}
.quiz .opt.right { background: #b9f0c8; }
.quiz .opt.wrong { background: #ffc4bd; }
.quiz .qres { font-weight: 800; margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions.col { flex-direction: column; }
.actions button, .big {
  padding: 10px 14px; border-radius: 12px; border: 3px solid #2b2116; background: var(--kaas); font-weight: 800;
  box-shadow: 0 3px 0 #2b2116;
}
.actions button.on { background: #2e8b57; color: #fff; }
.actions button.danger { background: #ffd6d0; }
.actions button:active, .big:active { transform: translateY(2px); box-shadow: 0 1px 0 #2b2116; }
.note { font-size: 13px; color: #6a5a48; }
.source { font-size: 12px; color: #8a7a68; margin-top: 12px; }
label { display: block; font-weight: 800; margin: 10px 0; }
label select, label input, label textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px; border-radius: 8px; border: 2px solid #2b2116; background: #fff;
}
.memory { text-align: center; padding: 10px 10px 0; }
.mem-street { font-weight: 900; color: var(--rood); }
.memory blockquote { font-size: 19px; font-style: italic; margin: 14px 6px; line-height: 1.5; }
.memory .who { font-weight: 800; }
.tabs { display: flex; gap: 6px; margin-right: 40px; }
.tabs button { padding: 8px 12px; border-radius: 10px; border: 2px solid #2b2116; background: #fff; font-weight: 800; }
.tabs button.on { background: var(--kaas); }
.book { list-style: none; padding: 0; margin: 10px 0; }
.book li { padding: 8px 10px; border-bottom: 1px dashed #c9b994; }
.book li.ok { background: #eef8ef; }
.book li small { color: #8a7a68; }
.book.mems li.own { background: #fde6f1; }
.bigmap-wrap { overflow: auto; border: 3px solid #2b2116; border-radius: 10px; max-height: 65dvh; touch-action: pan-x pan-y; }
#bigmap { display: block; width: 100%; min-width: 520px; image-rendering: pixelated; }
.legend { font-size: 13px; }
.dot { display: inline-block; width: 10px; height: 10px; border: 1px solid #000; margin: 0 3px 0 8px; vertical-align: -1px; }
.dot.y { background: #f1c40f; } .dot.g { background: #2ecc71; } .dot.w { background: #fff; border-radius: 50%; } .dot.p { background: #ff4fd8; } .dot.m { background: #e84393; }

.title-screen { text-align: center; }
.logo {
  font-size: clamp(34px, 9vw, 58px); font-weight: 900; line-height: 0.95; letter-spacing: 2px; color: var(--rood);
  text-shadow: 3px 3px 0 #2b2116; margin: 6px 0 10px;
}
.logo span { color: var(--kaas); -webkit-text-stroke: 2px #2b2116; }
.sub { font-size: 16px; }
.big { font-size: 22px; padding: 12px 28px; margin: 6px 0 12px; }
.controls { display: grid; gap: 8px; text-align: left; font-size: 13px; background: #f1e7cc; border-radius: 12px; padding: 10px; }
.tip { font-weight: 700; color: #2e6b45; }
.credit { font-size: 12px; color: #6a5a48; }
.credit a { color: inherit; }
.busted { text-align: center; }
.big-title { font-size: 40px; font-weight: 900; color: var(--rood); text-shadow: 3px 3px 0 #2b2116; }

@media (max-width: 520px) {
  .pill { font-size: 12px; padding: 3px 7px; }
  .toast { font-size: 13px; padding: 6px 10px; }
  #street { top: 26%; }
  #minimap { width: 96px; height: 96px; }
  .hud-buttons button { width: 32px; height: 32px; font-size: 15px; }
  .hud-left { max-width: calc(100vw - 120px); }
  body.touch #touchbtns { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); }
}
@media (max-height: 460px) {
  #minimap { width: 86px; height: 86px; }
  body.touch #touchbtns { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); }
  body.touch #prompt { bottom: calc(126px + var(--safe-b)); }
}

/* ---------- foto's, personage, Kobalt ---------- */
#hud-photo {
  position: absolute; top: calc(190px + var(--safe-t)); right: calc(8px + var(--safe-r)); width: 132px; border-radius: 10px;
  border: 3px solid #ff4fd8; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4); pointer-events: none;
}
@media (max-width: 520px) { #hud-photo { top: calc(150px + var(--safe-t)); width: 96px; } }
.photo { margin: 0 0 10px; }
.photo img { width: 100%; display: block; border-radius: 10px; border: 3px solid #2b2116; max-height: 260px; object-fit: cover; }
.photo-lg img { max-height: 46dvh; }
.photo figcaption { font-size: 11px; color: #6a5a48; margin-top: 4px; }
.photo figcaption a { color: inherit; }
.kobalt-badge {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px;
  background: #0047ab; color: #fff; font-weight: 900; font-size: 26px !important;
}
.btnlink {
  display: inline-block; padding: 10px 14px; border-radius: 12px; border: 3px solid #2b2116; background: #0047ab; color: #fff;
  font-weight: 800; text-decoration: none; box-shadow: 0 3px 0 #2b2116;
}
.credit.maker a, .maker-note a { color: #0047ab; font-weight: 800; }
.maker-note { font-size: 13px; }
.actions.center { justify-content: center; }
.preview-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 4px 0 8px; text-align: left; }
#start-avatar { width: 40px; height: 60px; image-rendering: pixelated; background: #e9dfc4; border-radius: 8px; padding: 2px; }
.avatar-stage { display: flex; gap: 10px; justify-content: center; background: linear-gradient(#9ccf72, #6fb84f); border-radius: 12px; padding: 12px; border: 3px solid #2b2116; }
.avatar-stage canvas { width: 50px; height: 75px; image-rendering: pixelated; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 30px; height: 30px; border-radius: 8px; border: 2px solid #2b2116; }
.swatches button.on { outline: 3px solid #f6c945; outline-offset: 1px; transform: scale(1.1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chips button { padding: 6px 10px; border-radius: 10px; border: 2px solid #2b2116; background: #fff; font-weight: 800; }
.chips button.on { background: #f6c945; }
.creator h3 { margin: 10px 0 4px; font-size: 14px; }

/* ---------- logo op het startscherm ---------- */
.title-screen h1.logo { margin: 4px auto 10px; text-shadow: none; }
.title-screen h1.logo img { width: min(300px, 70vw); height: auto; margin: 0 auto; display: block; image-rendering: pixelated; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)); }

/* ---------- verhaal en briefings ---------- */
#modal[data-kind="story"], #modal[data-kind="brief"] { background: rgba(6, 4, 10, 0.82); backdrop-filter: blur(4px); }
#modal[data-kind="story"] #card, #modal[data-kind="brief"] #card {
  width: min(780px, 100%); padding: 0; overflow: auto; background: #120e1a; color: #f4f0fa;
  border: 3px solid #e0283c; box-shadow: 0 0 40px rgba(224, 40, 60, 0.45), 0 20px 60px rgba(0, 0, 0, 0.6);
}
#modal[data-kind="brief"] #card .close { z-index: 2; background: rgba(0, 0, 0, 0.55); color: #fff; border-color: #fff; }
.story-img { margin: 0; position: relative; aspect-ratio: 16 / 8; overflow: hidden; background: #000; }
.story-img img { width: 100%; height: 100%; object-fit: cover; display: block; animation: storyzoom 12s ease-out both; }
.story-img.pix img { image-rendering: pixelated; }
.story-img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, #120e1a 0%, rgba(18, 14, 26, 0) 45%); }
@keyframes storyzoom { from { transform: scale(1.12); } to { transform: scale(1); } }
.story-body { padding: 4px 26px 22px; margin-top: -34px; position: relative; }
.story-kicker { text-transform: uppercase; letter-spacing: 2.5px; font-weight: 900; font-size: 12px; color: #ff5a6a; margin: 0 0 4px !important; text-shadow: 0 0 14px rgba(255, 75, 92, 0.6); }
#card .story h2 { font-size: clamp(22px, 4vw, 30px); font-family: "Arial Black", Impact, system-ui, sans-serif; text-transform: uppercase; letter-spacing: -0.3px; color: #fff; margin-bottom: 8px; }
#card .story p { font-size: 16.5px; line-height: 1.6; color: #e2dcec; }
#card .story p b { color: #ffc93c; }
.story .note { color: #b7aec8; font-size: 14px; }
.story .fact { background: rgba(255, 201, 60, 0.1); border: 1px solid rgba(255, 201, 60, 0.45); border-left: 5px solid #ffc93c; color: #f4f0fa; margin-top: 10px; }
.story .fact b { color: #ffc93c; }
.goal { margin: 14px 0 8px; padding: 12px 14px; border-radius: 12px; background: rgba(224, 40, 60, 0.14); border: 1px solid rgba(224, 40, 60, 0.6); font-weight: 700; }
.goal b { display: block; text-transform: uppercase; letter-spacing: 2px; font-size: 12px; color: #ff5a6a; margin-bottom: 2px; }
.story-nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.dots span.on { background: #ffc93c; box-shadow: 0 0 10px rgba(255, 201, 60, 0.8); width: 22px; border-radius: 6px; }
.story .actions button { box-shadow: none; border-width: 2px; }
.story .actions button.primary { background: linear-gradient(135deg, #ffc93c, #ff9a2e); color: #1a1206; border-color: #ffc93c; box-shadow: 0 0 18px rgba(255, 201, 60, 0.45); }
.story .actions button.ghost { background: transparent; color: #f4f0fa; border-color: rgba(255, 255, 255, 0.35); }
.story .actions button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (max-width: 520px) { .story-body { padding: 4px 16px 16px; } .story-img { aspect-ratio: 16 / 10; } }
@media (prefers-reduced-motion: reduce) { .story-img img { animation: none; } }

/* ---------- voertuignaam en radio ---------- */
#vbanner {
  position: fixed; left: 50%; bottom: calc(22% + var(--safe-b)); transform: translateX(-50%); z-index: 6;
  text-align: center; pointer-events: none; opacity: 0; max-width: 90vw;
}
#vbanner b { display: block; font-family: "Arial Black", Impact, system-ui, sans-serif; text-transform: uppercase;
  font-size: clamp(26px, 5vw, 46px); letter-spacing: 1px; color: #ffc93c;
  text-shadow: 3px 3px 0 #1a0b12, -1px -1px 0 #1a0b12, 1px -1px 0 #1a0b12, -1px 1px 0 #1a0b12, 0 0 24px rgba(255, 170, 40, 0.5); }
#vbanner span { display: inline-block; margin-top: 6px; background: rgba(12, 10, 18, 0.72); color: #fff; padding: 4px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; }
#vbanner.show { animation: vbanner 3.6s ease-out forwards; }
@keyframes vbanner { 0% { opacity: 0; transform: translate(-50%, 12px) scale(0.92); } 8% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
#radiolabel {
  position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 6; pointer-events: none;
  background: rgba(12, 10, 18, 0.78); color: #fff; border: 2px solid #e0283c; border-radius: 999px; padding: 4px 14px;
  font-weight: 800; font-size: 14px; opacity: 0; transition: opacity 0.3s; box-shadow: 0 0 14px rgba(224, 40, 60, 0.4);
}
#radiolabel.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #vbanner.show { animation-duration: 0.01s; opacity: 1; } }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
label.check input { display: inline-block; width: 20px; height: 20px; margin: 0; flex: none; }
