/* Red Star Over China: Bao'an Journey - interface shell
   Warm parchment and ink, matching the in-game pixel art direction.
   Layout is recomposed per aspect: portrait stack, landscape frame. */

:root {
  --ink: #2b1c12;
  --ink-soft: #4a3320;
  --paper: #f2e2c2;
  --paper-2: #e5d0a9;
  --paper-3: #d6bb8c;
  --wood: #4b2d1a;
  --wood-2: #35200f;
  --red: #c23a2a;
  --red-deep: #8d221a;
  --gold: #d9a53f;
  --line: rgba(43, 28, 18, 0.28);
  --shadow: 0 10px 30px rgba(20, 10, 4, 0.45);
  --chrome-top: var(--paean-chrome-inset-top, env(safe-area-inset-top, 0px));
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-ui: "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --font-book: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", "Songti TC", serif;
  --ui-scale: 1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #120d09;
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

body { position: fixed; inset: 0; }

.app {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 0%, #2c1d12 0%, #170f0a 60%, #0d0806 100%);
}

.stage {
  position: relative;
  overflow: hidden;
  background: #0f0a06;
  isolation: isolate;
  box-shadow: 0 0 0 1px rgba(217, 165, 63, 0.16), var(--shadow);
  width: 100%;
  height: 100%;
}

.world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.sky, .grade, .flash { position: absolute; inset: 0; pointer-events: none; }
.sky { opacity: 0; transition: opacity 0.25s ease; }
.grade {
  opacity: 0;
  mix-blend-mode: multiply;
  transition: opacity 0.4s ease;
}
.flash { opacity: 0; background: #fff8e6; }

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.app[data-hud="1"] .hud { opacity: 1; }
.hud-tl {
  position: absolute;
  left: calc(var(--safe-l) + max(10px, 2.2vmin));
  top: calc(var(--chrome-top) + max(10px, 2.2vmin));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  max-width: min(74%, 340px);
}

.quest-card {
  background: linear-gradient(180deg, rgba(246, 231, 203, 0.95), rgba(228, 205, 167, 0.94));
  border: 1px solid rgba(74, 45, 26, 0.55);
  border-radius: 4px;
  padding: 7px 10px 8px;
  box-shadow: 0 3px 0 rgba(74, 45, 26, 0.28), 0 6px 16px rgba(20, 10, 4, 0.3);
  min-width: 168px;
  backdrop-filter: blur(2px);
}
.quest-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--red-deep);
  text-transform: none;
  font-weight: 600;
}
.quest-head .ico { width: 13px; height: 13px; }
.ico-fill { fill: currentColor; }
.quest-title {
  font-family: var(--font-book);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
  line-height: 1.25;
}
.quest-hint {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 3px;
  line-height: 1.35;
  opacity: 0.92;
}
.quest-hint:empty { display: none; }

.util-row { display: flex; gap: 6px; pointer-events: auto; }
.util-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 4px;
  border: 1px solid rgba(74, 45, 26, 0.5);
  background: rgba(246, 231, 203, 0.9);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(74, 45, 26, 0.25);
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease, background 0.15s ease;
}
.util-btn:active { transform: translateY(1px); background: var(--paper-3); }
.util-btn svg { width: 19px; height: 19px; }
.util-btn .ln { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.util-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--red);
  color: #fff6e6;
  font-size: 10px;
  line-height: 15px;
  font-weight: 700;
  display: none;
}
.util-badge[data-on="1"] { display: block; }

/* ---------- Dialogue ---------- */

.dialog {
  position: absolute;
  left: calc(var(--safe-l) + max(8px, 1.6vmin));
  right: calc(var(--safe-r) + max(8px, 1.6vmin));
  bottom: calc(var(--safe-b) + max(8px, 1.6vmin));
  display: none;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px 12px;
  border-radius: 6px;
  border: 1px solid rgba(217, 165, 63, 0.42);
  background:
    linear-gradient(180deg, rgba(46, 28, 16, 0.94), rgba(28, 17, 10, 0.96));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(246, 231, 203, 0.12);
  color: #f6e9cf;
  max-width: 900px;
  margin: 0 auto;
  pointer-events: auto;
  z-index: 6;
}
.dialog[data-mode="on"] { display: grid; }
.dialog[data-mode="choice"] { display: grid; }

.dlg-portrait {
  width: 96px;
  height: 112px;
  align-self: start;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(217, 165, 63, 0.3);
  display: none;
}
.dlg-portrait[data-on="1"] { display: block; }
.dlg-portrait canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.dlg-body { min-width: 0; display: flex; flex-direction: column; }
.dlg-name {
  font-family: var(--font-book);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 3px;
}
.dlg-name:empty { display: none; }
.dlg-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: #f7ecd6;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  min-height: 3.2em;
  max-height: 32vh;
  overflow: hidden;
  font-family: var(--font-book);
}
.dlg-text .em { color: #ffd98a; }
.dlg-text .nar { color: #cbb89a; font-style: normal; }
.dlg-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dlg-choices:empty { display: none; }
.choice-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  min-height: 40px;
  border-radius: 4px;
  border: 1px solid rgba(217, 165, 63, 0.4);
  background: linear-gradient(180deg, rgba(246, 231, 203, 0.14), rgba(246, 231, 203, 0.06));
  color: #f7ecd6;
  font-family: var(--font-book);
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.choice-btn:active { transform: translateY(1px); }
.choice-btn[data-done="1"] { opacity: 0.55; }
.choice-btn .cb-mark {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(217, 165, 63, 0.75);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: var(--gold);
}
.choice-btn .cb-mark::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.choice-btn[data-done="1"] .cb-mark::after { background: var(--gold); }
.choice-btn .cb-text { flex: 1 1 auto; min-width: 0; }
.choice-btn .cb-new {
  flex: 0 0 auto;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(194, 58, 42, 0.85);
  color: #ffeccd;
  letter-spacing: 0.04em;
}
.choice-btn.leave { border-color: rgba(246, 231, 203, 0.2); background: rgba(0, 0, 0, 0.2); color: #d9c9ad; }

.dlg-next {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  opacity: 0.85;
  display: none;
}
.dialog[data-mode="on"] .dlg-next { display: block; }
.dlg-next svg { width: 18px; height: 18px; animation: bob 1.4s ease-in-out infinite; }
.dlg-next .ln { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes bob { 0%, 100% { transform: translateY(-1px); } 50% { transform: translateY(2px); } }

/* ---------- Touch controls ---------- */

.controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 5;
}
.controls[data-on="1"] { display: block; }

.stick {
  position: absolute;
  left: calc(var(--safe-l) + 14px);
  bottom: calc(var(--safe-b) + 14px);
  width: 124px;
  height: 124px;
  pointer-events: auto;
  touch-action: none;
}
.stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(246, 231, 203, 0.34);
  background: radial-gradient(circle at 50% 45%, rgba(28, 18, 10, 0.42), rgba(16, 10, 6, 0.62) 74%);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.28);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 1px solid rgba(217, 165, 63, 0.85);
  background: radial-gradient(circle at 40% 35%, rgba(246, 231, 203, 0.72), rgba(150, 106, 62, 0.62));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s linear;
}

.action-col {
  position: absolute;
  right: calc(var(--safe-r) + 14px);
  bottom: calc(var(--safe-b) + 14px);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.round-btn {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(217, 165, 63, 0.55);
  background: radial-gradient(circle at 40% 32%, rgba(246, 231, 203, 0.24), rgba(38, 22, 12, 0.72));
  color: #f8e9c8;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(246, 231, 203, 0.2);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.07s ease, background 0.15s ease;
}
.round-btn:active { transform: translateY(2px); background: rgba(120, 74, 40, 0.8); }
.round-btn svg { width: 26px; height: 26px; }
.round-btn .ln { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.round-btn.cam { width: 50px; height: 50px; }
.round-btn.cam svg { width: 22px; height: 22px; }

/* ---------- Prompt / toast ---------- */

.prompt {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 34%;
  padding: 5px 11px 6px;
  border-radius: 3px;
  background: rgba(24, 14, 8, 0.78);
  border: 1px solid rgba(217, 165, 63, 0.44);
  color: #f8e9c8;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}
.prompt[data-on="1"] { opacity: 1; }
.prompt kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  border: 1px solid rgba(217, 165, 63, 0.5);
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 5px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.25);
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(var(--chrome-top) + 64px);
  transform: translate(-50%, -6px);
  padding: 7px 14px 8px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(246, 231, 203, 0.97), rgba(226, 200, 158, 0.97));
  border: 1px solid rgba(74, 45, 26, 0.5);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font-book);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  z-index: 8;
  max-width: 78%;
  text-align: center;
  line-height: 1.4;
}
.toast[data-on="1"] { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Viewfinder ---------- */

.viewfinder {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 7;
  pointer-events: none;
}
.viewfinder[data-on="1"] { display: block; }
.viewfinder::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 50%, rgba(0,0,0,0) 42%, rgba(10, 6, 3, 0.66) 88%);
}
.vf-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(52vmin, 300px);
  height: min(38vmin, 220px);
  transform: translate(-50%, -50%);
  border: 1.5px solid rgba(255, 240, 210, 0.62);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35) inset;
}
.vf-frame::before, .vf-frame::after {
  content: "";
  position: absolute;
  background: rgba(255, 240, 210, 0.4);
}
.vf-frame::before { left: 50%; top: 50%; width: 14px; height: 1px; margin-left: -7px; }
.vf-frame::after { left: 50%; top: 50%; width: 1px; height: 14px; margin-top: -7px; }
.vf-target {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border: 1.5px solid rgba(255, 240, 210, 0.35);
  border-radius: 50%;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.vf-target[data-lock="1"] {
  border-color: #ffd98a;
  box-shadow: 0 0 0 2px rgba(255, 217, 138, 0.18), 0 0 16px rgba(255, 217, 138, 0.35);
  transform: scale(0.86);
}
.vf-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 240, 210, 0.5);
}
.vf-corner.tl { left: 10px; top: 10px; border-right: 0; border-bottom: 0; }
.vf-corner.tr { right: 10px; top: 10px; border-left: 0; border-bottom: 0; }
.vf-corner.bl { left: 10px; bottom: 10px; border-right: 0; border-top: 0; }
.vf-corner.br { right: 10px; bottom: 10px; border-left: 0; border-top: 0; }
.vf-hint {
  position: absolute;
  left: 50%;
  top: calc(50% + min(21vmin, 132px));
  transform: translateX(-50%);
  color: #ffeec8;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}
.vf-controls {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 20px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  pointer-events: auto;
}
.shutter {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(255, 240, 210, 0.7);
  background: rgba(20, 12, 6, 0.4);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.shutter span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f6ead1, #d8bf95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: transform 0.08s ease;
}
.shutter:active span { transform: scale(0.9); }
.vf-exit {
  padding: 6px 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 240, 210, 0.45);
  background: rgba(20, 12, 6, 0.5);
  color: #ffeec8;
  font-size: 12px;
  cursor: pointer;
}
.vf-counter {
  position: absolute;
  right: calc(var(--safe-r) + 16px);
  top: calc(var(--chrome-top) + 14px);
  color: #ffeec8;
  font-size: 12px;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* ---------- Panels (notebook, menu) ---------- */

.panel {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: calc(var(--chrome-top) + 8px) 8px calc(var(--safe-b) + 8px);
  background: rgba(12, 7, 4, 0.62);
  z-index: 9;
}
.panel[data-open="1"] { display: grid; }
.panel-card {
  width: min(680px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  border: 1px solid rgba(74, 45, 26, 0.6);
  background: linear-gradient(180deg, #f7ead1, #ead8b6 62%, #e2cca6);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 9px;
  border-bottom: 1px solid rgba(74, 45, 26, 0.22);
  background: linear-gradient(180deg, rgba(255, 249, 235, 0.7), rgba(255, 249, 235, 0));
}
.panel-title {
  font-family: var(--font-book);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.panel-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 4px;
  border: 1px solid rgba(74, 45, 26, 0.35);
  background: rgba(255, 250, 238, 0.6);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.panel-close svg { width: 15px; height: 15px; }
.panel-close .ln { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.panel-tabs { display: flex; gap: 4px; padding: 8px 12px 0; flex-wrap: wrap; }
.tab-btn {
  padding: 5px 11px 6px;
  border-radius: 3px 3px 0 0;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: var(--font-book);
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 34px;
}
.tab-btn[data-active="1"] {
  color: var(--red-deep);
  border-bottom-color: var(--red);
  background: rgba(255, 250, 238, 0.6);
}
.panel-body {
  padding: 10px 12px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
}
.panel-empty {
  font-family: var(--font-book);
  font-size: 13.5px;
  color: var(--ink-soft);
  opacity: 0.8;
  padding: 18px 4px;
  text-align: center;
  line-height: 1.7;
}
.entry {
  padding: 9px 10px 10px;
  border-radius: 4px;
  background: rgba(255, 252, 244, 0.62);
  border: 1px solid rgba(74, 45, 26, 0.16);
  border-left: 3px solid var(--red);
  margin-bottom: 8px;
}
.entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.entry-title {
  font-family: var(--font-book);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}
.entry-src { font-size: 10.5px; color: var(--red-deep); opacity: 0.8; white-space: nowrap; }
.entry-text {
  margin-top: 5px;
  font-family: var(--font-book);
  font-size: 13px;
  line-height: 1.75;
  color: #3a271a;
}
.entry-quote {
  margin-top: 6px;
  padding: 6px 8px;
  border-left: 2px solid rgba(194, 58, 42, 0.4);
  background: rgba(194, 58, 42, 0.05);
  font-family: var(--font-book);
  font-size: 12.5px;
  line-height: 1.7;
  color: #5b4028;
}
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.photo-card {
  border-radius: 3px;
  overflow: hidden;
  background: #1c120b;
  border: 1px solid rgba(74, 45, 26, 0.4);
}
.photo-thumb { aspect-ratio: 4 / 3; background: #241810; display: block; width: 100%; image-rendering: pixelated; }
.photo-cap {
  padding: 5px 7px 6px;
  font-family: var(--font-book);
  font-size: 11.5px;
  line-height: 1.45;
  color: #f0e0c2;
  background: rgba(40, 24, 13, 0.9);
}
.photo-card .photo-thumb[data-empty="1"] { filter: brightness(0.35) saturate(0.4); }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.stat {
  flex: 1 1 96px;
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(255, 252, 244, 0.6);
  border: 1px solid rgba(74, 45, 26, 0.16);
}
.stat-num { font-family: var(--font-book); font-size: 20px; font-weight: 700; color: var(--red-deep); line-height: 1.1; }
.stat-lbl { font-size: 11px; color: var(--ink-soft); margin-top: 2px; letter-spacing: 0.04em; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  min-height: 46px;
  border-radius: 4px;
  border: 1px solid rgba(74, 45, 26, 0.22);
  background: rgba(255, 252, 244, 0.7);
  font-family: var(--font-book);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.menu-item small { font-size: 11.5px; color: var(--ink-soft); font-family: var(--font-ui); }
.menu-item .val { color: var(--red-deep); font-weight: 700; font-family: var(--font-ui); font-size: 13px; }
.menu-note {
  margin-top: 12px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  font-family: var(--font-book);
  opacity: 0.85;
}

/* ---------- Chapter fiche ---------- */

.fiche {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: calc(var(--chrome-top) + 10px) 12px calc(var(--safe-b) + 10px);
  background: linear-gradient(180deg, rgba(16, 10, 6, 0.94), rgba(28, 18, 10, 0.96));
  z-index: 10;
}
.fiche[data-open="1"] { display: grid; }
.fiche-inner {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  color: #f4e6cb;
  padding: 6px;
}
.fiche-kicker {
  font-size: 11.5px;
  letter-spacing: 0.34em;
  color: var(--gold);
  text-transform: none;
}
.fiche-title {
  font-family: var(--font-book);
  font-size: clamp(21px, 5.4vw, 30px);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-top: 8px;
  color: #fdf3de;
  line-height: 1.35;
}
.fiche-rule {
  width: 46px;
  height: 1px;
  margin: 14px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.fiche-text {
  font-family: var(--font-book);
  font-size: 14.5px;
  line-height: 1.95;
  color: #ded0b6;
  text-align: left;
  white-space: pre-line;
}
.fiche-stats {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: #cbb894;
  letter-spacing: 0.05em;
}
.fiche-stats b { color: #ffd98a; font-size: 15px; font-family: var(--font-book); }
.fiche-btn {
  margin-top: 20px;
  padding: 11px 30px;
  min-height: 46px;
  border-radius: 3px;
  border: 1px solid rgba(217, 165, 63, 0.65);
  background: linear-gradient(180deg, rgba(194, 58, 42, 0.9), rgba(141, 34, 26, 0.95));
  color: #fdf1d8;
  font-family: var(--font-book);
  font-size: 15px;
  letter-spacing: 0.14em;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}
.fiche-btn:active { transform: translateY(1px); }

/* ---------- Demo cue / boot ---------- */

.demo-cue {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 22px);
  transform: translate(-50%, 8px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 8px;
  border-radius: 20px;
  background: rgba(20, 12, 6, 0.55);
  border: 1px solid rgba(246, 231, 203, 0.24);
  color: #f7ecd6;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
  z-index: 6;
  backdrop-filter: blur(3px);
}
.demo-cue[data-on="1"] { opacity: 1; transform: translate(-50%, 0); }
.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e4503e;
  box-shadow: 0 0 6px rgba(228, 80, 62, 0.8);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.boot-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  background: #140d08;
  color: #e6d5b6;
  z-index: 12;
  transition: opacity 0.6s ease;
}
.boot-msg[data-off="1"] { opacity: 0; pointer-events: none; }
.boot-title { font-family: var(--font-book); font-size: 24px; letter-spacing: 0.2em; color: #f6e6c6; }
.boot-sub { font-size: 12px; letter-spacing: 0.3em; color: #96795a; }
.boot-msg[data-error="1"] .boot-sub { color: #e08a6a; letter-spacing: 0.05em; max-width: 30ch; line-height: 1.7; }

/* ---------- Layout: landscape / desktop ---------- */

.app[data-layout="wide"] .stage {
  width: min(100vw, calc(100vh * 1.7778));
  height: min(100vh, calc(100vw / 1.7778));
}
.app[data-layout="portrait"] .stage { width: 100vw; height: 100vh; }

@media (max-height: 520px) {
  .dialog { padding: 8px 10px 9px; gap: 8px; }
  .dlg-portrait { width: 62px; height: 74px; }
  .dlg-text { font-size: 13px; line-height: 1.5; min-height: 2.6em; max-height: 26vh; }
  .dlg-name { font-size: 12.5px; }
  .choice-btn { font-size: 13px; min-height: 34px; padding: 6px 9px; }
  .stick { width: 104px; height: 104px; left: calc(var(--safe-l) + 10px); bottom: calc(var(--safe-b) + 10px); }
  .stick-knob { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .round-btn { width: 50px; height: 50px; }
  .round-btn.cam { width: 44px; height: 44px; }
  .quest-card { padding: 5px 8px 6px; min-width: 0; }
  .quest-title { font-size: 13.5px; }
  .quest-hint { font-size: 11px; }
  .quest-head { font-size: 10px; }
}

@media (max-width: 380px) {
  .dlg-text { font-size: 13.5px; }
  .quest-card { min-width: 0; }
}

@media (min-width: 900px) and (min-height: 620px) {
  .dialog { max-width: 840px; padding: 12px 16px 14px; }
  .dlg-text { font-size: 15.5px; }
  .dlg-portrait { width: 96px; height: 112px; }
  .quest-title { font-size: 16px; }
}
