/* ═══════════════════════════════════════════════════════════
   OERSOEP — bioluminescent diepzee-laboratorium
   display: Bricolage Grotesque · data: IBM Plex Mono
   ═══════════════════════════════════════════════════════════ */

:root {
  --abyss: #03141a;
  --abyss-diep: #010a0e;
  --paneel: rgba(5, 26, 32, 0.78);
  --paneel-rand: rgba(94, 255, 200, 0.16);
  --inkt: #d8f2e8;
  --inkt-zacht: rgba(216, 242, 232, 0.55);
  --bio: #45ffc7;
  --bio-dim: rgba(69, 255, 199, 0.35);
  --warm: #ffc14d;
  --gevaar: #ff4d7e;
  --glucose: #ffd970;
  --ammonia: #c79bff;
  --fosfaat: #6db4ff;
  --font-display: "Bricolage Grotesque", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  color: var(--inkt);
  font-family: var(--font-mono);
  font-size: 14px;
}

html { background: var(--abyss-diep); }

/* zwakke GPU (auto-kwaliteit op laag): dure backdrop-blur uit, solide panelen i.p.v. */
.perf-laag .paneel,
.perf-laag .hud-paneel {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(5, 26, 32, 0.94);
}
/* body MOET transparant blijven: een eigen achtergrond zou over de
   negatieve z-index-lagen (#achtergrond/#stralen/#gloed) heen schilderen */
body { background: transparent; }

#spel-canvas {
  position: fixed;
  inset: 0;
  display: block;
  z-index: 1;
}

/* ─── verre achtergrondlagen: statisch of traag, GPU-gecomposit ─── */
#achtergrond {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: linear-gradient(180deg, #0b3b40, #062227);
}

#stralen {
  position: fixed;
  inset: -14% -8%;
  z-index: -2;
  --straal-k: rgba(255, 243, 196, 0.07);
  background:
    repeating-linear-gradient(104deg, transparent 0px, transparent 190px, var(--straal-k) 280px, transparent 370px),
    repeating-linear-gradient(96deg, transparent 0px, transparent 260px, var(--straal-k) 350px, transparent 500px);
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 72%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 72%);
  animation: stralen-drift 80s ease-in-out infinite alternate;
  pointer-events: none;
  transition: opacity 1.2s;
}
@keyframes stralen-drift {
  from { transform: translateX(-1.2%); }
  to { transform: translateX(1.2%); }
}
@media (prefers-reduced-motion: reduce) {
  #stralen { animation: none; }
}

#gloed {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(70% 55% at 50% 112%, rgba(255, 94, 46, 0.20), transparent 70%);
  opacity: 0;
  transition: opacity 1.2s;
  pointer-events: none;
}

#vignet {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.48) 100%);
  pointer-events: none;
}

/* ─── touch: virtuele joystick ─── */
body.touch { touch-action: none; }
body.touch #spel-canvas { touch-action: none; }
#joy-base {
  position: fixed;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  border-radius: 50%;
  border: 2px solid rgba(69, 255, 199, 0.4);
  background: radial-gradient(circle, rgba(69, 255, 199, 0.10), rgba(69, 255, 199, 0.02));
  z-index: 9;
  pointer-events: none;
  display: none;
  box-shadow: 0 0 30px rgba(69, 255, 199, 0.2);
}
#joy-base.zichtbaar { display: block; }
#joy-thumb {
  position: fixed;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(69, 255, 199, 0.55), rgba(69, 255, 199, 0.25));
  border: 2px solid var(--bio);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 22px rgba(69, 255, 199, 0.4);
}
#joy-base:not(.zichtbaar) #joy-thumb { display: none; }

/* remove-mode knop op het editor-rooster */
.grid-knop {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--paneel-rand);
  background: rgba(5, 26, 32, 0.8);
  color: var(--inkt-zacht);
  transition: all 0.18s;
}
.grid-knop:hover { color: var(--inkt); border-color: var(--bio-dim); }
.grid-knop.actief {
  color: var(--gevaar);
  border-color: rgba(255, 77, 126, 0.6);
  background: rgba(255, 77, 126, 0.12);
}
.rooster-houder.verwijder-modus { box-shadow: inset 0 0 0 2px rgba(255, 77, 126, 0.3); }
.rooster-houder.verwijder-modus canvas { cursor: not-allowed; }

/* grotere raakdoelen op touch */
body.touch .grid-knop { font-size: 14px; padding: 12px 18px; }
body.touch .organel-kaart { padding: 12px 4px; }
body.touch .editor-tab { padding: 13px 18px; }
body.touch #btn-deel { padding: 18px 42px; }

button { font-family: inherit; cursor: pointer; }

h1, h2, h3 { font-family: var(--font-display); }

/* ─── panelen: glazen meetinstrumenten ─── */
.paneel {
  background: var(--paneel);
  border: 1px solid var(--paneel-rand);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 18px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(216, 242, 232, 0.06);
}

/* ─── knoppen ─── */
.knop {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 13px 26px;
  border-radius: 9px;
  border: 1px solid var(--paneel-rand);
  background: rgba(69, 255, 199, 0.05);
  color: var(--inkt);
  transition: all 0.22s ease;
}
.knop:hover {
  border-color: var(--bio-dim);
  background: rgba(69, 255, 199, 0.12);
  box-shadow: 0 0 24px rgba(69, 255, 199, 0.15);
  transform: translateY(-1px);
}
.knop.primair {
  border-color: var(--bio-dim);
  background: linear-gradient(180deg, rgba(69, 255, 199, 0.18), rgba(69, 255, 199, 0.08));
  color: var(--bio);
  font-weight: 600;
}
.knop.primair:hover {
  box-shadow: 0 0 34px rgba(69, 255, 199, 0.3);
  background: linear-gradient(180deg, rgba(69, 255, 199, 0.28), rgba(69, 255, 199, 0.12));
}
.knop.subtiel { border-color: transparent; color: var(--inkt-zacht); background: none; }
.knop.subtiel:hover { color: var(--inkt); box-shadow: none; }
.knop.groot { font-size: 15px; padding: 16px 38px; }
.knop.mini { font-size: 11px; padding: 7px 12px; }

.klein { font-size: 12px; color: var(--inkt-zacht); line-height: 1.7; }

/* ─── overlays ─── */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.overlay.open { display: flex; }
.overlay.modal { background: rgba(1, 8, 11, 0.65); backdrop-filter: blur(6px); z-index: 40; }

/* ─── titelscherm ─── */
#titel { flex-direction: column; pointer-events: none; }
#titel.open ~ * { }
.titel-inhoud { text-align: center; pointer-events: auto; padding: 24px; }

.titel-boven {
  font-size: 12px;
  letter-spacing: 0.5em;
  color: var(--bio);
  opacity: 0.8;
}

#titel h1 {
  font-size: clamp(54px, 10vw, 124px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 18px 0 10px;
  color: var(--inkt);
  text-shadow: 0 0 60px rgba(69, 255, 199, 0.35);
}
#titel h1 span {
  background: linear-gradient(120deg, var(--bio) 20%, #6db4ff 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(69, 255, 199, 0.45));
}

.titel-onder {
  font-size: 15px;
  line-height: 1.8;
  color: var(--inkt-zacht);
  margin-bottom: 38px;
}

.titel-knoppen {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.titel-credit {
  margin-top: 46px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(216, 242, 232, 0.35);
}
.titel-credit strong { color: rgba(216, 242, 232, 0.6); }

/* gefaseerde onthulling */
.reveal { opacity: 0; transform: translateY(18px); animation: onthul 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
}
.r1 { animation-delay: 0.15s; }
.r2 { animation-delay: 0.35s; }
.r3 { animation-delay: 0.6s; }
.r4 { animation-delay: 0.85s; }
.r5 { animation-delay: 1.15s; }
@keyframes onthul { to { opacity: 1; transform: none; } }

/* ─── moeilijkheidskiezer ─── */
.diff-paneel {
  max-width: 720px;
  margin: 24px;
  padding: 36px 40px;
  text-align: center;
}
.diff-paneel h2 { font-size: 28px; color: var(--bio); margin-bottom: 8px; }
.diff-paneel > .klein { margin-bottom: 22px; }
.diff-rij {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.diff-kaart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 18px;
  border-radius: 12px;
  border: 1px solid var(--paneel-rand);
  background: rgba(216, 242, 232, 0.025);
  color: var(--inkt);
  text-align: center;
  transition: all 0.2s;
  position: relative;
}
.diff-kaart:hover {
  border-color: var(--bio-dim);
  background: rgba(69, 255, 199, 0.08);
  transform: translateY(-3px);
  box-shadow: 0 0 28px rgba(69, 255, 199, 0.15);
}
.diff-kaart.aanbevolen { border-color: var(--bio-dim); background: rgba(69, 255, 199, 0.06); }
.diff-badge {
  position: absolute;
  top: -9px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--bio);
  color: #03141a;
  font-weight: 600;
}
.diff-naam { font-family: var(--font-display); font-size: 21px; font-weight: 700; }
.diff-tag { font-size: 11.5px; line-height: 1.55; color: var(--inkt-zacht); }

@media (max-width: 680px) {
  .diff-rij { grid-template-columns: 1fr; }
}

/* ─── over-paneel ─── */
.over-paneel {
  max-width: 560px;
  margin: 24px;
  padding: 36px 40px;
}
.over-paneel h2 { font-size: 30px; margin-bottom: 16px; color: var(--bio); }
.over-paneel h3 { font-size: 17px; margin: 20px 0 6px; }
.over-paneel p { line-height: 1.75; margin-bottom: 12px; font-size: 13px; }
.over-paneel .knop { margin-top: 16px; }

/* ─── Codex / wiki ─── */
#wiki { z-index: 45; padding: 0; background: rgba(1, 8, 11, 0.78); }
#wiki.open { display: flex; }
.wiki-raam {
  width: 100%; height: 100%;
  border-radius: 0; border: none;
  display: flex; flex-direction: column; overflow: hidden;
}
.wiki-kop {
  display: flex; align-items: center; gap: 20px;
  padding: 16px 26px; border-bottom: 1px solid var(--paneel-rand);
  flex-wrap: wrap;
}
.wiki-kop h2 { font-size: 22px; letter-spacing: 0.06em; color: var(--bio); }
.wiki-cats { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.wiki-cat {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 9px 16px; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--inkt-zacht); transition: all 0.18s;
}
.wiki-cat:hover { color: var(--inkt); }
.wiki-cat.actief { color: var(--bio); border-color: var(--bio-dim); background: rgba(69, 255, 199, 0.08); }
.wiki-knop { color: var(--glucose) !important; margin-left: auto; }
.wiki-inhoud {
  flex: 1; overflow-y: auto; padding: 24px 30px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; align-content: start;
}
.wiki-kaart {
  border: 1px solid var(--paneel-rand); border-radius: 14px;
  padding: 18px; background: rgba(216, 242, 232, 0.02);
}
.wiki-kaart h4 { font-family: var(--font-display); font-size: 17px; margin-bottom: 4px; }
.wiki-tag { font-family: var(--font-mono); font-size: 10.5px; color: var(--warm); letter-spacing: 0.04em; margin-bottom: 10px !important; }
.wiki-kaart p { font-size: 12.5px; line-height: 1.6; color: var(--inkt-zacht); margin-bottom: 8px; }
.wiki-proc { color: var(--inkt) !important; font-size: 12px !important; }

/* organel-kaart: glyph bovenaan, weinig tekst, rest inklapbaar */
.wiki-org { text-align: center; display: flex; flex-direction: column; align-items: center; }
.wiki-glyph {
  width: 96px; height: 96px; margin-bottom: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--glow) 14%, transparent), transparent 70%);
}
.wiki-org h4 { margin-bottom: 2px; }
.wiki-org .wiki-proc { margin: 4px 0 10px; }
.wiki-meer { width: 100%; text-align: left; margin-top: auto; }
.wiki-meer summary {
  cursor: pointer; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--bio); padding: 6px 0; list-style: none; user-select: none;
}
.wiki-meer summary::-webkit-details-marker { display: none; }
.wiki-meer summary::before { content: '＋ '; opacity: 0.7; }
.wiki-meer[open] summary::before { content: '－ '; }
.wiki-meer[open] summary { opacity: 0.7; }
.wiki-meer p { margin-top: 6px; }

.wiki-bio { margin-bottom: 0 !important; }
.wiki-bio span { display: inline-block; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bio); margin-right: 6px; }
.wiki-dim { color: var(--inkt-zacht); opacity: 0.5; }
.wiki-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 8px currentColor; display: inline-block; }
.wiki-note { grid-column: 1 / -1; font-size: 12px; color: var(--inkt-zacht); font-style: italic; padding: 4px 4px 0; }

/* patch-thumbnail: brede afgeronde banner i.p.v. ronde glyph */
.wiki-thumb { width: 150px !important; height: 96px !important; border-radius: 12px; background: none !important; }

/* lessen-hub */
.les-intro { grid-column: 1 / -1; font-size: 13px; color: var(--inkt-zacht); margin-bottom: 4px; }
.les-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.les-kaart { text-align: center; display: flex; flex-direction: column; align-items: center; min-height: 170px; }
.les-slot {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 10px;
  background: radial-gradient(circle, color-mix(in srgb, var(--glow, #5e7) 16%, transparent), transparent 70%);
}
.les-kaart h4 { font-family: var(--font-display); font-size: 17px; margin-bottom: 6px; }
.les-teaser { font-size: 12.5px; color: var(--inkt-zacht); line-height: 1.55; margin-bottom: 10px; }
.les-hint { font-size: 11.5px; color: var(--warm); margin-bottom: 0; }
.les-actie { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bio); margin-top: auto; margin-bottom: 0; }
.les-kaart.ontgrendeld { cursor: pointer; transition: all 0.18s; }
.les-kaart.ontgrendeld:hover { border-color: var(--bio-dim); transform: translateY(-3px); box-shadow: 0 0 26px rgba(69, 255, 199, 0.14); }
.les-kaart.vergrendeld { opacity: 0.5; }
.les-kaart.vergrendeld .les-slot { background: rgba(216, 242, 232, 0.05); filter: grayscale(1); }
.les-kaart.binnenkort { opacity: 0.8; }
.les-kaart.binnenkort .les-actie { color: var(--inkt-zacht); }

.les-terug {
  background: none; border: 1px solid var(--paneel-rand); border-radius: 8px;
  color: var(--inkt-zacht); font-family: var(--font-mono); font-size: 12px;
  padding: 8px 14px; margin-bottom: 18px; cursor: pointer; transition: all 0.18s;
}
.les-terug:hover { color: var(--inkt); border-color: var(--bio-dim); }

/* sim-keuzeknoppen (selectie + endosymbiose) */
.sel-knop, .endo-knop { font-size: 12px; padding: 9px 14px; }
.sel-knop.actief { border-color: var(--bio-dim); background: rgba(69, 255, 199, 0.12); color: var(--bio); }
.endo-knop[data-keuze="digest"].actief { border-color: rgba(255, 157, 92, 0.6); background: rgba(255, 157, 92, 0.14); color: #ff9d5c; }
.endo-knop[data-keuze="keep"].actief { border-color: var(--bio-dim); background: rgba(69, 255, 199, 0.12); color: var(--bio); }
#foto-dag-r.actief, #foto-dag-c.actief { border-color: rgba(109, 180, 255, 0.5); background: rgba(40, 60, 110, 0.3); color: #9fb8d4; }

/* size-sim schuifregelaar */
.ent-slider { -webkit-appearance: none; appearance: none; width: 220px; height: 6px; border-radius: 4px; background: rgba(216, 242, 232, 0.15); outline: none; cursor: pointer; }
.ent-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--bio); box-shadow: 0 0 12px rgba(69, 255, 199, 0.5); cursor: pointer; }
.ent-slider::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--bio); box-shadow: 0 0 12px rgba(69, 255, 199, 0.5); cursor: pointer; }

/* lesson-unlock toast */
#lesson-toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(24px);
  z-index: 60; pointer-events: none; opacity: 0; transition: all 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
  background: var(--paneel); border: 1px solid var(--bio-dim); border-radius: 12px;
  padding: 14px 26px; text-align: center; font-size: 13px; color: var(--inkt-zacht);
  backdrop-filter: blur(14px); box-shadow: 0 0 34px rgba(69, 255, 199, 0.25);
}
#lesson-toast.zichtbaar { opacity: 1; transform: translateX(-50%) translateY(0); }
#lesson-toast strong { color: var(--bio); font-size: 15px; }

/* entropie-artikel: één scrollkolom i.p.v. grid */
.wiki-inhoud.wiki-artikel { display: block; }
.ent-wrap { max-width: 720px; margin: 0 auto; padding-bottom: 40px; }
.ent-titel { font-family: var(--font-display); font-size: 34px; font-weight: 800; color: var(--bio); margin-bottom: 14px; letter-spacing: -0.01em; }
.ent-lead { font-size: 15px; line-height: 1.8; color: var(--inkt); margin-bottom: 8px; }
.ent-lead b { color: var(--bio); font-weight: 600; }
.ent-sec { margin-top: 34px; }
.ent-sec h3 { font-family: var(--font-display); font-size: 21px; color: var(--inkt); margin-bottom: 10px; }
.ent-sec p { font-size: 13.5px; line-height: 1.8; color: var(--inkt-zacht); margin-bottom: 12px; }
.ent-sec p b { color: var(--inkt); }
.ent-sim { border: 1px solid var(--paneel-rand); border-radius: 12px; overflow: hidden; background: rgba(3, 20, 26, 0.6); margin: 14px 0 8px; }
.ent-sim canvas { display: block; width: 100%; height: auto; }
.ent-knoppen { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border-top: 1px solid var(--paneel-rand); }
.ent-readout { font-family: var(--font-mono); font-size: 12px; color: var(--inkt-zacht); font-variant-numeric: tabular-nums; }
.ent-cap { font-size: 12px !important; color: var(--inkt-zacht) !important; font-style: italic; }

/* mechanica: nette inklapbare lijst i.p.v. tekstmuur */
.wiki-mech { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.wiki-mech-item { border: 1px solid var(--paneel-rand); border-radius: 10px; background: rgba(216, 242, 232, 0.02); }
.wiki-mech-item summary {
  cursor: pointer; padding: 14px 18px; font-family: var(--font-display); font-size: 15px;
  color: var(--inkt); list-style: none; user-select: none;
}
.wiki-mech-item summary::-webkit-details-marker { display: none; }
.wiki-mech-item summary::after { content: '▾'; float: right; color: var(--bio); transition: transform 0.2s; }
.wiki-mech-item[open] summary::after { transform: rotate(180deg); }
.wiki-mech-item p { padding: 0 18px 16px; font-size: 13px; line-height: 1.7; }

/* ─── HUD ─── */
#hud { display: none; }
#hud.zichtbaar { display: block; }

.hud-hoek { position: fixed; z-index: 10; }
.links-boven { top: calc(18px + env(safe-area-inset-top)); left: calc(18px + env(safe-area-inset-left)); }
.rechts-boven { top: calc(18px + env(safe-area-inset-top)); right: calc(18px + env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.hud-paneel { padding: 14px 18px; min-width: 280px; }

.hud-kop {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
#soort-label { color: var(--bio); font-style: italic; }
.tag {
  font-size: 10px;
  padding: 3px 8px;
  border: 1px solid var(--paneel-rand);
  border-radius: 5px;
  color: var(--inkt-zacht);
  letter-spacing: 0.1em;
}

.balk-rij {
  display: grid;
  grid-template-columns: 52px 1fr 44px;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
}
.balk-rij label { font-size: 10px; letter-spacing: 0.12em; color: var(--inkt-zacht); }
.balk-getal { font-size: 11px; text-align: right; color: var(--inkt-zacht); font-variant-numeric: tabular-nums; }

.balk {
  height: 7px;
  background: rgba(216, 242, 232, 0.07);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.balk i {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease;
  box-shadow: 0 0 10px currentColor;
}
.balk.hp i { background: #7be0a0; color: #7be0a0; }
.balk.atp i { background: var(--warm); color: var(--warm); }
.balk.glucose i { background: var(--glucose); color: var(--glucose); }
.balk.ammonia i { background: var(--ammonia); color: var(--ammonia); }
.balk.fosfaat i { background: var(--fosfaat); color: var(--fosfaat); }
.balk.deling i { background: var(--bio); color: var(--bio); }
.balk.toxine i { background: #a6e22e; color: #a6e22e; }
.balk.mp i { background: var(--bio); color: var(--bio); }

.deling-rij { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--paneel-rand); }

.kolonie-tag { color: var(--glucose); border-color: rgba(255, 217, 112, 0.4); }

/* tik om het HUD-paneel in/uit te klappen */
.hud-paneel { cursor: pointer; transition: min-width 0.2s ease; }
.hud-chevron { margin-left: auto; color: var(--inkt-zacht); font-size: 11px; transition: transform 0.25s ease; }
.hud-paneel.compact { min-width: 0; }
.hud-paneel.compact .secundair { display: none !important; }
.hud-paneel.compact .hud-chevron { transform: rotate(-90deg); }

#deling-klaar { display: flex; flex-direction: column; gap: 10px; align-items: center; }
#btn-kolonie { border-color: rgba(255, 217, 112, 0.5); color: var(--glucose); background: rgba(255, 217, 112, 0.08); }
#btn-kolonie:hover { background: rgba(255, 217, 112, 0.16); box-shadow: 0 0 24px rgba(255, 217, 112, 0.2); }

#atp-rij.kritiek label,
#atp-rij.kritiek .balk-getal { color: var(--gevaar); }
#atp-rij.kritiek .balk i { background: var(--gevaar); animation: knipper 0.7s infinite alternate; }
@keyframes knipper { from { opacity: 1; } to { opacity: 0.4; } }

.patch-paneel {
  padding: 12px 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
#patch-label { font-size: 14px; font-weight: 600; letter-spacing: 0.2em; color: var(--bio); }
.dag-label { margin-top: 3px; color: var(--inkt); letter-spacing: 0.04em; }

#deling-klaar {
  position: fixed;
  bottom: calc(42px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  z-index: 12;
}
#deling-klaar.zichtbaar {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  animation: zweef 2.2s ease-in-out infinite alternate;
}
@keyframes zweef { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-7px); } }

#btn-engulf, #btn-toxine {
  position: fixed;
  right: 28px;
  z-index: 12;
  font-size: 13px;
  padding: 13px 20px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#btn-engulf { bottom: calc(42px + env(safe-area-inset-bottom)); }
#btn-toxine { bottom: calc(92px + env(safe-area-inset-bottom)); }
#btn-engulf small, #btn-toxine small { font-size: 9px; opacity: 0.6; letter-spacing: 0.04em; }
#btn-engulf.actief {
  color: var(--warm);
  border-color: rgba(255, 157, 92, 0.6);
  background: rgba(255, 157, 92, 0.15);
  box-shadow: 0 0 22px rgba(255, 157, 92, 0.3);
}
#btn-toxine.actief {
  color: #a6e22e;
  border-color: rgba(166, 226, 46, 0.6);
  background: rgba(166, 226, 46, 0.15);
  box-shadow: 0 0 22px rgba(166, 226, 46, 0.3);
}

#hint {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 480px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--inkt);
  background: var(--paneel);
  border: 1px solid var(--paneel-rand);
  border-radius: 10px;
  padding: 12px 22px;
  opacity: 0;
  transition: opacity 0.6s;
  z-index: 11;
  backdrop-filter: blur(10px);
}
#hint.zichtbaar { opacity: 1; }

/* ─── dood ─── */
.dood-paneel {
  max-width: 480px;
  margin: 24px;
  padding: 44px 48px;
  text-align: center;
  border-color: rgba(255, 77, 126, 0.3);
}
.dood-paneel h2 {
  font-size: 34px;
  font-weight: 800;
  color: var(--gevaar);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
  text-shadow: 0 0 40px rgba(255, 77, 126, 0.4);
}
.dood-oorzaak { font-size: 14px; margin-bottom: 10px; }
.dood-paneel .titel-knoppen { margin-top: 26px; }

/* ─── editor: volledig scherm ─── */
#editor { z-index: 30; padding: 0; background: rgba(1, 8, 11, 0.62); }
#editor.open { display: flex; }

.editor-raam {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-kop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--paneel-rand);
  flex-wrap: wrap;
}
.editor-kop h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--bio);
}

.editor-tabs { display: flex; gap: 6px; }
.editor-tab {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  color: var(--inkt-zacht);
  transition: all 0.2s;
}
.editor-tab:hover { color: var(--inkt); }
.editor-tab.actief {
  color: var(--bio);
  border-color: var(--bio-dim);
  background: rgba(69, 255, 199, 0.08);
}

.mp-blok { text-align: right; min-width: 150px; }
.mp-teller { font-size: 22px; font-weight: 600; color: var(--bio); line-height: 1.1; }
.mp-teller span { font-size: 12px; color: var(--inkt-zacht); }
.mp-blok .balk { margin-top: 5px; }

.editor-paneel { display: none; flex: 1; min-height: 0; overflow: hidden; }
.editor-paneel.zichtbaar { display: flex; }

.editor-voet {
  padding: 14px 26px;
  border-top: 1px solid var(--paneel-rand);
  display: flex;
  justify-content: flex-end;
}

/* — cel bouwen — */
.editor-grid {
  display: grid;
  grid-template-columns: 330px 1fr 300px;
  gap: 0;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.palet-kolom, .stats-kolom {
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
}
.palet-kolom { border-right: 1px solid var(--paneel-rand); }
.stats-kolom { border-left: 1px solid var(--paneel-rand); }

.palet-kolom h3, .stats-kolom h3 {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--inkt-zacht);
  margin: 6px 0 12px;
  font-family: var(--font-mono);
  font-weight: 500;
}
.palet-kolom h3:not(:first-child) { margin-top: 22px; }

#organel-palet {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.organel-kaart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  border-radius: 9px;
  border: 1px solid var(--paneel-rand);
  background: rgba(216, 242, 232, 0.025);
  color: var(--inkt);
  transition: all 0.18s;
  position: relative;
}
.organel-kaart:hover { border-color: var(--bio-dim); background: rgba(69, 255, 199, 0.07); }
.organel-kaart.geselecteerd {
  border-color: var(--bio);
  background: rgba(69, 255, 199, 0.13);
  box-shadow: 0 0 18px rgba(69, 255, 199, 0.2);
}
.organel-kaart.uit { opacity: 0.32; }
.ok-naam { font-size: 9.5px; text-align: center; line-height: 1.25; }
.ok-mp { font-size: 9px; color: var(--warm); letter-spacing: 0.05em; }
.ok-slot { font-size: 8.5px; color: var(--gevaar); }

.membraan-kaart {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  margin-bottom: 8px;
  border-radius: 9px;
  border: 1px solid var(--paneel-rand);
  background: rgba(216, 242, 232, 0.025);
  color: var(--inkt);
  transition: all 0.18s;
}
.membraan-kaart:hover { border-color: var(--bio-dim); }
.membraan-kaart.geselecteerd {
  border-color: var(--bio);
  background: rgba(69, 255, 199, 0.1);
}
.membraan-kaart strong { font-size: 12.5px; }
.mk-stats { font-size: 10px; color: var(--warm); }
.mk-uitleg { font-size: 10.5px; color: var(--inkt-zacht); line-height: 1.45; }

.rooster-kolom {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(ellipse at center, rgba(69, 255, 199, 0.045), transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(94, 255, 200, 0.025) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(94, 255, 200, 0.025) 40px);
}
.rooster-houder { flex: 1; min-height: 0; position: relative; }
.rooster-houder canvas { position: absolute; inset: 0; }

/* ─── organel-infokaart: de economie van één bouwsteen ─── */
#organel-info {
  border-top: 1px solid var(--paneel-rand);
  padding: 14px 22px 16px;
  min-height: 132px;
  background: rgba(5, 26, 32, 0.55);
}
.oi-leeg {
  color: var(--inkt-zacht);
  font-size: 12.5px;
  line-height: 1.7;
  padding-top: 28px;
  text-align: center;
}
.oi-kop {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.oi-kop canvas { flex-shrink: 0; }
.oi-kop strong {
  font-family: var(--font-display);
  font-size: 18px;
  display: block;
}
.oi-meta { font-size: 11px; color: var(--warm); letter-spacing: 0.06em; }
.oi-uitleg { font-size: 12.5px; color: var(--inkt-zacht); line-height: 1.6; margin-bottom: 10px; }
.oi-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.oi-chip {
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--paneel-rand);
  background: rgba(216, 242, 232, 0.03);
  color: var(--inkt-zacht);
  white-space: nowrap;
}
.oi-chip.proces {
  border-color: rgba(69, 255, 199, 0.3);
  background: rgba(69, 255, 199, 0.05);
}
.oi-chip b { font-weight: 600; }
.oi-chip em { font-style: normal; color: var(--inkt-zacht); }
.oi-pijl { color: var(--bio); font-weight: 600; padding: 0 3px; }
.oi-plus { color: var(--inkt-zacht); }
.oi-voetnoot { font-size: 10.5px; color: var(--inkt-zacht); margin-top: 8px; opacity: 0.75; }

.stat-kop {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bio);
  margin: 14px 0 6px;
}
.stat-kop:first-child { margin-top: 0; }
.stat-rij {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3.5px 0;
  color: var(--inkt-zacht);
}
.stat-rij strong { font-weight: 500; font-variant-numeric: tabular-nums; }

.advies {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 1.6;
  border: 1px solid var(--paneel-rand);
}
.advies.goed { color: var(--bio); border-color: rgba(69, 255, 199, 0.35); background: rgba(69, 255, 199, 0.06); }
.advies.matig { color: var(--warm); border-color: rgba(255, 193, 77, 0.35); background: rgba(255, 193, 77, 0.06); }
.advies.slecht { color: var(--gevaar); border-color: rgba(255, 77, 126, 0.4); background: rgba(255, 77, 126, 0.07); animation: knipper 1.1s infinite alternate; }

/* — patchkaart — */
.kaart-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  flex: 1;
  width: 100%;
  min-height: 0;
}
.kaart-houder { position: relative; min-height: 0; }
.kaart-houder canvas { position: absolute; inset: 0; }
.patch-info-scroll {
  border-left: 1px solid var(--paneel-rand);
  padding: 20px;
  overflow-y: auto;
}
#patch-info h3 { font-size: 19px; margin-bottom: 8px; }
#patch-info h3 small { font-size: 11px; color: var(--inkt-zacht); font-family: var(--font-mono); font-weight: 400; }
#patch-info h4 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--inkt-zacht);
  margin: 18px 0 8px;
}
#patch-info p { font-size: 12px; line-height: 1.65; color: var(--inkt-zacht); margin-bottom: 12px; }

.omg-rij {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--inkt-zacht);
  margin: 5px 0;
}
.omg-balk {
  height: 6px;
  background: rgba(216, 242, 232, 0.07);
  border-radius: 3px;
  overflow: hidden;
}
.omg-balk i { display: block; height: 100%; border-radius: 3px; }

.bewoner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  margin: 6px 0;
}
.bewoner i { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.bewoner em { color: var(--inkt); flex: 1; }
.bewoner span { color: var(--inkt-zacht); font-size: 10.5px; }

.klimaat-rij {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  color: var(--inkt-zacht);
  margin: 4px 0;
}
.klimaat-rij b { color: var(--inkt); font-weight: 600; }
.klimaat-rij em { font-style: normal; color: var(--bio); font-size: 11px; }
.klimaat-straf { font-size: 11.5px; margin: 8px 0; padding: 8px 10px; border-radius: 8px; }
.klimaat-straf.goed { color: var(--bio); background: rgba(69, 255, 199, 0.06); border: 1px solid rgba(69, 255, 199, 0.25); }
.klimaat-straf.slecht { color: var(--gevaar); background: rgba(255, 77, 126, 0.07); border: 1px solid rgba(255, 77, 126, 0.3); }
.tol-knop { margin-bottom: 6px; }

.migratie { color: var(--bio) !important; font-weight: 500; }
.leeg { color: var(--inkt-zacht); font-style: italic; font-size: 12px; }

/* — ecosysteem-overzicht — */
.eco-scroll { flex: 1; overflow: auto; padding: 24px 30px; width: 100%; }
.eco-scroll h3 { font-size: 21px; margin-bottom: 6px; }
.eco-scroll > .klein { margin-bottom: 18px; max-width: 760px; }
.eco-tabel-wrap { overflow-x: auto; }
.eco-tabel {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.eco-tabel th, .eco-tabel td {
  padding: 9px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(94, 255, 200, 0.08);
  white-space: nowrap;
}
.eco-tabel thead th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--inkt-zacht);
  font-weight: 500;
  vertical-align: bottom;
  border-bottom: 1px solid var(--paneel-rand);
}
.eco-tabel thead th small { display: block; font-size: 9px; opacity: 0.6; margin-top: 2px; }
.eco-hoek { text-align: left !important; }
.eco-soort {
  text-align: left !important;
  font-weight: 500;
  font-size: 12.5px;
}
.eco-soort i {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 8px currentColor;
  vertical-align: middle;
}
.eco-soort em { color: var(--bio); font-style: italic; font-size: 11px; }
.eco-tabel td b { font-weight: 600; color: var(--inkt); }
.eco-up { color: var(--bio); font-size: 10px; }
.eco-down { color: var(--gevaar); font-size: 10px; }
.eco-flat { color: var(--inkt-zacht); opacity: 0.4; }
.eco-leeg { background: rgba(0, 0, 0, 0.15); }
.eco-streep { color: var(--inkt-zacht); opacity: 0.3; }
.eco-heerser { background: rgba(69, 255, 199, 0.06); }
.eco-kroon { color: var(--warm); margin-left: 4px; font-size: 11px; }
.eco-totaal b { color: var(--bio); }
.eco-speler { background: rgba(69, 255, 199, 0.08); }
.eco-speler .eco-soort { color: var(--bio); }
.eco-speler td { border-top: 1px solid var(--bio-dim); border-bottom: 1px solid var(--bio-dim); }
.eco-uitgestorven { opacity: 0.4; }
.eco-uitgestorven .eco-soort span { text-decoration: line-through; }

/* — rapport — */
.rapport-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 26px 34px;
  width: 100%;
}
.rapport-blok {
  margin-bottom: 22px;
  padding: 18px 22px;
  border: 1px solid var(--paneel-rand);
  border-radius: 11px;
  background: rgba(216, 242, 232, 0.02);
}
.rapport-blok h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bio);
  margin-bottom: 10px;
}
.rapport-blok p { font-size: 13px; line-height: 1.8; color: var(--inkt); }

/* ─── scrollbars ─── */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(94, 255, 200, 0.15); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(94, 255, 200, 0.3); }

/* ─── klein scherm ─── */
@media (max-width: 980px) {
  .editor-grid { grid-template-columns: 230px 1fr; }
  .stats-kolom { display: none; }
  .kaart-grid { grid-template-columns: 1fr; }
  .patch-info-scroll { display: none; }
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — kleine schermen (telefoon) en iPads
   ═══════════════════════════════════════════════════════ */

/* Codex/editor-tabs horizontaal scrollen i.p.v. wrappen op smal scherm */
@media (max-width: 760px) {
  .wiki-cats, .editor-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .wiki-cats::-webkit-scrollbar, .editor-tabs::-webkit-scrollbar { display: none; }
  .wiki-cat, .editor-tab { flex: 0 0 auto; }
}

/* ─── iPad / tablet (561–1024px) ─── */
@media (min-width: 561px) and (max-width: 1024px) {
  .hud-paneel { min-width: 230px; padding: 12px 15px; }
  .editor-tab { padding: 11px 14px; }
}

/* ─── telefoon (≤560px): compacte HUD + gestapelde editor ─── */
@media (max-width: 560px) {
  .links-boven { top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); }
  .rechts-boven { top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); gap: 7px; }

  .hud-paneel { min-width: 0; padding: 9px 12px; max-width: 62vw; }
  .hud-kop { font-size: 11px; gap: 6px; margin-bottom: 7px; }
  .tag { font-size: 8.5px; padding: 2px 5px; }
  .balk-rij { grid-template-columns: 36px 1fr 32px; gap: 7px; margin: 4px 0; }
  .balk-rij label { font-size: 9px; }
  .balk-getal { font-size: 10px; }
  .balk { height: 5px; }
  .deling-rij { margin-top: 7px; padding-top: 7px; }

  /* actieknoppen iets compacter, maar groot genoeg om te tikken */
  #btn-engulf, #btn-toxine { right: calc(14px + env(safe-area-inset-right)); padding: 11px 16px; font-size: 12px; }
  #patch-paneel, .patch-paneel { padding: 9px 12px; }
  #patch-label { font-size: 12px; letter-spacing: 0.12em; }
  #hint { bottom: 150px; font-size: 12px; max-width: 84vw; padding: 9px 14px; }

  /* editor: één kolom — rooster centraal, palet als horizontale lade */
  #editor { padding: 0; }
  .editor-kop { padding: 12px 14px; gap: 10px; }
  .editor-kop h2 { font-size: 17px; }
  .editor-grid { display: flex; flex-direction: column; }
  .palet-kolom {
    order: 2; border-right: none; border-top: 1px solid var(--paneel-rand);
    max-height: 38vh; padding: 12px;
  }
  #organel-palet { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .rooster-kolom { order: 1; min-height: 44vh; }
  #organel-info { max-height: 30vh; overflow-y: auto; }
  .mp-blok { min-width: 0; }
  .mp-teller { font-size: 18px; }

  /* Codex: lessen-hub en kaarten ruimer op smal scherm */
  .wiki-inhoud { padding: 16px; }
  .les-grid, .les-grid.les-grid { grid-template-columns: 1fr 1fr; }
  .ent-titel { font-size: 26px; }

  /* difficulty-picker en modals netjes binnen het scherm */
  .diff-rij { grid-template-columns: 1fr; }
  .over-paneel, .diff-paneel, .dood-paneel { max-height: 88vh; overflow-y: auto; }
}

/* zeer smal (≤380px): nog iets strakker */
@media (max-width: 380px) {
  .hud-paneel { max-width: 70vw; }
  #organel-palet { grid-template-columns: repeat(3, 1fr); }
  .les-grid { grid-template-columns: 1fr; }
}
