:root {
  --navy: #1B2440;
  --navy-2: #2B3352;
  --navy-3: #3A4466;
  --cream: #FFF4DC;
  --muted: #D9DEEE;
  --faint: #9AA3C2;
  --yellow: #FFC531;
  --yellow-dark: #B88A12;
  --red: #E2412F;
  --red-dark: #9E2A1E;
  --teal: #2E7D8C;
  --teal-dark: #1F5A65;
  --green: #8FD3A6;
  --display: "Bungee", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font-family: var(--body); cursor: pointer; touch-action: manipulation; }
h1, h2 { font-family: var(--display); font-weight: 400; color: var(--yellow); margin: 0; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}

/* ---------- Pincode ---------- */
.login { max-width: 430px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.login-hero { position: relative; height: 34vh; min-height: 170px; max-height: 300px; }
.login-hero svg { width: 100%; height: 100%; display: block; }
.tag {
  position: absolute; left: 16px; top: 16px; background: var(--navy); color: var(--yellow);
  font-family: var(--display); font-size: 12px; padding: 6px 10px; border-radius: 6px;
}
.login-body { padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 6px; }
.login-body h1 { font-size: clamp(22px, 7vw, 32px); line-height: 1.1; }
.login-body p { margin: 0; }
#pin-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
#pin-form label { font-weight: 800; font-size: 14px; letter-spacing: .04em; }
.pin-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.pin-boxes span {
  height: 48px; border-radius: 10px; background: var(--navy-2); display: flex;
  align-items: center; justify-content: center; font-size: 26px; font-weight: 800;
}
.pin-boxes span.filled { background: var(--cream); color: var(--navy); }
.pin-boxes span.next { outline: 2px solid var(--yellow); outline-offset: -2px; }
.pin-msg { min-height: 1.3em; font-weight: 700; color: var(--yellow); }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.keypad button {
  height: 50px; border: 0; border-radius: 10px; background: var(--navy-2);
  color: var(--cream); font-weight: 800; font-size: 20px;
}
.keypad button:active { background: var(--navy-3); }
.keypad .ghost { background: transparent; color: var(--muted); font-size: 15px; }
.keypad .go { background: var(--yellow); color: var(--navy); font-size: 15px; }
.shake { animation: shake .35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ---------- Spel ---------- */
.game {
  max-width: 480px; margin: 0 auto; height: 100%; height: 100dvh; display: flex;
  flex-direction: column; overflow: hidden; position: relative;
  padding-bottom: env(safe-area-inset-bottom);
  user-select: none; -webkit-user-select: none;
}
.game.cafe { background: #3B2418; }
.game.riool { background: #0D111E; }
.hud { padding: 12px 16px 8px; display: flex; justify-content: space-between; align-items: center; }
.hud-title { display: flex; flex-direction: column; gap: 1px; }
.hud-level { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .08em; }
.hud-name { font-family: var(--display); font-size: 20px; color: var(--yellow); }
.pill {
  background: var(--yellow); color: var(--navy); font-weight: 800; font-size: 18px;
  padding: 7px 14px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.pill.bump { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.15); } }
.subhud {
  padding: 0 16px 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  font-size: 13px; font-weight: 800; min-height: 36px;
}
.chip { background: rgba(255, 255, 255, .1); padding: 5px 9px; border-radius: 8px; }
.chip.accent { color: var(--yellow); margin-left: auto; }
.meter { flex: 1; min-width: 60px; height: 10px; background: rgba(255,255,255,.1); border-radius: 6px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: #4FA3C7; }
.stations { display: flex; align-items: center; gap: 5px; width: 100%; font-size: 11px; color: var(--muted); }
.stations .line { flex: 1; height: 3px; border-radius: 2px; background: var(--navy-3); }
.stations .done { color: var(--green); }
.stations .line.done { background: var(--green); }
.stations .now { background: var(--teal); color: var(--cream); padding: 3px 7px; border-radius: 6px; }

.stage { flex: 1 1 0; min-height: 0; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; }
#scene { display: block; touch-action: none; }
.toast {
  position: absolute; left: 50%; top: 18%; transform: translate(-50%, -50%) scale(.6);
  background: var(--cream); color: var(--navy); font-family: var(--display); font-size: 22px;
  padding: 10px 18px; border-radius: 14px; opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity .15s, transform .15s; box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
.toast small { display: block; font-family: var(--body); font-weight: 800; font-size: 14px; text-align: center; }

.controls {
  flex: 0 0 auto; padding: 10px 16px 16px; display: flex; flex-direction: column;
  gap: 10px; align-items: center;
}
.controls .hint { margin: 0; font-size: 14px; text-align: center; color: var(--muted); }
.controls .row { display: flex; gap: 12px; width: 100%; }
.big {
  border: 0; border-radius: 18px; font-family: var(--display); font-size: 24px;
  height: 92px; color: var(--cream); flex: 1; transition: transform .05s, box-shadow .05s;
}
.big:active, .big.down { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0,0,0,.3) !important; }
.big.red { background: var(--red); box-shadow: 0 6px 0 var(--red-dark); }
.big.round { flex: 0 0 auto; width: 132px; height: 132px; border-radius: 50%; border: 6px solid var(--cream); font-size: 28px; }
.big.teal { background: var(--teal); box-shadow: 0 6px 0 var(--teal-dark); }
.big.yellow { background: var(--yellow); color: var(--navy); box-shadow: 0 6px 0 var(--yellow-dark); }
.big.cam { flex: 0 0 110px; display: flex; align-items: center; justify-content: center; }
.joy-wrap { display: flex; align-items: center; gap: 16px; width: 100%; }
.joy {
  width: 128px; height: 128px; flex: 0 0 128px; border-radius: 50%; background: #1E2540;
  border: 3px solid var(--navy-3); position: relative; touch-action: none;
}
.joy .knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; background: var(--yellow); pointer-events: none;
}

.overlay {
  position: absolute; inset: 0; background: rgba(13, 17, 30, .92); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 5; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.card {
  width: 100%; max-width: 380px; background: var(--navy); border: 2px solid var(--navy-3);
  border-radius: 22px; padding: 22px 20px; display: flex; flex-direction: column; gap: 12px;
  text-align: center;
}
.card .kicker { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .08em; }
.card h2 { font-size: 28px; line-height: 1.1; }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.card .bigscore { font-family: var(--display); font-size: 52px; line-height: 1; color: var(--yellow); }
.card .cta {
  height: 56px; border: 0; border-radius: 14px; background: var(--yellow); color: var(--navy);
  font-weight: 800; font-size: 17px;
}
.card .cta.ghost { background: transparent; border: 2px solid var(--yellow); color: var(--yellow); }
.card .rules { text-align: left; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.breakdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.breakdown div { background: var(--navy-2); border-radius: 10px; padding: 8px 4px; display: flex; flex-direction: column; }
.breakdown span:first-child { font-size: 10px; font-weight: 800; color: var(--faint); }
.breakdown span:last-child { font-weight: 800; font-size: 16px; }
.name-row { display: flex; gap: 8px; }
.name-row input {
  flex: 1; min-width: 0; height: 48px; border: 0; border-radius: 12px; padding: 0 14px;
  font: 700 16px var(--body); background: var(--cream); color: var(--navy);
}
.name-row button {
  height: 48px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--yellow);
  color: var(--navy); font-weight: 800; font-size: 15px;
}
.board {
  background: var(--cream); color: var(--navy); border-radius: 16px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px; text-align: left;
}
.board h3 { margin: 0 0 2px; font-family: var(--display); font-weight: 400; font-size: 17px; }
.board ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.board li {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px;
  background: #E9DEC6; font-weight: 800;
}
.board li:first-child { background: var(--yellow); }
.board li.me { background: var(--navy); color: var(--cream); }
.board li .rank { font-family: var(--display); width: 22px; }
.board li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .empty { color: #5A6280; font-weight: 700; }

/* ---------- Startscherm, beheer ---------- */
[hidden] { display: none !important; }
.cta {
  height: 56px; border: 0; border-radius: 14px; background: var(--yellow); color: var(--navy);
  font-weight: 800; font-size: 17px; padding: 0 20px;
}
.cta.ghost { background: transparent; border: 2px solid var(--yellow); color: var(--yellow); }
.cta.danger { background: var(--red); color: var(--cream); }
.home .login-body { gap: 10px; }
.home #play { margin-top: 6px; }
.home #home-note:empty { display: none; }
.admin-link { color: var(--yellow); font-weight: 800; text-decoration: none; }
.admin-link:hover { text-decoration: underline; }
.hud-left { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .1);
  color: var(--cream); display: flex; align-items: center; justify-content: center;
}
.admin { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 20px; }
.admin h1 { font-size: 30px; }
.admin h2 { font-size: 18px; margin-bottom: 10px; }
.admin section { display: flex; flex-direction: column; gap: 10px; }
.admin form { margin: 0; }
.admin .cta { width: 100%; max-width: 320px; }
.notice { background: var(--green); color: var(--navy); font-weight: 800; padding: 10px 14px; border-radius: 12px; margin: 0; }
.table-wrap { overflow-x: auto; background: var(--cream); border-radius: 14px; }
.admin table { border-collapse: collapse; width: 100%; color: var(--navy); font-size: 14px; }
.admin th, .admin td { padding: 8px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid #E9DEC6; }
.admin th { font-size: 12px; letter-spacing: .04em; color: #5A6280; }
.controls > .big:not(.round) { flex: 0 0 auto; width: 100%; }
.logout { margin: 4px 0 0; }
.link-btn {
  background: none; border: 0; padding: 8px 0; color: var(--muted); font-weight: 700;
  font-size: 14px; text-decoration: underline; min-height: 44px;
}
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin-top .logout { margin: 0; }
.level-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.level-links .cta { display: flex; align-items: center; justify-content: center; text-decoration: none; height: 48px; font-size: 15px; }

/* ---------- Naam, wie is er online ---------- */
.name-input {
  height: 48px; border: 0; border-radius: 12px; padding: 0 14px; margin-bottom: 4px;
  font: 700 16px var(--body); background: var(--cream); color: var(--navy);
}
.online {
  display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap;
  padding: 6px 16px 10px; font-size: 11px; font-weight: 700; color: var(--faint);
}
.online .dot {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 800; color: var(--navy);
}
.online .label { margin-left: 4px; }
.home .online { padding-top: 18px; }
.game .online { padding: 0 16px 6px; }
#name-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
#name-form label { font-weight: 800; font-size: 14px; letter-spacing: .04em; }
#name-form .link-btn { align-self: center; }
