:root {
  --bg: #0b0d14;
  --panel: #10121a;
  --panel-2: #151826;
  --ink: #e6e6ee;
  --muted: #8089a0;
  --line: rgba(255, 255, 255, 0.08);
  --green: #50fa7b;
  --gold: #ffd866;
  --red: #ff5555;
  --orange: #ffb86c;
  --pixel: "Pixel", ui-monospace, "SF Mono", Menlo, monospace;
}

/* Bundled pixel font (VT323 — readable CRT pixel face, Latin + Cyrillic, with a clearly open 'C'
   so names like CYRUS/CLERK don't read as OYRUS/OLERK). Used for the VN voice and on-canvas labels
   so the dialogue reads like a pixel game, not a terminal. */
@font-face {
  font-family: "Pixel";
  src: url("/static/fonts/VT323.ttf") format("truetype");
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
}
/* the canvas width derives from 100vw — reserve the scrollbar gutter so the appearing/vanishing
   scrollbar (chips, log, panel change the page height) can't make the dialogue width jump */
html { scrollbar-gutter: stable; }

#app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.45; }
.sep { color: var(--muted); margin: 0 6px; }

/* ---- HUD ---- */
#hud {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.hud-title { font-family: var(--pixel); font-weight: 400; letter-spacing: 2px; font-size: 26px; }
.hud-stats { color: var(--muted); }
.hud-stats b { color: var(--ink); }

/* ---- Stage: a single game field; the brain folds into the VN box on the field ---- */
#stage { display: block; }
#world {
  position: relative;
  width: fit-content;        /* hug the canvas so overlays track it when the height cap kicks in */
  max-width: 860px;
  margin: 0 auto;
}

#screen {
  /* fit a laptop/projector viewport with no page scroll: capped by width AND by the viewport
     height (HUD + log + controls allowance), keeping the 640:448 pixel aspect either way */
  width: min(860px, calc(100vw - 32px), calc((100vh - 175px) * (640 / 448)));
  height: auto;
  aspect-ratio: 640 / 448;
  background: #05060a;
  border-radius: 10px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  display: block;
}

#prompt {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--pixel);
  pointer-events: none;
  z-index: 3;
}

#log {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  min-height: 18px;
  margin-top: 6px;
}
#log .ev { display: block; transition: opacity .7s; }
#log .ev.fade { opacity: 0; }

/* ---- VN dialogue: an in-world pixel plaque on the bottom of the game field ----
   Sharp corners, chunky black+gold frame, solid warm fill, hard offset shadow (no web blur)
   so it reads as an object in the game, not a floating UI card. */
#dialogue {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-height: calc(100% - 32px);   /* the plaque may never outgrow the game field */
  z-index: 4;
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  background: #18110a;
  border: 4px solid #0a0805;
  border-radius: 0;
  box-shadow:
    inset 0 0 0 3px #2a1d0e,        /* dark bevel */
    inset 0 0 0 5px #e8c25a,        /* gold inner rule */
    6px 6px 0 0 rgba(0, 0, 0, 0.5); /* hard pixel drop shadow */
  image-rendering: pixelated;
  font-family: var(--pixel);
}
#dlg-portrait {
  flex: 0 0 96px;
  width: 96px;
  height: 96px;
  background: #05060a;
  border: 3px solid #0a0805;
  border-radius: 0;
  box-shadow: inset 0 0 0 2px #e8c25a;   /* gold inner frame, like an inset portrait */
  align-self: flex-start;
}
#dlg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
#dlg-head { display: flex; align-items: center; gap: 10px; align-self: stretch; }
#dlg-life { font-family: var(--pixel); font-size: 15px; color: var(--green); white-space: nowrap; }
#dlg-brainbtn {                           /* visible "open the skull" toggle (same as /brain) */
  margin-left: auto; cursor: pointer; font-size: 15px; line-height: 1; padding: 3px 8px;
  background: #0d0a06; border: 2px solid #e8c25a; color: var(--gold);
  border-radius: 0; box-shadow: 2px 2px 0 0 rgba(0, 0, 0, 0.45);
}
#dlg-brainbtn:hover { background: #241a0a; }
#dlg-brainbtn:active { transform: translate(2px, 2px); box-shadow: none; }
#dlg-speaker {                            /* gold nameplate tab */
  display: inline-block;
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 19px;
  letter-spacing: .5px;
  color: #241803;
  background: var(--gold);
  padding: 0 12px;
  border: 2px solid #0a0805;
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, 0.45);
}
#dlg-reply { font-size: 19px; line-height: 1.4; min-height: 24px; max-height: 132px; overflow-y: auto;
  align-self: stretch; color: #c9c0ad; scrollbar-width: thin; }   /* ~5 lines, then scroll — the box stops growing */
#dlg-reply.said { color: #f3ecd9; }
#dlg-reply.saying { color: #f3ecd9; }     /* typewriter in flight — no blinking ▼ yet */
#dlg-reply.said::after { content: " ▼"; color: var(--gold); animation: dlg-blink 1s steps(1) infinite; }
#dlg-reply.thinking { color: var(--gold); animation: dlg-pulse 0.9s ease-in-out infinite; }
#dlg-reply.listing { white-space: pre; font-size: 15px; line-height: 1.35; color: #8fe0a8;
  max-height: 280px; }                      /* green readout: the depot gateway's file tree */
#dlg-reply.granted { color: var(--green); font-family: var(--pixel); letter-spacing: 2px;
  text-shadow: 0 0 14px rgba(80, 250, 123, 0.55); }      /* terminal: ACCESS GRANTED, held green */
@keyframes dlg-blink { 50% { opacity: 0; } }
@keyframes dlg-pulse { 50% { opacity: 0.35; } }

/* the brain ("open the skull"), folded into a compact strip under the reply */
#dlg-brain { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; align-self: stretch; }
.brain-regions { display: flex; flex-wrap: wrap; gap: 4px; }
.brain-chip {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.38);
  border-left: 3px solid var(--c, #555);
  color: #d8d2c2;
  white-space: nowrap;
  cursor: help;
}
.brain-chip.pop { animation: chipPop .18s ease-out; }     /* regions report one by one */
@keyframes chipPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.brain-chip.d-good { color: var(--green); }               /* the signal moved your way */
.brain-chip.d-bad { color: var(--red); }                  /* …or against you */
.brain-chip.flip { font-weight: 700; animation: chipPop .18s ease-out, chipFlash .45s steps(2) 3; }
@keyframes chipFlash { 50% { background: rgba(80, 250, 123, 0.35); } }
.brain-verdict { font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; color: var(--gold); }
.brain-verdict.key { color: var(--green); }
.brain-burn { color: #8a8270; font-weight: 400; }
.brain-tell { font-family: ui-monospace, monospace; font-size: 11px; color: var(--gold); margin-top: 4px; line-height: 1.35; }
.brain-tell-more { color: #8a8270; }

#dlg-input-row { display: flex; gap: 8px; margin-top: 4px; align-self: stretch; }
#dlg-input {
  flex: 1;
  min-width: 0;
  background: #0d0a06;
  color: var(--ink);
  border: 2px solid #0a0805;
  border-radius: 0;
  box-shadow: inset 2px 2px 0 0 rgba(0, 0, 0, 0.55);   /* sunken field */
  padding: 7px 10px;
  font-family: var(--pixel);
  font-size: 17px;
}
#dlg-input:focus { outline: none; border-color: var(--gold); }
#dlg-send {
  background: var(--gold);
  color: #241803;
  border: 2px solid #0a0805;
  border-radius: 0;
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, 0.45);
  padding: 0 16px;
  font-family: var(--pixel);
  font-size: 16px;
  cursor: pointer;
}
#dlg-send:active { transform: translate(3px, 3px); box-shadow: none; }   /* press-down */

/* ---- "Open the skull": full per-region reasoning, summoned with /brain ---- */
#brain-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  bottom: 16px;
  z-index: 6;
  overflow-y: auto;
  padding: 14px 16px;
  background: #120d07;
  border: 4px solid #0a0805;
  border-radius: 0;
  box-shadow: inset 0 0 0 3px #2a1d0e, inset 0 0 0 5px #e8c25a;
  font-family: var(--pixel);
}
.bp-head {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--gold); font-size: 20px; letter-spacing: .5px;
  border-bottom: 2px solid #2a1d0e; padding-bottom: 8px; margin-bottom: 10px;
}
.bp-close { color: #8a8270; font-size: 14px; }
.bp-region {
  padding: 7px 10px; margin: 7px 0;
  background: rgba(0, 0, 0, 0.35);
  border-left: 4px solid var(--c, #555);
}
.bp-region-h { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.bp-label { font-family: var(--pixel); font-size: 17px; font-weight: 700; color: var(--c, #fff); }
.bp-head-line { font-family: ui-monospace, monospace; font-size: 12px; color: #d8d2c2; text-align: right; }
.bp-detail { font-family: ui-monospace, monospace; font-size: 12px; color: #9a927f; margin-top: 3px; line-height: 1.4; }
.bp-lever { font-family: ui-monospace, monospace; font-size: 12px; color: #e8c25a; margin-top: 4px; line-height: 1.4; }
.bp-tok { font-family: ui-monospace, monospace; font-size: 11px; color: #6f6857; margin-top: 3px; }
.bp-reach { margin: 6px 0 12px; padding: 9px 12px; background: rgba(232, 194, 90, 0.08);
  border: 2px solid #2a1d0e; border-left: 4px solid var(--gold); }
.bp-reach-h { font-family: var(--pixel); font-size: 16px; color: var(--gold); margin-bottom: 5px; }
.bp-reach ul { margin: 0; padding-left: 18px; }
.bp-reach li { font-family: ui-monospace, monospace; font-size: 12px; color: #d8d2c2; line-height: 1.5; margin: 2px 0; }
.bp-verdict {
  margin-top: 12px; padding: 9px; text-align: center;
  font-family: var(--pixel); font-size: 18px; color: var(--gold);
  background: rgba(0, 0, 0, 0.35); border: 2px solid #2a1d0e;
}
.bp-verdict.key { color: var(--green); }
.bp-burn { font-family: ui-monospace, monospace; font-size: 11px; color: #6f6857; }

/* ---- Controls ---- */
#controls { display: flex; gap: 18px; color: var(--muted); font-size: 15px; padding-top: 2px; font-family: var(--pixel); }
#controls b { color: var(--ink); }

/* ---- Moral overlay ---- */
#moral {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.moral-card { text-align: center; max-width: 560px; padding: 24px; }
#moral-text {
  font-family: var(--pixel);
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 19px;
  color: #d7d7e2;
  margin: 0 0 22px;
}
#moral-restart {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: var(--pixel);
}
#moral-restart:hover { color: var(--ink); }

/* ===================== Main menu ===================== */
.hud-title .ai { color: var(--green); }
#snd {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-family: var(--pixel); font-size: 16px; line-height: 1; padding: 1px 8px; cursor: pointer;
  border-radius: 4px;
}
#snd:hover { color: var(--gold); border-color: var(--gold); }
#snd.off { color: #5a5f70; text-decoration: line-through; }

#menu {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  text-align: center; overflow: hidden; font-family: var(--pixel);
  background:
    radial-gradient(800px 520px at 50% 34%, #241803 0%, #120c05 42%, #07060c 78%, #040308 100%);
  transition: opacity .55s ease, transform .55s ease;
}
#menu.closing { opacity: 0; transform: scale(1.04); pointer-events: none; }
#menu.hidden { display: none; }
.menu-vignette { position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.10) 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 220px 60px rgba(0,0,0,.85); mix-blend-mode: overlay; opacity: .6; }
.menu-inner { position: relative; z-index: 2; max-width: 600px; padding: 28px; max-height: 100vh; overflow-y: auto; }
.menu-emblem { height: 168px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 4px; }
.menu-emblem img { height: 168px; image-rendering: pixelated;
  filter: drop-shadow(0 0 26px rgba(255,180,70,.42)) drop-shadow(0 6px 10px rgba(0,0,0,.6));
  animation: emblemFloat 5s ease-in-out infinite; }
@keyframes emblemFloat { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }
.menu-title {
  margin: 6px 0 2px; font-size: clamp(54px, 12vw, 104px); letter-spacing: 7px; color: var(--gold);
  line-height: .95; text-shadow: 0 0 26px rgba(255,216,102,.4), 0 4px 0 #5a3c0c, 0 2px 1px #000;
}
.menu-title .ai { color: var(--green); text-shadow: 0 0 26px rgba(80,250,123,.55), 0 4px 0 #14492a; }
.menu-rule { height: 30px; margin: 2px 0 8px; display: flex; justify-content: center; opacity: .9; }
.menu-rule img { height: 30px; image-rendering: pixelated; filter: drop-shadow(0 0 12px rgba(255,180,70,.4)); }
.menu-tag { color: var(--gold); font-size: 24px; letter-spacing: 2px; margin-bottom: 12px; }
.menu-sub { font-family: ui-monospace, Menlo, monospace; color: var(--muted); font-size: 13px;
  line-height: 1.6; max-width: 480px; margin: 0 auto 22px; }
.menu-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.menu-btn {
  font-family: var(--pixel); font-size: 22px; letter-spacing: 1px; cursor: pointer; padding: 9px 22px;
  color: var(--gold); background: #1a1206; border: 2px solid #6b4f1d; border-radius: 5px;
  box-shadow: inset 0 0 0 1px #2a1d0e, 0 4px 0 #0a0805; transition: transform .08s, background .15s, color .15s;
}
.menu-btn:hover { background: #241a0a; color: #fff0c2; }
.menu-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1px #2a1d0e, 0 1px 0 #0a0805; }
.menu-btn.primary { color: #1a1206; background: linear-gradient(#ffe08a, #e8b23c); border-color: #b6913a;
  text-shadow: none; box-shadow: inset 0 1px 0 #fff4cf, 0 4px 0 #6b4f1d; }
.menu-btn.primary:hover { background: linear-gradient(#fff0b8, #f0bf52); }
.menu-btn.ghost { font-size: 18px; color: var(--muted); background: transparent; border-color: var(--line); box-shadow: none; }
.menu-btn.ghost:hover { color: var(--gold); border-color: var(--gold); }
.menu-btn.ghost.off { color: #5a5f70; }
.menu-howto { margin: 18px auto 0; max-width: 460px; text-align: left; font-family: ui-monospace, Menlo, monospace;
  font-size: 13px; color: var(--muted); line-height: 1.9; background: rgba(0,0,0,.34);
  border: 1px solid #2a1d0e; border-left: 3px solid var(--gold); border-radius: 6px; padding: 12px 16px; }
.menu-howto b { color: var(--ink); }
.menu-howto.hidden { display: none; }
.menu-foot { margin-top: 22px; color: #6f6857; font-size: 14px; letter-spacing: 1px; }
.menu-hint { position: absolute; bottom: 26px; left: 0; right: 0; z-index: 2; color: var(--gold);
  font-family: var(--pixel); font-size: 20px; letter-spacing: 2px; opacity: .85;
  pointer-events: none;
  animation: hintPulse 1.6s ease-in-out infinite; }
.menu-hint span { color: var(--green); }
.menu-hint.gone { opacity: 0; transition: opacity .5s; pointer-events: none; }
@keyframes hintPulse { 0%,100% { opacity: .35 } 50% { opacity: .9 } }

/* ---- Flip banner: the decision flips on screen (REFUSE → HELP · 🔑 / HE BREAKS) ---- */
#flip-banner {
  position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%);
  z-index: 5; pointer-events: none;
  display: flex; align-items: center; gap: 16px; white-space: nowrap; max-width: 94%;
  font-family: var(--pixel); font-size: clamp(26px, 4.5vw, 42px); letter-spacing: 3px; line-height: 1;
  color: var(--green); background: rgba(0, 0, 0, 0.82);
  border: 4px solid var(--green); padding: 12px 28px;
  box-shadow: 6px 6px 0 0 rgba(0, 0, 0, 0.6);
  text-shadow: 0 3px 0 #0a3318;
  image-rendering: pixelated;
  animation: bannerIn .16s ease-out, bannerFlash .14s steps(2) 5;
}
#flip-banner img { height: 38px; image-rendering: pixelated; }
#flip-banner.fading { opacity: 0; transition: opacity 1.2s ease-out; }   /* slow fade after the ~2.7s hold */
#flip-banner.dark { color: #ff5555; border-color: #ff5555; background: rgba(12, 0, 0, 0.9); text-shadow: 0 3px 0 #3a0a0a; }
@keyframes bannerIn { from { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes bannerFlash { 50% { filter: invert(1); } }

/* ---- Bark: a black, light-framed remark the protagonist mutters (triggerable on demand) ---- */
#bark {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  max-width: 80%; z-index: 5;
  background: #060608; color: #eef0f6;
  border: 3px solid #e6e6ee;                 /* light frame on a black box */
  box-shadow: 5px 5px 0 0 rgba(0, 0, 0, 0.55);   /* hard pixel drop shadow */
  padding: 8px 16px;
  font-family: var(--pixel); font-size: 18px; line-height: 1.35; text-align: center;
  image-rendering: pixelated;
  animation: barkIn .16s ease-out;
}
#bark .bark-who { display: block; color: var(--gold); font-size: 13px; letter-spacing: 1px; margin-bottom: 2px; }
@keyframes barkIn { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* mode descriptions under the menu buttons */
.menu-modes { margin-top: 14px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.menu-modes b { color: var(--gold); }
.menu-credits { margin-top: 18px; display: flex; flex-direction: column; gap: 4px; align-items: center;
  font-family: var(--pixel); font-size: 15px; color: #8e8676; letter-spacing: 0.4px; }
.menu-credits b { color: #c9bfa6; }
.menu-credits .mc-ico { height: 18px; width: auto; vertical-align: -3px; image-rendering: pixelated; }
.menu-credits .mc-wide { height: 14px; }

/* laptop/projector heights: shrink the emblem + title so nothing crops or collides
   (placed after the base menu rules so these overrides win at equal specificity) */
@media (max-height: 900px) {
  .menu-emblem, .menu-emblem img { height: 104px; }
  .menu-title { font-size: clamp(40px, 8vw, 64px); margin-top: 0; }
  .menu-rule, .menu-rule img { height: 22px; }
  .menu-tag { font-size: 18px; margin-bottom: 8px; }
  .menu-sub { margin-bottom: 12px; font-size: 12px; }
  .menu-foot { margin-top: 10px; }
  .menu-inner { padding: 8px 28px; }
  .menu-hint { bottom: 6px; font-size: 16px; }
}

/* ---- Layout editor: searchable object picker ---- */
#objpicker {
  position: absolute; top: 16px; right: 16px; bottom: 16px; width: 206px; z-index: 7;
  background: #120d07; border: 3px solid #e6e6ee; box-shadow: 5px 5px 0 0 rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; font-family: var(--pixel);
}
.op-head { padding: 8px; border-bottom: 2px solid #2a1d0e; display: flex; flex-direction: column; gap: 6px; }
.op-head span { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
#op-search { background: #0d0a06; color: var(--ink); border: 2px solid #2a1d0e; border-radius: 0;
  padding: 5px 8px; font-family: ui-monospace, monospace; font-size: 12px; }
#op-search:focus { outline: none; border-color: var(--gold); }
#op-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; }
.op-item { cursor: pointer; background: rgba(0, 0, 0, 0.35); border: 1px solid #2a1d0e; border-radius: 4px;
  padding: 6px 4px; text-align: center; }
.op-item:hover { background: rgba(232, 194, 90, 0.12); }
.op-item.sel { border-color: var(--gold); background: rgba(232, 194, 90, 0.16); }
.op-item img { width: 42px; height: 42px; object-fit: contain; image-rendering: pixelated; display: block; margin: 0 auto 3px; }
.op-item span { font-size: 11px; color: var(--muted); word-break: break-word; }
.op-empty { grid-column: 1 / -1; color: var(--muted); font-size: 12px; padding: 12px; text-align: center; }

/* ---- layout editor: legend (toggle with H) ---- */
#ed-help {
  position: absolute; top: 30px; left: 16px; z-index: 7; max-width: 320px;
  background: rgba(10, 8, 5, 0.94); border: 3px solid #e8c25a;
  box-shadow: 5px 5px 0 0 rgba(0, 0, 0, 0.5); padding: 10px 12px;
  font-family: ui-monospace, monospace; font-size: 11px; color: #d8d2c2;
}
#ed-help .edh-title { font-family: var(--pixel); color: var(--gold); font-size: 16px; letter-spacing: 1px; margin-bottom: 6px; }
#ed-help .edh-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
#ed-help .edh-grid b { color: var(--gold); white-space: nowrap; }
#ed-help .edh-grid span { color: #b9b2a0; }

/* ---- character editor: rewrite a mind's prompts ---- */
#charedit {
  position: absolute; top: 16px; left: 16px; right: 16px; bottom: 16px; z-index: 8;
  background: #120d07; border: 3px solid #e8c25a; box-shadow: 6px 6px 0 0 rgba(0, 0, 0, 0.55);
  display: flex; flex-direction: column; font-family: ui-monospace, monospace; font-size: 12px;
}
.ce-head { display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 12px; border-bottom: 2px solid #2a1d0e; }
.ce-head #ce-title { font-family: var(--pixel); color: var(--gold); font-size: 17px; letter-spacing: 1px; }
.ce-close { color: var(--muted); font-size: 11px; cursor: pointer; }
.ce-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 12px; padding: 10px 12px; }
.ce-grid label { display: flex; flex-direction: column; gap: 3px; color: var(--gold); font-size: 11px; }
.ce-grid label.wide { grid-column: 1 / -1; }
.ce-grid input, .ce-grid textarea, .ce-grid select {
  background: #0d0a06; color: var(--ink); border: 2px solid #2a1d0e; border-radius: 0;
  padding: 5px 8px; font-family: ui-monospace, monospace; font-size: 12px; resize: vertical;
}
.ce-grid input:focus, .ce-grid textarea:focus, .ce-grid select:focus { outline: none; border-color: var(--gold); }
#charedit.knower .holder-only { display: none; }
.ce-foot { display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding: 8px 12px; border-top: 2px solid #2a1d0e; }
#ce-err { color: var(--red); font-size: 11px; flex: 1; }
#ce-save { background: var(--gold); color: #241803; border: 2px solid #0a0805; border-radius: 0;
  padding: 6px 16px; font-family: var(--pixel); font-size: 15px; cursor: pointer;
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, 0.45); }
#ce-save:active { transform: translate(2px, 2px); box-shadow: none; }

/* ---- pause menu (Esc) ---- */
#pausemenu {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 6, 10, 0.62);
}
.pm-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 240px; padding: 18px 22px;
  background: #18110a; border: 4px solid #0a0805; border-radius: 0;
  box-shadow: inset 0 0 0 3px #2a1d0e, inset 0 0 0 5px #e8c25a, 6px 6px 0 0 rgba(0, 0, 0, 0.5);
  font-family: var(--pixel);
}
.pm-title { color: var(--gold); font-size: 22px; letter-spacing: 2px; text-align: center; margin-bottom: 4px; }
.pm-card button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  background: #0d0a06; color: var(--ink); border: 2px solid #2a1d0e; border-radius: 0;
  padding: 8px 12px; font-family: var(--pixel); font-size: 17px; cursor: pointer; text-align: left;
}
.pm-card button:hover { border-color: var(--gold); color: var(--gold); }
.pm-k { color: var(--muted); font-size: 13px; }
