/* Story UI: scenery, frame, nameplate, text, and controls are separate layers. */
.story-screen{--story-background-blur:0px;--story-name-height:34px;--story-ink:#493a28;position:relative;isolation:isolate;display:flex;flex-direction:column;width:100%;max-width:760px;min-height:100svh;height:100dvh;margin:auto;background:#26382b;overflow:hidden}
/* Extra scenery around the clipped edge prevents transparent blur borders. */
.story-illustration{position:absolute;z-index:-3;inset:-10px;width:calc(100% + 20px);height:calc(100% + 20px);object-fit:cover;object-position:center 40%;pointer-events:none;clip-path:inset(10px);filter:blur(var(--story-background-blur));transition:filter .24s ease-out}
.story-screen[data-portrait-speaker]{--story-background-blur:clamp(2px,.45vw,3px)}
.story-screen::before{content:"";position:absolute;z-index:-2;inset:0;pointer-events:none;background:linear-gradient(#17261c88,transparent 24%,transparent 58%,#221c1b55)}
.story-screen::after{content:"";position:absolute;z-index:-1;inset:0;pointer-events:none;background:transparent;transition:background .35s}
.story-screen[data-tone=evening]::after{background:linear-gradient(#d48a3826,#914b4929)}
.story-screen[data-tone=afternoon]::after{background:#e6bf5510}
.story-screen[data-tone=shade]::after{background:#203b4230}
.story-header{display:flex;align-items:center;gap:8px;flex:none;padding:max(2px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 2px max(12px,env(safe-area-inset-left));background:linear-gradient(#30261bee,#30261bb8);border-bottom:1px solid #c3a97744;box-shadow:0 2px 7px #1c160d33}
.story-location{flex:1;min-width:0;text-align:center;font-size:11px;line-height:1.5;color:#f4e4c5;text-shadow:0 1px 2px #17100b}
#storyPhase{display:block;font-size:10px;line-height:1.5;color:#d9c6a4}
#storyScene{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.story-screen .story-control{--wood-height:32px;position:relative;isolation:isolate;display:inline-flex;align-items:center;justify-content:center;gap:4px;flex:none;min-height:44px;padding:6px 12px;border:0;border-radius:6px;background:transparent;color:#fff0cf;font-size:12px;font-weight:700;line-height:1.5;text-shadow:0 1px 2px #201309;white-space:nowrap;box-shadow:none}
.story-control::before{content:"";position:absolute;z-index:-1;pointer-events:none;inset:calc(6px - var(--wood-height) * 95 / 152) calc(var(--wood-height) * -31 / 152) calc(6px - var(--wood-height) * 101 / 152) calc(var(--wood-height) * -27 / 152);border:solid transparent;border-width:0 calc(var(--wood-height) * 120 / 152);border-image:var(--story-nav-frame) 0 120 0 120 fill / 0 calc(var(--wood-height) * 120 / 152) stretch;filter:drop-shadow(0 2px 1px #20130888)}
.story-screen .story-control:active:not(:disabled){transform:translateY(1px)}
.story-screen .story-control:focus-visible{outline:2px solid #ffe0a0;outline-offset:-2px}
.story-screen .story-control:disabled{opacity:.5}
.story-back-chevron{display:flex;transform:rotate(180deg)}
.story-screen .story-skip{min-width:44px;min-height:44px;padding:6px 8px;border:0;background:transparent;color:#ecdcbd;border-radius:6px;font-size:11px;text-shadow:0 1px 2px #201309}
.story-skip svg{width:13px;height:13px;vertical-align:-2px;margin-left:3px;fill:currentColor}
.story-tap{flex:1;min-height:0!important;display:flex;flex-direction:column;justify-content:flex-end;width:100%;text-align:left;border:0;border-radius:0;padding:24px max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));background:none;color:var(--story-ink);overflow:auto;scrollbar-width:thin;touch-action:pan-y}
.story-tap:hover:not(:disabled){filter:none}.story-tap:focus-visible{outline-offset:-4px}
.story-portrait-stage{position:relative;z-index:0;display:block;flex:1;min-height:0;width:100%;margin-bottom:-24px;overflow:hidden;pointer-events:none}
.story-portrait{position:absolute;left:50%;bottom:0;display:block;width:auto;max-width:none;height:min(200%,calc((100vw - 32px)*2.4));max-height:1100px;transform:translate(-50%,52%);pointer-events:none}
.story-portrait[hidden]{display:none}
.story-caption{position:relative;z-index:1;isolation:isolate;display:flex;flex-direction:column;flex:none;width:100%;height:clamp(228px,34svh,300px);padding:28px 24px 18px;background:#f3e8ce;border:1px solid #b29a69;border-radius:14px;box-shadow:0 7px 24px #19120f66}
.story-caption::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;border:0 solid transparent;border-image-source:var(--story-frame,none);border-image-slice:var(--story-frame-slice,0);border-image-width:var(--story-frame-width,0);border-image-outset:var(--story-frame-outset,0)}
.has-story-frame .story-caption{background:transparent;border-color:transparent}
.story-speaker{position:absolute;top:-14px;left:20px;z-index:1;isolation:isolate;display:flex;align-items:center;justify-content:center;width:max-content;min-width:120px;min-height:var(--story-name-height);max-width:calc(100% - 40px);padding:5px 22px;background:linear-gradient(#657e56,#486046);border:1px solid #c2a269;border-radius:6px;color:#fff2d6;text-align:center;font-size:14px;font-weight:700;line-height:1.5;box-shadow:0 2px 4px #20130944;overflow-wrap:anywhere}
.story-speaker::before{content:"";position:absolute;inset:var(--story-nameplate-inset,0);z-index:-1;pointer-events:none;border:0 solid transparent;border-image-source:var(--story-nameplate,none);border-image-slice:var(--story-nameplate-slice,0);border-image-width:var(--story-nameplate-width,0);border-image-outset:var(--story-nameplate-outset,0)}
.has-story-nameplate .story-speaker{background:transparent;border-color:transparent;box-shadow:none}
.is-narration .story-caption{padding-top:22px}
.story-text{display:block;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding-right:3px;color:var(--story-ink);font-size:17px;line-height:1.85;white-space:pre-wrap;overflow-wrap:anywhere;letter-spacing:.035em;scrollbar-width:thin}
.story-hint{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex:none;font-size:11px;line-height:1.6;color:#786544;margin-top:12px}
.story-tap-cue{display:flex;color:#6d7f4e}
.story-screen[data-typing=true] .story-tap-cue{visibility:hidden}
.story-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:6px max(18px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));background:linear-gradient(transparent,#241b1599)}
.story-page-marker{display:flex;flex-direction:column;align-items:center;gap:5px;flex:none;min-width:52px;color:#fff1d3;font-size:11px;font-variant-numeric:tabular-nums;text-shadow:0 1px 3px #21180e}
.story-progress{display:block;width:42px;height:3px;border-radius:3px;background:#f6ecd344;overflow:hidden}
.story-progress>span{display:block;height:100%;border-radius:inherit;background:#ead093}
@media(max-width:360px){.story-header{gap:5px;padding-inline:8px}.story-screen .story-control{font-size:11px;padding-inline:10px;gap:2px}.story-location{font-size:10px}.story-screen .story-skip{font-size:10px;padding-inline:4px}.story-tap{padding-inline:12px}.story-caption{padding:26px 20px 16px}.story-text{font-size:16px;line-height:1.85}.story-footer{padding-inline:12px;gap:5px}}
@media(max-height:520px){.story-screen{height:auto;min-height:100dvh;overflow:visible}.story-header{position:sticky;top:0;z-index:4}.story-tap{flex:none;overflow:visible;padding-top:40px}.story-caption{height:224px}.story-text{font-size:16px}.story-footer{padding-top:6px}}
@media(prefers-reduced-motion:reduce){.story-screen::after,.story-screen *{transition:none;animation:none;scroll-behavior:auto}}

@media(max-height:520px){.story-screen[data-portrait-speaker] .story-portrait-stage{flex:none;height:240px}}
