:root {
  --ink: #31251d; --paper: #f8efde; --spine: #243a49; --leaf: #465b40;
  --lake: #334f62; --rule: #b9a789; --brass: #e7d4a4; --focus: #994817;
  --text: Georgia, "Noto Serif", "Songti SC", "SimSun", serif;
  --ui: "Trebuchet MS", "Noto Sans", Arial, sans-serif;
  --gutter: clamp(1rem,2.35vw,2.4rem); --tap: 44px; --turn: 160ms;
  font: 100%/1.5 var(--text); color: var(--ink); background: var(--spine);
}
* { box-sizing: border-box }
body { margin: 0 }
button,input,textarea { font: inherit; color: inherit }
button { cursor: pointer; border: 0; background: transparent; padding: .45rem .75rem; min-height: var(--tap) }
button:focus-visible,input:focus-visible,textarea:focus-visible,a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px }
.spine button:focus-visible,.mobilebar button:focus-visible { outline-color: #f5d892 }
button:hover { text-decoration: underline; text-underline-offset: .2em }
svg { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -.22em; flex-shrink: 0 }
h1,h2,h3,p,dl,dd { margin: 0 }
.sr,.skip:not(:focus) { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%) }
.skip:focus { position:absolute; z-index:8; color:var(--ink); background:white; padding:1rem }
[hidden] { display:none !important }
.book { display: grid; grid-template-columns: minmax(155px,15.6fr) minmax(0,62.5fr) minmax(210px,21.9fr); min-height:100svh }
.paper { background: var(--paper) url("assets/paper.webp") repeat; }
.spine { display:flex; flex-direction:column; color:#fff6e5; background:var(--spine) url("assets/cloth.webp") repeat; min-width:0; position:relative; isolation:isolate; padding: clamp(1.15rem,2.8vw,2.7rem) .85rem 0; }
.imprint { display:flex; align-items:center; text-align:center; flex-direction:column; gap:.55rem; color:#f4e6cd; font-style:italic; font-size:clamp(1.6rem,2.85vw,3rem); line-height:1.02; }
.imprint svg { width:1.28em; height:1em; color:var(--brass) }
.case-slip { margin:1.65rem .05rem 1rem; padding:.9rem .25rem; text-align:center; color:var(--ink); background:var(--paper) url("assets/paper.webp"); font-size:clamp(1.3rem,2vw,2.1rem); font-style:italic; font-weight:bold; line-height:1.14; border-radius:3% 2% 5% 2% / 6% 7% 3% 5%; transform:rotate(-1deg); }
.locations { margin-top:clamp(.8rem,3vh,2.25rem) }
.locations h2 { font-size:1.1rem; font-weight:400; color:var(--brass); display:flex; align-items:center; gap:.45rem; border-bottom:1px solid #ad9e7f; padding:.55rem .25rem }
nav { display:grid; gap:.27rem; margin-top:.51rem }
nav button,.note-link,.mobilebar button,.mobile-evidence,.pinned,.paint { display:flex; align-items:center; gap:.6rem }
nav button { text-align:left; border-radius:3px; font-size:clamp(1rem,1.32vw,1.3rem); line-height:1.2 }
nav [aria-current="location"] { background:#eee2c2; color:var(--ink); font-weight:bold; }
.bookplate { width:100%; max-height:35vh; min-height:0; object-fit:contain; object-position:bottom center; margin:auto auto 0; padding-top:1rem; }
.scene { display:flex; flex-direction:column; min-width:0; background:#654d34; outline:0 }
.illustration { height:clamp(275px,57svh,690px); position:relative; flex: 1 0 auto; min-height:250px }
.illustration img { display:block; position:absolute; width:100%; height:100%; object-fit:cover; object-position:47% 43% }
.story-leaf { margin:-.65rem .4rem .5rem; position:relative; padding:clamp(1.1rem,2.35vw,2.1rem) var(--gutter) 1.35rem; border:1px solid var(--rule); border-radius:12px 7px 15px 6px / 6px 15px 7px 14px; box-shadow:0 3px 0 #d7c6a7,0 6px 0 #968266; }
.narration { font-size:clamp(1.08rem,1.55vw,1.52rem); font-style:italic; line-height:1.43; }
.speech { display:flex; align-items:baseline; gap:1rem; padding:1.12rem 0; margin:.75rem 0 .8rem; border-block:1px solid var(--rule); }
.speech b,.label { display:inline-block; padding:.18rem .78rem; background:#68775c; color:#fffbed; font:italic bold 1.1rem/1.35 var(--text); border-radius:6% 4% 3% 5%; }
.speech p { font-size:clamp(1.25rem,2vw,2.1rem); line-height:1.3; }
.actions { display:flex; gap:.8rem; }
.paint { border-radius:4px 7px 3px 6px; justify-content:center; color:#fffbed; font-weight:bold; line-height:1.25; padding:.7rem 1rem; }
.paint:hover,.send:hover { filter:brightness(1.12) }
.green,.send { background:var(--leaf) }
.blue { background:var(--lake) }
.actions .paint { flex:1; min-height:3rem; font-size:clamp(1.02rem,1.32vw,1.35rem) }
#question { margin-top:1rem; border:1px solid #9b8b70; border-radius:6px; display:flex; gap:.4rem; padding:3px; background:#fff7e8; align-items:center }
#ask { width:100%; min-width:0; border:0; background:transparent; padding:.45rem .65rem; font-style:italic; font-size:1.05rem }
.send { color:#fff6e6; border-radius:4px; min-width:var(--tap); }
.shelf { padding:1.3rem clamp(.85rem,1.6vw,1.8rem) 2rem; border-left:3px double var(--rule); min-width:0 }
.shelf h2 { font-size:clamp(1.6rem,2.55vw,2.7rem); font-weight:500; font-style:italic; line-height:1.2; padding:.2rem 0 1rem; border-bottom:1px solid var(--rule); }
.shelf h2 svg { width:.95em }
.label { background:#e1cfaa; color:var(--ink); margin:1.1rem 0 .65rem }
.specimen { display:flex; flex-direction:column; align-items:center; width:100%; max-height:38vh; margin-bottom:.7rem; padding:.45rem .55rem; border:1px solid #c8b899; border-radius:4px 11px 6px 4px; background:#efe3cb; }
.specimen img { width:100%; max-height:26vh; object-fit:contain; }
.specimen span { align-self:flex-end; font:.8rem/1.4 var(--ui); padding:.25rem; }
.evidence-name { font-size:clamp(1.25rem,1.95vw,2rem); line-height:1.3; }
.caption { font-size:clamp(1.04rem,1.38vw,1.3rem); line-height:1.45; margin:.4rem 0 .9rem }
.shelf .pin-toggle { width:100%; font-size:clamp(.98rem,1.3vw,1.25rem) }
.note-link { border-top:1px solid var(--rule); margin-top:1.05rem; padding:.8rem 0; width:100%; font-style:italic }
.mobilebar,.mobile-evidence { display:none }
dialog { width:min(610px,calc(100% - 2rem)); max-height:88svh; overflow:auto; border:1px solid var(--rule); border-radius:8px; color:var(--ink); padding:1.25rem clamp(1.1rem,4vw,2.25rem) 2rem; box-shadow:0 .8rem 3rem #18202470; }
dialog::backdrop { background:#182331aa }
dialog[open] { animation:insert var(--turn) ease-out }
@keyframes insert { from { opacity:.15; transform:translateY(.4rem) } }
.dialog-head { display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid var(--rule); font:italic 1.05rem var(--text); }
.close { min-width:var(--tap); }
dialog h2 { font-size:clamp(1.8rem,3.5vw,2.5rem); font-weight:500; font-style:italic; margin:1rem 0; }
.inspection { display:grid; grid-template-columns: 2fr 3fr; gap:1.5rem; align-items:center; margin-bottom:1.5rem }
.inspection img { width:100%; max-height:35vh; object-fit:contain }
dt { font:bold .86rem var(--ui); color:var(--leaf); margin:.8rem 0 .25rem }
dd { line-height:1.45 }
textarea { width:100%; resize:vertical; margin:.5rem 0; padding:.75rem; background:#fff8e9; border:1px solid var(--rule); border-radius:4px }
.note-footer { display:flex; gap:.8rem; align-items:center }
#note-status { font:.92rem var(--ui); }
.pinned { margin-bottom:.8rem; color:var(--leaf); border-bottom:1px solid var(--rule); }
.pinned button { padding-left:0; text-decoration:underline }
@media(max-width:900px) {
  .book { grid-template-columns: minmax(0,1fr) minmax(210px,28%); min-height:calc(100svh - 48px) }
  .spine { display:none }
  .mobilebar { display:flex; justify-content:space-between; align-items:center; padding:.1rem .55rem; background:var(--spine) url("assets/cloth.webp"); color:#fff4dc; }
}
@media(max-width:650px) {
  .book { display:block; min-height:auto; background:var(--paper) }
  .shelf { display:none }
  .illustration { height:clamp(210px,36svh,360px); min-height:0; flex:none }
  .scene { min-height:calc(100svh - 48px); background:var(--paper) url("assets/paper.webp"); }
  .story-leaf { flex:1; margin:-.65rem .32rem .32rem; padding:1.1rem .95rem .8rem; }
  .speech { gap:.6rem; padding:.85rem 0; }
  .speech b { font-size:.95rem; }
  .actions { gap:.5rem }
  .actions .paint { font-size:1rem; padding:.45rem .5rem; }
  .actions svg { width:1.05rem }
  .mobile-evidence { display:flex; width:100%; justify-content:center; border-top:1px solid var(--rule); margin:.7rem auto 0; padding-top:.7rem; font-style:italic; }
  .mobile-evidence img { width:2.4rem; height:2.7rem; object-fit:contain; }
  .inspection { gap:1rem; }
}
@media(max-width:370px) { .actions { flex-direction:column } .inspection { grid-template-columns:1fr } .inspection img { max-height:24vh } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important } }
.entrance { max-width: 680px; margin: 5vh auto; padding: clamp(1rem,5vw,3rem); border-radius: 8px; }
.entrance h1 { font-size: 2.5rem; font-style: italic; margin-bottom: 1rem; }
.entrance form, .case-card { display: grid; gap: .8rem; margin-top: 1rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
input,select { padding: .6rem; border: 1px solid var(--rule); border-radius: 4px; background: #fff8e9; min-width: 0; max-width: 100%; }
.actions { flex-wrap: wrap; margin-block: 1rem; }
.actions .paint { flex: 1 1 155px; }
.question { display: flex; gap: .5rem; margin-block: 1rem; }
.question input { flex: 1; }
.puzzle,.editor,.evidence-card { border-top: 1px solid var(--rule); padding: .85rem 0; }
.puzzle input { width: 100%; margin: .5rem 0; }
.evidence-card img { width: 100%; max-height: 200px; object-fit: contain; }
summary { cursor: pointer; padding: .6rem 0; min-height: 44px; }
.status { font: .9rem var(--ui); color: var(--leaf); min-height: 1.3em; overflow-wrap: anywhere; }
button:disabled { opacity: .5; cursor: default; }
.shelf { overflow-wrap: anywhere; }
.scene { overflow-wrap: anywhere; }
.shelf .paint { margin-block: .4rem; width: 100%; }
.puzzle { background:#fff9ec; border:2px solid #ad8b4e; border-radius:12px; padding:1.25rem; margin:1.5rem 0; box-shadow:0 4px 14px #59432612; }
.puzzle-tag { display:inline-block; font-size:.82rem; font-weight:700; letter-spacing:.08em; color:#79541e; background:#ebddbd; border-radius:4px; padding:.25rem .6rem; }
.puzzle-question { font-size:clamp(1.35rem,2.3vw,1.75rem); color:#3d3829; margin:.7rem 0; line-height:1.5; }
.puzzle-reference { color:#665b47; margin:0 0 1rem; }
.puzzle label { font-weight:700; display:block; }
.feedback { border-radius:6px; padding:.7rem .85rem; margin:.8rem 0 0; font-weight:700; }
.correct { background:#e1eccd; color:#30552b; }
.wrong { background:#f5ded4; color:#852c21; }
.hint { background:#eee2c3; color:#634819; }
.investigation-dialog { width:min(680px,calc(100% - 2rem)); max-height:90dvh; padding:1.5rem; color:var(--ink,#332e27); border:1px solid var(--rule); border-radius:12px; box-shadow:0 18px 70px #17251c60; overflow:hidden; }
.investigation-dialog[open] { display:flex; flex-direction:column; }
.dialog-scroll { min-height:0; overflow:auto; overscroll-behavior:contain; }
.investigation-dialog::backdrop { background:#17251cb8; backdrop-filter:blur(3px); }
.dialog-header { display:flex; flex:none; justify-content:space-between; gap:1rem; align-items:center; border-bottom:1px solid var(--rule); margin-bottom:1rem; background:inherit; }
.dialog-header h2 { font-size:1.45rem; margin:.2rem 0 .8rem; }
.dialog-close { flex:none; border:1px solid var(--rule); border-radius:5px; }
.dialog-content { display:grid; gap:.8rem; }
.detail-card { border:1px solid var(--rule); padding:1rem; border-radius:8px; background:#fffaf0; }
.detail-body { white-space:pre-line; font-size:1.12rem; line-height:1.85; }
.detail-image { width:100%; max-height:55dvh; object-fit:contain; background:#e9dfca; border-radius:6px; display:block; }
.conversation-history { display:grid; gap:.7rem; max-height:45dvh; overflow:auto; padding:.2rem; }
.chat-line { background:#f3ead9; padding:.85rem; border-radius:8px; border-left:3px solid #64785a; }
.chat-line.player { margin-left:12%; background:#dae6e5; border-color:#537b80; }
.chat-line strong { color:#365d3b; }
.chat-evidence { margin-top:.5rem; border-top:1px solid var(--rule); }
.evidence-list { max-height:28rem; overflow:auto; margin-bottom:.7rem; }
.evidence-entry { width:100%; display:flex; flex-direction:column; text-align:left; gap:.15rem; padding:.7rem .4rem; border-bottom:1px solid var(--rule); }
.evidence-entry small { font-size:.82rem; opacity:.8; }
.shelf input { width:100%; }
.case-cover { display:block; }
.case-cover img { display:block; width:100%; max-height:36rem; object-fit:contain; border-radius:6px; }
.shelf { position:relative; isolation:isolate; }
.notebook-decoration { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; opacity:.13; z-index:-1; pointer-events:none; }
@media(max-width:650px) { .investigation-dialog { width:calc(100% - 1rem); padding:1rem; } .puzzle { padding:1rem; } }
@media(max-width:650px) {
  .shelf { display:block; border-left: 0; border-top: 3px double var(--rule); }
  .mobilebar { position: sticky; top: 0; z-index: 5; gap: .25rem; }
  .mobilebar select { flex: 1; width: 0; }
  .scene { min-height: auto; }
  .entrance { margin: 0; min-height: 100svh; border-radius: 0; }
}
