/* Shared adventure UI: physical controls, readable paper, stable scene coordinates. */
:root{--ui-target:48px;--ui-gap:8px;--ui-ink:#38291b;--ui-paper:#f8edcc;--ui-edge:#765334;--ui-focus:#f5ce78;--ui-safe-top:env(safe-area-inset-top,0px);--ui-safe-bottom:env(safe-area-inset-bottom,0px)}
button,a{touch-action:manipulation}
button:focus-visible,a:focus-visible{outline:3px solid var(--ui-focus);outline-offset:3px}
.scene-navigation,.case-hotspot,.case-npc{cursor:pointer}
.scene-navigation{min-width:var(--ui-target);min-height:var(--ui-target)}
.scene-navigation svg{max-width:100%;max-height:100%}
/* Navigation returns only after the dialogue, including pauses between lines. */
body.ds-dialogue-visible .scene-navigation,
.tbt-conversation-active .scene-navigation,
.scene:has(#speech-bubble.visible) .scene-navigation{visibility:hidden!important;pointer-events:none!important}
.scene-navigation:active svg{filter:drop-shadow(0 0 4px #ffe2a4);opacity:.75}
.case-hotspot:active,.hotspot:active{background:#f5d89524;box-shadow:inset 0 0 0 2px #eed39988}
.game-tools button:active,.case-paper-button:active,#items button:active{filter:brightness(.92)}
#ds-dialogue{border-color:var(--ui-ink);box-shadow:inset 0 0 0 2px #b39a67,0 3px 0 #24180d66}
#ds-dialogue .ds-advance{min-height:44px;min-width:110px;padding:7px 14px}
.ds-message>p:not(.sr-only){line-height:1.2}
.ds-speaker span{letter-spacing:.025em}
.tbt-ds .game-tools .small-tool,.tbt-ds .game-tools #show-points{width:44px;height:44px}
.inventory #close-inventory,.case-sheet .case-close,dialog#panel #close{min-width:44px;min-height:44px;display:grid;place-items:center;padding:0;z-index:5}
.inventory-heading{gap:12px}
.inventory #items button{min-height:48px}
.inventory{overscroll-behavior:contain}
#tbt-case-panel{overscroll-behavior:contain}
.case-sheet header{min-height:48px;height:auto}
.case-paper-button{min-height:44px}
@media(hover:hover){.scene-navigation:hover svg{filter:drop-shadow(0 0 4px #ffe3a5)}.case-npc:focus-visible{filter:drop-shadow(0 0 5px #ffe7a0)}}
/* Portrait uses the space below the composition, without stretching/cropping its art. */
@media(max-width:900px) and (orientation:portrait), (max-width:1100px) and (max-height:600px) and (orientation:landscape){
 body{display:flex;flex-direction:column;min-height:100dvh;padding:max(8px,var(--ui-safe-top)) 6px max(12px,var(--ui-safe-bottom));overflow-x:hidden}
 .game-window{width:100%;flex:none;margin:auto 0;padding:0 0 var(--ui-lower-height,0px);border-width:2px;border-radius:8px;overflow:visible;box-shadow:0 8px 24px #0004}
 .game-menu-visible .game-window{display:none}
 .game-window>header{height:auto;min-height:54px;padding:5px 8px;gap:6px;flex-wrap:wrap}
 .game-window>header .game-brand{margin-right:auto}
 .game-window>header .game-brand p{display:none}
 .game-window>header a{font-size:11px;min-height:44px;display:flex;align-items:center}
 .game-window>header #main-menu-toggle{min-width:48px;min-height:44px;font-size:12px;padding:6px 10px}
 .game-window>header #restart{display:none} /* New game remains in the main menu. */
 .game-window>header #debug-toggle{font-size:9px;min-height:44px;padding:5px}
 .scene{aspect-ratio:4/3;overflow:visible}
 .room-tag{font-size:9px;max-width:75%;letter-spacing:.05em;pointer-events:none}
 .scene .game-tools,.scene.tbt-ds .game-tools{top:calc(100% + 10px);bottom:auto;left:8px;right:8px;display:flex;gap:6px;justify-content:space-between;align-items:start;padding:0;border:0;background:none;box-shadow:none;backdrop-filter:none;z-index:18}
 .scene:has(.case-notebook) .game-tools{right:66px}
 .scene .game-tools .tool,.scene .game-tools #show-points{position:relative;width:52px;min-width:48px;height:56px;min-height:48px;display:flex;justify-content:center;padding:3px 2px;gap:2px;border:2px solid var(--ui-edge);border-radius:7px;background:linear-gradient(#fff5d7,#dfc998);box-shadow:inset 0 1px #fff9e5,0 2px #51351e55;color:var(--ui-ink);font:12px/1.1 'Trebuchet MS',sans-serif}
 .scene .game-tools .tool svg,.scene .game-tools .small-tool svg{width:27px;height:27px}
 .scene .game-tools .tool>span,.scene .game-tools #phone>span,.scene .game-tools #inventory-toggle>span{display:block;font:11px/1.1 'Trebuchet MS',sans-serif}
 .scene .game-tools .small-tool .hint-icon{font:bold 27px/27px Georgia;height:27px}
 .scene .game-tools .tool-status{position:absolute;left:0;right:0;top:65px;font-size:12px;line-height:1.4}
 .scene .game-tools #save{display:none}
 #tbt-investigation .case-notebook{top:calc(100% + 10px)!important;right:8px!important;width:52px;min-width:48px;height:56px;padding:3px;font-size:25px;line-height:1;z-index:18}
 .case-notebook span{font:11px/1.1 'Trebuchet MS',sans-serif}
 #ds-dialogue{top:calc(100% + 88px);bottom:auto;left:8px;right:8px;min-height:138px;padding:22px 14px 10px;border-width:2px;border-radius:9px}
 .ds-speaker{font-size:23px;min-width:86px;max-width:65%;left:12px}
 #ds-dialogue:not([data-speaker="AKIEL"]) .ds-speaker{right:12px}
 .ds-speaker span{padding:5px 14px}
 .ds-message{gap:8px}
 .ds-message>p:not(.sr-only){font-size:25px;line-height:1.12;min-height:2.25em}
 #ds-dialogue .ds-advance{font-size:23px;min-height:44px;padding:6px 12px}
 .ds-dialogue-visible .game-tools,.ds-dialogue-visible .case-notebook{opacity:.48}
 .scene .inventory,.scene.tbt-ds .inventory{top:calc(100% + 78px);left:8px;right:8px;bottom:auto;width:auto;max-height:min(340px,48dvh);padding:10px 12px;z-index:20;border-width:2px}
 .inventory h2,.tbt-ds .inventory h2{font:26px 'Nintendo DS',monospace}
 .scene .inventory p,.scene #items button{font-size:16px;line-height:1.35}
 .scene.tbt-ds .inventory p,.scene.tbt-ds #items button{font-size:23px;line-height:1.15}
 #items{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 #items button{padding:8px;min-width:0}
 #items button span{white-space:normal}
 .scene-navigation{min-width:48px;min-height:48px}
 .scene-navigation svg{width:34px;height:34px}
 .case-hotspot,.hotspot{min-width:44px;min-height:44px}
 .case-hotspot span,.hotspot span{max-width:160px;white-space:normal;font-size:16px}
 /* Normal document overlays can use the lower screen; art inspections retain their geometry. */
 #tbt-case-panel:not([data-view=guitar]):not([data-view=photo-front]){inset:8px 8px auto;max-height:calc(100svh - 100px - var(--ui-safe-top) - var(--ui-safe-bottom));min-height:calc(100% - 16px);border-width:2px}
 #tbt-case-panel .case-sheet{padding:12px}
 #tbt-case-panel .case-sheet header{position:sticky;top:-12px;background:var(--ui-paper);z-index:4;padding:0 0 8px;gap:8px}
 .case-sheet h2{font-size:26px}
 .case-document p,.case-notes p,.case-instructions,.case-feedback{font-size:24px;line-height:1.2}
 .case-paper-button{font-size:23px;padding:8px 12px}
 .case-guitar-back{min-width:48px;min-height:48px}
 dialog#panel{left:50%;top:50%;width:calc(100vw - 20px);max-width:calc(100vw - 20px);max-height:calc(100dvh - 32px - var(--ui-safe-top) - var(--ui-safe-bottom));padding:20px 16px;border-radius:10px}
 dialog#panel h2{font-size:22px;margin-right:40px}
 dialog#panel p,.choices button,.bubble{font-size:15px;line-height:1.45}
 dialog#panel .choices button{min-height:48px;padding:10px}
 dialog#panel.phone-panel{width:min(360px,calc(100vw - 20px));height:min(600px,calc(100dvh - 40px - var(--ui-safe-top) - var(--ui-safe-bottom)));padding:6px}
 .phone-panel #close{top:8px;right:8px}
 .phone-status{padding-right:55px;min-height:44px}
 .phone-message{font-size:14px;padding:8px 10px}
 .phone-replies button,.phone-apps button,.phone-text-button,.phone-call-button{min-height:44px}
 .phone-apps button{font-size:11px}
 .phone-home{padding:16px;gap:16px}
 .phone-clock{font-size:40px}
 .phone-ep-card{padding:10px;min-height:85px}
 .phone-ep-card strong{font-size:15px}
 .phone-ep-card small,.phone-ep-card span span{font-size:11px}
 .phone-apps{gap:12px;padding:10px 0}
 .phone-apps i{width:44px;height:44px}
 .phone-home-bar,.phone-home-button{min-height:44px}
 .phone-app-header{min-height:48px}
 .phone-app-header strong{font-size:16px}
 .phone-replies button{font-size:14px;padding:8px}
 .music-track{min-height:48px}.music-track strong{font-size:14px}.music-track small{font-size:11px}
 .tbt-case-inspecting .game-tools,.tbt-case-inspecting .case-notebook{opacity:.4}
 #main-menu{position:fixed;inset:0;min-height:0;height:100dvh;padding:max(16px,var(--ui-safe-top)) 16px max(16px,var(--ui-safe-bottom));overflow:auto;z-index:40}
 .main-menu-content{width:100%;max-width:360px;max-height:none;padding:22px}
 #main-menu button{min-height:48px;font-size:15px;padding:10px 14px}
 #main-menu button small,.main-menu-note{font-size:11px}
 #main-menu #restart{margin-top:16px;background:none;border:1px solid #ad9166;color:#e8d5b4;width:100%;font-size:12px}
 .menu-akiel{display:none}
 .case-photo-talking #ds-dialogue{z-index:26}
}
@media(prefers-reduced-motion:reduce){.scene-navigation svg,.game-tools button{transition:none}}

/* Keep menu padding inside the scene rather than extending its scroll area. */
#main-menu{box-sizing:border-box;min-height:0}
#main-menu .main-menu-content{box-sizing:border-box;flex-shrink:0}


@media(min-width:601px){#main-menu{padding-top:24px;padding-bottom:24px}.main-menu-content{max-height:100%}}

/* Portrait-only mobile play, including browsers without orientation locking. */
.game-rotation-guard[open]{position:fixed;inset:0;box-sizing:border-box;width:100vw;max-width:none;height:100dvh;max-height:none;margin:0;padding:max(24px,env(safe-area-inset-top)) max(28px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(28px,env(safe-area-inset-left));border:0;border-radius:0;background:#1f241b;color:#efe0b9;display:grid;place-items:center;text-align:center;overflow:hidden;touch-action:none}
.game-rotation-guard::backdrop{background:#1f241b}
.rotation-guard-copy{max-width:460px}
.rotation-guard-copy>span{display:block;color:#d2b774;font:64px/1 Georgia,serif;margin-bottom:12px}
.rotation-guard-copy h2{font:400 24px/1.25 'Syne Mono',monospace;margin:0 0 12px}
.rotation-guard-copy p{font:14px/1.5 'Syne Mono',monospace;margin:0;color:#c8bea4}
