/* The new interface. The picture is the integer-scaled canvas (core/stage.js);
   everything over it is plain DOM in CSS pixels (approved: no fractional
   scaling of the HUD). Text is at least 12 px. Colours are tokens here only. */
:root {
  color-scheme: dark;
  --border: #293a31;
  --ink: #f4f0e2;
  --ink-soft: #d9d5c3;
  --panel: rgba(30, 44, 36, .88);
  --panel-solid: #1f2d25;
  --edge: #c39b4f;
  --edge-soft: rgba(195, 155, 79, .55);
  --hp: #c96f5a;
  --hp-track: #3a2a26;
  --focus: #f0cf6a;
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
}

html, body { margin: 0; height: 100%; overflow: hidden; background: var(--border); color: var(--ink); font-family: var(--font); }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }

/* Layers placed over the picture by app/boot.js (left, top, width, height).
   --hud is the HUD's size: max(1, picture scale in CSS px ÷ 2), so the HUD
   keeps its size relative to the picture (小克, 2026-10-05). The layers are
   zoomed by it and app/boot.js divides their geometry by it, so everything
   inside (offsets included) grows with the picture while text stays sharp. */
.over-picture { position: fixed; left: 0; top: 0; pointer-events: none; zoom: var(--hud, 1); }
.over-picture[hidden] { display: none; }

.key {
  display: inline-block; margin: 0 6px 0 0; padding: 1px 6px; border: 1px solid rgba(244, 240, 226, .45);
  border-radius: 4px; font-size: 12px; line-height: 18px; color: var(--ink);
}

.hud-menu {
  position: absolute; right: 16px; top: 16px; padding: 6px 10px; border: 2px solid var(--edge);
  border-radius: 8px; background: var(--panel); color: var(--ink); font: 14px/18px var(--font);
  cursor: pointer; pointer-events: auto;
}
.hud-menu .key { margin: 0 0 0 8px; }
.hud-menu:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.hud-hp { position: absolute; right: 20px; bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-hp-track {
  position: relative; display: block; width: 16px; height: 120px; overflow: hidden;
  border: 2px solid var(--edge); border-radius: 6px; background: var(--hp-track);
}
.hud-hp-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; background: var(--hp); transition: height .25s; }
.hud-hp-label { font-size: 13px; font-weight: 700; letter-spacing: .06em; }

.hud-log {
  position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 8px;
  max-width: 60%; padding: 4px 12px 4px 6px; border-radius: 8px; background: var(--panel); font-size: 16px; line-height: 22px;
}
.hud-log[hidden] { display: none; }
.hud-icon { display: block; image-rendering: pixelated; }

.hud-hint {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); box-sizing: border-box; width: max-content;
  max-width: calc(100% - 240px); margin: 0; padding: 6px 14px; border: 2px solid var(--edge-soft); border-radius: 8px;
  background: var(--panel); font-size: 15px; line-height: 20px; text-align: center;
}
.hud-hint[hidden] { display: none; }

.world-prompt {
  position: absolute; transform: translate(-50%, -100%); padding: 3px 12px 3px 4px; white-space: nowrap;
  border: 2px solid var(--edge); border-radius: 999px; background: var(--panel); font-size: 15px; line-height: 20px;
}
/* The family's 「……」 above the head (world/family-actors.js): no key. */
.world-prompt.world-bubble { padding: 1px 10px; border-color: var(--edge-soft); }

.menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.menu[hidden] { display: none; }
.menu-panel {
  min-width: 220px; display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 2px solid var(--edge);
  border-radius: 12px; background: var(--panel-solid); pointer-events: auto; zoom: var(--hud, 1);
}
.menu-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--edge); text-align: center; }
.menu button {
  padding: 8px 12px; border: 1px solid var(--edge-soft); border-radius: 8px; background: var(--panel);
  color: var(--ink); font: 15px/20px var(--font); cursor: pointer;
}
.menu button:hover { border-color: var(--edge); }
.menu button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* The red edge when the player is hurt (ui/hud.js flash). */
.hud-flash {
  position: absolute; inset: 0; box-shadow: inset 0 0 0 6px rgba(201, 111, 90, .8);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.hud-flash.on { opacity: 1; transition: none; }

/* While a dialog is open, the event log's corner is under the box. */
body.dialogue-open .hud-log { display: none; }

/* P02's approved I2 picture uses the same lower 20% caption area as the
   comics. It keeps the dialogue keys, completion report and persistence. */
body.illustrated-dialogue #hud, body.illustrated-dialogue #hint, body.illustrated-dialogue .world-prompt { display: none; }
body.illustrated-dialogue .dialogue-box {
  left: 0; right: 0; bottom: 0; height: var(--band); min-height: 0;
  padding: 8px 20px; border: 0; border-top: 2px solid var(--edge-soft); border-radius: 0;
  background: rgba(16, 22, 19, .9);
}

/* The dialogue box (ui/dialogue.js): the bottom of the picture, from the left
   edge to the HP bar. A click or Space shows the whole line, then the next. */
.dialogue-box {
  position: absolute; left: 16px; right: 64px; bottom: 16px; box-sizing: border-box; min-height: 92px;
  padding: 10px 16px 14px; border: 2px solid var(--edge); border-radius: 10px; background: var(--panel-solid);
  pointer-events: auto; cursor: pointer;
}
.dialogue-speaker { margin: 0 0 4px; font-size: 14px; line-height: 18px; font-weight: 700; color: var(--edge); }
.dialogue-speaker[hidden] { display: none; }
.dialogue-text { margin: 0 0 0; padding-right: 64px; font-size: 18px; line-height: 28px; white-space: pre-wrap; }
.dialogue-box.narration .dialogue-text { color: var(--ink-soft); }
.dialogue-next { position: absolute; right: 12px; bottom: 10px; margin: 0; }
.dialogue-box.typing .dialogue-next { visibility: hidden; }

/* While a comic or the transition holds the picture, the HUD steps aside
   (the Esc menu still opens). */
body.cinematic #hud, body.cinematic #hint, body.cinematic .world-prompt { display: none; }

/* The comic's own picture for a panel with art (ui/comic-art.js): 1280×720,
   placed in the window's 16:9 box by script, smoothly scaled (not the
   stage's pixelated whole numbers). */
.comic-art { position: fixed; display: block; image-rendering: auto; }
.comic-art[hidden] { display: none; }

/* The comic layer (ui/comic.js): the panel is the picture itself; the
   caption band covers its bottom 72 art pixels (--band, set by place()), or
   the bottom 20% of a panel with art, with the skip button in its corner, so
   the safe area above stays clear. */
.comic-tag {
  position: absolute; left: 12px; top: 10px; margin: 0; padding: 2px 8px; border-radius: 6px;
  background: rgba(20, 28, 24, .7); color: var(--ink-soft); font-size: 12px; line-height: 18px;
}
.comic-caption {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--band, 72px); box-sizing: border-box;
  padding: 8px 160px 8px 20px; background: rgba(16, 22, 19, .9); border-top: 2px solid var(--edge-soft);
  pointer-events: auto; cursor: pointer;
}
.comic-speaker { margin: 0 0 2px; font-size: 14px; line-height: 18px; font-weight: 700; color: var(--edge); }
.comic-speaker[hidden], .comic-note[hidden], .comic-wait[hidden] { display: none; }
.comic-text { margin: 0; font-size: 18px; line-height: 26px; white-space: pre-wrap; }
.comic-note { margin: 2px 0 0; font-size: 13px; line-height: 18px; color: var(--ink-soft); }
.comic-wait { position: absolute; right: 150px; bottom: 10px; margin: 0; font-size: 16px; color: var(--ink-soft); }
.comic-skip {
  position: absolute; right: 12px; bottom: 10px; padding: 5px 10px; border: 1px solid var(--edge-soft);
  border-radius: 8px; background: var(--panel); color: var(--ink); font: 13px/18px var(--font); cursor: pointer;
}
.comic-skip:disabled { opacity: .5; cursor: default; }
.comic-skip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* The P11 transition (ui/transition.js): opaque, so the map under it never
   shows; it fades away when chapter two begins. */
#transition { transition: opacity .6s; }
#transition.leaving { opacity: 0; }
.transition-screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 0 48px; background: #101613; pointer-events: auto; cursor: pointer;
}
.transition-text { max-width: 520px; margin: 0; font-size: 19px; line-height: 30px; color: var(--ink); text-align: center; white-space: pre-wrap; }
.transition-note { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-soft); text-align: center; }
.transition-note[hidden], .transition-retry[hidden] { display: none; }
.transition-retry {
  padding: 8px 16px; border: 1px solid var(--edge-soft); border-radius: 8px; background: var(--panel);
  color: var(--ink); font: 15px/20px var(--font); cursor: pointer;
}
.transition-retry:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* The reconnecting veil: the game stays visible under it. */
.veil { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20, 28, 24, .55); }
.veil[hidden] { display: none; }
.veil-text {
  margin: 0; padding: 10px 18px; border: 2px solid var(--edge-soft); border-radius: 10px;
  background: var(--panel-solid); font-size: 16px; line-height: 22px; zoom: var(--hud, 1);
}

/* The screens around the game (ui/screens.js): one panel in the middle. */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20, 28, 24, .6); }
.screen[hidden] { display: none; }
.screen-panel {
  box-sizing: border-box; width: 360px; max-width: calc(100vw / var(--hud, 1) - 32px);
  display: flex; flex-direction: column; gap: 12px; padding: 20px 22px;
  border: 2px solid var(--edge); border-radius: 12px; background: var(--panel-solid); zoom: var(--hud, 1);
}
.screen-title { margin: 0; font-size: 20px; line-height: 28px; color: var(--edge); text-align: center; }
.screen-note { margin: 0; font-size: 15px; line-height: 22px; color: var(--ink-soft); text-align: center; }
.screen-error { margin: 0; font-size: 14px; line-height: 20px; color: #f0a08e; }
.screen-code {
  display: block; padding: 8px; border-radius: 6px; background: #121a16; font: 16px/22px Consolas, "Courier New", monospace;
  text-align: center; user-select: all;
}
.screen-panel button {
  padding: 9px 14px; border: 1px solid var(--edge-soft); border-radius: 8px; background: var(--panel);
  color: var(--ink); font: 15px/20px var(--font); cursor: pointer;
}
.screen-panel button:hover { border-color: var(--edge); }
.screen-panel button:focus-visible, .screen-panel input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.screen-panel button:disabled { opacity: .6; cursor: default; }
.screen-form { display: flex; flex-direction: column; gap: 12px; }
.screen-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.screen-field input {
  padding: 8px 10px; border: 1px solid var(--edge-soft); border-radius: 6px; background: #121a16;
  color: var(--ink); font: 16px/22px var(--font);
}
.screen-looks { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; padding: 0; border: 0; font-size: 14px; }
.screen-looks legend { width: 100%; padding: 0; margin-bottom: 4px; }
.screen-look { display: flex; align-items: center; gap: 6px; font-size: 15px; }
