:root {
  color-scheme: dark;
  font-family: Inter, "Yu Gothic UI", "Meiryo", sans-serif;
  color: #e6e7dc;
  background: #171d1b;
  font-synthesis: none;
}
#story-event-lines .story-line-dialogue {
  border-left: 3px solid var(--speaker-color, #d8c47e);
  padding: 16px 20px;
  border-radius: 0 12px 12px 0;
  background: #0a13114d;
}
#story-event-lines .story-line-dialogue b {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--speaker-color, #d8c47e);
  font-size: clamp(20px, 3vw, 27px);
  font-weight: 600;
  letter-spacing: .1em;
  margin-bottom: 18px;
}
#story-event-lines .story-line-dialogue b small {
  font: 11px "Yu Gothic UI", sans-serif;
  letter-spacing: .04em;
  color: #cbd1c7;
}
#speaking-character {
  position: absolute;
  z-index: 9;
  transform: translate(-50%, -100%);
  pointer-events: none;
  white-space: nowrap;
  padding: 6px 10px;
  background: #111b18e6;
  border: 1px solid var(--speaker-color);
  border-radius: 8px;
  color: var(--speaker-color);
  font-size: 11px;
  box-shadow: 0 3px 12px #0005;
}
#speaking-character::after {
  content: "";
  position: absolute;
  top: 100%;
  left: calc(50% - 4px);
  border: 4px solid transparent;
  border-top-color: var(--speaker-color);
}
#speaking-character[hidden] { display: none; }
#hint-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 8px; padding: 7px 9px; font-size: 11px; background: transparent; border: 0; color: #d6d8bd; }
#hint-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
#progress-hint { box-sizing: border-box; width: min(480px, calc(100vw - 32px)); max-height: 85dvh; overflow: auto; padding: 24px; border: 1px solid #c8ceb05c; border-radius: 16px; background: #18211cf5; color: #e6e7dc; }
#progress-hint::backdrop { background: #08120ca8; }
#progress-hint small { color: #d9ca92; letter-spacing: .1em; }
#progress-hint h2 { font-size: 20px; }
#progress-hint p { line-height: 2; font-size: 15px; }
.progress-hint-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.progress-hint-actions button { min-height: 44px; padding: 10px 14px; border-radius: 8px; color: #e6e7dc; border: 1px solid #c8ceb055; background: #c8ceb010; cursor: pointer; }
#hint-toggle:focus-visible, .progress-hint-actions button:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 3px; }
@media (max-width: 700px) {
  .panel #hint-toggle { display: flex; justify-content: center; order: 4; flex-shrink: 0; width: 44px; height: 44px; margin: 0; padding: 0; border: 1px solid #c8ceb047; border-radius: 50%; background: #18211ccc; color: #e6e7dc; backdrop-filter: blur(12px); }
  #hint-toggle span { display: none; }
}
#item-puzzle { box-sizing: border-box; width: min(640px, calc(100vw - 24px)); max-height: 90dvh; overflow: auto; background: #18211c; color: #e6e7dc; border: 1px solid #b8aa73; border-radius: 16px; padding: 22px; }
#item-puzzle::backdrop { background: #07110cbd; }
#item-puzzle h2 { font-size: 21px; }
#item-puzzle p { line-height: 1.8; font-size: 14px; }
#item-puzzle button { min-height: 44px; padding: 10px 14px; margin: 4px; border: 1px solid #b8aa7366; border-radius: 8px; background: #343d2d; color: #eee8cf; cursor: pointer; }
#item-puzzle button:focus-visible { outline: 2px solid #e5c67e; outline-offset: 2px; }
.puzzle-controls { display: flex; flex-wrap: wrap; }
.puzzle-controls button { flex: 1; }
.puzzle-drawing { background: #101914; border-radius: 12px; }
.puzzle-drawing { height: clamp(240px, 40vh, 390px); overflow: hidden; position: relative; }
.puzzle-drawing canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.puzzle-drawing canvas:active { cursor: grabbing; }
.puzzle-drawing::after { content: "クリックで回転 · ドラッグで角度変更"; position: absolute; bottom: 9px; left: 0; right: 0; text-align: center; font-size: 11px; color: #d6d3ba; pointer-events: none; text-shadow: 0 1px 3px #000; }
.puzzle-drawing svg { width: 100%; display: block; }
#item-puzzle [role="status"] { min-height: 2em; color: #dfc581; }
#inventory-list .inventory-item-detail {
  display: block; width: 100%; text-align: left; padding: 12px;
  color: inherit; background: #c8ceb008; border: 1px solid #c8ceb033;
  border-radius: 8px; cursor: pointer;
}
#inventory-list .inventory-item-detail:hover { background: #c8ceb019; border-color: #c8ceb080; }
#inventory-list .inventory-item-detail { display: flow-root; }
.inventory-item-image { float: left; width: 64px; height: 64px; object-fit: contain; border-radius: 8px; margin: 0 12px 8px 0; }
.item-detail-image { display: block; width: min(240px, 100%); height: auto; aspect-ratio: 1; object-fit: contain; margin: 18px auto; border-radius: 12px; }
#inventory-list .inventory-item-detail > span { display: block; color: #d9ca92; font-size: 11px; margin-top: 8px; }
#item-detail {
  box-sizing: border-box; width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px); overflow-y: auto; padding: 26px;
  border: 1px solid #c8ceb05c; border-radius: 18px;
  background: #18211cf5; color: #e6e7dc; box-shadow: 0 15px 60px #0006;
}
#item-detail::backdrop { background: #08120ca8; }
#item-detail > small { display: block; margin-top: 26px; color: #d9ca92; letter-spacing: .16em; }
#item-detail h2 { font-size: 22px; margin: 10px 0 16px; }
#item-detail button { min-height: 44px; padding: 10px 14px; color: #e6e7dc; background: #c8ceb010; border: 1px solid #c8ceb055; border-radius: 8px; cursor: pointer; }
#item-detail button:focus-visible, .inventory-item-detail:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 3px; }
.item-detail-summary { color: #bec8bb; font-size: 13px; line-height: 1.8; padding-bottom: 18px; border-bottom: 1px solid #c8ceb030; }
.item-detail-reading { font-size: 15px; line-height: 2.1; overflow-wrap: anywhere; }
.item-detail-reading p { margin: 20px 0; }
.item-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 700px) { #item-detail { padding: 20px; max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); } }
#item-notice {
  position: absolute;
  z-index: 9;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  max-width: min(420px, calc(100% - 32px));
  box-sizing: border-box;
  padding: 18px 24px;
  border: 1px solid #d8c587a6;
  border-radius: 12px;
  background: linear-gradient(120deg, #343b29f2, #131e19f5);
  box-shadow: 0 8px 36px #0006, 0 0 26px #d8c58720;
  color: #f0ebd8;
  pointer-events: none;
}
#item-notice[hidden] { display: none; }
#item-notice .item-notice-icon { font-size: 30px; color: #e2cc87; }
#item-notice small { display: block; color: #e2cc87; font-size: 11px; letter-spacing: .16em; }
#item-notice strong { display: block; margin: 6px 0; font-size: 19px; }
#item-notice div > span { font-size: 11px; color: #c4cdbd; }
@media (max-width: 700px) {
  #item-notice { top: 25%; padding: 14px 18px; gap: 12px; }
  #item-notice strong { font-size: 17px; }
}
#episode-ending { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 24px; border: 0; background: transparent; color: #e7e0cb; }
#episode-ending::backdrop { background: transparent; transition: background 2.5s ease; }
#episode-ending.is-revealed::backdrop { background: #080e0de8; }
#episode-ending[open] { display: grid; place-items: center; }
.ending-card { opacity: 0; text-align: center; transition: opacity 2.5s ease; }
.is-revealed .ending-card { opacity: 1; }
.ending-card p { font-size: 12px; letter-spacing: .35em; color: #bdb897; }
.ending-card h2 { margin: 26px 0 40px; font-size: clamp(26px, 5vw, 42px); font-weight: 400; letter-spacing: .18em; }
.ending-card > span { display: block; font-size: 13px; letter-spacing: .55em; }
#ending-return { display: block; margin: 64px auto 0; min-height: 44px; background: transparent; border: 0; color: #c3c8b8; font-size: 12px; }
#ending-return:disabled { visibility: hidden; }
.is-ending > :not(canvas):not(#episode-ending) { visibility: hidden !important; }
#scene-effect { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; }
#scene { filter: saturate(calc(1 - var(--cinema-mute, 0))) brightness(calc(1 - var(--scene-dim, 0))); }
#story-atmosphere { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
#story-atmosphere > i { position: absolute; inset: 0; display: block; }
.cinema-warm { background: radial-gradient(ellipse at 70% 15%, #efbc68, transparent 75%); opacity: var(--cinema-warm, 0); mix-blend-mode: screen; }
.cinema-cool { background: linear-gradient(140deg, #73989f, transparent 75%); opacity: var(--cinema-cool, 0); mix-blend-mode: color; }
.cinema-shade { background: radial-gradient(ellipse at 50% 38%, transparent 28%, #030b09 100%); opacity: var(--cinema-shade, 0); }
.cinema-frame::before, .cinema-frame::after { content: ''; position: absolute; left: 0; right: 0; height: clamp(18px, 5vh, 52px); background: #050b09; }
.cinema-frame::before { top: 0; transform: translateY(calc(-100% * (1 - var(--cinema-frame, 0)))); }
.cinema-frame::after { bottom: 0; transform: translateY(calc(100% * (1 - var(--cinema-frame, 0)))); }
#viewer > header, #story-progress, #viewer > .panel { transition: opacity .65s ease; }
.is-story-directed > header, .is-story-directed > #story-progress, .is-story-directed > .panel { opacity: 0; pointer-events: none; }
.is-story-directed #story-event { justify-content: flex-end; padding-bottom: max(7vh, 42px); background: linear-gradient(180deg, transparent 30%, #0b141226 50%, #0b1412cb 100%); }
.is-story-directed #story-event > span { font-size: 9px; opacity: .68; }
.is-story-directed #story-event > strong { font-size: clamp(14px, 1.4vw, 18px); color: #d7d9c8; margin: 7px 0 16px; letter-spacing: .08em; }
.is-story-directed #story-event-lines .story-line-dialogue { background: linear-gradient(90deg, #09131068, transparent); }
.is-story-directed #story-event-lines .story-line-narration { text-align: left; margin-inline: 0; max-width: 100%; font-style: normal; }
@media (max-width: 700px) {
  .cinema-frame::before, .cinema-frame::after { height: max(16px, 2.6dvh); }
  .is-story-directed #story-event { padding: 24px 20px max(28px, calc(env(safe-area-inset-bottom) + 20px)); }
  .is-story-directed #story-event-lines p { font-size: 17px; line-height: 1.85; }
  .is-story-directed #story-event-lines .story-line-dialogue { padding: 10px 14px; }
  .is-story-directed #story-event-lines .story-line-dialogue b { margin-bottom: 12px; }
}
@media (max-height: 550px) {
  .is-story-directed #story-event { justify-content: flex-start; padding-block: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  #viewer > header, #story-progress, #viewer > .panel { transition: none; }
}
#scene-effect-settings { margin: 14px 0 18px; padding-bottom: 14px; border-bottom: 1px solid #c8ceb030; font-size: 12px; }
#scene-effect-settings summary { cursor: pointer; padding: 10px 0; color: #d8c47e; }
#scene-effect-settings label { display: block; margin: 10px 0; }
#scene-effect-settings select, #scene-effect-settings button { width: 100%; margin-top: 8px; }
#report-toggle { display: inline-flex; align-items: center; gap: 6px; margin: 8px; padding: 7px 9px; font-size: 11px; background: transparent; border: 0; color: #d6d8bd; }
#report-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#story-report { width: min(620px, calc(100vw - 32px)); max-height: 82dvh; padding: 22px; border: 1px solid #c8ceb05c; border-radius: 18px; background: #18211cf5; color: #e6e7dc; box-shadow: 0 15px 60px #0006; }
#story-report[open] { display: flex; flex-direction: column; }
#story-report::backdrop { background: #08120ca8; }
.report-heading { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.report-heading small { color: #c8bd89; font-size: 10px; letter-spacing: 2px; }
.report-heading h2 { font-size: 21px; margin: 6px 0; font-weight: 500; }
#report-close { width: 44px; height: 44px; border: 0; background: transparent; color: #e6e7dc; font-size: 26px; }
#report-objective { font-size: 12px; line-height: 1.8; padding: 12px 0; border-bottom: 1px solid #c8ceb030; flex-shrink: 0; }
.report-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; line-height: 1.85; font-size: 13px; }
.report-scroll h3 { font-size: 14px; color: #d8c47e; }
#report-milestones { padding-left: 24px; }
#report-milestones li { padding: 6px 0; }
.report-read, #report-back { min-height: 44px; padding: 8px 12px; border: 1px solid #c8ceb040; border-radius: 8px; background: #c8ceb00c; color: #dfd4aa; cursor: pointer; }
.report-read { margin-bottom: 14px; font-size: 12px; }
#report-reading { padding: 8px 4px 24px; }
.report-reading-label { margin-top: 28px; color: #aebbac; font-size: 11px; letter-spacing: 0.08em; }
#report-reading-title { font-size: 22px; font-weight: 500; margin: 12px 0 26px; }
#report-reading-body { font-size: 15px; line-height: 2.2; letter-spacing: 0.035em; }
#report-reading-body p { margin: 0 0 1.8em; }
#report-reading[hidden], #report-overview[hidden] { display: none; }
#report-milestones p { margin: 4px 0 12px; color: #bfc7ba; }
#report-entries details { border-top: 1px solid #c8ceb030; padding: 12px 0; }
#report-entries summary { cursor: pointer; padding: 6px 0; }
#report-entries p { display: flex; flex-direction: column; gap: 3px; margin: 15px 0; }
#report-entries strong { color: #d8c47e; font-size: 11px; }
.report-narration { color: #aebbac; }
@media (max-width: 700px) {
  .panel #report-toggle { display: flex; justify-content: center; align-items: center; order: 3; flex-shrink: 0; width: 44px; height: 44px; margin: 0; padding: 0; border: 1px solid #c8ceb047; border-radius: 50%; background: #18211ccc; color: #e6e7dc; backdrop-filter: blur(12px); touch-action: manipulation; }
  #report-toggle span { display: none; }
  #story-report { padding: 16px; max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
#viewer {
  position: relative;
  height: 100dvh;
  min-height: 440px;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
header {
  position: absolute;
  inset: 32px 36px auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: auto;
  cursor: pointer;
  text-shadow: 0 2px 20px #0008;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 3px;
  color: #cbcbb7;
}
h1 {
  font-size: 32px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 5px;
  margin: 10px 0;
}
h1 span {
  color: #c5bb87;
}
.identity p {
  font-size: 11px;
  color: #d1d1c3;
  letter-spacing: 2px;
  margin: 0;
}
.tag {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid #d2d7bf40;
  border-radius: 30px;
  padding: 9px 13px;
  background: #1b2526b0;
  font-size: 9px;
  letter-spacing: 1.8px;
}
.tag i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #bbca99;
  box-shadow: 0 0 10px #bccb99;
}
.panel {
  position: absolute;
  right: 28px;
  bottom: 84px;
  width: 235px;
  padding: 20px;
  background: #17211ee8;
  border: 1px solid #acb69b35;
  border-radius: 12px;
  box-shadow: 0 10px 40px #0003;
  backdrop-filter: blur(16px);
}
.panel-title,
.range-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #acb9aa;
}
.panel-title {
  margin-bottom: 14px;
}
.panel-title span:last-child {
  color: #e4e6d6;
}
nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
button {
  font: inherit;
  font-size: 11px;
  border: 1px solid #74836a55;
  color: #cad3c4;
  background: #ffffff04;
  border-radius: 5px;
  padding: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover {
  background: #d4dcbf18;
}
button[aria-pressed="true"] {
  background: #c8ceb0;
  color: #222d26;
  border-color: #c8ceb0;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid #e2cd8e;
  outline-offset: 3px;
}
.divider {
  height: 1px;
  background: #b6c0a424;
  margin: 17px 0;
}
.range-label output {
  color: #e5e4d6;
  font-size: 10px;
}
input[type="range"] {
  width: 100%;
  accent-color: #c7cca7;
  margin: 14px 0 8px;
  height: 3px;
}
.reset {
  width: 100%;
  border: 0;
  text-align: left;
  padding: 11px 0;
  color: #d0d5c7;
}
.hint {
  font-size: 10px;
  color: #8e9e8f;
  line-height: 1.9;
  margin: 7px 0 0;
}
footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 52px;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  border-top: 1px solid #cad3b526;
  background: #141d1bdc;
  font-size: 10px;
  color: #a3b29f;
  backdrop-filter: blur(12px);
}
footer div {
  display: flex;
  gap: 24px;
}
a {
  color: #c9d0bb;
  text-decoration: none;
}
a:hover {
  color: #fff;
  text-decoration: underline;
}
#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #19231f;
  z-index: 5;
  transition: opacity 0.4s;
}
#loading.done {
  opacity: 0;
  pointer-events: none;
}
.loader-mark {
  font-size: 64px;
  font-weight: 200;
  color: #c6c9a8;
  letter-spacing: 8px;
  border-top: 1px solid #c6c9a850;
  padding-top: 20px;
}
#loading p {
  font-size: 12px;
  color: #adb7a5;
  letter-spacing: 2px;
  text-align: center;
  max-width: 80%;
}
.progress {
  width: 180px;
  height: 2px;
  background: #77856b40;
  margin-top: 15px;
}
#progress-fill {
  width: 0;
  height: 100%;
  background: #c2c8a6;
  transition: width 0.2s;
}
#retry {
  margin-top: 24px;
}
.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fffc;
  box-shadow: 0 0 2px #000;
  pointer-events: none;
  opacity: 0.35;
}
@media (max-width: 700px) {
  header {
    inset: 20px 20px auto;
  }
  h1 {
    font-size: 23px;
  }
  .eyebrow {
    font-size: 8px;
    letter-spacing: 2px;
  }
  .tag {
    padding: 7px 9px;
    font-size: 7px;
    letter-spacing: 1px;
  }
  .panel {
    left: 14px;
    right: 14px;
    bottom: 74px;
    width: auto;
    padding: 12px 15px;
  }
  .panel-title,
  .divider,
  .range-label,
  input[type="range"],
  .reset {
    display: none;
  }
  nav {
    grid-template-columns: repeat(4, 1fr);
  }
  .hint {
    margin-top: 8px;
    font-size: 9px;
    text-align: center;
    line-height: 1.5;
  }
  footer {
    padding: 10px 16px;
    min-height: 60px;
    flex-direction: column;
    gap: 7px;
    font-size: 9px;
  }
  footer div {
    gap: 22px;
  }
}
.resident-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 8px;
}
.resident-controls button {
  font-size: 10px;
  padding: 9px 4px;
}
button:disabled {
  opacity: 0.45;
  cursor: wait;
}
.motion-label {
  display: block;
  font-size: 10px;
  color: #acb9aa;
  margin: 14px 0 7px;
}
#motion-pattern {
  width: 100%;
  padding: 9px 7px;
  background: #26312b;
  color: #e6e7dc;
  border: 1px solid #74836a55;
  border-radius: 5px;
  font: inherit;
  font-size: 11px;
}
@media (max-width: 700px) {
  .motion-label {
    display: none;
  }
  #motion-pattern {
    margin-top: 8px;
  }
}
.room-label {
  display: block;
  font-size: 11px;
  color: #acb9aa;
  margin-bottom: 8px;
}
#room-select {
  width: 100%;
  padding: 9px;
  background: #26312b;
  color: #e6e7dc;
  border: 1px solid #74836a55;
  border-radius: 5px;
  font: inherit;
  font-size: 12px;
}
.room-controls {
  display: flex;
  gap: 6px;
  margin: 8px 0 14px;
}
.room-controls button {
  flex: 1;
}
#room-status {
  font-size: 11px;
  color: #e2cd8e;
  margin: 0 0 8px;
}
.panel {
  max-height: calc(100dvh - 170px);
  overflow-y: auto;
}
#echo-controls[hidden] {
  display: none;
}
select:focus-visible {
  outline: 2px solid #e2cd8e;
  outline-offset: 3px;
}
@media (max-width: 700px) {
  .room-controls {
    margin-bottom: 8px;
  }
  .room-label {
    display: none;
  }
  .panel {
    max-height: calc(100dvh - 180px);
  }
}
#companion-status {
  font-size: 11px;
  font-weight: 400;
  color: #cad3c4;
  margin: 8px 0;
}
#companion-toggle {
  width: 100%;
  margin-bottom: 14px;
}
#companion-pattern {
  width: 100%;
  padding: 9px 7px;
  background: #26312b;
  color: #e6e7dc;
  border: 1px solid #74836a55;
  border-radius: 5px;
  font: inherit;
  font-size: 11px;
}
#explore-hint {
  font-size: 11px;
  line-height: 1.6;
  color: #e2cd8e;
}
#discovery {
  position: absolute;
  left: 28px;
  bottom: 85px;
  width: min(380px, calc(100% - 56px));
  padding: 22px;
  background: #17211ef2;
  border: 1px solid #c8ceb066;
  border-radius: 12px;
  z-index: 3;
  font-size: 13px;
  line-height: 1.9;
}
#discovery strong {
  color: #e2cd8e;
}
#close-discovery {
  float: right;
  padding: 2px 8px;
}
#discovery[hidden] {
  display: none;
}
#story-event {
  position: absolute;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  padding: clamp(24px, 6vh, 80px) max(24px, calc((100vw - 860px) / 2)) max(7vh, 42px);
  background: linear-gradient(180deg, transparent 35%, #1018153d 55%, #101815b8 100%);
  backdrop-filter: none;
  text-shadow: 0 2px 5px #000, 0 0 16px #000a;
}
#story-event[hidden] {
  display: none;
}
#night-transition {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #020403;
  color: #d9d8c8;
  opacity: 0;
  pointer-events: all;
  transition: opacity 1.1s ease;
}
#night-transition[hidden] {
  display: none;
}
#night-transition.is-dark {
  opacity: 1;
}
#night-transition span {
  font-size: 13px;
  letter-spacing: 0.45em;
  transition: opacity 0.5s ease;
}
#story-event > span {
  color: #d8c47e;
  font-size: 11px;
  letter-spacing: 2px;
}
#story-event > strong {
  display: block;
  margin: 12px 0 32px;
  color: #f0f0e8;
  font-size: clamp(18px, 2.4vw, 28px);
  font-weight: 500;
}
#story-event-lines p {
  margin: 7px 0;
  color: #d9ded7;
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 2;
}
#story-event-lines .story-line-dialogue span {
  display: block;
  color: #f4f1e6;
  text-shadow: 0 2px 12px #000b;
}
#story-event-lines .story-line-narration {
  max-width: 720px;
  margin: 16px auto;
  color: #bdc8bf;
  font-family: serif;
  font-size: clamp(16px, 1.8vw, 21px);
  font-style: italic;
  line-height: 2.15;
  letter-spacing: 0.08em;
  text-align: center;
}
#story-event-lines .story-line-narration b {
  display: none;
}
#story-event-lines .story-line-guide {
  padding: 14px 16px;
  border: 1px solid #d8c47e55;
  border-radius: 6px;
  background: #0b120f66;
  color: #d4d9d1;
  font-size: 14px;
  line-height: 1.7;
}
#story-event-lines .story-line-guide b {
  display: inline-block;
  min-width: auto;
  margin: 0 12px 0 0;
  color: #d8c47e;
}
#story-event-lines .story-line-guide span {
  display: inline;
}
#story-event-lines b {
  display: block;
  margin-bottom: 12px;
  min-width: 62px;
  color: #d8c47e;
  font:
    13px ui-monospace,
    "Cascadia Mono",
    monospace;
  letter-spacing: 1px;
}
#story-event-close {
  align-self: flex-end;
  margin-top: 0;
  min-height: 48px;
  padding-inline: 32px;
}
.story-event-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 28px; flex-shrink: 0; }
#story-event-back { min-height: 48px; background: transparent; border-color: transparent; color: #c6cbbd; padding: 8px 12px; font-size: 12px; }
#story-event-back:disabled { opacity: .3; cursor: default; }
.story-event-actions button:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 3px; }
#report-toggle { position: relative; }
#report-toggle.has-new-memories::after { content: ""; position: absolute; top: 3px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: #e5ca7d; box-shadow: 0 0 0 2px #18211c; }
#report-memories { margin-bottom: 24px; }
.memory-empty { color: #aebbac; }
.memory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.memory-grid button { display: flex; flex-direction: column; padding: 0 0 12px; text-align: left; overflow: hidden; border: 1px solid #c8ceb030; border-radius: 8px; background: #c8ceb009; color: #e6e7dc; cursor: pointer; }
.memory-grid img { display: block; width: 100%; aspect-ratio: 2.39; object-fit: cover; background: #101813; opacity: 0; }
.memory-grid img.is-ready, #memory-image.is-ready { opacity: 1; }
.memory-grid span { margin: 10px 12px 0; font-size: 13px; }
.memory-grid small { margin: 3px 12px 0; color: #dfca8c; font-size: 10px; }
.memory-grid button:hover { border-color: #dfca8c88; }
.memory-grid button:focus-visible, #story-memory button:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 2px; }
#story-memory { box-sizing: border-box; width: min(1100px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid #c8ceb055; border-radius: 16px; background: #151e18; color: #e6e7dc; }
#story-memory::backdrop { background: #060d09d6; }
.memory-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.memory-heading small { color: #cbbd88; font-size: 11px; letter-spacing: .15em; }
.memory-heading h2 { font-size: clamp(18px, 3vw, 25px); font-weight: 500; margin: 6px 0; }
#memory-close { min-width: 44px; min-height: 44px; font-size: 26px; border: 0; background: transparent; color: inherit; }
#story-memory figure { margin: 0; }
#memory-image { display: block; width: 100%; height: auto; border-radius: 5px; opacity: 0; }
#memory-image[hidden] { display: none; }
#memory-caption { max-width: 700px; margin: 24px auto; line-height: 2; letter-spacing: .04em; font-size: 15px; }
#story-memory nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#story-memory nav button { min-height: 44px; padding: 8px 12px; color: #ded9c6; background: transparent; border: 1px solid #c8ceb040; border-radius: 6px; }
#story-memory nav button:disabled { opacity: .3; cursor: default; }
#memory-position { color: #aebbac; font-size: 12px; white-space: nowrap; }
@media (max-width: 700px) {
  #story-memory { padding: 16px; max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  #memory-caption { margin-block: 20px; font-size: 14px; }
  .story-event-actions { gap: 6px; margin-top: 16px; }
  .story-event-actions #story-event-close { margin-top: 0; padding-inline: 18px; }
}
#story-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
#story-topics button {
  padding: 9px 12px;
  color: #e9ddbb;
  border-color: #d8c47e55;
}
#story-event {
  overflow: auto;
}
@media (max-height: 550px) {
  #story-event {
    justify-content: flex-start;
  }
}
@media (max-width: 700px) {
  #discovery {
    bottom: auto;
    top: 110px;
  }
}
#hover-label {
  position: fixed;
  z-index: 8;
  pointer-events: none;
  padding: 9px 13px;
  border: 1px solid #cfdec087;
  border-radius: 7px;
  background: #17251ef2;
  color: #e2ecd5;
  font-size: 12px;
  box-shadow: 0 6px 24px #0006;
  max-width: 270px;
}
#target-status {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  padding: 10px 18px;
  background: #24281cf0;
  border: 1px solid #e2bd6f80;
  color: #f0dba4;
  border-radius: 30px;
  font-size: 12px;
  box-shadow: 0 4px 22px #0004;
  max-width: 55%;
  text-align: center;
}
#hover-label[hidden],
#target-status[hidden] {
  display: none;
}
@media (max-width: 700px) {
  #target-status {
    top: 98px;
    max-width: 90%;
    width: max-content;
    font-size: 11px;
  }
}
@media (max-width: 700px) {
  nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

#inventory {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid #74836a55;
  border-radius: 8px;
  background: #17211e;
}
#inventory summary {
  cursor: pointer;
  font-size: 12px;
  color: #e2cd8e;
}
#inventory-count {
  float: right;
  border-radius: 12px;
  padding: 0 7px;
  background: #394332;
}
#inventory-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  max-height: 190px;
  overflow-y: auto;
}
#inventory-list li {
  border-top: 1px solid #74836a33;
  padding: 9px 0;
}
#inventory-list strong {
  font-size: 12px;
  color: #e5dfc4;
}
#inventory-list p,
#inventory-empty,
#inventory-status {
  font-size: 11px;
  line-height: 1.6;
  color: #acb9aa;
  margin: 5px 0;
}
#inventory-status:empty {
  display: none;
}
#take-item {
  padding: 9px 14px;
  color: #e2cd8e;
}
#take-item[hidden] {
  display: none;
}

/* Normal play: compact camera switch and an expandable inventory. */
.panel {
  top: 24px;
  right: 24px;
  bottom: auto;
  width: 272px;
  padding: 12px;
  border-radius: 16px;
  max-height: calc(100dvh - 48px);
  background: #18211cde;
  box-shadow: 0 8px 28px #0002;
}
.panel .panel-title {
  display: none;
}
.panel nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: #0d151280;
}
.panel nav button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  background: transparent;
}
.panel nav button[aria-pressed="true"] {
  background: #c8ceb0;
  color: #222d26;
  box-shadow: 0 2px 7px #0003;
}
.panel #inventory {
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
.panel #inventory summary {
  padding: 12px 8px;
  min-height: 44px;
  list-style: none;
  color: #e6e7dc;
  font-size: 12px;
}
.panel #inventory summary::before {
  content: "＋";
  margin-right: 10px;
  color: #c8ceb0;
}
.panel #inventory[open] summary::before {
  content: "−";
}
.panel #inventory summary::-webkit-details-marker {
  display: none;
}
.panel #inventory-empty {
  padding: 6px 8px 12px;
  margin: 0;
  max-width: 220px;
}
.panel #inventory-list {
  padding: 0 8px;
  max-height: 45dvh;
}
.panel #inventory-status {
  padding: 0 8px;
}
header {
  inset: 26px auto auto 28px;
}
header h1 {
  font-size: 24px;
  letter-spacing: 3px;
}
header .identity p {
  display: none;
}
header .eyebrow {
  font-size: 9px;
  letter-spacing: 2px;
}
#story-progress {
  position: absolute;
  top: 106px;
  left: 28px;
  z-index: 4;
  display: grid;
  gap: 4px;
  max-width: 310px;
  padding: 11px 14px;
  border-left: 2px solid #d8c47e;
  background: linear-gradient(90deg, #111a17d9, #111a1700);
  pointer-events: none;
}
#story-progress span {
  color: #d8c47e;
  font-size: 8px;
  letter-spacing: 2px;
}
#story-progress strong {
  color: #f0f0e8;
  font-size: 12px;
  font-weight: 500;
}
#story-progress small {
  color: #9eaca0;
  font-size: 9px;
  letter-spacing: 0.5px;
}
#debug-panel {
  position: absolute;
  left: 24px;
  bottom: 72px;
  width: 280px;
  max-height: calc(100dvh - 150px);
  overflow: auto;
  padding: 18px;
  background: #111a17f2;
  border: 1px solid #d2b96c66;
  border-radius: 12px;
  box-shadow: 0 12px 42px #0007;
  backdrop-filter: blur(18px);
  z-index: 7;
}
#debug-item-pointers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
#story-seat-prompt {
  position: absolute;
  z-index: 6;
  display: grid;
  justify-items: center;
  gap: 2px;
  transform: translate(-50%, -100%);
  padding: 9px 13px;
  border: 1px solid #e4ce826e;
  border-radius: 7px;
  background: #101815e6;
  color: #f4e7ba;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 7px 24px #0008;
}
#story-seat-prompt[hidden] {
  display: none;
}
#story-seat-prompt span {
  color: #e9c95f;
  font-size: 16px;
}
#story-seat-prompt:hover,
#story-seat-prompt:focus-visible {
  border-color: #f4d77e;
  background: #1a271ff2;
  outline: none;
}
#story-seat-prompt strong {
  font-size: 12px;
  font-weight: 500;
}
#story-seat-prompt small {
  color: #aeb9af;
  font-size: 9px;
}
.debug-item-pointer {
  position: absolute;
  transform: translate(-50%, calc(-100% - 20px));
  padding: 7px 10px;
  border: 1px solid #f4d684;
  border-radius: 5px;
  background: #16221af0;
  color: #ffe5a0;
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 3px 12px #0008;
}
.debug-item-pointer::after {
  content: "▼";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  color: #f4d684;
  font-size: 17px;
}
#debug-panel[hidden] {
  display: none;
}
#debug-launcher {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 7;
  min-width: 104px;
  padding: 9px 13px;
  border: 1px solid #d2b96c66;
  border-radius: 6px;
  background: #111a17d9;
  color: #d8c47e;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  box-shadow: 0 6px 24px #0005;
  backdrop-filter: blur(12px);
}
#debug-launcher span {
  margin-right: 6px;
}
#debug-launcher:hover,
#debug-launcher.is-open {
  background: #2a2a1eeb;
  border-color: #e2cd8e;
  color: #f0dfa2;
}
.debug-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  color: #e2cd8e;
  letter-spacing: 2px;
  font-size: 12px;
}
#close-debug {
  padding: 5px 10px;
}
#stats {
  font-size: 10px;
  color: #8e9e8f;
}
#story-debug {
  margin: 12px 0;
  padding: 12px 0;
  border-block: 1px solid #d2b96c33;
}
#story-flags {
  display: grid;
  gap: 3px;
  max-height: 116px;
  overflow: auto;
  margin: 9px 0;
  padding: 0;
  list-style: none;
  color: #718078;
  font:
    9px/1.45 ui-monospace,
    "Cascadia Mono",
    monospace;
}
#story-flags li.is-set {
  color: #d8c47e;
}
#story-reset {
  width: 100%;
}
#post-effects {
  margin: 14px 0 4px;
  padding: 10px 0 2px;
  border-top: 1px solid #d2b96c33;
}
#post-effects summary {
  cursor: pointer;
  color: #e2cd8e;
  font-size: 11px;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.post-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: #d5ddcf;
  font-size: 11px;
}
.post-toggle input {
  accent-color: #d8c47e;
}
#post-effects .range-label {
  margin-top: 8px;
}
#post-effects input[type="range"] {
  margin: 8px 0 4px;
}
#post-reset {
  width: 100%;
  margin-top: 10px;
}
#discovery {
  bottom: 24px;
}
#target-status {
  top: auto;
  bottom: 24px;
}
@media (max-width: 700px) {
  header {
    inset: 18px auto auto 18px;
  }
  header h1 {
    font-size: 20px;
  }
  #story-progress {
    top: 78px;
    left: 18px;
    max-width: calc(100% - 36px);
  }
  .panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 12px;
    width: auto;
    padding: 8px 10px;
    border-radius: 14px;
    max-height: 52dvh;
  }
  .panel nav button {
    min-height: 44px;
  }
  .panel #inventory {
    margin-top: 4px;
  }
  .panel #inventory-list {
    max-height: 25dvh;
  }
  .panel #inventory summary {
    padding: 10px 8px;
  }
  #debug-panel {
    top: 84px;
    bottom: 126px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: none;
  }
  #debug-launcher {
    left: 12px;
    bottom: 72px;
  }
  #debug-panel .motion-label,
  #debug-panel .room-label,
  #debug-panel .range-label,
  #debug-panel input[type="range"],
  #debug-panel .reset {
    display: block;
  }
  #discovery {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    width: auto;
    max-height: 48dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    z-index: 8;
  }
  #target-status {
    top: auto;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 52px);
    max-width: calc(100% - 32px);
    z-index: 8;
  }
  #viewer:has(#discovery:not([hidden])) #target-status {
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + var(--discovery-height, 48dvh) + 12px);
  }
}

/* One continuous sliding selector, rather than individual button surfaces. */
.panel nav.view-switch {
  position: relative;
  isolation: isolate;
  padding: 0;
  gap: 0;
  border-radius: 24px;
  border: 1px solid #c8ceb036;
  background: #0d15124d;
  overflow: hidden;
}
.view-switch-thumb {
  position: absolute;
  z-index: -1;
  left: 4px;
  top: 4px;
  bottom: 4px;
  width: calc(50% - 4px);
  border-radius: 20px;
  background: #c8ceb0;
  box-shadow: 0 2px 8px #0003;
  transform: translateX(0);
  transition: transform 0.25s ease;
}
.view-switch:has([data-view="cutaway"][aria-pressed="true"])
  .view-switch-thumb {
  transform: translateX(100%);
}
.panel nav.view-switch button {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 22px;
  min-height: 46px;
  padding: 12px 8px;
  color: #aebbac;
  transition: color 0.2s ease;
}
.panel nav.view-switch button[aria-pressed="true"] {
  color: #253026;
}
.panel nav.view-switch button:hover {
  color: #f0efdf;
}
.panel nav.view-switch button[aria-pressed="true"]:hover {
  color: #253026;
}
.panel nav.view-switch button:focus-visible {
  outline: 2px solid #e2cd8e;
  outline-offset: -3px;
}
@media (prefers-reduced-motion: reduce) {
  .view-switch-thumb {
    transition: none;
  }
}

.bgm-toggle {
  width: auto;
  margin: 8px 8px 0;
  padding: 6px 9px;
  border: 0;
  border-radius: 14px;
  color: #aebbac;
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.08em;
}
.bgm-toggle span {
  display: inline-block;
  width: 15px;
  color: #d6d8bd;
  font-size: 13px;
}
.bgm-toggle[aria-pressed="false"] {
  opacity: 0.55;
}
.bgm-toggle:hover {
  background: #d4dcbf12;
}

/* Mobile play toolbar: three compact controls on the safe right edge. */
#mobile-view-toggle, .inventory-icon, .mobile-inventory-heading { display: none; }
@media (max-width: 700px) {
  .panel {
    inset: max(18px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto auto;
    width: 44px;
    max-height: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }
  .panel nav.view-switch { display: none; }
  #mobile-view-toggle, .panel #inventory summary, .panel .bgm-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    border: 1px solid #c8ceb047;
    border-radius: 50%;
    background: #18211ccc;
    color: #e6e7dc;
    backdrop-filter: blur(12px);
    box-shadow: 0 3px 12px #0002;
    touch-action: manipulation;
  }
  #mobile-view-toggle svg, .inventory-icon {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  #mobile-view-toggle .view-icon-echo { display: none; }
  #mobile-view-toggle[data-current-view="focus"] .view-icon-room { display: none; }
  #mobile-view-toggle[data-current-view="focus"] .view-icon-echo { display: block; }
  .panel #inventory { order: 1; margin: 0; }
  .panel .bgm-toggle { order: 2; font-size: 0; letter-spacing: 0; }
  .panel .bgm-toggle span { font-size: 20px; width: auto; }
  .panel #inventory summary { position: relative; }
  .panel #inventory summary::before { display: none; }
  .inventory-icon { display: block; }
  .inventory-label { display: none; }
  #inventory-count {
    position: absolute;
    right: -3px;
    top: -3px;
    margin: 0;
    min-width: 17px;
    padding: 2px 4px;
    text-align: center;
    font-size: 10px;
    border-radius: 10px;
    background: #c8ceb0;
    color: #253026;
  }
  .panel #inventory[open] summary { color: #253026; background: #c8ceb0; }
  .inventory-content {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    z-index: 9;
    width: min(340px, calc(100vw - 32px));
    max-height: min(65dvh, calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
    border: 1px solid #c8ceb047;
    border-radius: 16px;
    background: #18211cf5;
    box-shadow: 0 8px 28px #0005;
  }
  .mobile-inventory-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .mobile-inventory-heading strong { font-size: 13px; }
  #close-inventory { width: 44px; height: 44px; padding: 0; font-size: 23px; background: transparent; border: 0; color: #e6e7dc; }
  .panel #inventory-list { max-height: none; }
  #debug-launcher { bottom: max(12px, env(safe-area-inset-bottom)); }
  #story-progress { max-width: calc(100% - 90px); }
  #mobile-view-toggle:focus-visible, .panel #inventory summary:focus-visible, #close-inventory:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 3px; }
}

/* Scene 10: NEMU's drawing appears above the dialogue. */
#story-illustration { position: absolute; left: 50%; top: max(9vh, 52px); z-index: 9; width: min(46vw, 520px); aspect-ratio: 1448 / 1086; translate: -50% 0; rotate: -1.2deg; pointer-events: none; opacity: 0; transition: opacity .9s ease; }
#story-illustration.is-visible { opacity: 1; }
#story-illustration img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 3px; box-shadow: 0 18px 50px #000b, 0 0 0 1px #0006; transition: opacity 1.1s ease; }
#story-illustration img.is-back { opacity: 0; }
#story-illustration.show-back img.is-back { opacity: 1; }
#story-illustration.show-back img.is-front { opacity: 0; }
@media (max-width: 700px) { #story-illustration { width: 82vw; top: max(12vh, 70px); } }
@media (prefers-reduced-motion: reduce) { #story-illustration, #story-illustration img { transition: none; } }

/* Episode opening film */
#opening-film { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: #000; transition: opacity 1.2s ease; }
#opening-film video { width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .8s ease; }
#opening-film.is-playing video { opacity: 1; }
#opening-film.is-ending video { opacity: 0; transition-duration: 1.1s; }
#opening-film .opening-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
#opening-film.is-leaving { opacity: 0; pointer-events: none; }
#opening-film .opening-start { position: absolute; padding: 14px 34px; border: 1px solid #d8d6c455; border-radius: 999px; background: transparent; color: #e6e5d8; font: inherit; font-size: 14px; letter-spacing: .4em; cursor: pointer; }
#opening-film .opening-start:hover, #opening-film .opening-start:focus-visible { border-color: #d8c47e; color: #f3e7bd; outline: none; }
#opening-film .opening-skip { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); padding: 8px 16px; border: 1px solid #ffffff30; border-radius: 999px; background: #0008; color: #cfcfc4; font: inherit; font-size: 12px; letter-spacing: .15em; cursor: pointer; }
#opening-film [hidden] { display: none; }

/* ==========================================================
   Polish layer (2026-09-27): motion, depth and readability.
   CSS only, no extra assets. Motion is removed for users who
   ask the OS to reduce it.
   ========================================================== */
:root {
  --ui-accent: #d8c47e;
  --ui-ink: #ecebe0;
  --ui-muted: #aab6a8;
  --ui-glass: #121b18e6;
  --ui-line: #c8ceb033;
  --ui-ease: cubic-bezier(.2, .7, .2, 1);
}
::selection { background: #d8c47e55; color: #fff; }
* { -webkit-tap-highlight-color: transparent; }

/* Buttons: one consistent, tactile feel. */
button {
  transition: background .2s var(--ui-ease), border-color .2s var(--ui-ease),
    color .2s var(--ui-ease), transform .12s var(--ui-ease), box-shadow .2s var(--ui-ease);
}
button:hover:not(:disabled) { border-color: #c8ceb070; }
button:active:not(:disabled) { transform: scale(.97); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px #d8c47e1f;
}

/* Header: the room number slides in when ECHO changes shelter. */
h1 span { display: inline-block; }
h1 span.is-changing { animation: ui-room-number .7s var(--ui-ease); }
@keyframes ui-room-number {
  from { opacity: 0; transform: translateY(-.35em); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* Objective card: easier to read, and it answers when the goal changes. */
#story-progress {
  padding: 12px 16px 12px 15px;
  border-left-width: 2px;
  background: linear-gradient(90deg, #0f1815e6 0%, #0f1815b3 60%, #0f181500 100%);
  border-radius: 0 10px 10px 0;
}
#story-progress span { font-size: 9px; letter-spacing: .22em; }
#story-progress strong { font-size: 13px; line-height: 1.6; letter-spacing: .02em; }
#story-progress small { font-size: 10px; color: var(--ui-muted); letter-spacing: .06em; }
#story-progress.is-updated { animation: ui-objective 1.8s var(--ui-ease); }
#story-progress.is-updated strong { animation: ui-objective-text .9s var(--ui-ease); }
@keyframes ui-objective {
  0% { border-left-color: #fff3c4; box-shadow: -6px 0 22px -6px #e8d38e; }
  100% { border-left-color: var(--ui-accent); box-shadow: none; }
}
@keyframes ui-objective-text {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}

/* Side panel: softer glass with a thin highlight edge. */
.panel {
  background: linear-gradient(180deg, #18221ff0, #121a17eb);
  border-color: var(--ui-line);
  box-shadow: 0 18px 50px #0006, inset 0 1px 0 #ffffff0d;
}

/* Dialogue: new lines rise in gently; rereading stays still. */
#story-event-lines p.is-new { animation: ui-line-in .45s var(--ui-ease) both; }
@keyframes ui-line-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
#story-event-lines .story-line-dialogue {
  background: linear-gradient(90deg, #0a1311b3, #0a131166 70%, #0a131100);
  box-shadow: inset 1px 0 0 #ffffff08;
}
#story-event-lines .story-line-dialogue span { line-height: 1.85; letter-spacing: .03em; }
#story-event-close { position: relative; white-space: nowrap; border-color: #d8c47e66; color: #efe4c0; background: #d8c47e14; }
#story-event-close:hover { background: #d8c47e26; border-color: #d8c47eaa; }
#story-event-close.is-advance::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 10px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
  animation: ui-next-hint 1.6s ease-in-out infinite;
  opacity: .8;
}
@keyframes ui-next-hint {
  0%, 100% { translate: 0 0; opacity: .45; }
  50% { translate: 3px 0; opacity: .95; }
}
#story-topics button { border-radius: 999px; padding: 9px 16px; background: #d8c47e0d; }
#story-topics button:hover { background: #d8c47e22; border-color: #d8c47e99; }
#story-topics button { animation: ui-line-in .4s var(--ui-ease) both; }
#story-topics button:nth-child(2) { animation-delay: .06s; }
#story-topics button:nth-child(3) { animation-delay: .12s; }
#story-topics button:nth-child(4) { animation-delay: .18s; }

/* Toasts and labels: arrive instead of popping. */
#target-status:not([hidden]) { animation: ui-toast-in .35s var(--ui-ease); backdrop-filter: blur(10px); }
#discovery:not([hidden]) { animation: ui-panel-in .35s var(--ui-ease); box-shadow: 0 16px 44px #0007; backdrop-filter: blur(12px); }
#hover-label:not([hidden]) { animation: ui-fade .18s ease-out; backdrop-filter: blur(8px); }
#item-notice { backdrop-filter: blur(12px); }
@keyframes ui-toast-in {
  from { opacity: 0; translate: 0 8px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes ui-panel-in {
  from { opacity: 0; translate: 0 12px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }

/* Keep the discovery card clear of the debug button, and keep that
   button quiet in normal play. */
#discovery { bottom: 72px; }
#debug-launcher:not(.is-open) { opacity: .35; transition: opacity .2s ease; }
#debug-launcher:hover, #debug-launcher:focus-visible { opacity: 1; }

/* Dialog windows open with a small lift. */
dialog[open]:not(#episode-ending) { animation: ui-panel-in .32s var(--ui-ease); }
dialog::backdrop { backdrop-filter: blur(3px); }

/* Seat prompt breathes softly so it reads as the next step. */
#story-seat-prompt:not([hidden]) { animation: ui-seat 2.4s ease-in-out infinite; }
@keyframes ui-seat {
  0%, 100% { box-shadow: 0 0 0 0 #d8c47e00; }
  50% { box-shadow: 0 0 0 6px #d8c47e26; }
}

/* Loading: a slow shimmer on the bar. */
#progress-fill {
  background: linear-gradient(90deg, #c2c8a6, #efe6bf, #c2c8a6);
  background-size: 200% 100%;
  animation: ui-shimmer 1.6s linear infinite;
}
@keyframes ui-shimmer { to { background-position: -200% 0; } }
.loader-mark { animation: ui-fade 1.2s ease-out both; }

/* Thin scrollbars in reports and dialogs. */
#story-report *, #story-memory, #debug-panel, #progress-hint, #story-event {
  scrollbar-width: thin;
  scrollbar-color: #c8ceb040 transparent;
}

@media (prefers-reduced-motion: reduce) {
  h1 span.is-changing, #story-progress.is-updated, #story-progress.is-updated strong,
  #story-event-lines p.is-new, #story-topics button, #target-status:not([hidden]),
  #discovery:not([hidden]), #hover-label:not([hidden]), dialog[open]:not(#episode-ending),
  #story-seat-prompt:not([hidden]), #progress-fill, .loader-mark { animation: none; }
  #story-event-close.is-advance::after { animation: none; }
  button:active:not(:disabled) { transform: none; }
}

/* NEMU's colour question: paint the unfinished sky. */
.color-painter { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 14px 18px; align-items: center; width: 100%; margin-top: 4px; }
.color-painter svg { grid-row: span 2; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 10px 30px #0008; }
.color-painter .sky { transition: fill .4s ease; }
.color-painter.is-painted svg { animation: ui-fade .5s ease-out; }
.color-painter .swatches { display: flex; flex-direction: column; gap: 8px; }
.color-painter .swatch { display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 12px; border-radius: 999px; color: #eae2c8; background: #ffffff08; }
.color-painter .swatch i { flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px #0004; }
.color-painter .swatch-sunset i { background: linear-gradient(#f3b36b, #c9707a); }
.color-painter .swatch-sky i { background: linear-gradient(#6f9fd0, #bfd8ec); }
.color-painter .swatch-unknown i { background: #efe7d3; border: 1px dashed #9a8c6c; }
.color-painter .swatch[aria-checked="true"] { border-color: #d8c47e; background: #d8c47e22; }
.color-painter .paint-confirm { justify-self: start; padding: 10px 22px; border-color: #d8c47e88; color: #f0e4bd; background: #d8c47e18; }
.color-painter .paint-confirm:disabled { opacity: .4; cursor: default; }
@media (max-width: 700px) {
  .color-painter { grid-template-columns: 1fr; }
  .color-painter svg { grid-row: auto; max-width: 240px; }
}

/* ==========================================================
   Title screen: episode select over the live, dimmed room.
   ========================================================== */
.is-title > header, .is-title > #story-progress, .is-title > .panel, .is-title > footer,
.is-title #debug-launcher, .is-title #target-status, .is-title #hover-label { opacity: 0 !important; pointer-events: none !important; }
#title-screen {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(28px, 6vh, 72px) clamp(24px, 7vw, 120px);
  background:
    linear-gradient(90deg, #0b1210f5 0%, #0b1210d9 34%, #0b121066 62%, #0b121000 100%),
    radial-gradient(ellipse at 72% 45%, transparent 30%, #060b09b3 100%);
  opacity: 0; transition: opacity 1s ease;
}
#title-screen.is-shown { opacity: 1; }
#title-screen.is-leaving { opacity: 0; pointer-events: none; transition-duration: .9s; }
.title-inner { width: min(520px, 100%); }
.title-kicker { margin: 0 0 22px; color: var(--ui-accent, #d8c47e); font-size: 10px; letter-spacing: .42em; }
.title-logo { margin: 0; line-height: .95; font-weight: 200; }
.title-logo span { display: block; font-size: clamp(46px, 6.4vw, 104px); letter-spacing: .2em; color: #f1efe4; text-shadow: 0 0 40px #d8c47e22; }
.title-logo small { display: flex; align-items: center; gap: 14px; margin-top: 14px; font-size: clamp(13px, 1.3vw, 17px); font-weight: 400; letter-spacing: .6em; color: #c9c2a4; }
.title-logo small::before { content: ""; width: 48px; height: 1px; background: #d8c47e99; }
.title-tagline { margin: 28px 0 40px; color: #b9c0b1; font-size: 14px; line-height: 2; letter-spacing: .08em; }
.episode-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.episode {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px;
  width: 100%; padding: 14px 18px; text-align: left;
  border: 1px solid #c8ceb026; border-left: 2px solid transparent; border-radius: 0 10px 10px 0;
  background: #121b18b3; color: #e8e6da; backdrop-filter: blur(6px);
}
.episode-number { font-size: 26px; font-weight: 200; letter-spacing: .08em; color: #d8c47e; }
.episode-name { display: grid; gap: 4px; font-size: 16px; letter-spacing: .06em; }
.episode-name small { font-size: 9px; letter-spacing: .3em; color: #9fab9c; }
.episode-action { display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: .18em; color: #efe4c0; }
.episode.is-open { border-left-color: #d8c47e; background: linear-gradient(90deg, #d8c47e1c, #121b18c7 60%); }
.episode.is-open .episode-action i { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); animation: ui-next-hint 1.6s ease-in-out infinite; }
.episode.is-open:hover, .episode.is-open:focus-visible { border-color: #d8c47e88; border-left-color: #f0dc98; background: linear-gradient(90deg, #d8c47e30, #121b18d9 70%); transform: translateX(4px); }
.episode.is-locked { opacity: .34; filter: grayscale(1); cursor: not-allowed; }
.episode.is-locked:hover { background: #121b18b3; }
.episode.is-locked:active { transform: none; }
.episode.is-locked .episode-number { color: #9aa196; }
.episode.is-locked .episode-action { color: #9aa196; letter-spacing: .12em; }
.title-foot { position: absolute; left: clamp(24px, 7vw, 120px); bottom: 24px; margin: 0; font-size: 9px; letter-spacing: .4em; color: #6f7a70; }
/* Staggered entrance. */
#title-screen.is-shown .title-kicker, #title-screen.is-shown .title-logo, #title-screen.is-shown .title-tagline, #title-screen.is-shown .episode-list li {
  animation: ui-title-in .9s var(--ui-ease, ease) both;
}
#title-screen.is-shown .title-logo { animation-delay: .15s; }
#title-screen.is-shown .title-tagline { animation-delay: .35s; }
#title-screen.is-shown .episode-list li:nth-child(1) { animation-delay: .5s; }
#title-screen.is-shown .episode-list li:nth-child(2) { animation-delay: .58s; }
#title-screen.is-shown .episode-list li:nth-child(3) { animation-delay: .66s; }
#title-screen.is-shown .episode-list li:nth-child(4) { animation-delay: .74s; }
#title-screen.is-shown .episode-list li:nth-child(5) { animation-delay: .82s; }
@keyframes ui-title-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) {
  #title-screen { justify-content: flex-end; padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 28px)); background: linear-gradient(180deg, #0b121033 0%, #0b1210cc 38%, #0b1210f5 70%); }
  .title-tagline { margin: 18px 0 24px; font-size: 13px; }
  .episode { grid-template-columns: 40px 1fr auto; padding: 12px 14px; }
  .episode-number { font-size: 20px; }
  .episode-name { font-size: 14px; }
  .title-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #title-screen, #title-screen.is-shown * { animation: none !important; transition: none !important; }
}
/* On the title screen the room sits to the right of the menu. */
#scene { transition: transform 1.1s var(--ui-ease, ease); }
.is-title #scene { transform: translateX(17vw) scale(1.08); }
@media (max-width: 700px) { .is-title #scene { transform: translateY(-14vh) scale(1.02); } }
@media (prefers-reduced-motion: reduce) { #scene { transition: none; } }
#title-screen { user-select: none; -webkit-user-select: none; }

/* Title credits. */
.title-logo { margin-bottom: 44px; }
.episode.is-locked .episode-name { font-size: 13px; letter-spacing: .3em; color: #9aa196; }
.title-foot { display: flex; align-items: center; gap: 18px; font-size: 11px; letter-spacing: .12em; color: #8f9a8f; }
.title-foot a { display: inline-flex; align-items: center; gap: 7px; color: #c9cfbf; text-decoration: none; letter-spacing: .06em; pointer-events: auto; }
.title-foot a:hover, .title-foot a:focus-visible { color: #f0e4bd; text-decoration: none; }
.title-foot svg { width: 13px; height: 13px; fill: currentColor; }
@media (max-width: 700px) {
  .title-logo { margin-bottom: 28px; }
  .title-foot { display: flex; position: static; margin-top: 22px; font-size: 10px; }
}

/* Language switch on the title screen. */
.language-switch { position: absolute; top: clamp(20px, 4vh, 36px); right: clamp(20px, 4vw, 48px); display: grid; justify-items: end; gap: 6px; }
.language-switch > div { display: flex; padding: 3px; border: 1px solid #c8ceb033; border-radius: 999px; background: #0f1714b3; backdrop-filter: blur(8px); }
.language-switch button { min-width: 52px; padding: 6px 12px; border: 0; border-radius: 999px; background: transparent; color: #aab4a6; font-size: 11px; letter-spacing: .08em; }
.language-switch button[aria-checked="true"] { background: #d8c47e; color: #1d241f; }
.language-switch button:hover:not([aria-checked="true"]) { color: #f0e4bd; background: #ffffff0d; }
.language-switch small { min-height: 1em; font-size: 10px; letter-spacing: .1em; color: #9fab9c; }

/* Title: restart from the beginning (asks first). */
.title-restart { margin-top: 18px; }
.restart-open { padding: 6px 2px; border: 0; background: none; color: #8f9a8f; font-size: 11px; letter-spacing: .14em; text-decoration: underline; text-underline-offset: 4px; }
.restart-open:hover, .restart-open:focus-visible { color: #d6d0b4; background: none; }
.restart-confirm { padding: 14px 16px; border: 1px solid #d9957d55; border-radius: 10px; background: #1a1412cc; backdrop-filter: blur(6px); animation: ui-panel-in .3s var(--ui-ease, ease); }
.restart-confirm[hidden] { display: none; }
.restart-confirm p { margin: 0 0 12px; font-size: 12px; line-height: 1.8; color: #e6ddd2; }
.restart-confirm div { display: flex; gap: 8px; justify-content: flex-end; }
.restart-confirm button { padding: 8px 14px; border-radius: 999px; font-size: 11px; }
.restart-yes { border-color: #d9957d99; color: #f3d6c9; background: #d9957d22; }
.restart-yes:hover { background: #d9957d3d; }

/* Supplemental introduction, also reachable from the game's title screen. */
#about-link { position: absolute; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 45; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border: 1px solid #c8ceb047; border-radius: 24px; background: #18211ce6; color: #d6d8bd; font-size: 12px; text-decoration: none; backdrop-filter: blur(8px); }
#about-link:hover { color: #f0dfab; border-color: #d1bd7e; }
#about-link:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 3px; }
.is-story-directed #about-link { visibility: hidden; }
@media (max-width: 700px) { #about-link { right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); font-size: 11px; padding: 10px 12px; } }

#share-game { position:absolute; right:24px; bottom:calc(max(24px, env(safe-area-inset-bottom)) + 52px); z-index:45; display:inline-flex; align-items:center; gap:7px; padding:10px 14px; margin:0; border:1px solid #c8ceb047; border-radius:24px; background:#18211ce6; color:#d6d8bd; font-size:12px; backdrop-filter:blur(8px); }
#share-game svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
#share-game:hover { color:#f0dfab; border-color:#d1bd7e; }
#share-game:focus-visible { outline:2px solid #e2cd8e; outline-offset:3px; }
.is-story-directed #share-game { visibility:hidden; }
#share-dialog { position:fixed; inset:0; margin:auto; width:min(440px,calc(100vw - 32px)); max-height:calc(100dvh - 32px); overflow:auto; padding:26px; color:#e6e7dc; background:#18211cf5; border:1px solid #c8ceb047; border-radius:16px; }
#share-dialog::backdrop { background:#07100bb3; }
#share-dialog h2 { font-size:19px; margin:0 0 16px; }
#share-dialog p { font-size:13px; line-height:1.8; }
#share-dialog label { display:block; font-size:11px; margin:20px 0 6px; color:#b9c1ac; }
#share-url { box-sizing:border-box; width:100%; padding:12px; background:#0f1714; color:#e6e7dc; border:1px solid #c8ceb047; border-radius:5px; font-size:14px; }
.share-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:18px; }
.share-actions button,.share-actions a { display:inline-flex; align-items:center; min-height:44px; padding:10px 12px; margin:0; border:1px solid #c8ceb047; border-radius:6px; background:#29352c; color:#e6e7dc; text-decoration:none; font:inherit; font-size:12px; }
#share-feedback { min-height:24px; color:#dfce95; }
@media(max-width:700px) { #share-game { right:12px; bottom:calc(max(16px, env(safe-area-inset-bottom)) + 48px); font-size:11px; padding:10px 12px; } }
/* Phones: share and about stay off the play area. In game they are hidden;
   on the title they become two small icons beside the credit line. */
@media (max-width: 700px), (max-height: 550px) {
  #viewer:not(.is-title) #about-link, #viewer:not(.is-title) #share-game { display: none; }
  #viewer.is-title #about-link, #viewer.is-title #share-game { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 15px; }
  #viewer.is-title #about-link { right: 12px; }
  #viewer.is-title #share-game { right: 60px; }
  #viewer.is-title #about-link span + span, #viewer.is-title #share-game span { display: none; }
}

#story-illustration img.is-front { object-fit: contain; background: #dbcfaa; }
#viewer:has(#opening-film) > #about-link, #viewer:has(#opening-film) > #share-game { visibility: hidden; }

/* Locale is a compact control, including on the mobile icon rail. */
.game-language { order: 6; max-width: 100%; min-height: 36px; margin-top: 8px; padding: 6px 8px; color: #d4dbc5; border: 1px solid #c8ceb044; border-radius: 18px; background: #1a251f; font: inherit; font-size: 12px; cursor: pointer; }
.game-language:focus-visible { outline: 2px solid #e2cd8e; outline-offset: 3px; }
@media (max-width: 700px) { .game-language { width: 44px; height: 44px; margin: 0; padding: 2px; font-size: 10px; border-radius: 50%; } }
html[lang=en] #story-event, html[lang=zh-Hans] #story-event { overflow-wrap: break-word; }

.game-language { appearance: none; text-align: center; text-align-last: center; letter-spacing: .02em; min-width: 44px; }
@media(max-width:700px) { .game-language { padding: 0; font-size: 12px; } }
