:root{color-scheme:dark;--bg:#080808;--surface:#151515;--text:#ffffff;--muted:#d2d2d2;--gold:#ff5454;--line:#444444;--red:#ff9393}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:1rem/1.65 system-ui,sans-serif}button,input,select{font:inherit}button{cursor:pointer;min-height:48px;padding:11px 20px;border:1px solid #777777;border-radius:5px;background:transparent;color:var(--text);text-align:left}button:hover{background:#252525;border-color:var(--gold)}button:disabled{opacity:.5;cursor:default}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid var(--gold);outline-offset:4px}button.primary{background:var(--gold);border-color:var(--gold);color:#080808;font-weight:700}button.quiet{border-color:transparent;color:var(--muted)}a{color:inherit}header{max-width:1360px;margin:auto;padding:30px 5%;display:flex;justify-content:space-between;gap:24px;align-items:center;border-bottom:1px solid var(--line)}.brand{text-decoration:none;font-family:Georgia,serif;letter-spacing:.14em;font-size:1.05rem}.brand span{display:block;font: .75rem/2.1 system-ui,sans-serif;letter-spacing:.17em;color:var(--muted)}main{max-width:1240px;margin:auto;padding:52px 4% 80px}.welcome{max-width:820px;padding:25px 0}.eyebrow{color:var(--gold);font-size:.8rem;letter-spacing:.16em;font-weight:650;margin:0 0 18px}h1{font-family:Georgia,serif;font-weight:400;font-size:clamp(2.5rem,5.5vw,4.8rem);line-height:1.12;letter-spacing:-.025em;margin:20px 0 28px}h2,h3{font-family:Georgia,serif;font-weight:400}h2{font-size:1.65rem}.intro{font-size:1.25rem;color:var(--muted);line-height:1.8}.start-actions{display:flex;gap:14px;flex-wrap:wrap;margin-top:34px}.fine{font-size:.875rem;color:var(--muted)}.opening-notes{border-top:1px solid var(--line);margin-top:38px;padding-top:18px;max-width:600px;color:var(--muted)}.opening-notes strong{color:var(--text)}.chapterline{display:flex;justify-content:space-between;gap:20px;color:var(--muted);font-size:.8rem;letter-spacing:.08em;padding-bottom:28px;border-bottom:1px solid var(--line)}.game-grid{display:grid;grid-template-columns:minmax(0,1fr) 250px;gap:64px;margin-top:32px}.scene-top{display:flex;align-items:center;justify-content:space-between}.scene-top .eyebrow{margin:0}#sceneTitle{font-size:clamp(2.2rem,4vw,3.4rem);outline:none}.transport{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:0 0 30px}.transport button{font-size:.875rem;padding:7px 12px;min-height:44px}#playback{color:var(--muted);font-size:.8rem;width:100%}.line{margin:0 0 23px;font-size:1.13rem;line-height:1.9}.line.rook{padding-left:20px;border-left:2px solid var(--gold)}.line.other{padding-left:20px;border-left:2px solid var(--red)}.speaker{display:block;font-size:.75rem;line-height:1.5;font-family:system-ui,sans-serif;color:var(--gold);letter-spacing:.12em;font-weight:700;margin-bottom:6px}.line.other .speaker{color:var(--red)}#choices{display:grid;gap:12px;margin-top:38px}#choices button{display:flex;align-items:baseline;gap:16px;background:var(--surface);padding:18px;border-color:var(--line);width:100%}#choices button:hover{border-color:var(--gold);background:#222222}.choice-number{color:var(--gold);font-size:.875rem}.choiceHint{font-size:.875rem;color:var(--muted)}aside{border-left:1px solid var(--line);padding-left:28px}aside .eyebrow{margin-bottom:8px}aside h2{margin:0}aside p{margin-top:5px;color:var(--muted)}.aside-block{margin-bottom:30px}aside ul{padding-left:18px;color:var(--muted)}aside button{width:100%;margin-bottom:10px;font-size:.875rem}.aside-block li{margin:8px 0}footer{max-width:1240px;padding:24px 4%;margin:auto;border-top:1px solid var(--line);display:flex;justify-content:space-between;gap:16px;color:var(--muted);font-size:.75rem;letter-spacing:.08em}dialog{width:min(580px,92vw);max-height:90vh;background:var(--surface);color:var(--text);border:1px solid #777777;border-radius:8px;padding:30px}dialog::backdrop{background:#000b}dialog h2{margin-top:0}dialog label:not(.check){display:block;margin:18px 0 8px}dialog select{width:100%;padding:10px;background:var(--bg);color:var(--text);border:1px solid var(--line)}dialog input[type=range]{width:100%;accent-color:var(--gold)}dialog .check{display:flex;gap:12px;align-items:center;margin:20px 0}input[type=checkbox]{width:22px;height:22px;accent-color:var(--gold)}dialog button{margin:8px 8px 4px 0}.sr-only,.skip:not(:focus){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.skip:focus{display:block;padding:15px} [hidden]{display:none!important}@media(max-width:780px){header{padding:20px 5%;align-items:flex-start}.brand{font-size:.85rem}.brand span{font-size:.65rem;letter-spacing:.07em}header button{padding:8px;font-size:.875rem}.game-grid{grid-template-columns:1fr;gap:35px}aside{border-left:0;padding-left:0;border-top:1px solid var(--line);padding-top:30px}main{padding:30px 5% 50px}.chapterline{flex-direction:column;gap:5px}.welcome{padding-top:8px}footer{flex-direction:column}.line{font-size:1.05rem}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}

#geminiKey{width:100%;padding:12px;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:4px}#geminiStatus{color:var(--gold)}

#tapDialog{width:100vw;max-width:none;height:100dvh;max-height:none;margin:0;border:0;border-radius:0;padding:20px;overflow:auto}#tapDialog h2{font-size:1.5rem;margin:0}#tapSurface{display:block;width:100%;min-height:55dvh;background:var(--surface);border:2px solid var(--gold);text-align:center;font-size:1.4rem;touch-action:manipulation;user-select:none;-webkit-user-select:none}#tapNumbered{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:14px 0}#tapNumbered button{margin:0;font-size:1rem}.tap-tools{display:flex;flex-wrap:wrap;gap:8px}#tapStatus{font-size:1rem}

.transport{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));max-width:420px;align-items:stretch}.transport #playback{grid-column:1 / -1}.transport #restartGame{grid-column:2;grid-row:2}

/* Only the choice overlay locks the page; regular controls retain scrolling and zoom. */
html.tap-viewport-locked{overflow:hidden;overscroll-behavior:none}
body.tap-viewport-locked{position:fixed;width:100%;overflow:hidden;overscroll-behavior:none}
#tapDialog{position:fixed;inset:0;width:100%;height:100vh;height:100dvh;overflow:hidden;overscroll-behavior:none;padding:16px;padding-bottom:max(16px,env(safe-area-inset-bottom))}
#tapDialog[open]{display:grid;grid-template-rows:auto auto minmax(0,1fr) auto;gap:10px}
#tapDialog h2{font-size:1.15rem;line-height:1.3}
#tapStatus{margin:0;font-size:.9rem;line-height:1.35;overflow-wrap:anywhere}
#tapSurface{min-height:0;height:100%;min-width:0;margin:0;touch-action:none;-webkit-touch-callout:none;overflow-wrap:anywhere;font-size:1.25rem}
#tapRepeat{margin:0;width:100%;min-height:52px;text-align:center}
#tapDialog.controls-open{grid-template-rows:auto auto minmax(0,1fr)}
#tapControlsPanel{min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y pinch-zoom;padding:4px}
#tapNumbered{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;margin:0 0 18px}
#tapNumbered button{min-width:0;min-height:56px;height:auto;overflow-wrap:anywhere}
.tap-tools{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;min-width:0}.tap-tools button{margin:0;min-height:56px;touch-action:manipulation}
@media(max-height:480px){#tapDialog[open]{gap:6px;padding:8px}#tapSurface{font-size:1rem;padding:8px}}

/* Reserve a measured strip for fixed corner controls, including inside modals. */
:root{--playback-bar-height:80px}
#floatingPlayback{position:fixed;z-index:1000;top:0;left:0;right:0;display:flex;justify-content:space-between;gap:12px;padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));background:var(--bg);border-bottom:1px solid var(--line)}
#floatingPlayback button{margin:0;min-height:56px;width:calc(50% - 6px);max-width:230px;padding:8px 12px;font-size:1rem;line-height:1.3;background:var(--surface);border-color:var(--gold);text-align:center;touch-action:manipulation}
body.adventure-active{padding-top:var(--playback-bar-height)}
body.adventure-active #tapDialog{padding-top:calc(var(--playback-bar-height) + 8px)}
body.adventure-active dialog:not(#tapDialog){margin-top:calc(var(--playback-bar-height) + 12px);max-height:calc(100dvh - var(--playback-bar-height) - 24px)}
html:has(body.adventure-active){scroll-padding-top:calc(var(--playback-bar-height) + 12px)}

:root{--bottom-bar-height:80px}
#floatingBottom{position:fixed;z-index:1000;bottom:0;left:0;right:0;display:flex;justify-content:space-between;gap:12px;padding:8px max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));background:var(--bg);border-top:1px solid var(--line)}
#floatingBottom button{margin:0;min-height:56px;width:calc(50% - 6px);max-width:230px;padding:8px 12px;font-size:1rem;line-height:1.3;background:var(--surface);border-color:var(--gold);text-align:center;touch-action:manipulation}
body.adventure-active{padding-bottom:var(--bottom-bar-height)}
body.adventure-active #tapDialog{padding-bottom:calc(var(--bottom-bar-height) + 8px)}
body.adventure-active dialog:not(#tapDialog){max-height:calc(100dvh - var(--playback-bar-height) - var(--bottom-bar-height) - 24px);margin-bottom:calc(var(--bottom-bar-height) + 12px)}
html:has(body.adventure-active){scroll-padding-bottom:calc(var(--bottom-bar-height) + 12px)}
.playback-status{margin-bottom:20px}

.line.speaking-passage{background:#ff545415;outline:1px solid #ff545466;outline-offset:6px;border-radius:2px}
