:root {
  --bg: #121829;
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
  --red: #e5322d;
  --green: #2fbf55;
  --yellow: #ffd34d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #070a12; color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none;
}
#app {
  position: relative; margin: 0 auto; height: 100dvh; max-width: 480px; overflow: hidden; background: var(--bg);
}
canvas#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top) + 8px) 16px 0; pointer-events: none; }
#hud .row { display: flex; align-items: center; gap: 8px; }
#hud button { pointer-events: auto; }
.round { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.18); font-size: 16px; display: grid; place-items: center; position: relative; }
.toggle.off { opacity: 0.6; background: rgba(255,255,255,0.06); }
.toggle.off::after { content: ""; position: absolute; width: 30px; height: 3px; background: var(--red); transform: rotate(-45deg); }
#strikes { display: flex; gap: 6px; margin-left: 4px; }
.led { width: 18px; height: 18px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.led.broken { background: var(--red); box-shadow: 0 0 8px var(--red); }
.spacer { flex: 1; }
.score { text-align: right; }
#score { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
#clock { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
#clock.low { color: var(--red); }
#level-label { color: var(--yellow); font-weight: 700; font-size: 12px; margin: 6px 0; }
.talk { gap: 10px !important; }
#portrait { width: 72px; height: 72px; border-radius: 50%; background: rgba(51,77,128,0.6); border: 2px solid rgba(255,255,255,0.8); object-fit: cover; transition: transform 0.18s; }
#portrait.pop { transform: scale(1.15) rotate(5deg); }
#bubble { flex: 1; background: rgba(255,255,255,0.95); color: #000; border-radius: 14px; padding: 10px; font-size: 15px; font-weight: 500; animation: bubble 0.3s; }
@keyframes bubble { from { transform: scale(0.85); opacity: 0; transform-origin: left; } }

/* Opdrachtkaart */
#card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(300px, 86%);
  background: rgba(30, 36, 56, 0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--yellow); border-radius: 22px; padding: 20px; text-align: center; pointer-events: none;
  animation: pop 0.25s;
}
#card img { width: 70px; height: 70px; object-fit: contain; }
#card h3 { margin: 8px 0 4px; }
#card-cost { color: var(--green); font-size: 14px; }
#card p { margin: 8px 0 0; font-size: 15px; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; } }

/* Eindscherm */
#end { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: grid; place-items: center; padding: 24px; }
#end .panel { background: rgba(30, 36, 56, 0.95); border-radius: 28px; padding: 28px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
#end-img { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; background: rgba(51,77,128,0.6); }
#end h2 { margin: 0; font-size: 34px; font-weight: 900; }
#end-score { font-size: 22px; font-weight: 800; }
.big { width: 100%; padding: 14px; border-radius: 16px; font-size: 20px; font-weight: 800; color: #fff; }
.big.red { background: var(--red); }
.big.green { background: var(--green); }
.link { background: none; color: var(--muted); padding: 6px; }

/* Menu */
#menu {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 20px);
  background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, transparent 22%, transparent 45%, rgba(0,0,0,0.92) 68%), url(img/title.jpg) center / cover, var(--bg);
}
.title { text-align: center; }
.title h1 { margin: 0; font-size: 40px; font-weight: 900; text-shadow: 0 0 12px rgba(255,0,0,0.8); animation: glow 1.1s ease-in-out infinite alternate; }
@keyframes glow { to { transform: scale(1.04); text-shadow: 0 0 20px rgba(255,0,0,0.9); } }
.sub { font-weight: 600; color: rgba(255,255,255,0.85); }
.quote { text-align: center; font-style: italic; color: rgba(255,255,255,0.85); }
#level-name { font-weight: 700; }
#levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
#levels button { height: 42px; border-radius: 10px; background: rgba(255,255,255,0.15); font-weight: 700; }
#levels button.sel { background: var(--red); }
#levels button:disabled { background: rgba(255,255,255,0.05); color: var(--muted); cursor: default; }
.seg { display: flex; background: rgba(255,255,255,0.12); border-radius: 9px; padding: 2px; }
.seg button { flex: 1; padding: 7px 4px; border-radius: 7px; background: none; font-size: 14px; font-weight: 600; }
.seg button.sel { background: rgba(255,255,255,0.3); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 15px; }
.toggles input { accent-color: var(--green); width: 18px; height: 18px; vertical-align: -3px; }
#highscore { color: var(--muted); font-variant-numeric: tabular-nums; }
