.story-overlay{position:fixed;inset:0;z-index:650;background:rgba(5,9,20,.93);display:flex;align-items:center;justify-content:center;padding:16px;box-sizing:border-box;backdrop-filter:blur(9px)}
.story-panel{box-sizing:border-box;width:min(740px,100%);max-height:calc(100dvh - 32px);overflow-y:auto;padding:26px 32px;border:1px solid #7e617b;border-radius:16px;background:linear-gradient(140deg,#202538,#101421);color:#f4eeee;font:16px/1.65 system-ui,sans-serif;box-shadow:0 24px 90px #0008}
.story-panel h2{font-size:24px;margin:0 0 4px}.story-panel h3{font-size:16px;margin:16px 0 8px}.story-panel p{margin:8px 0}.story-eyebrow{color:#edc192;letter-spacing:.12em}.story-power{display:grid;grid-template-columns:auto 1fr auto 1fr;align-items:center;gap:14px;padding:12px 0}.story-power strong{font-size:36px;color:#ffd4b1}.story-power span{font-size:13px}.story-breakdown{display:flex;flex-wrap:wrap;gap:6px 14px;color:#abd5ea;font-size:13px}.story-actions{display:flex;gap:8px;flex-wrap:wrap}.story-panel button{white-space:normal;min-height:44px;max-width:100%;background:#30354b;border:1px solid #758298;border-radius:8px;color:#fff;padding:10px 14px;font:inherit;cursor:pointer;text-align:left}.story-panel button:hover,.story-panel button[aria-pressed=true]{background:#5c3750;border-color:#ffb79b}.story-panel button:disabled{opacity:.45;cursor:default}.story-panel button:focus-visible{outline:3px solid #f7d7ae;outline-offset:3px}.story-panel .story-primary{display:block;width:100%;text-align:center;background:#9b405c;margin:12px 0;font-weight:700}.story-panel .story-fine{font-size:12px;color:#aeb9ca}.story-warning,.story-failure{color:#ffd4a3}.story-ready{color:#aff0ce}.story-hint{padding-left:12px;border-left:2px solid #e4b28b}.story-punch{border:0;background:transparent;text-align:center;box-shadow:none;padding:48px 18px}.story-punch blockquote{margin:34px 0;font-size:clamp(27px,5vw,46px);font-weight:700;line-height:1.6;color:#ffdec1;animation:story-rise .9s ease both}.story-punch button{margin-top:32px;font-size:14px;opacity:.8}.story-battle-meter{position:fixed;top:70px;left:50%;transform:translateX(-50%);z-index:220;color:#fff;background:#151b30dc;padding:8px 20px;border-radius:30px;pointer-events:none;white-space:nowrap;font:15px system-ui}.story-journal-button{display:block;margin:10px auto;min-height:40px}.story-failure{padding:12px;background:#53283a44;border-radius:8px}@keyframes story-rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@media(max-width:600px){.story-overlay{padding:8px}.story-panel{padding:18px 16px;max-height:calc(100dvh - 16px);font-size:14px}.story-panel h2{font-size:21px}.story-power{gap:8px}.story-power strong{font-size:30px}.story-actions button{flex:1 1 100%;font-size:13px}.story-panel h3{margin-top:12px}.story-battle-meter{top:54px;font-size:12px}}
@media(prefers-reduced-motion:reduce){.story-punch blockquote{animation:none}}
.story-free-hint{box-sizing:border-box;overflow-wrap:anywhere;display:block;color:#fff5e8;background:none;border:0;border-radius:0;box-shadow:none;font-size:13px;line-height:1.55;text-align:left;width:100%;padding:0 4px;text-shadow:0 1px 3px #000,0 0 7px #000;cursor:default;user-select:text}
.bubble[data-send-state=pending]{opacity:.85}.chat-send-status{display:block;font-size:12px;color:#fff0ce;margin-top:5px}.bubble[data-send-state=failed]{outline:1px solid #eabd84}
/* The game is a viewport, not a vertically scrolling document. Panels alone may scroll. */
html,body{position:fixed;inset:0;width:100%;height:var(--game-height,100dvh);overflow:hidden;overscroll-behavior:none}
#stage{inset:auto;top:0;left:0;width:100%;height:var(--game-height,100dvh);overflow:hidden;touch-action:none}
#stage canvas{display:block;touch-action:none}
#dialog{bottom:max(12px,env(safe-area-inset-bottom));touch-action:none}
#dialog-box{position:relative}
#nameplate{box-sizing:border-box;height:32px;line-height:23px;white-space:nowrap;max-width:calc(100% - 40px);overflow:hidden;text-overflow:ellipsis;vertical-align:bottom}
#genscene-btn{z-index:2;pointer-events:auto}
#textbox{box-sizing:border-box;height:148px;min-height:148px;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y}
/* 選項只准直向捲（選項多到超過半個畫面才會出現）；橫向一律不捲，長句在按鈕內換行（使用者 2026-09-13：中間那條橫捲軸沒有意義） */
#choices{max-height:46dvh;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y}
#choices button{box-sizing:border-box;max-width:100%;white-space:normal}
#free-input{font-size:16px!important}
#title-card{flex-direction:column;gap:12px;overflow-wrap:normal;word-break:normal;font-size:clamp(22px,4vw,34px);letter-spacing:2px}
.story-ordinal{display:block;white-space:nowrap;word-break:keep-all;font-size:.72em;letter-spacing:.16em;color:#d3c7bd}
#story-npc{position:fixed;z-index:4;object-fit:contain;object-position:center;pointer-events:none;transform:none;border:0;box-shadow:none;mask-image:none}
#story-npc[hidden]{display:none}
#story-npc[data-presentation=photo]{border:3px solid #a8b2be;box-sizing:border-box;box-shadow:0 8px 26px #0006}
.story-overlay,.story-panel{overscroll-behavior:contain}.story-panel{touch-action:pan-y;max-height:calc(var(--game-height,100dvh) - 24px)}
.story-locked-plan{padding:8px 12px;border-left:2px solid #9bafc2;color:#dce9ef}
@media(max-width:600px){#dialog{width:94vw}#textbox{font-size:16px;line-height:1.65;letter-spacing:.5px;padding:14px 16px 22px;height:148px;min-height:148px}#nameplate{font-size:15px;letter-spacing:1px}#genscene-btn{top:-34px;font-size:12px;padding:5px 10px}#title-card{padding:0 6vw}#story-npc{width:88vw}.story-panel{font-size:15px}.story-actions button{font-size:14px}}
@media(max-height:500px){#textbox{height:100px;min-height:100px}#story-npc{top:42px;height:calc(var(--game-height,100dvh) - 165px)}#choices{max-height:45dvh}}
.story-prep{width:min(920px,100%)}
.story-item-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.story-item-cell{position:relative;display:flex;flex-direction:column;align-items:center!important;text-align:center!important;gap:4px}
.story-item-cell img{width:72px;height:72px;object-fit:contain}.story-item-cell span{position:absolute;right:8px;top:8px;font-weight:800;background:#050a18;padding:2px 7px;border-radius:7px}.story-item-cell small{font-size:12px;color:#fff0c8}
.story-slots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.story-slot{display:flex!important;flex-direction:column;align-items:center!important;text-align:center!important;gap:4px;min-height:132px;justify-content:center;border-style:dashed!important;border-color:#d9ae74!important;background:#151a28!important}
.story-slot[aria-pressed=true]{border-style:solid!important}.story-slot img{width:64px;height:64px;object-fit:contain}.story-slot small{font-size:12px;color:#fff0c8}.story-slot-plus{font-size:34px;line-height:1;color:#d9ae74}
.story-bag-pick{margin-top:10px;padding:12px;background:#101522;border:1px solid #657387;border-radius:10px}.story-bag-pick .story-eyebrow{margin:0 0 8px}.story-bag-pick>button{width:100%;margin-top:8px}.story-bag-pick .story-actions{margin-top:8px}.story-bag-pick .story-actions button{flex:1}
/* 背包彈窗與購買確認：疊在整備面板之上（使用者 2026-09-13） */
.story-modal{position:fixed;inset:0;z-index:700;background:rgba(3,6,14,.72);display:flex;align-items:center;justify-content:center;padding:12px;box-sizing:border-box;overscroll-behavior:contain}
.story-modal.story-confirm{z-index:720;background:rgba(3,6,14,.6)}
.story-modal-panel{width:min(620px,100%);padding:20px 22px}
.story-modal-panel h2{font-size:20px}
.story-bag-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;margin:10px 0}
.story-bag-grid .bag-cell{aspect-ratio:auto;min-height:92px;padding:6px 4px;text-align:center!important;align-items:center!important;justify-content:center;display:flex!important;flex-direction:column;gap:3px;background:rgba(20,20,38,.85)!important;border:1px solid var(--panel-border)!important;min-width:0}
.story-bag-grid .bag-cell img{width:44px;height:44px;object-fit:contain}
.story-bag-grid .bag-cell small{font-size:11px;line-height:1.25;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.story-bag-grid .bag-cell i{font-style:normal;font-size:10px;color:#ffe2b0;line-height:1.2}
.story-bag-grid .bag-cell.empty{background:rgba(20,20,38,.35)!important;border-style:dashed!important}
.story-bag-grid .bag-cell.selected{border-color:#ffb79b!important;background:#5c3750!important;box-shadow:0 0 0 2px #ffb79b inset}
.story-bag-grid .bag-cell:disabled:not(.empty){opacity:.45}
.story-bag-detail{min-height:2.6em;margin:4px 0 8px!important;font-size:13px;color:#dce9ef}
.story-modal-panel .story-bag-buy{width:100%;text-align:center;margin-bottom:8px}
.story-bag-actions,.story-confirm-actions{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(0,1fr));gap:8px;margin-top:6px}
.story-bag-actions button,.story-confirm-actions button{text-align:center!important;margin:0!important;flex:none!important}
.story-confirm-panel{width:min(420px,100%);text-align:center}
.story-confirm-icon{display:block;width:72px;height:72px;object-fit:contain;margin:6px auto}
.story-confirm-q{font-size:17px;color:#fff}.story-confirm-cost{color:#ffd9a8}
@media(max-width:600px){.story-modal{padding:8px}.story-modal-panel{padding:16px 12px}.story-bag-grid{gap:5px}.story-bag-grid .bag-cell{min-height:78px}.story-bag-grid .bag-cell img{width:34px;height:34px}.story-bag-grid .bag-cell small{font-size:10px}.story-bag-grid .bag-cell i{font-size:9px}}
.story-earned{display:flex;flex-wrap:wrap;gap:6px}.story-earned span{font-size:12px;color:#dcfff0;background:#183d33;padding:4px 9px;border-radius:6px}
.story-formation{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}.story-formation button{display:grid;grid-template-columns:54px 1fr;align-items:center;gap:4px 10px}.story-formation button img{width:54px;height:62px;object-fit:contain;grid-row:1/3}.story-formation button small{grid-column:2;color:#ffdfb7}.story-formation button b{font-size:14px}
.story-item-used{position:fixed;bottom:14%;left:50%;transform:translateX(-50%);z-index:230;display:flex;align-items:center;gap:12px;padding:12px 18px;color:#fff;background:#142d37f0;border:1px solid #92e1f5;border-radius:14px;font:15px system-ui;pointer-events:none}.story-item-used img{width:54px;height:54px;object-fit:contain}
/* 放大字：短語不拆開、各行平均（phraseText）；短語本身比一行還長時才在短語內換行，也一樣平均 */
.phrased{text-wrap:balance;word-break:normal;overflow-wrap:normal}.phrased .phrase{display:inline-block;max-width:100%;text-wrap:balance}.phrased .w{white-space:nowrap}
.story-punch{width:min(1000px,100%)}.story-punch blockquote{white-space:pre-line;color:#fff1df;text-shadow:0 3px 16px #000;line-height:1.65}
.care-notice{position:fixed;z-index:40;right:16px;top:74px;box-sizing:border-box;max-width:430px;width:calc(100% - 32px);display:grid;grid-template-columns:54px 1fr;gap:8px 12px;padding:14px;background:#171d2bf7;border:1px solid #e3b885;border-radius:14px;box-shadow:0 14px 48px #000a;font:14px/1.6 system-ui;color:#fff}.care-notice>img{width:54px;height:70px;object-fit:contain}.care-notice p{margin:3px 0}.care-notice-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:8px}.care-notice button,.care-header button{padding:8px 12px;background:#303c51;border:1px solid #a6b5ca;color:#fff;border-radius:8px;cursor:pointer;min-height:40px;font:13px system-ui}.care-notice button:first-child{background:#bc8748;color:#100d0a;font-weight:bold}
.care-header{background:#192234;padding:10px 12px;border:1px solid #667e9a;border-radius:10px;display:flex;flex-direction:column;gap:6px;color:#fff;font:14px/1.5 system-ui}.care-header[hidden]{display:none}.care-header small{color:#e0e7ee!important;font-size:12px!important}.care-controls{display:flex;gap:6px;flex-wrap:wrap}.care-header button:disabled{opacity:.5;cursor:default}.care-header p{margin:4px 0}.care-header details{font-size:12px}.care-header summary{cursor:pointer;color:#ffdfb4}
.care-gift-progress{display:flex;align-items:center;gap:8px;font-size:12px}.care-gift-progress img{width:45px;height:64px;object-fit:contain}.care-gift-progress span{flex:1}.story-gift-icon{display:block;width:96px;height:96px;object-fit:contain;margin:12px auto}
/* 通訊頁首資訊列（使用者 2026-09-13）：日常／心事都有；手機拿掉造型小圖、字縮小，最多兩行 */
.chat-info{display:grid;grid-template-columns:40px 1fr;gap:4px 10px;align-items:center;padding-top:2px}
.chat-info .ci-thumb{grid-row:1/3;width:40px;height:56px;object-fit:contain}
.chat-info-line{display:flex;flex-wrap:wrap;gap:2px 14px;font-size:12px;line-height:1.5;color:#e8eef5}
.chat-info-line .ci-aff{color:#ffb3c2;font-weight:700}.chat-info-line .ci-like{display:inline-flex;align-items:center;gap:4px}.chat-info-line .ci-like img{width:18px;height:18px;object-fit:contain}
.chat-info-row{display:flex;align-items:flex-start;gap:8px;flex-wrap:wrap}
.chat-info-row .ci-memory{flex:1 1 auto;min-width:0}.chat-info-row .ci-memory summary{display:inline-block;padding:5px 10px;border:1px solid #8a7a5e;border-radius:8px;background:#2a2a36;color:#ffdfb4;cursor:pointer;font-size:12px;list-style:none}
.chat-info-row .ci-memory summary::-webkit-details-marker{display:none}.chat-info-row .ci-memory[open] summary{background:#4a3a2c}
.chat-info-row .ci-memory b{display:block;margin-top:6px;font-size:12px;color:#ffdfb4}.chat-info-row .ci-memory p{margin:2px 0;font-size:12px}
.chat-info-row>button{min-height:30px!important;padding:5px 10px!important;font-size:12px!important}
#chat-screen .chatp{height:min(90dvh,760px);max-height:calc(var(--game-height,100dvh) - 20px);display:flex;flex-direction:column;gap:10px;overflow:hidden}#chat-msgs{min-height:80px}#chat-screen .care-header{max-height:220px;overflow-y:auto;flex-shrink:0}
@media(max-width:600px){.story-slot{min-height:112px}.story-slot img{width:52px;height:52px}.story-item-cell img{width:58px;height:58px}.story-item-used{bottom:12%;font-size:12px;gap:6px;padding:8px 10px}.story-item-used img{width:36px;height:36px}.care-notice{top:64px;font-size:13px}.care-header{padding:7px 9px}.care-header button{font-size:12px;padding:6px 8px}.care-gift-progress{flex-wrap:wrap}#chat-screen .care-header{max-height:34%}.chat-info{grid-template-columns:1fr}.chat-info .ci-thumb{display:none}.chat-info-line{gap:0 10px;font-size:11px}.chat-info-row .ci-memory summary,.chat-info-row>button{font-size:11px!important}.story-free-hint{font-size:13px}}
/* Dimensions are calculated with the same stage ground line as the original Spine cast.
   The transparent alpha is real; never fake extraction with masks or crop-to-cover. */
