/* ROV:ER — style.css: thema volgens docs/STYLE.md §6 (palet §1) */
:root {
  --bg: #0a0e0c;
  --floor: #161c18;
  --wall: #2e3630;
  --amber: #f5a623;
  --amber-hot: #ffb02e;
  --cyan: #35e0e6;
  --toxic: #7dff5e;
  --hud-bg: rgba(10,14,12,0.88);
  --batt-ok: #57e389;
  --batt-warn: #f5d020;
  --batt-low: #ff4a3d;
  --editor-bg: #0d1210;
  --editor-text: #c8e6d8;
  --editor-hl: rgba(53,224,230,0.14);
  --btn-bg: #1c2420;
  --btn-hover: #24332d;
  --txt: #d7e3dc;
  --txt-dim: #8fa39a;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font-ui);
  overflow: hidden;
}
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.hint { color: var(--txt-dim); font-size: 13px; }

.screen { position: fixed; inset: 0; }

:focus-visible { outline: 2px solid var(--amber-hot); outline-offset: 2px; } /* één focuskleur: oranje */

/* ---------- knoppen ---------- */
.btn {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: clamp(11px, 1.6vmin, 14px);
  min-height: clamp(34px, 5vmin, 44px);
  padding: 0.6em 1em;
  background: var(--btn-bg);
  color: var(--txt);
  border: 1px solid rgba(53,224,230,0.4);
  border-radius: 4px;
  cursor: pointer;
}
.btn:hover { background: var(--btn-hover); border-color: var(--cyan); box-shadow: 0 0 10px rgba(53,224,230,0.25); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--amber); color: var(--amber-hot); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 12px; }

/* ---------- intro / titel ---------- */
#screen-intro { display: flex; align-items: center; justify-content: center; }
/* NB: geen position:relative hier — .screen is position:fixed (ID-selector zou dat overrulen
   en het scherm uit de flow halen, waardoor de inhoud bovenin zou staan). De .credits hieronder
   is absolute en ankert vanzelf aan het fixed scherm. */
.intro-center { text-align: center; width: min(720px, 92vw); }

.credits {
  position: absolute;
  left: 0; right: 0;
  bottom: 3.5vh;
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--txt-dim);
  min-height: 1.5em;
  pointer-events: none;
  clip-path: inset(0 0 0 0);
}
/* menu-knop in het hoofdmenu — zelfde knop als in de game, rechtsonder */
.screen-menu-btn { position: absolute; right: 1.6vmin; bottom: 1.6vmin; z-index: 5; }

.title {
  font-size: clamp(48px, 12vw, 96px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--txt);
  text-shadow: 0 0 18px rgba(53,224,230,0.45);
  margin: 0;
  animation: fadein 1.2s ease-out;
  transition: font-size 0.4s ease;
}
.title .dp { font-size: 0.4em; vertical-align: middle; }
.title.small { font-size: 40px; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#subtitles { transition: opacity 0.3s ease, height 0.3s ease; overflow: hidden; }
#subtitles.collapse { opacity: 0; height: 0 !important; }
.subtitle { margin-top: 10px; }
.sub1 { text-transform: uppercase; letter-spacing: 0.35em; font-size: 14px; color: var(--txt-dim); }
.sub2 { letter-spacing: 0.2em; font-size: 14px; color: var(--amber); }

#intro-hint { margin-top: 48px; }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- save-slots ---------- */
#slots { margin-top: 28px; text-align: left; }
.slot {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #2a352e;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
}
.slot:hover { background: var(--btn-bg); border-color: var(--cyan); }
.slot-idx { font-family: var(--font-mono); color: var(--txt-dim); width: 18px; }
.slot-name {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  color: var(--txt);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 6px 4px;
}
.slot-name::placeholder { color: var(--txt-dim); font-style: italic; }
.slot-name:focus { outline: none; border-bottom-color: var(--amber-hot); color: var(--amber-hot); }
/* focus in het hoofdmenu = oranje rand + oranje tekst (zelfde focuskleur als in de game) */
#slots .btn:focus, #btn-menu-intro:focus { outline: none; border-color: var(--amber-hot); color: var(--amber-hot); }
.slot-btns { display: flex; gap: 10px; margin-top: 14px; justify-content: center; }

/* ---------- multiplayer paneel ---------- */
.mp-panel {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(680px, 94vw);
  max-height: 86vh; overflow: auto;
  background: var(--hud-bg);
  border: 1px solid #2a352e;
  border-radius: 8px;
  padding: 20px;
}
.mp-panel h3 { margin-top: 0; text-transform: uppercase; letter-spacing: 0.15em; }
.mp-panel textarea, .mp-panel input {
  width: 100%;
  background: var(--editor-bg);
  color: var(--editor-text);
  border: 1px solid #2a352e;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px;
  margin: 8px 0;
  min-height: 70px;
}
.mp-panel input { min-height: 40px; }
.mp-code { font-family: var(--font-mono); color: var(--amber-hot); font-size: 18px; margin: 8px 0; }
#mp-status { margin: 10px 0; min-height: 18px; }

/* ---------- story ---------- */
#screen-story { background: #000; display: flex; align-items: center; justify-content: center; }
#story-canvas { width: min(96vw, calc(96vh * 16 / 9)); height: auto; }
.story-sub {
  position: absolute; bottom: 8%; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.72);
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--txt);
  max-width: 80vw;
  text-align: center;
  border-radius: 4px;
  animation: subfade 0.4s ease-out;
}
@keyframes subfade { from { opacity: 0; } to { opacity: 1; } } /* alleen opacity: transform (translateX(-50%)) intact laten, anders springt de sub na de animatie */
.story-next { position: absolute; right: 2vw; bottom: 4.5vh; } /* zelfde knipper-hint als de titel, rechtsonder */

/* ---------- game layout (vmin-scaling; geen voordeel van een groter scherm) ---------- */
#screen-game { display: flex; height: 100vh; }
.game-left {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;   /* speelveld gecentreerd in de resterende ruimte */
  background: #050706;
}
#game-canvas {
  width: min(66vmin, 96vh);   /* speelveld max 66% van het kleinste scherm */
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid #1a201c;
}
#game-canvas:focus { outline: none; border-color: var(--amber-hot); box-shadow: 0 0 12px rgba(255,176,46,0.25); } /* speelveld gefocust -> oranje rand */
.toast {
  position: absolute; left: 1.5vmin; bottom: 1.5vmin;
  background: rgba(0,0,0,0.8);
  border-left: 3px solid var(--toxic);
  color: var(--txt);
  font-family: var(--font-mono);
  font-size: clamp(11px, 1.6vmin, 13px);
  padding: 0.6em 1em;
  border-radius: 4px;
}

.game-panel {
  width: 33vmin;               /* menu rechts = 33% van het kleinste scherm */
  min-width: 300px;
  max-width: 520px;
  height: 100vh;
  overflow-y: auto;
  background: var(--hud-bg);
  border-left: 1px solid #2a352e;
  padding: 1.2vmin;
  display: flex;
  flex-direction: column;
  gap: 1.2vmin;                /* 1 witregel tussen alle rijen (rond de joystick dus ook) */
  font-size: clamp(11px, 1.6vmin, 14px);
}
/* de reset-rij staat onderaan; er zit geen lege ruimte onder de knoppen */
.game-panel > .ed-row:last-child { margin-top: auto; }
/* focus in de zijbalk: oranje rand + oranje tekst op de knop zelf, geen extra gele outline */
.game-panel .btn:focus, .game-panel .jbtn:focus {
  outline: none;
  border-color: var(--amber-hot);
  color: var(--amber-hot);
}
/* missie-naam + level als overlay linksboven op het speelveld */
.hud-overlay {
  position: absolute; top: 1vmin; left: 1vmin; z-index: 3;
  display: flex; gap: 1.2vmin; flex-wrap: wrap;
  background: rgba(10,14,12,0.62);
  border: 1px solid #2a352e; border-radius: 4px;
  padding: 0.4vmin 0.8vmin;
  font-size: clamp(11px, 1.6vmin, 13px);
  pointer-events: none;
  color: var(--txt);
}
.hud-goal { font-size: clamp(11px, 1.6vmin, 13px); border: 1px solid #2a352e; border-radius: 4px; padding: 0.6em; background: rgba(0,0,0,0.3); }
.hud-batt { display: flex; align-items: center; gap: 0.8vmin; }
.batt-bar { flex: 1; height: 1.4vmin; min-height: 8px; background: #0d1210; border: 1px solid #2a352e; border-radius: 3px; overflow: hidden; }
#batt-fill { height: 100%; width: 100%; background: var(--batt-ok); transition: width 0.2s; }
.hud-inv { display: flex; gap: 0.6vmin; min-height: 2.6vmin; align-items: center; flex-wrap: wrap; }
.hud-inv:empty { display: none; }   /* lege inventory = geen lege regel onder de accu-indicator */
.inv-tile {
  display: inline-block; width: 2.6vmin; height: 2.6vmin; min-width: 20px; min-height: 20px; line-height: 2.4vmin; text-align: center;
  border-radius: 4px; font-family: var(--font-mono); font-weight: bold; font-size: clamp(10px, 1.6vmin, 13px);
  border: 1px solid; color: var(--dark);
}
.inv-B { background: #57e389; border-color: #57e389; }
.inv-G { background: #35e0e6; border-color: #35e0e6; }
.inv-P { background: #ff6b4a; border-color: #ff6b4a; }
.inv-K { background: #e8d44d; border-color: #e8d44d; }

/* ---------- editor ---------- */
.editor-wrap {
  position: relative;
  background: var(--editor-bg);
  border: 1px solid #2a352e;
  border-radius: 4px;
  height: clamp(180px, 44vmin, 460px);   /* groter code-venster (log weg, besturing compacter) */
  flex: 1 1 auto;              /* vangt de vrije ruimte op: joystick + reset-rij komen onderaan te staan */
  min-height: 140px;
  overflow: hidden;
}
/* code-veld heeft focus (de wrap zelf via cursortoetsen, of de textarea erin) -> oranje rand;
   de rec/max-knopjes in de hoek tellen NIET als focus van het code-veld */
.editor-wrap:focus, .editor-wrap:has(> #ed-ta:focus) {
  border-color: var(--amber-hot);
  outline: none;
}
#ed-hl, #ed-ta {
  position: absolute; inset: 0;
  margin: 0; padding: 0.8vmin; padding-right: 7.8vmin;   /* ruimte voor de rec/max knopjes rechtsboven */
  font-family: var(--font-mono);
  font-size: clamp(11px, 1.8vmin, 14px);
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
#ed-hl { color: var(--editor-text); pointer-events: none; z-index: 1; }
#ed-ta { background: transparent; color: transparent; caret-color: var(--cyan); resize: none; border: none; z-index: 2; padding-left: calc(0.8vmin + 2.4em); /* tekst uitlijnen met de gutter van #ed-hl .ln */ }
#ed-ta::selection { background: rgba(53,224,230,0.25); }
#ed-hl .ln { display: block; min-height: 1.5em; padding-left: 2.4em; position: relative; }
#ed-hl .no {
  position: absolute; left: 0; width: 1.8em; text-align: right;
  color: var(--txt-dim); user-select: none;
}
#ed-hl .ln.cur { background: var(--editor-hl); box-shadow: inset 3px 0 0 var(--cyan); }
#ed-hl .ln.err { background: rgba(255,74,61,0.15); box-shadow: inset 3px 0 0 var(--batt-low); }
#ed-hl .cmd { color: var(--cyan); }
#ed-hl .cmd.curcmd { background: rgba(255,176,46,0.30); color: var(--amber-hot); border-radius: 2px; box-shadow: 0 0 6px rgba(255,176,46,0.45); }   /* actief commando binnen de regel */
#ed-hl .num { color: var(--amber-hot); }
#ed-hl .cmt { color: var(--txt-dim); font-style: italic; }
/* kleine toggle-knopjes rechtsbovenin het code-venster */
.ed-tools { position: absolute; top: 0.4vmin; right: 0.4vmin; z-index: 3; display: flex; gap: 0.4vmin; }
.btn.ed-fab { min-height: 0; height: 3vmin; min-width: 3.2vmin; padding: 0 0.5vmin; font-size: clamp(10px, 1.6vmin, 13px); background: rgba(13,18,16,0.85); border-radius: 4px; }

.ed-row { display: flex; gap: 8px; align-items: center; padding: 2px; /* paar pixels ruimte rondom de knoppen-groep */ }
.ed-err { color: var(--batt-low); font-size: 12px; min-height: 16px; }
.ed-err:empty { display: none; }   /* lege error-regel = geen extra witruimte onder de knoppen-groep */

/* rec-knop actief / max-knop actief */
.btn.rec-on { border-color: var(--batt-low); color: var(--batt-low); box-shadow: 0 0 10px rgba(255,74,61,0.35); }
.btn.toggle-on { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(53,224,230,0.3); }

/* code-venster gemaximaliseerd (ed-max): doel dicht, accu als 2px lijn, knoppen half hoog, editor groter */
.game-panel.ed-max { gap: 0; }                 /* geen witregel boven/onder de joystick-knoppen */
.game-panel.ed-max #hud-goal { display: none; }
.game-panel.ed-max .batt-bar { height: 2px; min-height: 2px; border: none; border-radius: 1px; }
.game-panel.ed-max #batt-txt { display: none; }              /* accu = alleen de 2px lijn */
.game-panel.ed-max .btn { min-height: clamp(17px, 2.5vmin, 22px); padding: 0.3em 0.8em; }
.game-panel.ed-max .btn.ed-fab { height: 2.4vmin; min-width: 2.8vmin; padding: 0 0.4vmin; }
.game-panel.ed-max .jbtn { aspect-ratio: 2 / 1; }              /* joystick-knoppen half zo hoog */
.game-panel.ed-max .editor-wrap { height: clamp(260px, 66vmin, 680px); min-height: 240px; }

/* ---------- joystick (2 rijen van 3, onderaan het paneel) ---------- */
.controls-row { display: flex; gap: 1.4vmin; align-items: center; justify-content: center; flex-wrap: wrap; }
.joystick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);  /* 2 rijen van 3 knoppen */
  grid-auto-rows: 1fr;
  gap: 0.6vmin;
  width: 19vmin;
  min-width: 130px;
  max-width: 240px;
}
.jbtn {
  aspect-ratio: 1 / 1;
  font-size: clamp(13px, 2.6vmin, 22px);
  background: var(--btn-bg);
  color: var(--txt);
  border: 1px solid rgba(53,224,230,0.4);
  border-radius: 6px;
  cursor: pointer;
  touch-action: none;
}
.jbtn.down, .jbtn:active { background: var(--btn-hover); border-color: var(--cyan); }

/* ---------- overlay ---------- */
#overlay {
  position: fixed; inset: 0;
  background: rgba(4,8,6,0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.ov-card {
  background: var(--hud-bg);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  padding: 28px 36px;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 0 30px rgba(53,224,230,0.2);
}
.ov-card h2 { margin-top: 0; letter-spacing: 0.15em; color: var(--amber-hot); }
.ov-btns { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
/* pauze-menu: opties onder elkaar + volume-sliders */
.ov-menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin-top: 18px; min-width: 260px; }
.ov-menu .btn { width: 100%; }
/* focus in het pauze-menu = oranje tekst (en bij knoppen ook oranje rand; geen extra outline) */
.ov-menu button.ov-focus { border-color: var(--amber-hot); color: var(--amber-hot); }
.ov-row:has(input.ov-focus) span { color: var(--amber-hot); }
.ov-row { display: flex; align-items: center; gap: 10px; }
/* label van een slider-rij: zelfde tekststijl als de knoppen (.btn) */
.ov-row span {
  min-width: 70px; text-align: left;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: clamp(11px, 1.6vmin, 14px);
  color: var(--txt);
}
/* slider: één dun balkje (4px), appearance:none op input én thumb — anders tekent Chrome er 2 lijnen van */
.ov-row input[type="range"] {
  flex: 1; height: 12px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.ov-row input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--btn-bg); border-radius: 2px; }
.ov-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin-top: -4px; /* (track 4 - thumb 12)/2 -> thumb gecentreerd op de balk */
  border: none; border-radius: 50%; background: #fff;
}
.ov-row input[type="range"].ov-focus::-webkit-slider-runnable-track { background: var(--amber); }
.ov-row input[type="range"].ov-focus::-webkit-slider-thumb { background: var(--amber-hot); }
.ov-row input[type="range"]::-moz-range-track { height: 4px; background: var(--btn-bg); border-radius: 2px; }
.ov-row input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: #fff; }
.ov-row input[type="range"].ov-focus::-moz-range-track { background: var(--amber); }
.ov-row input[type="range"].ov-focus::-moz-range-thumb { background: var(--amber-hot); }

/* ---------- editor pagina ---------- */
body.editor { overflow: auto; }
.ed-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; background: var(--hud-bg); border-bottom: 1px solid #2a352e; position: sticky; top: 0; z-index: 10; }
.ed-toolbar .pal { display: flex; gap: 4px; }
.pal-btn {
  width: 36px; height: 36px;
  font-family: var(--font-mono); font-weight: bold;
  background: var(--btn-bg); color: var(--txt);
  border: 1px solid #2a352e; border-radius: 4px; cursor: pointer;
}
.pal-btn.sel { border-color: var(--amber-hot); color: var(--amber-hot); box-shadow: 0 0 8px rgba(255,176,46,0.4); }
#ed-canvas { display: block; margin: 12px auto; border: 1px solid #2a352e; cursor: crosshair; background: var(--bg); }
.ed-meta { width: min(900px, 94vw); margin: 0 auto 30px; display: flex; flex-direction: column; gap: 8px; }
.ed-meta input, .ed-meta textarea {
  background: var(--editor-bg); color: var(--editor-text);
  border: 1px solid #2a352e; border-radius: 4px;
  font-family: var(--font-mono); font-size: 13px; padding: 8px;
}
.ed-meta textarea { min-height: 90px; }

@media (prefers-reduced-motion: reduce) {
  .blink, .title { animation: none; }
  * { transition: none !important; }
}
