:root{color-scheme:light;--ink:#25252a;--muted:#8a8988;--paper:#f6f4f0;--line:#e7e3dc;--accent:#b7644d;--dark:#1b1f2a;--serif:Georgia,'Times New Roman',serif;--sans:Inter,'Segoe UI',sans-serif}
*{box-sizing:border-box}html{background:var(--paper);scroll-behavior:smooth}body{margin:0;color:var(--ink);font-family:var(--sans);font-size:14px}button,input,textarea{font:inherit}button{cursor:pointer}.hidden{display:none!important}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.topbar{height:76px;background:#fff;display:flex;align-items:center;justify-content:space-between;padding:0 5.3%;border-bottom:1px solid #eeeae4}.brand{display:flex;align-items:center;gap:11px;text-decoration:none;color:#20232a;font-size:15px;font-weight:800;letter-spacing:.09em}.brand small{display:block;font-size:8px;font-weight:600;letter-spacing:.35em;margin-top:4px}.brand-mark{font-size:29px;color:var(--accent);font-weight:400}.topbar-right{display:flex;align-items:center;gap:30px}.status{font-size:11px;color:#93918d}.status span{display:inline-block;width:7px;height:7px;background:#8cae92;border-radius:50%;margin-right:7px}.text-button{border:0;background:none;font-size:11px;font-weight:600;color:#5e5b58}.text-button span{font-size:15px;margin-left:8px;color:var(--accent)}
.layout{display:grid;grid-template-columns:305px minmax(0,1fr);min-height:calc(100vh - 76px);max-width:1600px;margin:0 auto}.sidebar{background:var(--dark);color:#faf8f4}.sidebar-inner{padding:53px 32px 34px;position:sticky;top:0;min-height:calc(100vh - 76px);display:flex;flex-direction:column}.eyebrow{font-size:9px;font-weight:750;letter-spacing:.2em;color:#99969a}.eyebrow span{float:right;color:#6b7078}.line{height:1px;background:#3c3f48;margin:23px 0 34px}.sidebar-heading p{font-family:var(--serif);font-size:29px;line-height:1.2;letter-spacing:-.03em;margin:0}.sidebar-heading em{color:#d79a83;font-weight:400}.aside-copy{font-size:12px;color:#a7a8ad;line-height:1.8;margin:19px 0 46px;max-width:220px}.aside-section{border-top:1px solid #3a3d46;padding-top:23px}.aside-label{font-size:9px;letter-spacing:.17em;font-weight:700;color:#aaa9ad;display:flex;justify-content:space-between}.aside-label span{color:#6b7078}.character-list{display:grid;gap:17px;margin-top:25px}.character{display:flex;gap:12px;align-items:center}.avatar{flex:none;width:38px;height:38px;border-radius:50%;display:grid;place-items:center;font-family:var(--serif);font-size:17px;background:#645246;color:#f0d9cb}.avatar.lina{background:#626755;color:#e2e2cf}.avatar.maya{background:#4c5c71;color:#d5ddea}.character strong{display:block;font-size:12px;font-weight:600}.character small{display:block;margin-top:4px;font-size:10px;color:#999ba2}.character .seen{margin-left:auto;color:#b89a8d;font-size:13px}.sidebar-footer{margin-top:auto;padding-top:50px;display:flex;gap:13px;align-items:center;color:#85858c;font-family:var(--serif);font-size:13px;line-height:1.35}.sidebar-footer p{margin:0}.spark{font-size:24px;color:#b66c57}
.story-area{background:#f8f7f4;min-width:0}.story-top{height:68px;padding:0 7%;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.breadcrumb{font-size:9px;font-weight:700;letter-spacing:.17em;color:#a8a49e}.breadcrumb span{color:#d0ccc5;margin:0 9px}.mode{font-size:10px;color:#88847d;border:1px solid #e0dcd6;padding:8px 10px;border-radius:2px}.story-content{max-width:810px;margin:0 auto;padding:58px 38px 70px}.warm{color:#b2705d}.bullet{float:none!important;margin:0 9px;color:#c5aa99!important}.story-heading h1{font-family:var(--serif);font-size:clamp(50px,7vw,78px);line-height:.94;letter-spacing:-.055em;font-weight:400;margin:22px 0 18px}.story-heading h1 em{color:#b56c57;font-weight:400}.story-description{font-family:var(--serif);font-size:17px;color:#8b8178;line-height:1.5}.chapter-bar{display:flex;justify-content:space-between;align-items:center;border-top:1px solid #ded9d1;border-bottom:1px solid #ded9d1;margin:45px 0 30px;padding:14px 0;color:#9c9690;font-size:9px;letter-spacing:.16em;font-weight:750}.chapter-bar>div{display:flex;gap:11px;align-items:center}.chapter-icon{font-size:19px;color:var(--accent)}
.messages{display:grid;gap:19px}.message{max-width:100%;line-height:1.76;white-space:pre-wrap;overflow-wrap:anywhere}.message.scene{font-family:var(--serif);font-size:17px;color:#55514d;line-height:1.8;padding:2px 0 12px}.message.player{justify-self:end;background:#ece7e0;padding:15px 19px;border-radius:3px 3px 0 3px;max-width:85%;font-size:13px}.message.assistant{background:white;border:1px solid #ece8e2;padding:20px 23px;font-size:14px;color:#4e4a46}.message.choice{justify-self:end;color:#a67665;font-size:11px;font-weight:600;letter-spacing:.02em}.message-label{display:block;color:#ae725f;font:700 9px var(--sans);letter-spacing:.15em;margin-bottom:10px}.message.scene .message-label{font-family:var(--sans)}.pending{opacity:.7}.choices{display:grid;gap:9px;margin:23px 0}.choice{display:flex;justify-content:space-between;align-items:center;text-align:left;border:1px solid #e5e0d9;background:#fff;padding:15px 18px;color:#37332f;transition:background .15s,border-color .15s}.choice:hover{border-color:#c6907c;background:#fffaf7}.choice span{display:block;font-weight:600;font-size:12px}.choice small{display:block;font-size:11px;color:#a9a29a;margin-top:5px}.choice b{font-weight:400;font-size:18px;color:#bf806a}.composer{margin-top:33px}.composer-caption{display:flex;justify-content:space-between;font-size:9px;letter-spacing:.16em;font-weight:750;color:#8d8780;margin-bottom:12px}.composer-caption span:last-child{color:#bab3ab}.composer form{background:white;border:1px solid #e5e1da;padding:16px 17px}.composer textarea{width:100%;border:0;resize:vertical;min-height:70px;color:#38322e;outline:0;line-height:1.5}.composer textarea::placeholder{color:#b8b2ab}.composer-bottom{display:flex;align-items:center;justify-content:space-between;border-top:1px solid #f0ece6;padding-top:11px}.composer-bottom>span{font-size:10px;color:#b6b0a9}.button{border:0;padding:13px 18px;font-size:11px;font-weight:700;letter-spacing:.02em}.button.primary{color:white;background:#b66c55}.button.primary:hover{background:#9e5845}.button.primary:disabled{opacity:.55;cursor:wait}.button span{margin-left:25px;font-size:15px}.story-foot{border-top:1px solid var(--line);margin-top:55px;padding-top:23px;color:#b76d57;font-size:18px;display:flex;gap:12px;align-items:center}.story-foot span{color:#b6afa7;letter-spacing:.16em;font-size:8px;font-weight:700}.error{color:#9f3e35;line-height:1.5;font-size:12px;margin-top:15px}
.locked{max-width:520px;margin:10vh auto;background:white;border:1px solid var(--line);padding:55px}.locked h1,dialog h2{font-family:var(--serif);font-size:40px;font-weight:400;letter-spacing:-.04em}.locked p,dialog p{color:#827a73;line-height:1.6}.locked label,dialog label{display:block;font-size:11px;font-weight:700;margin:25px 0 8px}.unlock-row{display:flex;gap:8px}.unlock-row input,dialog input{min-width:0;flex:1;border:1px solid #ded9d1;padding:12px;outline-color:#bd816d}dialog{width:min(460px,calc(100% - 32px));border:0;padding:32px;box-shadow:0 15px 70px #0003}dialog::backdrop{background:#1119}dialog h2{font-size:32px;margin:18px 0 10px}dialog input{width:100%}.dialog-actions{display:flex;justify-content:flex-end;gap:9px;margin-top:25px}.button.outline{background:white;border:1px solid #e2ddd7}
.message.pending::after{content:'Пишет ответ…';display:block;color:#a67665;font-size:12px;letter-spacing:.02em;animation:thinking 1.4s ease-in-out infinite}@keyframes thinking{50%{opacity:.38}}@media(prefers-reduced-motion:reduce){.message.pending::after{animation:none}}
.chapter-actions{display:flex;align-items:center;gap:16px}.history-button{display:inline-flex;align-items:center;gap:7px;border:1px solid #ded7d0;border-radius:30px;background:#fff;color:#756a64;padding:9px 13px;font-size:11px;letter-spacing:0;font-weight:650}.history-button:hover{border-color:#b9705c;color:#9e5845}.turn-status{color:#a67665;font-size:12px;margin-top:12px;animation:thinking 1.4s ease-in-out infinite}.history-dialog{width:min(720px,calc(100% - 28px));max-height:min(80vh,780px);padding:0;border-radius:10px;overflow:hidden;background:#f8f7f4;color:#25252a}.history-header{display:flex;align-items:center;justify-content:space-between;gap:15px;padding:22px 26px;border-bottom:1px solid #e5e0d9;background:#fff}.history-kicker{font-size:9px;font-weight:700;letter-spacing:.15em;color:#b2705d}.history-header h2{font-size:28px;margin:6px 0 0}.history-close{border:1px solid #e3dcd5;background:#fff;color:#675d57;border-radius:50%;width:36px;height:36px}.history-messages{max-height:calc(min(80vh,780px) - 110px);overflow-y:auto;padding:24px 26px;overscroll-behavior:contain}.history-messages .message.scene{padding:0}.history-messages .message.choice{justify-self:start;border-left:2px solid #d9b4a7;padding-left:10px}.history-messages .message.player{max-width:90%}@media(prefers-reduced-motion:reduce){.turn-status{animation:none}}
@media(max-width:800px){.layout{display:block}.sidebar-inner{position:static;min-height:0;padding:26px}.sidebar .line,.sidebar-heading,.aside-copy,.sidebar-footer{display:none}.aside-section{border:0;padding:0}.character-list{display:flex;gap:20px;margin-top:16px;flex-wrap:wrap}.character .seen{display:none}.character strong{font-size:11px}.character small{font-size:9px}.story-top{padding:0 22px;height:55px}.story-content{padding:42px 24px 60px}.story-heading h1{font-size:56px}.topbar{padding:0 22px;height:65px}.status{display:none}.layout{min-height:calc(100vh - 65px)}.composer-bottom>span{font-size:9px;max-width:160px}.locked{margin:35px 16px;padding:30px}}
@media(max-width:420px){.character-list{gap:13px}.avatar{width:32px;height:32px}.character{gap:7px}.character small{display:none}.story-heading h1{font-size:48px}.topbar-right{gap:0}.story-content{padding-left:18px;padding-right:18px}.breadcrumb{font-size:8px}}

/* Игровая сцена занимает экран; длинная реплика прокручивается внутри карточки. */
body.playing{height:100dvh;overflow:hidden;background:#f3efeb}
body.playing .topbar{height:60px}
body.playing main{height:calc(100dvh - 60px)}
body.playing .layout{height:100%;min-height:0;max-width:none;grid-template-columns:260px minmax(0,1fr)}
body.playing .sidebar{min-height:0}
body.playing .sidebar-inner{height:100%;min-height:0;padding:30px 24px;position:static}
body.playing .line{margin:20px 0 28px}
body.playing .sidebar-heading p{font-size:27px}
body.playing .aside-copy{margin:16px 0 32px}
body.playing .character-list{gap:8px;margin-top:16px}
body.playing .character{padding:8px;border:1px solid transparent;border-radius:9px}
body.playing .character.current{border-color:#655457;background:#302e37}
body.playing .character .seen{font-size:9px;letter-spacing:.08em}
body.playing .sidebar-footer{padding-top:18px}
body.playing .story-area{min-height:0;display:flex;flex-direction:column;background:linear-gradient(145deg,#f4eeea,#f9f7f4 52%,#f2eee9)}
body.playing .story-top{height:48px;flex:none;padding:0 4%;background:#fbf9f7aa}
.story-top-actions{display:flex;gap:18px;align-items:center}.scene-status{font-size:10px;color:#94877d}.fullscreen-button{border:0;background:transparent;color:#88766c;font-size:11px;font-weight:600;padding:8px}.fullscreen-button:hover{color:#a75e4c}
body.playing .story-content{width:min(100%,1060px);max-width:none;margin:0 auto;padding:16px 24px 18px;display:flex;flex-direction:column;flex:1;min-height:0;overflow:auto}
body.playing .chapter-bar{flex:none;margin:0 0 12px;padding:0 2px 12px;border:0;border-bottom:1px solid #ded5cd}
.scene-title{display:block;margin-top:5px;font:normal 23px/1 var(--serif);letter-spacing:-.02em;color:#39312e;text-transform:none}
body.playing .history-button{padding:8px 12px}
.scene-stage{position:relative;isolation:isolate;display:flex;flex-direction:column;flex:1;min-height:155px;overflow:hidden;border:1px solid #e6d8cf;border-radius:15px;background:linear-gradient(135deg,#f0e0da 0%,#f3e7df 46%,#e9e7e3 100%);box-shadow:0 12px 35px #80645510}
.scene-decor{position:absolute;z-index:-1;inset:0;overflow:hidden;pointer-events:none;background:radial-gradient(ellipse at 80% 10%,#fff5df 0%,transparent 31%),linear-gradient(155deg,transparent 56%,#c6c9c82b 57%,#81929930 78%,#667b883b 100%)}
.scene-decor:before{content:'';position:absolute;width:120%;height:38%;left:-10%;bottom:-21%;background:#8b9c9b23;border-radius:50% 50% 0 0;transform:rotate(-3deg)}
.scene-decor i{position:absolute;right:12%;bottom:11%;width:24px;height:80px;background:linear-gradient(#d8b19a 0 16%,#f8ece4 17% 75%,#b68d79 76%);clip-path:polygon(33% 0,67% 0,70% 12%,84% 13%,79% 18%,100% 100%,0 100%,21% 18%,16% 13%,30% 12%);opacity:.48}
.scene-decor b{position:absolute;right:13%;bottom:calc(11% + 63px);width:230px;height:80px;transform-origin:right center;transform:rotate(-8deg);background:linear-gradient(90deg,transparent,#fff3d5a1);clip-path:polygon(0 5%,100% 46%,100% 54%,0 95%);opacity:.6}
.scene-caption{display:flex;justify-content:space-between;gap:12px;flex:none;padding:15px 20px;color:#9b786b;font-size:9px;font-weight:750;letter-spacing:.16em}
body.playing #messages{display:block;flex:1;min-height:0;overflow:auto;margin:0 14px 14px;padding:18px 22px;background:#fffdfbf0;border:1px solid #f1e5dc;border-radius:10px;overscroll-behavior:contain;scrollbar-color:#d4c2b8 transparent}
body.playing #messages:focus-visible{outline:2px solid #b7644d;outline-offset:-2px}
body.playing #messages .message{font:16px/1.68 var(--serif);color:#4c4540;padding:0;border:0;background:transparent}
body.playing #messages .message.player{font-family:var(--sans);font-size:14px}
body.playing #messages .message-label{font:750 10px var(--sans);letter-spacing:.15em;color:#aa6957;margin-bottom:10px}
body.playing .turn-status{flex:none;margin:5px 0 0 4px}
body.playing .composer{flex:none;margin:12px 0 0}
body.playing .composer-caption{margin:0 1px 6px}
body.playing .composer form{display:flex;align-items:stretch;gap:10px;padding:8px 9px 8px 14px;border:1px solid #e5d9d1;border-radius:10px;box-shadow:0 5px 15px #8c6b5910}
body.playing .composer textarea{flex:1;min-height:50px;max-height:110px;resize:vertical;padding:5px 0}
body.playing .composer-bottom{border:0;padding:0;flex:none;align-items:flex-end}
body.playing .composer-bottom>span{display:none}
body.playing .button.primary{border-radius:6px}
body.playing .error{flex:none;margin:4px 0 0}
body.playing .choices{display:flex;flex-wrap:wrap;gap:7px;flex:none;max-height:min(22vh,128px);overflow:auto;margin:10px 0 0;padding:0 1px 3px}
body.playing .choice{flex:1 1 190px;min-height:44px;padding:9px 12px;border-radius:8px;background:#fffcfa}
body.playing .choice small{margin-top:3px;font-size:10px}
body.playing .choice b{margin-left:10px;font-size:15px}
body.playing .choice:disabled{opacity:.55}
@media(max-width:800px){
 body.playing .topbar{height:52px;padding:0 16px}body.playing main{height:calc(100dvh - 52px)}body.playing .layout{display:flex;flex-direction:column}
 body.playing .sidebar{flex:none}body.playing .sidebar-inner{height:auto;padding:10px 16px}body.playing .sidebar .eyebrow{display:none}body.playing .aside-section{padding:0}body.playing .aside-label{display:none}
 body.playing .character-list{display:flex;flex-wrap:nowrap;overflow:auto;gap:6px;margin:0}body.playing .character{flex:none;padding:5px 8px}body.playing .avatar{width:30px;height:30px;font-size:14px}body.playing .character small{display:none}body.playing .character .seen{display:none}
 body.playing .story-area{flex:1;min-height:0}body.playing .story-top{height:35px;padding:0 16px}.scene-status{display:none}.fullscreen-button{font-size:10px;padding:5px}
 body.playing .story-content{padding:10px 12px 12px}body.playing .chapter-bar{padding-bottom:8px;margin-bottom:8px}.scene-title{font-size:19px}.scene-caption{padding:10px 12px}
 body.playing #messages{margin:0 8px 8px;padding:12px 14px}body.playing #messages .message{font-size:15px;line-height:1.55}
 body.playing .composer{margin-top:8px}body.playing .composer textarea{min-height:42px}body.playing .choices{max-height:21vh;margin-top:7px}body.playing .choice{flex-basis:145px}
}
@media(max-width:420px){body.playing .brand{font-size:12px}body.playing .topbar-right{gap:8px}body.playing .text-button{font-size:10px}.fullscreen-button span{display:none}.scene-caption{font-size:8px}body.playing .choice{flex-basis:100%;min-height:38px}body.playing .choice small{display:none}body.playing .chapter-actions{gap:7px}body.playing .chapter-actions>span{display:none}}
@media(max-height:600px){body.playing .sidebar-heading,body.playing .aside-copy,body.playing .sidebar-footer,body.playing .line{display:none}body.playing .sidebar-inner{padding-top:15px}body.playing .aside-section{padding-top:10px}body.playing .story-content{padding-top:8px}.scene-caption{padding:8px 12px}body.playing .choices{max-height:17vh}}
.game-objective { margin: 8px 0; color: #a99ba1; font-size: 13px; line-height: 1.45; }

/* Photographic scenery is scoped to the new story; old saves keep their look. */
.avatar{position:relative;overflow:hidden}
.avatar-photo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:50% 23%}
.scene-stage[data-backdrop] .scene-decor{background-size:cover;background-position:center}
.scene-stage[data-backdrop="villa"] .scene-decor{background-image:linear-gradient(#4d393127,#4d393127),url('./backstage-art/villa.webp')}
.scene-stage[data-backdrop="living"] .scene-decor{background-image:linear-gradient(#4d393127,#4d393127),url('./backstage-art/living.webp')}
.scene-stage[data-backdrop="kitchen"] .scene-decor{background-image:linear-gradient(#4d393127,#4d393127),url('./backstage-art/kitchen.webp')}
.scene-stage[data-backdrop="promenade"] .scene-decor{background-image:linear-gradient(#3e302d33,#3e302d33),url('./backstage-art/promenade.webp')}
.scene-stage[data-backdrop="editing"] .scene-decor{background-image:linear-gradient(#33292733,#33292733),url('./backstage-art/editing.webp')}
.scene-stage[data-backdrop="music"] .scene-decor{background-image:linear-gradient(#4d393127,#4d393127),url('./backstage-art/music.webp')}
.scene-stage[data-backdrop="studio"] .scene-decor{background-image:linear-gradient(#33292744,#33292744),url('./backstage-art/studio.webp')}
.scene-stage[data-backdrop]:not([data-backdrop=""]) .scene-decor:before,.scene-stage[data-backdrop]:not([data-backdrop=""]) .scene-decor i,.scene-stage[data-backdrop]:not([data-backdrop=""]) .scene-decor b{display:none}
.scene-stage[data-backdrop]:not([data-backdrop=""]) .scene-caption{position:relative;color:#fff;text-shadow:0 1px 5px #000b;z-index:1}
.scene-portrait{position:absolute;right:0;top:0;bottom:0;width:34%;height:100%;object-fit:cover;object-position:center 28%;z-index:-1}
body.playing .scene-stage.has-portrait #messages{width:calc(66% - 14px);margin-right:auto;background:#fffdfbf2}
@media(max-width:800px){.scene-portrait{width:34%}body.playing .scene-stage.has-portrait #messages{width:calc(66% - 8px)}}
@media(max-width:480px){.scene-portrait{width:30%}body.playing .scene-stage.has-portrait #messages{width:calc(70% - 8px)}}

/* Full-screen story stage and a drawer kept closed until the reader opens it. */
.stage-menu-toggle,.drawer-heading,.drawer-actions,.sidebar-shade{display:none}
body.playing .topbar{display:none}
body.playing main{height:100dvh}
body.playing .layout{position:relative;display:block;height:100%;min-height:0}
body.playing .story-area{position:relative;height:100%;overflow:hidden;background:#2d3336}
body.playing .sidebar{position:fixed;z-index:20;inset:0 auto 0 0;width:min(320px,87vw);overflow:auto;transform:translateX(-105%);transition:transform .2s ease;box-shadow:12px 0 40px #0004}
body.playing .menu-open .sidebar{transform:translateX(0)}
body.playing .sidebar-inner{min-height:100%;height:auto;padding:18px 20px;display:flex}
body.playing .sidebar .eyebrow,body.playing .sidebar-heading,body.playing .aside-copy,body.playing .line,body.playing .sidebar-footer{display:none}
body.playing .drawer-heading{display:flex;align-items:center;justify-content:space-between;font-size:17px;margin:0 0 12px}
body.playing .drawer-heading button{background:none;border:0;color:#eee;font-size:28px}
body.playing .drawer-actions{display:grid;gap:6px;margin-bottom:22px}
body.playing .drawer-actions button,body.playing .drawer-actions a{display:block;width:100%;border:1px solid #44414b;border-radius:8px;padding:11px 12px;background:#292b35;color:#f6f1ec;font:600 12px var(--sans);text-align:left;text-decoration:none}
body.playing .sidebar .aside-label{display:flex}
body.playing .sidebar .character-list{display:grid;overflow:visible;gap:6px;margin-top:12px}
body.playing .sidebar .character{display:flex;gap:12px;padding:7px}
body.playing .sidebar .character small,body.playing .sidebar .character .seen{display:block}
body.playing .stage-menu-toggle{display:flex;align-items:center;gap:7px;position:fixed;z-index:12;top:14px;left:14px;color:#fff;border:1px solid #ffffff70;background:#221d24bb;border-radius:9px;padding:10px 13px;font-weight:700}
body.playing .sidebar-shade:not(.hidden){display:block;position:fixed;inset:0;z-index:19;border:0;background:#08070b88}
body.playing .story-top{position:absolute;right:0;top:0;height:48px;background:transparent;border:0;z-index:3;padding:0 20px}
body.playing .story-top .breadcrumb,body.playing .scene-status{display:none}
body.playing .fullscreen-button{color:#fff;text-shadow:0 1px 3px #000;background:#221d2499;border-radius:8px}
body.playing .story-content{position:relative;z-index:1;width:100%;height:100%;padding:15px max(3vw,18px) 16px;overflow:hidden;justify-content:flex-end}
body.playing .scene-stage{position:absolute;z-index:-2;inset:0;border:0;border-radius:0;box-shadow:none;display:block}
body.playing .scene-decor{background-size:cover;background-position:center}
body.playing .scene-portrait{position:absolute;top:auto;bottom:0;left:50%;right:auto;width:auto;max-width:70%;height:95%;object-fit:contain;object-position:bottom;transform:translateX(-50%);z-index:0;filter:drop-shadow(0 5px 13px #0004);pointer-events:none}
body.playing .hide-portrait .scene-portrait{display:none}
body.playing .scene-caption{position:absolute;top:18px;left:125px;right:170px;color:white!important;text-shadow:0 1px 5px #000;z-index:1;padding:8px}
body.playing .chapter-bar{position:absolute;top:12px;right:180px;border:0;margin:0;padding:0;z-index:3;color:white;text-shadow:0 1px 5px #000}
body.playing .chapter-bar>div:first-child{display:none}
body.playing .history-button{background:#221d24bb;border-color:#ffffff60;color:#fff}
body.playing #messages,body.playing .scene-stage.has-portrait #messages{width:min(100%,1000px);min-height:0;max-height:min(30dvh,260px);flex:0 1 auto;overflow-y:auto;display:grid;gap:8px;align-self:center;margin:0;padding:13px 18px;background:#fffdfbeF;border:1px solid #ffffffaa;border-radius:11px;box-shadow:0 8px 30px #0003}
body.playing #messages .message.player{justify-self:start;max-width:100%;font-size:13px;color:#80645d}
body.playing #messages .message.assistant,body.playing #messages .message.scene{font-size:15px;line-height:1.5}
body.playing #messages .message-label{margin-bottom:4px}
body.playing .composer,body.playing .choices,body.playing .game-objective,body.playing .error,body.playing .turn-status{width:min(100%,1000px);align-self:center}
body.playing .composer{margin:8px 0 0}
body.playing .composer-caption{display:none}
body.playing .composer form{background:#fffdfbf2}
body.playing .composer textarea{min-height:38px;max-height:64px;resize:none}
body.playing .game-objective{margin:5px 0 0;color:#fff;font-size:11px;text-shadow:0 1px 4px #000}
body.playing .choices{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;max-height:min(24dvh,180px);overflow:auto;margin:7px 0 0}
body.playing .choice{min-height:38px;padding:7px 9px;background:#fffdfbf0}
body.playing .choice small{display:none}
body.playing .history-dialog{width:min(900px,calc(100% - 20px));height:min(86dvh,850px);max-height:86dvh}
body.playing .history-messages{max-height:calc(86dvh - 110px)}
@media(max-width:800px){body.playing .sidebar-inner{padding:18px}body.playing .story-content{padding:8px 10px 10px}body.playing .scene-caption{top:58px;left:8px;right:8px}body.playing .chapter-bar{top:12px;right:90px}body.playing .scene-portrait{height:80%;max-width:90%}body.playing .choices{grid-template-columns:repeat(2,minmax(0,1fr));max-height:23dvh}body.playing #messages{max-height:27dvh;font-size:14px}body.playing .story-top{right:4px;padding:0 8px}body.playing .fullscreen-button span{display:none}}
@media(max-height:600px){body.playing .scene-caption{display:none}body.playing .choices{max-height:21dvh}body.playing #messages{max-height:26dvh}body.playing .game-objective{display:none}}
@media(prefers-reduced-motion:reduce){body.playing .sidebar{transition:none}}
.history-dialog::backdrop{background:#17141a}
.history-dialog{width:min(920px,calc(100% - 24px));max-height:calc(100dvh - 24px)}
.history-messages{max-height:calc(100dvh - 130px)}

/* Readable, compact dialogue while retaining scrolling for unusually long text. */
body.playing #messages,body.playing .scene-stage.has-portrait #messages{max-height:min(40dvh,360px);gap:7px;padding:13px 18px;background:#fffdfaF7}
body.playing #messages .message,body.playing #messages .message.player,body.playing #messages .message.assistant,body.playing #messages .message.scene{font:15px/1.38 var(--sans);color:#393331;letter-spacing:0}
body.playing #messages .message-label{font:700 10px/1.2 var(--sans);letter-spacing:.1em;color:#8b483a;margin-bottom:4px}
body.playing .turn-status{width:auto;align-self:center;margin:5px 0 0;padding:7px 13px;background:#30262ceF;border:1px solid #ffffff80;border-radius:16px;color:#fff;font:600 13px/1.2 var(--sans);text-shadow:none;animation:none}
body.playing .error:not(:empty){padding:7px 10px;border-radius:7px;background:#fff5ee;color:#8f3025;font-weight:650}
@media(max-width:800px){body.playing #messages{max-height:36dvh}body.playing #messages .message,body.playing #messages .message.player,body.playing #messages .message.assistant,body.playing #messages .message.scene{font-size:14px;line-height:1.38}}
@media(max-height:600px){body.playing #messages{max-height:33dvh}}

/* Keep the current goal legible over photographs. */
body.playing .game-objective{display:block;margin:8px 0 0;padding:8px 12px;border-left:4px solid #c96350;border-radius:7px;background:#fff7eef2;color:#65372e;text-shadow:none;font:650 14px/1.35 var(--sans);box-shadow:0 4px 15px #0003}
body.playing .choice.replay-choice{background:#9b5748;color:#fff;border-color:#9b5748}
body.playing .choice.replay-choice b{color:#fff}
@media(max-height:600px){body.playing .game-objective{display:block;font-size:12px;padding:5px 9px}}

/* Distinct speech cards make speaker changes clear in the scene and history. */
body.playing #messages,body.playing .scene-stage.has-portrait #messages{max-height:min(48dvh,420px);gap:8px;padding:9px;background:#fffdfae8}
body.playing #messages .message,.history-messages .message{display:block;width:100%;max-width:100%;padding:8px 11px;border:1px solid #e8ddd7;border-left:3px solid #bc7768;border-radius:8px;background:#fffdfb;color:#393331;box-shadow:none}
.history-messages .message,.history-messages .message.scene,.history-messages .message.assistant,.history-messages .message.player{font:15px/1.45 var(--sans);letter-spacing:0}
body.playing #messages .message.player,.history-messages .message.player{justify-self:end;width:fit-content;max-width:90%;padding:8px 11px;border:1px solid #e3cabd;border-right:3px solid #a65c4c;background:#f8eae1;color:#533b34}
body.playing #messages .message.scene,.history-messages .message.scene{padding:8px 11px;border:1px solid #dedbd4;border-left:3px solid #8f918c;background:#f5f4ef;color:#454641}
body.playing #messages .message-label,.history-messages .message-label{display:block;margin:0 0 3px;font:750 11px/1.2 var(--sans);letter-spacing:.07em;color:#964c3c}
body.playing #messages .message.player .message-label,.history-messages .message.player .message-label{color:#814537}
body.playing #messages .message.scene .message-label,.history-messages .message.scene .message-label{color:#666e68}
body.playing #messages .message.intro-scene,.history-messages .message.intro-scene{padding:0;border:0;background:transparent}
.intro-narration,.intro-speech{padding:8px 11px;border:1px solid #dedbd4;border-left:3px solid #8f918c;border-radius:8px;background:#f5f4ef;white-space:pre-wrap}
.intro-speech{margin-top:7px;border-color:#e8ddd7;border-left-color:#bc7768;background:#fffdfb}
.group-portraits{position:absolute;top:56px;left:50%;transform:translateX(-50%);z-index:2;display:flex;justify-content:center;gap:8px;width:max-content;max-width:calc(100% - 12px);flex-wrap:nowrap;pointer-events:none}
.group-portrait{display:grid;justify-items:center;gap:2px;padding:4px 6px;border:2px solid transparent;border-radius:12px;background:#241d21b8;color:white;font:600 11px/1.2 var(--sans);text-shadow:0 1px 3px #000}
.group-portrait img{width:52px;height:52px;border-radius:50%;object-fit:cover;object-position:50% 20%;border:1px solid #ffffffaa}
.group-portrait.speaking{border-color:#ffd58b;background:#694337ed;box-shadow:0 0 0 2px #fff7}
@media(max-width:600px){.group-portraits{top:52px;gap:3px}.group-portrait{padding:3px;font-size:9px}.group-portrait img{width:34px;height:34px}}
#game.hide-portrait .group-portraits{display:none}
body.playing .story-content:has(.group-portraits:not(.hidden)){padding-top:135px}
@media(max-width:600px){body.playing .story-content:has(.group-portraits:not(.hidden)){padding-top:115px}}
body.playing #messages .message.scene .intro-speech .message-label,.history-messages .message.scene .intro-speech .message-label{color:#964c3c}
.intro-hint{margin:6px 4px 0;color:#665c54;font:12px/1.35 var(--sans)}
body.playing #messages .intro-hint{display:none}
.history-messages .message.choice{width:fit-content;padding:7px 10px;border:1px solid #e9d8cf;border-left:3px solid #c9a08d;border-radius:7px;background:#fff9f5;color:#81594c}
@media(max-width:800px){body.playing #messages,body.playing .scene-stage.has-portrait #messages{max-height:44dvh}}
@media(max-height:600px){body.playing #messages,body.playing .scene-stage.has-portrait #messages{max-height:40dvh}}
