/* Mobile browsers highlight the whole clickable reader on every tap. */
body[data-ui-screen="story"],#story{-webkit-tap-highlight-color:transparent}
#story.story-screen{display:flex;flex-direction:column;width:min(780px,100%);height:calc(100dvh - 64px);min-height:420px;margin:0 auto;background:#f6f3ec;border:1px solid #e5dfd3;border-radius:18px;overflow:hidden;color:#25231f;box-shadow:0 20px 60px #27201715;cursor:pointer}
#story .story-header{position:relative;z-index:2;flex:none;display:flex;align-items:center;gap:18px;min-height:82px;margin:0;padding:16px 24px;background:#fffdf8;border-bottom:1px solid #e8e1d6}
#story .story-header>div{flex:1;min-width:0}
#story .story-kicker{font-size:11px;font-weight:700;letter-spacing:.15em;color:#8b7655}
#story h1{font-size:18px;line-height:1.35;margin:3px 0 0;font-weight:650}
#story .story-scene-count{font-size:12px;color:#968e83;white-space:nowrap}
#story .story-back{flex:none;display:grid;place-items:center;width:42px;height:42px;padding:0;background:#f1ede5;color:#302b24;border:0;border-radius:50%;font-size:22px;box-shadow:none}
#story .story-menu-toggle{flex:none;display:grid;place-items:center;width:42px;height:42px;padding:0;border:0;border-radius:12px;background:#f1ede5;color:#302b24;cursor:pointer}
#story .story-menu-toggle[aria-expanded="true"]{background:#e5d8bf}
#story .story-menu-toggle svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
#story .story-menu-toggle:focus-visible,#story .story-menu-scene:focus-visible{outline:3px solid #a78348;outline-offset:2px}
#story .story-scene-menu{position:absolute;top:calc(100% - 4px);right:16px;z-index:3;width:min(360px,calc(100vw - 32px));max-height:min(420px,calc(100dvh - 110px));overflow-y:auto;box-sizing:border-box;padding:10px;border:1px solid #ded4c1;border-radius:14px;background:#fffdf8;box-shadow:0 18px 42px #27201738;cursor:default}
#story .story-scene-menu[hidden]{display:none}
#story .story-menu-heading{display:block;padding:8px 10px 10px;color:#8b7655;font-size:12px}
#story .story-menu-scene{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:11px 10px;border:0;border-radius:9px;background:transparent;color:#302b24;text-align:left;font:inherit;font-size:13px;cursor:pointer}
#story .story-menu-scene:hover:not(:disabled),#story .story-menu-scene[aria-current="step"]{background:#f0e8d9}
#story .story-menu-scene:disabled{color:#aaa39a;cursor:not-allowed}
#story .story-menu-scene span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#story .story-menu-scene small{flex:none;color:#907d62;font-size:11px}
#story .story-messages{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:18px;padding:28px clamp(16px,5vw,48px)}
#story .story-message{display:flex;align-items:flex-end;gap:9px;align-self:flex-start;width:fit-content;max-width:min(86%,600px);animation:story-in .2s ease-out}
#story .story-avatar{flex:none;width:48px;height:48px;border-radius:0;background:#dedbd5;border:1px solid #bfb7ab;object-fit:cover}
#story .story-avatar-button{flex:none;display:block;width:50px;height:50px;padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;cursor:zoom-in}
#story .story-avatar-button .story-avatar{display:block}
#story .story-avatar-button:focus-visible{outline:3px solid #a78348;outline-offset:3px}
.story-portrait-dialog{width:min(560px,calc(100vw - 32px));max-height:calc(100dvh - 32px);box-sizing:border-box;padding:16px;border:1px solid #d6c9b5;border-radius:16px;background:#fffdf8;color:#25231f;box-shadow:0 24px 70px #080a13a6;overflow-y:auto}
.story-portrait-dialog::backdrop{background:#0d1429c9}
.story-portrait-dialog>header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px}
.story-portrait-dialog h2{margin:0;font-size:18px;line-height:1.3}
.story-portrait-close{flex:none;width:38px;height:38px;padding:0;border:0;border-radius:50%;background:#eee8de;color:#302b24;font-size:26px;line-height:1;cursor:pointer}
.story-portrait-view{text-align:center}
.story-portrait-view>img{display:block;width:min(100%,500px);max-height:calc(100dvh - 155px);margin:auto;object-fit:contain}
.story-portrait-card-button,.story-portrait-back{display:block;margin:14px auto 0;padding:10px 18px;border:1px solid #a78348;border-radius:10px;background:#7f5d2f;color:#fff9ec;font:inherit;font-weight:700;cursor:pointer}
.story-portrait-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:10px;margin-top:14px}
.story-portrait-actions .story-portrait-card-button,.story-portrait-save{margin:0;padding:10px 18px;border:1px solid #a78348;border-radius:10px;background:#7f5d2f;color:#fff9ec;font:inherit;font-weight:700;cursor:pointer}
.story-portrait-save:disabled{border-color:#c9c2b7;background:#eee8de;color:#766d61;cursor:default}
.story-portrait-save-status{margin:8px 0 0;color:#766d61;font-size:13px;text-align:center}
.story-portrait-card-button:disabled{opacity:.6;cursor:wait}
.story-portrait-close:focus-visible,.story-portrait-card-button:focus-visible,.story-portrait-back:focus-visible,.story-portrait-save:focus-visible{outline:3px solid #d3a957;outline-offset:3px}
.story-portrait-card-view{padding:16px;border-radius:12px;background:#17223b;color:#eaf0ff}
.story-portrait-card-view>.card{width:min(300px,100%);margin:14px auto}
.story-portrait-card-view .story-portrait-back{margin-top:0}
.story-portrait-card-notes{max-width:460px;margin:12px auto 0;text-align:left;line-height:1.5;overflow-wrap:anywhere}
.story-portrait-error{color:#a4362d;font-size:13px}
#story .story-bubble{min-width:0;padding:12px 16px;background:white;border:1px solid #e6e0d7;border-radius:16px 16px 16px 5px;box-shadow:0 2px 8px #2c221009}
#story .story-message.story-player{align-self:flex-end}
#story .story-player .story-bubble{background:#dfe9dc;border-color:#cbd9c8;border-radius:16px 16px 5px 16px}
#story .story-wave-defs{position:absolute;pointer-events:none}
#story .story-thought .story-bubble{position:relative;isolation:isolate;background:#edf0fa;border:0;border-radius:18px 18px 7px 18px;color:#343f60}
#story .story-thought .story-bubble::before{content:"";position:absolute;inset:-3px;border:2px solid #7183b4;border-radius:20px 20px 9px 20px;pointer-events:none;filter:url(#story-thought-wave)}
#story .story-thought .story-speaker{color:#586b9d}
#story .story-message.story-narration{align-self:center;max-width:92%;text-align:center;color:#655a4a}
#story .story-narration .story-bubble{background:#ebe5d9;border:0;border-radius:12px;box-shadow:none}
#story .story-speaker{display:block;margin-bottom:5px;font-size:11px;color:#8b7655}
#story .story-message p .story-mention{color:#1766c2;font-weight:700}
#story .story-player .story-speaker{color:#527153}
#story .story-private-heading{display:flex;align-items:center;gap:4px;flex-wrap:wrap;margin-bottom:5px;font-size:11px}
#story .story-private-heading .story-speaker{display:inline;margin:0;color:#527153}
#story .story-private-badge{display:inline-flex;align-items:center;gap:2px;color:#527153;font-weight:700;white-space:nowrap}
#story .story-private-badge svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linejoin:round}
#story .story-message p{margin:0;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere;font-size:15px}
#story .story-message.story-battle{align-self:center;max-width:92%}
body:not(.story-workbench-page) #story .story-encounter-info{display:none}
#story .story-enter-battle{min-width:180px;padding:13px 24px;border:1px solid #a78348;border-radius:12px;background:#7f5d2f;color:#fff9ec;font-size:15px;font-weight:700;box-shadow:0 4px 12px #35250b30;cursor:pointer}
#story .story-enter-battle:hover{background:#6a4a21}
#story .story-enter-battle:focus-visible{outline:3px solid #d3a957;outline-offset:3px}
#story .story-enter-battle:disabled{opacity:.6;cursor:wait}
.story-battle-intro{position:fixed;inset:0;margin:auto;width:min(520px,calc(100vw - 32px));max-height:calc(100dvh - 32px);box-sizing:border-box;overflow:auto;padding:28px;border:1px solid #d4b984;border-radius:18px;background:#17223b;color:#fff4d8;text-align:left;box-shadow:0 24px 70px #071021a8}
.story-battle-intro::backdrop{background:#050914bc;backdrop-filter:blur(2px)}
.story-battle-intro-kicker{margin:0 0 10px;color:#e2bd7b;font-size:12px;font-weight:800;letter-spacing:.12em}
.story-battle-intro h2{margin:0 0 20px;color:#fff9e9;font-size:clamp(20px,5vw,26px);line-height:1.35}
.story-battle-intro-message{margin:0 0 22px;font-size:16px;line-height:1.7;white-space:pre-wrap}
.story-battle-intro-first-turn{margin:0 0 20px;padding:10px 13px;border-left:3px solid #d4b984;background:#fff2cf12;font-size:14px;line-height:1.6}
.story-battle-intro button{display:block;min-height:44px;margin-left:auto;padding:10px 22px;border:1px solid #d4b984;border-radius:10px;background:#a87b3d;color:#fff9ec;font:inherit;font-weight:700;cursor:pointer}
.story-battle-intro button:hover{background:#8b6635}
.story-battle-intro button:focus-visible{outline:3px solid #f1cb82;outline-offset:3px}
#story .story-footer{flex:none;display:flex;justify-content:space-between;gap:12px;padding:13px 25px;background:#fffdf8;border-top:1px solid #e8e1d6;color:#968e83;font-size:12px}
@keyframes story-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@media(max-width:600px){body[data-ui-screen="story"] main{width:100%;padding:0}#story.story-screen{height:100dvh;min-height:0;border:0;border-radius:0}#story .story-header{gap:10px;padding:12px 16px}#story .story-messages{padding:20px 16px}#story .story-message{max-width:88%}}
@media(prefers-reduced-motion:reduce){#story .story-message{animation:none}#story .story-thought .story-bubble::before{filter:none}}
