@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&family=DM+Serif+Display:ital@0;1&display=swap');
:root{--paper:#f6f2ed;--surface:#fffdfa;--ink:#352b39;--muted:#71626e;--rose:#914b66;--rose-soft:#eee0e3;--line:#dcd1d3;--dark:#211e29;--danger:#a1283c;--radius:12px;font-family:'Noto Sans Thai',sans-serif;color:var(--ink);background:var(--paper);font-size:16px;color-scheme:light}
*{box-sizing:border-box}body{margin:0}button,input,textarea,select{font:inherit}button,a,input,textarea,select{-webkit-tap-highlight-color:transparent}button{border:1px solid var(--line);background:var(--surface);color:var(--ink);padding:11px 19px;min-height:44px;border-radius:7px;cursor:pointer;transition:background .18s,color .18s}button:hover{background:var(--rose-soft)}button:disabled{opacity:.55;cursor:wait}a{color:inherit;text-underline-offset:4px}button:focus-visible,a:focus-visible,[tabindex]:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #b76b84;outline-offset:3px}::selection{background:#e8c1cf;color:#352b39}input,textarea,select{border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--ink);width:100%;padding:10px 12px;caret-color:var(--rose);min-height:44px}textarea{resize:vertical;min-height:110px;line-height:1.7}label{display:grid;gap:6px;font-size:.88rem;font-weight:500}input::placeholder,textarea::placeholder{color:#786872}input[type=checkbox]{width:18px;min-height:18px;accent-color:var(--rose)}[hidden]{display:none!important}.primary{background:var(--rose);border-color:var(--rose);color:#fff}.primary:hover{background:#763b53;border-color:#763b53}.text-button{border:0;background:transparent;text-decoration:underline;text-underline-offset:4px}.muted{color:var(--muted)}.status{white-space:pre-line;color:var(--danger);font-size:.88rem;line-height:1.65;min-height:1.4em}.status:empty{margin:0;min-height:0}.stack{display:grid;gap:15px}.wordmark{font-family:'DM Serif Display',serif;font-size:30px;letter-spacing:-.03em;text-decoration:none;white-space:nowrap;display:inline-flex;align-items:baseline;gap:4px}.brand-dot{height:7px;width:7px;border-radius:50%;display:inline-block;background:var(--rose)}.home{max-width:1440px;min-height:100svh;padding:30px 6vw 24px;margin:auto;display:flex;flex-direction:column}.home-header,.home-footer{display:flex;justify-content:space-between;align-items:center;gap:20px}.home-header>span,.home-footer{font-size:.82rem;color:var(--muted)}.home-header{padding-bottom:20px;border-bottom:1px solid var(--line)}.home-content{display:grid;grid-template-columns:1.3fr 1fr;align-items:center;gap:8vw;flex:1;padding:44px 0 56px}.home-copy h1{font-weight:500;font-size:clamp(2.5rem,4.5vw,4.3rem);line-height:1.36;letter-spacing:-.03em;margin:18px 0 24px}.home-copy h1 span{display:block;color:var(--rose)}.home-copy p{line-height:1.9;color:var(--muted);font-size:1rem}.flower-mark{width:68px;height:68px;color:var(--rose);transform:rotate(-12deg)}.flower-mark svg{width:100%;height:100%}.entry-panel{border-left:1px solid var(--line);padding:8px 0 8px 4vw;max-width:430px}.entry-panel h2{margin:0 0 8px;font-size:1.6rem;font-weight:600}.entry-panel>.muted{font-size:.9rem;margin:0 0 24px}.auth-tabs{display:flex;border-bottom:1px solid var(--line);gap:18px;margin:28px 0 20px}.auth-tabs button{border:none;background:none;border-radius:0;padding:8px 2px;min-height:44px;color:var(--muted)}.auth-tabs button.active{color:var(--rose);box-shadow:0 2px 0 var(--rose)}.entry-note{font-size:.76rem;line-height:1.8;color:var(--muted);margin:24px 0 0}.home-footer{padding-top:20px;border-top:1px solid var(--line)}
.play-screen{min-height:100svh;background:var(--dark);color:#f8f0f3;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:8px 16px}.game-top,.game-bottom{display:flex;justify-content:space-between;align-items:center;width:min(100%,1280px);gap:12px}.game-top{height:55px}.game-top .wordmark{font-size:25px}.game-top>div{display:flex;gap:8px;align-items:center}.game-top button{background:transparent;color:#f5e8ee;border-color:#5d4a5d;padding:5px 12px;font-size:.8rem;min-height:36px}.game-top button:hover{background:#493746}.game-bottom{padding:12px 0;font-size:.75rem;color:#d5c5d0}.viewport{position:relative;overflow:hidden;isolation:isolate;width:min(100%,1280px,calc((100svh - 116px)*16/9));aspect-ratio:16/9;background:#292532;container-type:inline-size}#phaser{position:absolute;inset:0}#phaser canvas{display:block;width:100%;height:100%}.dialog-box{display:flex;flex-direction:column;position:absolute;bottom:0;left:0;width:100%;height:33.333%;background:rgba(255,253,250,.93);color:var(--ink);padding:1.5cqw 3cqw 2.3cqw;cursor:pointer;z-index:2}.dialog-meta{flex-shrink:0;display:flex;align-items:center;justify-content:space-between;min-height:1.8cqw;margin-bottom:.5cqw;color:var(--rose);font-size:clamp(12px,1.35cqw,18px);font-weight:600}#page-number{font-size:clamp(11px,1cqw,14px);color:var(--muted);font-variant-numeric:tabular-nums}#dialog-text{flex:1;min-height:0;font-size:clamp(14px,2.05cqw,28px);line-height:1.65;white-space:pre-wrap;overflow-wrap:anywhere;margin:0;height:auto;overflow:hidden}.next-indicator{position:absolute;right:2.4cqw;bottom:1.1cqw;width:0;height:0;border-left:.6cqw solid transparent;border-right:.6cqw solid transparent;border-top:.85cqw solid var(--rose);animation:blink 1.1s ease-in-out infinite}@keyframes blink{50%{opacity:.2;transform:translateY(3px)}}.choices{position:absolute;right:3%;bottom:36%;width:52%;max-height:58%;overflow:auto;display:grid;gap:9px;z-index:3;padding:5px}.choices button{background:rgba(255,253,250,.97);color:var(--ink);border:1px solid #c09ca9;text-align:left;font-size:clamp(12px,1.65cqw,22px);padding:10px 18px;line-height:1.5;min-height:44px;border-radius:6px}.choices button:hover{background:#f0dce5;border-color:var(--rose)}.ending{position:absolute;inset:0;z-index:5;background:rgba(33,30,41,.94);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;text-align:center;padding:24px}.ending h2{font-size:clamp(18px,3cqw,40px);margin:0 0 14px;max-width:80%}.ending p{font-size:clamp(12px,1.4cqw,20px);margin:0;color:#d7becb}.ending button{min-width:220px}.ending-rule{height:1px;width:70px;background:#c9a6b7;margin-bottom:16px}.game-loading{position:absolute;inset:0;z-index:7;background:rgba(33,30,41,.9);display:grid;place-content:center}.rotate-note{display:none}.play-screen:fullscreen{width:100%;height:100%;padding:0 8px}.play-screen:fullscreen .viewport{width:min(100%,calc((100svh - 80px)*16/9))}.play-screen:fullscreen .game-bottom{padding:4px 0}.play-screen:fullscreen .game-top{height:44px}
.admin-page{background:#f5f2ee}.admin-header{background:var(--surface);padding:14px 28px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:20px}.admin-header>div{display:flex;align-items:center;gap:18px}.admin-header small{color:var(--muted)}.admin-login{max-width:420px;margin:12vh auto;padding:24px}.admin-login h1{font-size:1.7rem;margin-top:0}.admin-toolbar{padding:20px 28px;display:flex;align-items:end;justify-content:space-between;gap:18px;background:var(--paper);border-bottom:1px solid var(--line)}.admin-toolbar .story-fields{display:flex;gap:16px;flex:1;max-width:720px}.admin-toolbar label{flex:1}.toolbar-actions{display:flex;gap:8px;flex-wrap:wrap}.admin-layout{display:grid;grid-template-columns:250px minmax(0,1fr);min-height:70vh}.scene-sidebar{padding:22px 16px;border-right:1px solid var(--line)}.scene-sidebar h2{font-size:1rem;margin:0 0 12px}.scene-list{display:grid;gap:8px;margin:16px 0}.scene-item{display:flex;align-items:center;gap:10px;text-align:left;padding:8px;font-size:.8rem;overflow:hidden}.scene-item.active{background:var(--rose-soft);border-color:#b67a91}.scene-item img{width:56px;height:36px;object-fit:cover;border-radius:3px}.scene-item span{overflow:hidden;text-overflow:ellipsis}.editor{padding:26px 32px;max-width:1100px}.editor-heading{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:20px}.editor-heading h2{margin:0;font-size:1.25rem}.scene-grid{display:grid;grid-template-columns:minmax(220px,.8fr) 1fr;gap:24px}.scene-image{width:100%;aspect-ratio:16/9;object-fit:contain;background:#e7dfe4;border-radius:8px;display:block;margin:12px 0}.help{font-size:.78rem;line-height:1.65;color:var(--muted);margin:6px 0}.field-row{display:flex;gap:12px;align-items:end}.field-row>*{flex:1;min-width:0}.effects{margin:16px 0;border:1px solid var(--line);border-radius:8px;padding:0 14px}.effects summary{cursor:pointer;font-size:.88rem;padding:12px 0}.effects-body{padding-bottom:12px;display:grid;gap:10px}.effect-row{display:flex;flex-wrap:wrap;gap:12px;align-items:center}.effect-row>label:first-child{display:flex;align-items:center;gap:8px;min-width:150px}.effect-row input[type=number]{width:100px}.effect-row select{max-width:220px}.effect-row .duration-label{display:flex;align-items:center;gap:8px;font-size:.75rem}.section-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:32px 0 16px;padding-top:24px;border-top:1px solid var(--line)}.section-bar h3{margin:0;font-size:1.1rem}.dialog-editor{border:1px solid var(--line);border-radius:10px;padding:18px;margin:0 0 16px;background:var(--surface)}.dialog-editor header{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:14px}.dialog-editor header strong{font-size:.9rem}.small-actions{display:flex;gap:6px}.small-actions button{min-height:36px;padding:5px 10px;font-size:.78rem}.danger{color:var(--danger)}.choice-editor{padding:16px 0;border-top:1px solid var(--line);margin-top:16px}.choice-editor>.field-row{align-items:start}.choice-editor .effects{background:var(--paper)}.inline-check{display:flex;align-items:center;gap:9px;margin:16px 0}.dialog-editor textarea{margin-top:8px}.admin-status{margin:0;padding:0 28px;white-space:pre-line}.admin-status:not(:empty){padding-top:12px;padding-bottom:12px}.audio-library{padding:20px 28px;border-top:1px solid var(--line)}.audio-library summary{cursor:pointer;font-weight:600}.audio-library .field-row{max-width:700px;margin-top:16px}.audio-list{display:flex;flex-wrap:wrap;gap:12px;padding-top:16px}.audio-item{display:grid;gap:6px;font-size:.8rem;border:1px solid var(--line);padding:12px;border-radius:8px;max-width:320px}.audio-item audio{max-width:100%;width:280px;height:36px}.empty-editor{padding:60px 24px;text-align:center;color:var(--muted)}.unsaved{font-size:.78rem;color:var(--rose)}.preview-link{font-size:.8rem}.admin-footer{padding:22px 28px;font-size:.75rem;color:var(--muted);border-top:1px solid var(--line)}
@media(max-width:900px){.home-content{gap:4vw}.home-copy h1{font-size:2.8rem}.admin-toolbar{align-items:stretch;flex-direction:column}.admin-layout{grid-template-columns:200px 1fr}.editor{padding:20px}.scene-grid{grid-template-columns:1fr}.admin-header{padding:14px 18px}.admin-header small{display:none}}
@media(max-width:600px){.home{padding:20px 24px}.home-header>span{font-size:.75rem}.home-content{grid-template-columns:1fr;padding:28px 0;gap:26px}.home-copy h1{font-size:2.3rem;margin:12px 0}.home-copy h1 br{display:none}.home-copy p{font-size:.9rem;margin:12px 0}.flower-mark{width:42px;height:42px}.entry-panel{border-left:0;border-top:1px solid var(--line);padding:24px 0 0;max-width:none}.home-footer{font-size:.75rem;align-items:start}.home-footer span{max-width:65%}.admin-layout{grid-template-columns:1fr}.scene-sidebar{border-right:0;border-bottom:1px solid var(--line)}.scene-list{display:flex;overflow:auto}.scene-item{min-width:160px}.scene-sidebar h2{display:none}.scene-sidebar>input{max-width:100%}.admin-toolbar{padding:18px}.story-fields{flex-direction:column}.editor{padding:18px}.field-row{flex-wrap:wrap}.field-row>label{flex-basis:180px}.editor-heading{align-items:start}.admin-header>div{gap:8px}.admin-header .wordmark{font-size:24px}.admin-header button{padding:7px;font-size:.8rem}.admin-header a:not(.wordmark){font-size:.8rem}.audio-library{padding:18px}.game-top{height:60px}.game-top .wordmark{font-size:23px}.game-top button{padding:5px 8px;font-size:.75rem}.play-screen{padding:8px;justify-content:flex-start}.viewport{margin-top:15vh;width:100%}.rotate-note{display:block;font-size:.8rem;color:#d5c5d0;text-align:center}.game-bottom{align-items:start;font-size:.75rem}.game-bottom>span{max-width:60%}.choices{width:72%;max-height:60%;bottom:35%;gap:4px}.choices button{min-height:32px;padding:5px 10px;font-size:12px}.ending{gap:8px;padding:10px}.ending button{min-height:32px;padding:5px 12px;font-size:12px}.ending h2{margin:0;font-size:16px}.ending p{font-size:12px}.ending-rule{margin:0}}
@media(orientation:landscape) and (max-height:600px){.play-screen{padding:0 10px;justify-content:center}.game-top{height:38px}.game-top .wordmark{font-size:22px}.game-top button{min-height:30px;padding:2px 10px}.viewport{width:min(100%,calc((100svh - 70px)*16/9));margin-top:0}.game-bottom{padding:4px 0;font-size:.75rem}.rotate-note{display:none}.game-status:empty{display:none}.choices button{min-height:36px;padding:6px 12px}.ending button{min-height:36px;padding:6px 14px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}

/* Dialogue portraits share the existing bottom-third region. */
.dialog-body{display:flex;gap:2cqw;flex:1;min-height:0}.dialog-copy{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0}.speaker-portrait{width:auto;height:150px;max-height:none;max-width:none;object-fit:contain;border-radius:8px;flex-shrink:0;align-self:flex-start}.portrait-editor{display:grid;gap:12px;padding:16px 0}.portrait-preview{width:80px;height:80px;object-fit:cover;border-radius:8px}.portrait-editor .field-row{align-items:end}.audio-item .status{max-width:280px;overflow-wrap:anywhere}.game-top #skip{border-color:#b6879e;color:#ffe8f2}
@media(max-width:600px){.game-top{height:auto;min-height:60px;flex-wrap:wrap;padding:6px 0}.game-top>div{flex-wrap:wrap}.game-top #preview-badge{font-size:12px}.portrait-editor .field-row{align-items:stretch}.speaker-portrait{border-radius:5px}}

/* Community library and per-story playback controls. */
.home-content{grid-template-columns:minmax(0,1fr) minmax(260px,340px);align-items:start;gap:4vw}.story-library{min-width:0}.story-library h1{font-size:clamp(1.7rem,3vw,2.5rem);font-weight:600;line-height:1.4;margin:0 0 12px}.story-library>p{margin:0 0 28px;line-height:1.7}.story-catalog{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(240px,100%),1fr));gap:28px 20px}.story-card{display:block;text-decoration:none;min-width:0;padding-bottom:16px;border-bottom:1px solid var(--line)}.story-card img{display:block;width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:8px}.story-card h2{font-size:1.15rem;margin:12px 0 4px;overflow-wrap:anywhere}.story-card span{font-size:.82rem}.story-card:hover h2,.story-card.selected h2{color:var(--rose)}.story-card.selected{border-bottom-color:var(--rose)}.studio-link{display:block;margin:20px 0;color:var(--rose);font-weight:600}.entry-panel{min-width:0}.entry-panel h2{overflow-wrap:anywhere}.entry-panel #home-album{width:100%}.scene-list-row{display:flex;align-items:stretch;gap:4px;min-width:0}.scene-list-row .scene-item{flex:1;min-width:0}.scene-remove{width:44px;flex-shrink:0;padding:4px;font-size:24px}.speaker-colors{display:flex;align-items:end;gap:12px;margin:12px 0}.speaker-colors input{width:80px;padding:4px}.cutscene-editor{display:grid;gap:12px;border-top:1px solid var(--line);padding:18px 0;margin:8px 0}.cutscene-panel{position:absolute;inset:0;background:#111;z-index:8;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:10px}.cutscene-panel video{width:100%;height:calc(100% - 70px);object-fit:contain;min-height:0}.cutscene-panel p{font-size:12px;margin:0}.cutscene-panel>div{display:flex;gap:10px}.cutscene-panel button{min-height:32px;padding:4px 14px}.album-modal{color:var(--ink);background:var(--paper);border:1px solid var(--line);border-radius:12px;width:min(960px,94vw);max-height:90svh;padding:24px}.album-modal::backdrop{background:rgba(20,15,24,.75)}.album-modal header{display:flex;align-items:center;justify-content:space-between;gap:16px}.album-modal h2{font-size:1.3rem;margin:0;overflow-wrap:anywhere}.album-modal>p{font-size:.88rem;color:var(--muted)}.album-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(180px,100%),1fr));gap:16px}.album-item{padding:0 0 8px;overflow:hidden;max-width:360px;text-align:left}.album-item img{width:100%;aspect-ratio:16/9;object-fit:cover;display:block}.album-item span{display:block;padding:8px 12px 0;font-size:.85rem}.album-item.locked{opacity:1;cursor:default}.album-item.locked img{filter:grayscale(1);opacity:.3}.album-item.locked span{color:var(--muted)}#album-large{max-width:100%;max-height:65svh;object-fit:contain;display:block;margin:24px auto 0}
@media(max-width:700px){.home-content{grid-template-columns:1fr;gap:36px;padding:28px 0}.entry-panel{max-width:none;border-left:0;border-top:1px solid var(--line);padding:24px 0}.story-catalog{grid-template-columns:repeat(auto-fit,minmax(min(210px,100%),1fr))}.scene-list-row{min-width:210px}.album-modal{padding:16px}.album-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.game-top>div{gap:5px}}

/* Story scores, run flags, and branching rules. */
.story-logic{padding:16px 28px;border-bottom:1px solid var(--line);background:var(--surface)}.story-logic>summary{cursor:pointer;font-size:.9rem;font-weight:600;min-height:32px;padding:4px 0}.story-logic #story-logic-fields{max-width:1040px}.logic-definitions{padding:8px 0 14px}.logic-definitions h3{font-size:.95rem;margin:10px 0}.logic-definition-row{display:flex;align-items:end;flex-wrap:wrap;gap:12px;margin:12px 0}.logic-definition-row>label:first-child{flex:1;min-width:180px}.logic-definition-row>label:nth-child(2){max-width:170px}.logic-checkbox{display:flex;align-items:center;gap:9px;min-height:44px;line-height:1.6;overflow-wrap:anywhere}.logic-checkbox input{flex-shrink:0;order:-1}.logic-panel{border:1px solid var(--line);border-radius:8px;margin:16px 0;padding:0 14px;background:var(--paper)}.logic-panel>summary{cursor:pointer;font-size:.88rem;padding:12px 0;overflow-wrap:anywhere}.logic-panel>.help{margin-bottom:12px}.logic-body{display:grid;gap:12px;padding-bottom:14px}.logic-body>button{justify-self:start}.logic-rule{border-top:1px solid var(--line);padding:14px 0 0;display:grid;gap:12px}.logic-rule-heading{display:flex;justify-content:space-between;align-items:center;gap:12px}.logic-rule-heading>strong{font-size:.88rem}.logic-rule>button{justify-self:start}.logic-rule>label{max-width:100%}.logic-condition-row{display:flex;flex-wrap:wrap;gap:10px;align-items:end;padding:12px;border:1px solid var(--line);border-radius:6px;background:var(--surface)}.logic-condition-row>label{flex:1 1 140px;min-width:0}.logic-condition-row>label:has(input[type=number]){flex-basis:100px;flex-grow:0}.logic-condition-row>button{padding:10px;font-size:.8rem}.logic-change-row{display:flex;gap:10px;align-items:end;flex-wrap:wrap}.logic-change-row>label:first-child{flex:1;min-width:160px}.logic-change-row>label:nth-child(2){width:145px}.logic-label{font-size:.85rem;font-weight:500;margin-top:8px}.logic-flag-list{display:flex;flex-wrap:wrap;gap:4px 20px;padding-bottom:10px}.logic-flag-list .logic-checkbox{font-size:.85rem;max-width:100%}.run-info{width:min(100%,1280px);font-size:.75rem;color:#d5c5d0;border-bottom:1px solid #5d4a5d;padding:5px 0}.run-info>summary{cursor:pointer;min-height:30px;padding:6px 0}.run-info #run-info-body{max-height:120px;overflow:auto;line-height:1.7;padding:6px 0;overflow-wrap:anywhere}.run-info #run-info-body p{margin:0 0 4px}.run-info #run-info-body:empty{padding:0}
@media(max-width:600px){.story-logic{padding:14px 18px}.logic-definition-row>label{max-width:100%}.logic-definition-row>label:first-child{flex-basis:100%}.logic-definition-row>button{margin-left:auto}.logic-panel{padding:0 10px}.logic-rule-heading{align-items:start}.logic-rule-heading .small-actions{flex-wrap:wrap;justify-content:end}.logic-condition-row{padding:10px;gap:10px}.logic-condition-row>label{flex-basis:100%}.logic-condition-row>label:has(input[type=number]){flex-basis:130px}.logic-condition-row>button{margin-left:auto}.logic-change-row>label:first-child{flex-basis:100%}.logic-change-row>label:nth-child(2){flex:1}.logic-flag-list{display:grid;gap:4px}.run-info{font-size:.75rem}}

/* Dedicated reusable speaker portrait library. */
.portrait-library{scroll-margin-top:20px}.portrait-library-search{display:flex;align-items:end;gap:16px;margin-top:20px}.portrait-library-search label{max-width:360px;flex:1}.portrait-library-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:14px;margin-top:16px}.portrait-library-item{margin:0;padding:12px;border:1px solid var(--line);border-radius:10px;min-width:0}.portrait-library-item img{display:block;width:80px;height:80px;object-fit:cover;border-radius:8px;margin-bottom:10px}.portrait-library-item figcaption{display:grid;gap:5px;font-size:.82rem;overflow-wrap:anywhere}.portrait-library-item figcaption span{color:var(--muted);font-size:.75rem}.portrait-library .field-row>label{min-width:0}.portrait-library select{max-width:100%}#speaker{color:#000000}img,canvas{-webkit-touch-callout:none}

/* Compact dialogue surface: 150px portrait and at most three text lines. */
.dialog-box,.dialog-box:has(.speaker-portrait:not([hidden])){height:min(100%,calc(150px + 2cqw));padding:1cqw 3cqw;max-height:100%}
#dialog-text{font-size:clamp(14px,1.8cqw,24px);max-height:3lh}
.choices{bottom:calc(150px + 2cqw + 8px);max-height:max(0px,calc(100% - 150px - 2cqw - 16px))}
.speaker-portrait{max-height:100%}

/* Portrait phones: preserve the art area and keep all answers in normal flow. */
@media (max-width:900px) and (orientation:portrait){
 .play-screen{padding:8px 10px;justify-content:flex-start}
 .game-top{height:auto;min-height:0;flex-wrap:wrap;padding:6px 0 12px;gap:8px}
 .game-top>div{flex-wrap:wrap;gap:6px}
 .game-top button{min-height:40px;padding:6px 10px}
 .viewport{width:100%;margin-top:0;aspect-ratio:auto;display:flex;flex-direction:column}
 #phaser{position:relative;inset:auto;flex:none;aspect-ratio:16/9;width:100%;order:0;overflow:hidden}
 #phaser canvas{position:absolute;inset:0;width:100%!important;height:100%!important;margin:0!important}
 .dialog-box,.dialog-box:has(.speaker-portrait:not([hidden])){position:relative;inset:auto;order:1;flex:none;width:100%;height:174px;max-height:none;padding:12px}
 .dialog-body{gap:12px}
 .speaker-portrait{height:150px;max-height:100%;max-width:42%;object-fit:contain;object-position:top left}
 .dialog-meta{font-size:14px;min-height:22px;margin-bottom:5px}
 #dialog-text{font-size:16px;line-height:1.6;max-height:4.8em}
 .choices{position:relative;inset:auto;order:2;flex:none;width:100%;max-height:none;overflow:visible;padding:10px;gap:8px;background:#292532}
 .choices button{min-height:44px;padding:10px 14px;font-size:16px;touch-action:manipulation}
 .game-bottom{flex-wrap:wrap;gap:4px;padding:10px 0}
 .game-bottom>span{max-width:100%}
 .rotate-note{margin:6px 0 12px;font-size:12px}
}
/* Short landscape screens retain the overlay, scaled to available height. */
@media (orientation:landscape) and (max-height:600px){
 .dialog-box,.dialog-box:has(.speaker-portrait:not([hidden])){height:40%;padding:1cqw 2cqw}
 .speaker-portrait{height:100%;max-height:150px}
 .choices{bottom:42%;max-height:55%;width:65%;padding:4px}
 .choices button{min-height:40px;touch-action:manipulation}
 #dialog-text{font-size:clamp(12px,1.8cqw,18px);line-height:1.5}
}

/* High-contrast reading controls. */
.game-top #dialog-back,.game-top #dialog-next,.game-top #skip{background:#ffd3e2;color:#42182b;border:2px solid #ffaccb;font-weight:700;min-height:40px}
.game-top #dialog-back:hover:not(:disabled),.game-top #dialog-next:hover:not(:disabled),.game-top #skip:hover:not(:disabled){background:#fff0f5;border-color:#fff0f5;color:#42182b}
.game-top #dialog-back:disabled,.game-top #dialog-next:disabled,.game-top #skip:disabled{background:#625360;color:#e2d6de;border-color:#897584;opacity:1;cursor:not-allowed}
.game-top #dialog-back:focus-visible,.game-top #dialog-next:focus-visible,.game-top #skip:focus-visible{outline:3px solid #fff;outline-offset:3px}
.transport-symbol{display:inline-block;margin-right:4px;font-family:Arial,sans-serif;font-size:1.05em;line-height:1}

.game-cover-preview{display:block;width:min(100%,400px);height:auto;max-height:225px;object-fit:contain;margin:12px 0;background:var(--rose-soft);border-radius:8px}#cover-remove{margin-top:14px}
