:root {
  --bg: #0d0907;
  --panel: rgba(24, 16, 11, 0.86);
  --panel-solid: #1b130e;
  --line: rgba(227, 181, 91, 0.28);
  --gold: #e3b55b;
  --gold-2: #f3d58f;
  --text: #f7efe3;
  --muted: #c3b09a;
  --red: #b3122a;
  --green: #1f6b3c;
  --paper: #f7f1e1;
  --ink: #2a2440;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* lichte vignettering, zoals bij een foto */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.32) 100%);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

/* ---------- knoppen ---------- */

.btn {
  font: 600 15px/1 Inter, sans-serif;
  border-radius: 999px;
  padding: 13px 22px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
  color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #2a1a0c;
  box-shadow: 0 6px 20px rgba(227, 181, 91, 0.25);
}
.btn.primary:hover { box-shadow: 0 8px 28px rgba(227, 181, 91, 0.4); }
.btn.ghost { background: rgba(255, 255, 255, 0.06); border-color: var(--line); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn.small { padding: 10px 18px; font-size: 14px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:focus-visible, .round:focus-visible, .slot:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }

/* ---------- HUD ---------- */

#hud, #zoom, #inventory, #nav { display: none; }
body.playing #hud { display: flex; }
body.playing #zoom { display: flex; }
body.playing #inventory { display: flex; }
body.playing #nav { display: flex; }

#nav {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}
.nav-btn {
  font: 500 13px Inter, sans-serif;
  text-align: left;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.nav-btn:hover { color: var(--text); background: #2a1d14; }
.nav-btn.active { color: #2a1a0c; background: var(--gold); border-color: var(--gold); font-weight: 600; }
.nav-btn::before { content: '● '; font-size: 9px; vertical-align: 2px; opacity: 0.7; }

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  z-index: 10;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

.team-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  max-width: 34vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ad66d; box-shadow: 0 0 10px #4ad66d; flex: none; }

#timer {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 0.04em;
  padding: 6px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
#timer.low { color: #ff7b7b; border-color: rgba(255, 123, 123, 0.5); animation: pulse 1s infinite; }
#timer.penalty { animation: penalty 0.9s; }

.hud-buttons { display: flex; gap: 8px; }

#zoom {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}
.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}
.round:hover { background: #2a1d14; }

/* ---------- tas ---------- */

#inventory {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  gap: 10px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  z-index: 10;
}
.slot {
  width: 78px;
  height: 78px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  font: inherit;
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.slot:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); }
.slot:disabled { cursor: default; }
.slot .icon { font-size: 30px; line-height: 1; }
.slot .name { font-size: 11px; color: var(--muted); }
.slot.active { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold), 0 0 22px rgba(227, 181, 91, 0.45); background: rgba(227, 181, 91, 0.12); }
.slot.new { animation: pop 0.7s ease-out; }

/* ---------- tooltip en melding ---------- */

#tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  pointer-events: none;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(14, 9, 6, 0.9);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}
#tooltip.show { opacity: 1; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 124px;
  transform: translate(-50%, 12px);
  z-index: 20;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- start- en eindscherm ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(13, 9, 7, 0.45), rgba(13, 9, 7, 0.92));
  backdrop-filter: blur(5px);
}
.intro {
  width: min(620px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 36px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
h1, h2 { font-family: 'Playfair Display', serif; font-weight: 700; }
h1 { font-size: clamp(38px, 7vw, 58px); line-height: 1.04; margin: 0 0 16px; }
h2 { font-size: 26px; margin: 0 0 10px; }
.lead { color: var(--muted); font-size: 17px; line-height: 1.6; margin: 0 0 20px; }
.howto {
  list-style: none;
  padding: 16px 18px;
  margin: 0 0 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  font-size: 14px;
  color: var(--muted);
}
.howto b { display: block; color: var(--text); font-weight: 600; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.row { display: flex; gap: 10px; }
input {
  flex: 1;
  min-width: 0;
  font: 500 16px Inter, sans-serif;
  padding: 13px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}
input:focus { outline: none; border-color: var(--gold); }
.small-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; }
.small-link:hover { color: var(--gold-2); }

.end-card { text-align: center; }
.end-card .big-time { font-family: 'Playfair Display', serif; font-size: 64px; font-weight: 700; color: var(--gold-2); margin: 8px 0; font-variant-numeric: tabular-nums; }
.end-card .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.end-card .actions a { text-decoration: none; }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 5, 4, 0.55);
  backdrop-filter: blur(3px);
}
.modal .card {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.22s ease-out;
}
.modal .card p { line-height: 1.6; }
.muted { color: var(--muted); }
.close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: inherit;
  opacity: 0.6;
  font-size: 26px;
  cursor: pointer;
}
.close:hover { opacity: 1; }

.modal.paper .card {
  background: var(--paper) repeating-linear-gradient(transparent 0 31px, rgba(60, 90, 160, 0.18) 31px 32px);
  background-position: 0 10px;
  color: var(--ink);
  border: none;
  font-family: Caveat, cursive;
  font-size: 25px;
  line-height: 32px;
  transform: rotate(-1deg);
}
.modal.paper .card p { margin: 0 0 32px; line-height: 32px; }
.modal.paper .sign { text-align: right; }
.modal.paper .ps { font-size: 22px; opacity: 0.8; margin-bottom: 0; }

.modal.kaart .card {
  background: linear-gradient(160deg, #fffaf0, #f2e3c6);
  color: #4a1620;
  border: 6px double #a51229;
  font-family: Caveat, cursive;
  font-size: 26px;
  line-height: 1.3;
  text-align: center;
  transform: rotate(1deg);
}
.modal.kaart .card p { margin: 0 0 14px; line-height: 1.3; }
.modal.kaart .names { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; color: var(--red); }
.modal.kaart .card::before { content: '✶ ✶ ✶'; display: block; color: var(--gold); letter-spacing: 0.4em; font-size: 16px; margin-bottom: 10px; }

.wheels { display: flex; gap: 12px; justify-content: center; margin: 22px 0; }
.wheel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px;
  border-radius: 14px;
  background: linear-gradient(#2c2018, #120c09);
  border: 1px solid var(--line);
}
.wheel button { background: none; border: none; color: var(--gold); font-size: 18px; padding: 8px 16px; cursor: pointer; }
.wheel button:hover { color: var(--gold-2); }
.digit {
  width: 58px;
  padding: 6px 0;
  border-radius: 8px;
  background: linear-gradient(#fbf4e4, #e5d8bd);
  color: #1b130e;
  font: 700 40px 'Playfair Display', serif;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.keypad { display: grid; grid-template-columns: repeat(3, 66px); gap: 10px; justify-content: center; margin: 20px 0 6px; }
.kp-display {
  grid-column: 1 / -1;
  padding: 12px;
  border-radius: 10px;
  background: #0f2a17;
  border: 1px solid #2f5f3a;
  color: #9fe0a8;
  font: 600 28px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.2em;
  text-align: center;
}
.kp-key {
  height: 54px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(#3a3a44, #26262d);
  color: #eee;
  font: 600 20px Inter, sans-serif;
  cursor: pointer;
}
.kp-key:hover { background: linear-gradient(#45454f, #2e2e36); }
.kp-key.ok { background: linear-gradient(#2f8a4a, #1f6b3c); }
.kp-key.clear { background: linear-gradient(#8a2a35, #6b1a24); }

.lock-msg { min-height: 24px; text-align: center; color: #ff8b8b; margin: 10px 0 0; }
.center { text-align: center; }
.modal .btn.primary { display: block; margin: 0 auto; }

.hint-list { padding-left: 20px; line-height: 1.6; }
.hint-list li { margin-bottom: 8px; }

.shake { animation: shake 0.42s; }

/* ---------- animaties ---------- */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@keyframes pop {
  0% { transform: scale(0.6); box-shadow: 0 0 0 rgba(227, 181, 91, 0); }
  50% { transform: scale(1.12); box-shadow: 0 0 30px rgba(227, 181, 91, 0.8); }
  100% { transform: scale(1); }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: 0.6; } }
@keyframes penalty { 0% { color: #ff6b6b; transform: translateX(-50%) scale(1.15); } 100% { transform: translateX(-50%) scale(1); } }

/* ---------- klein scherm ---------- */

@media (max-width: 640px) {
  #timer { font-size: 24px; padding: 6px 16px; top: 64px; }
  .team-pill { max-width: 46vw; font-size: 13px; }
  .slot { width: 62px; height: 62px; }
  .slot .icon { font-size: 24px; }
  .slot .name { font-size: 10px; }
  #toast { bottom: 104px; }
  .intro { padding: 26px 20px 22px; }
  .howto { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  #zoom { right: 10px; }
  #nav { left: 10px; top: auto; bottom: 104px; transform: none; }
  .nav-btn { padding: 7px 11px; font-size: 12px; }
}

/* ---------- plattegrond in X-Cube-stijl ---------- */

.map-overlay {
  position: fixed;
  inset: 0;
  z-index: 36;
  overflow: hidden;
  color: #9dffc6;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
  background:
    linear-gradient(rgba(61, 255, 142, 0.05) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(61, 255, 142, 0.05) 1px, transparent 1px) 0 0 / 44px 44px,
    radial-gradient(ellipse at 50% 55%, #062a1a 0%, #03140c 55%, #010604 100%);
  animation: map-in 0.35s ease-out;
}
.map-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(61, 255, 142, 0.035) 0 1px, transparent 1px 3px);
}
#map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 4px rgba(61, 255, 142, 0.75));
  cursor: grab;
  touch-action: none;
}
.map-labels { position: absolute; inset: 0; pointer-events: none; }
.map-label {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(61, 255, 142, 0.7);
  background: rgba(2, 20, 12, 0.85);
  color: #b9ffd5;
  font: 600 12px ui-monospace, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(61, 255, 142, 0.25);
}
.map-label:hover { background: rgba(61, 255, 142, 0.18); }
.map-label .dot { width: 7px; height: 7px; background: #3dff8e; box-shadow: 0 0 8px #3dff8e; }
.map-label.here { background: #3dff8e; color: #022313; border-color: #3dff8e; }
.map-label.here .dot { background: #022313; box-shadow: none; }
.map-label.here::after { content: 'je bent hier'; font-weight: 500; opacity: 0.75; text-transform: none; letter-spacing: 0; }
.map-head { position: absolute; left: 28px; top: 22px; text-shadow: 0 0 10px rgba(61, 255, 142, 0.7); pointer-events: none; }
.map-title { font-size: 22px; font-weight: 700; letter-spacing: 0.18em; color: #3dff8e; }
.map-sub { font-size: 12px; letter-spacing: 0.22em; opacity: 0.75; margin-top: 4px; }
.map-status {
  position: absolute;
  left: 28px;
  bottom: 26px;
  min-width: 260px;
  padding: 14px 16px;
  border: 1px solid rgba(61, 255, 142, 0.45);
  background: rgba(2, 20, 12, 0.7);
  font-size: 12px;
  letter-spacing: 0.12em;
  line-height: 1.9;
  text-shadow: 0 0 8px rgba(61, 255, 142, 0.5);
  pointer-events: none;
}
.map-status div { display: flex; justify-content: space-between; gap: 18px; }
.map-status span { opacity: 0.65; }
.map-status b { color: #d6ffe6; font-weight: 600; }
.map-hint { position: absolute; right: 28px; bottom: 30px; font-size: 12px; letter-spacing: 0.1em; opacity: 0.7; pointer-events: none; }
.map-radar {
  position: absolute;
  right: 80px;
  top: 22px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(61, 255, 142, 0.7);
  box-shadow: 0 0 18px rgba(61, 255, 142, 0.35), inset 0 0 18px rgba(61, 255, 142, 0.25);
  background:
    radial-gradient(circle, transparent 30%, rgba(61, 255, 142, 0.35) 31%, transparent 33%),
    radial-gradient(circle, transparent 60%, rgba(61, 255, 142, 0.3) 61%, transparent 63%);
  overflow: hidden;
  pointer-events: none;
}
.map-radar .sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, rgba(61, 255, 142, 0.55), transparent 25%);
  animation: radar 3s linear infinite;
}
.map-close {
  position: absolute;
  right: 22px;
  top: 22px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(61, 255, 142, 0.7);
  background: rgba(2, 20, 12, 0.85);
  color: #3dff8e;
  font-size: 24px;
  cursor: pointer;
}
.map-close:hover { background: rgba(61, 255, 142, 0.2); }
@keyframes radar { to { transform: rotate(360deg); } }
@keyframes map-in { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }

/* ---------- filmpje vooraf ---------- */

.intro-overlay { position: fixed; inset: 0; z-index: 32; pointer-events: none; }
.letterbox { position: absolute; left: 0; right: 0; height: 9vh; background: #000; }
.letterbox.top { top: 0; }
.letterbox.bottom { bottom: 0; }
.intro-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  text-align: center;
  font: italic 600 clamp(26px, 4vw, 44px) 'Playfair Display', serif;
  color: #f7efe3;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 1s;
}
.intro-title.show { opacity: 1; }
.intro-subs {
  position: absolute;
  left: 50%;
  bottom: calc(9vh + 18px);
  transform: translateX(-50%);
  width: min(900px, calc(100vw - 32px));
  text-align: center;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.5;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 2px #000;
  opacity: 0;
  transition: opacity 0.35s;
}
.intro-subs.show { opacity: 1; }
.intro-subs .who {
  display: block;
  font: 600 12px Inter, sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.intro-skip { position: absolute; right: 18px; bottom: calc(9vh + 16px); pointer-events: auto; }
.flash { position: fixed; inset: 0; z-index: 50; background: #fff; opacity: 0; pointer-events: none; transition: opacity 1.1s ease-out; }
.flash.on { opacity: 1; transition: opacity 0.8s ease-in; }

@media (max-width: 640px) {
  .map-radar { display: none; }
  .map-status { left: 12px; right: 12px; bottom: 12px; min-width: 0; }
  .map-hint { display: none; }
  .map-head { left: 14px; top: 14px; }
  .intro-skip { bottom: calc(9vh + 70px); }
}
