:root {
  --hud-h: 62px;
  --ui-bg: #1b1430;
  --ui-btn: #2c2154;
  --ui-btn2: #221a44;
  --ui-line: #4b3c86;
  --ui-hi: #ffd84a;
  --ui-txt: #fff6dc;
  --ok: #7be06a;
  --bad: #ff6b6b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed; inset: 0;
  font-family: 'Press Start 2P', ui-monospace, Menlo, monospace;
  color: var(--ui-txt);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }

#app {
  position: absolute; inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex; flex-direction: column; background: #0b0820;
}
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- info bovenin ---------- */
#info {
  position: absolute; left: 6px; top: 6px; display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 9px; line-height: 1.4; pointer-events: none;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000;
  max-width: calc(100% - 150px);
}
#info b { color: var(--ui-hi); font-weight: normal; }
#info b.ok { color: var(--ok); }
#i-skill { color: var(--ui-hi); min-width: 6.5em; }
#i-time.low { color: var(--bad); }
#mini {
  position: absolute; right: 6px; top: 6px; width: 130px; height: 48px;
  border: 2px solid var(--ui-line); border-radius: 4px; touch-action: none;
}
#toast {
  position: absolute; left: 50%; top: 30px; transform: translateX(-50%);
  background: rgba(27, 20, 48, 0.92); border: 2px solid var(--ui-hi); border-radius: 8px;
  padding: 8px 12px; font-size: 9px; line-height: 1.6; max-width: 80%; text-align: center;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
#toast.on { opacity: 1; }

/* ---------- knoppenbalk ---------- */
#hud {
  height: var(--hud-h); flex: none; display: flex; gap: 3px; padding: 3px 4px;
  background: var(--ui-bg); border-top: 2px solid var(--ui-line);
}
#hud-skills { display: contents; }
.hb {
  flex: 1 1 0; min-width: 0; max-width: 76px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: linear-gradient(var(--ui-btn), var(--ui-btn2)); border: 2px solid var(--ui-line); border-radius: 8px;
  padding: 0; touch-action: none;
}
.hb canvas { width: 27px; height: 30px; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
.hb .n { font-size: 9px; min-height: 9px; pointer-events: none; }
.hb .sym { font-size: 16px; line-height: 1; pointer-events: none; }
.hb.sel { border-color: var(--ui-hi); background: linear-gradient(#5a4a1a, #3a2e10); box-shadow: 0 0 0 1px var(--ui-hi) inset; }
.hb.empty canvas { opacity: .35; }
.hb:active { transform: translateY(1px); }
#b-nuke.arm { border-color: var(--bad); background: linear-gradient(#6a1f2a, #3a1018); }

/* ---------- schermen ---------- */
.screen {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(10, 6, 30, 0.6); padding: 10px;
}
.screen.on { display: flex; }
#s-title { background: rgba(10, 6, 30, 0.25); }
.card {
  background: var(--ui-bg); border: 3px solid var(--ui-hi); border-radius: 12px;
  padding: 14px 18px; max-width: 560px; max-height: 100%; overflow: auto; text-align: center;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .5); touch-action: pan-y;
}
.card.wide { max-width: 760px; width: 100%; }
.title-card { background: rgba(27, 20, 48, 0.88); }
h1.logo {
  margin: 4px 0 10px; font-size: clamp(28px, 10vh, 54px); color: var(--ui-hi); letter-spacing: 2px;
  text-shadow: 3px 3px 0 #e3501c, 6px 6px 0 #000;
}
h2 { margin: 2px 0 10px; font-size: 13px; color: var(--ui-hi); line-height: 1.5; }
p { font-size: 10px; line-height: 1.7; margin: 8px 0; }
p.sub { font-size: 11px; }
p.small { font-size: 8px; opacity: .8; }
p.hint { color: #ffe9a8; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 220px; }
.big {
  font-size: 12px; padding: 11px 16px; background: var(--ui-hi); color: #2a1a00;
  border: none; border-radius: 8px; box-shadow: 0 4px 0 #b0801a;
}
.big.alt { background: #3a2d6b; color: var(--ui-txt); box-shadow: 0 4px 0 #120c28; }
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #b0801a; }

#lv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.tile {
  background: linear-gradient(var(--ui-btn), var(--ui-btn2)); border: 2px solid var(--ui-line); border-radius: 8px;
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 76px;
}
.tile .num { font-size: 16px; color: var(--ui-hi); }
.tile .nm { font-size: 7px; line-height: 1.4; }
.tile .bs { font-size: 7px; opacity: .8; }
.tile.done { border-color: var(--ok); }
.tile.done .bs { color: var(--ok); opacity: 1; }
.tile.locked { opacity: .4; }

#in-skills { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin: 8px 0; }
.isk { display: flex; align-items: center; gap: 6px; font-size: 8px; }
.isk canvas { width: 27px; height: 30px; image-rendering: pixelated; }

#rs-bar { position: relative; height: 16px; background: #0b0820; border: 2px solid var(--ui-line); border-radius: 4px; margin: 6px 0 4px; }
#rs-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bad); width: 0; transition: width .8s; }
#rs-fill.ok { background: var(--ok); }
#rs-need { position: absolute; top: -5px; bottom: -5px; width: 3px; background: var(--ui-hi); margin-left: -1px; }

/* HUD en info alleen tijdens een level */
body[data-mode="title"] #hud, body[data-mode="levels"] #hud,
body[data-mode="title"] #info, body[data-mode="levels"] #info,
body[data-mode="title"] #mini, body[data-mode="levels"] #mini { display: none; }

#rotate {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  background: var(--ui-bg); z-index: 10; padding: 20px;
}
#rotate .rot-ico { font-size: 54px; color: var(--ui-hi); margin-bottom: 12px; font-family: system-ui, sans-serif; }
#rotate p { font-size: 11px; }
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: flex; } }

@media (max-height: 340px) {
  :root { --hud-h: 54px; }
  .hb canvas { width: 22px; height: 24px; }
  h1.logo { margin-bottom: 4px; }
  .card { padding: 10px 14px; }
  .tile { min-height: 62px; padding: 6px 3px; }
}
