/* The download prompt and reading settings use the same type scale in the 720px frame. */
:root {
  --panel-font-family: "Noto Serif SC","Songti SC","Hiragino Mincho ProN","Yu Mincho",serif;
  --panel-title-size: 32px;
  --panel-title-spacing: .15em;
  --panel-label-size: 26px;
  --panel-action-size: 25px;
  --panel-status-size: 21px;
}
body{font-family:"Hiragino Mincho ProN","Yu Mincho","Noto Serif CJK JP",serif;-webkit-tap-highlight-color:transparent;user-select:none;touch-action:manipulation}
button,input{font:inherit}button{cursor:pointer}button:focus-visible{outline:3px solid #efd082;outline-offset:3px}button:disabled{cursor:default;opacity:.42}[hidden]{display:none!important}
#reader,#background,#scene-tone,#actor,#scene-flash,#advance{position:absolute;top:0;right:0;bottom:0;left:0;inset:0;width:100%;height:100%}#reader{background:#000;overflow:hidden}#background{background-position:center;background-size:cover;background-repeat:no-repeat}#scene-tone{pointer-events:none}#actor{object-fit:contain}#scene-flash{pointer-events:none;background:transparent}#advance{border:0;background:transparent;touch-action:manipulation}
#reading-tools{position:absolute;left:14px;bottom:18px;display:flex;align-items:center;gap:10px}#reading-tools button{border:1px solid #cbc4dfb5;color:#f9f5ff;background:linear-gradient(#80708eaa,#55465fbb);border-radius:40px;min-width:66px;height:45px;padding:0 12px;font-family:Arial,sans-serif;font-size:18px;text-shadow:0 1px 2px #000}#reading-tools button[aria-pressed=true]{color:#ffdf81;box-shadow:0 0 0 2px #e8c16b}#settings-button{position:absolute;right:20px;bottom:20px;width:45px;height:45px;border-radius:50%;border:2px solid #e6cf9f;background:#766346b8;color:#fff2ca;font-size:30px;line-height:1}
#choices{position:absolute;left:45px;right:45px;top:450px;display:grid;gap:16px}#choices button{background:linear-gradient(#f2edf6,#d4d0df);color:#383243;border:2px solid #d1b773;min-height:75px;padding:14px 24px;font-size:28px;box-shadow:0 3px 10px #0007;clip-path:polygon(4% 0,96% 0,100% 50%,96% 100%,4% 100%,0 50%)}
.modal{position:absolute;top:0;right:0;bottom:0;left:0;inset:0;background:#0a0a0dcc;display:flex;justify-content:center;align-items:center;z-index:5}.panel{width:610px;max-height:1100px;padding:28px 32px;background:linear-gradient(#514756f5,#2c2735fa);border:2px solid #a08a64;box-shadow:0 14px 50px #000b;overflow:auto;color:#f9f3e9}.panel h1{text-align:center;font-size:var(--panel-title-size);letter-spacing:var(--panel-title-spacing);margin:0 0 25px}.panel button{display:block;width:100%;font-size:var(--panel-action-size);min-height:60px;margin-top:14px;color:#fff0cc;border:1px solid #bca36b;background:#24202b;padding:12px}.panel label{display:flex;justify-content:space-between;align-items:center;font-size:var(--panel-label-size);margin-bottom:24px;gap:25px}.panel input{width:320px;accent-color:#dbbe76;height:30px}.panel p{font-size:25px;line-height:1.6}.log-row{border-bottom:1px solid #91839270;padding:20px 0;font-size:24px;white-space:pre-wrap;line-height:1.6}.log-row strong{display:block;color:#e9c780;font-size:21px;margin-bottom:6px}#log-content{max-height:850px;overflow-y:auto;user-select:text}#error{position:absolute;left:40px;right:40px;top:450px;z-index:30;padding:30px;background:#27202cf5;border:2px solid #c7a15b;font-size:24px;color:#fff}#error button{font-size:25px;padding:10px 28px}@keyframes breathe{50%{opacity:.25}}@media(prefers-reduced-motion:reduce){*{animation:none!important}}

/* v13 portrait Card canvas: original-sized controls and an angular paper bubble. */
#background-canvas,#picture-canvas{position:absolute;top:0;right:0;bottom:0;left:0;inset:0;width:100%;height:100%;pointer-events:none}
#reading-tools{left:18px;bottom:16px;gap:14px}#reading-tools button{min-width:96px;width:96px;height:96px;border-radius:50%;font-size:23px;padding:9px;color:#f5f0fb;background:linear-gradient(#a6a4b478,#665279b3);border:2px solid #e0dce8aa;line-height:1.15;box-shadow:0 2px 6px #0003}
#log-button:before,#auto-button:before{content:"";display:block;width:38px;height:32px;margin:0 auto 2px;background:currentColor;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M3 4h26v18H17l-7 6v-6H3z'/%3E%3C/svg%3E") center/contain no-repeat}
#auto-button:before{mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M15 2v8l6-4zM16 4A12 12 0 1 0 28 16h-3A9 9 0 1 1 16 7z'/%3E%3C/svg%3E") center/contain no-repeat}
#settings-button{right:22px;bottom:22px;width:72px;height:72px;font-size:32px;background:#171812b5;border:1px solid #f5d98e}

#scene-flash{z-index:3}#reading-tools,#settings-button{z-index:4}#choices{z-index:4}
#choices button[data-read]{opacity:.35;position:relative;padding-inline:92px;background:linear-gradient(rgba(238,234,242,.93),rgba(215,212,221,.92));border-color:#baa986;color:#5b5563}
#choices .choice-read-badge{position:absolute;inset-inline-end:30px;top:50%;transform:translateY(-50%);padding:4px 9px;border:1px solid #a58956;border-radius:3px;background:#f5e8ce;color:#624b27;font-size:18px;line-height:1.2;white-space:nowrap;pointer-events:none}

/* Confine reader effects/controls below the whole entry surface. */
#reader{z-index:0;isolation:isolate}#entry-frame{z-index:10}

#audio-controls{border:0;padding:0;margin:0}#audio-controls label,#audio-controls button{opacity:.42}

/* Original ADV2 sprites pre-rendered once at native nine-slice dimensions to avoid strip alpha seams.
   Native SafeFrame 1080 -> logical portrait720; the fixed body never follows text height. */
#dialogue{position:absolute;left:6.666667px;right:auto;top:107.333333px;width:706.666667px;height:218.666667px;min-height:0;max-height:218.666667px;padding:0;border:0;background:none;clip-path:none;filter:none;pointer-events:none;overflow:visible;color:#3b3a40;font-family:"Hiragino Kaku Gothic ProN","Yu Gothic","Noto Sans CJK JP","Noto Sans JP",sans-serif;line-height:1;z-index:2}
#dialogue::before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;inset:0;box-sizing:border-box;border:0;border-image:none;background:var(--download-speech-frame, url("assets/ui/speech-frame.png")) center/100% 100% no-repeat;opacity:1;pointer-events:none;filter:drop-shadow(0 2px 2px #0003)}
#dialogue::after{display:none}
#speaker{position:absolute;left:80.666667px;top:15px;width:516.666667px;height:30px;margin:0;padding:0;color:#6e6c75;font-size:24px;font-weight:400;line-height:30px;white-space:nowrap;overflow:visible;letter-spacing:0;isolation:isolate}
#speaker::before{content:"";position:absolute;left:-36px;top:-5px;width:573.333333px;height:38px;box-sizing:border-box;border:0;border-image:none;background:var(--download-nameplate, url("assets/ui/speech-nameplate.webp")) center/100% 100% no-repeat;z-index:-1;pointer-events:none}
#speaker:empty{display:none}
#text{position:absolute;left:86.666667px;top:58.666667px;width:533.333333px;height:90.666667px;margin:0;padding:0;font-size:24.466667px;line-height:30.222222px;font-weight:400;letter-spacing:0;white-space:pre-wrap;overflow-wrap:normal;word-break:normal;line-break:strict;overflow:visible;color:inherit}
#next-mark{position:absolute;left:619.466666px;top:88.666667px;width:35.733333px;height:48px;margin:0;padding:0;background:var(--download-next-mark, url("assets/ui/ic_tell_next_page.png")) center/contain no-repeat;font-size:0;line-height:0;animation:breathe 1.2s ease-in-out infinite}
#dialogue[data-kind="narration"]{top:115.2px;height:162.933333px;max-height:162.933333px;color:#fff}
#dialogue[data-kind="narration"]::before{border:0;border-image:none;background-image:var(--download-narration-frame, url("assets/ui/narration-frame.png"));filter:drop-shadow(0 2px 2px #0004)}
#dialogue[data-kind="narration"] #speaker{display:none}
#dialogue[data-kind="narration"] #text{top:28.133333px;height:100px;font-size:26.666667px;line-height:32px}
#dialogue[data-kind="narration"] #next-mark{left:649.466667px;top:70.8px}
/* Three legacy restoration notices have25-character hard lines, unlike the20-character story source. */
#dialogue[data-compact="true"] #text{font-size:20.5px;line-height:30.222222px}
#reader.title-scene #dialogue{left:16px;right:16px;top:480px;width:auto;height:auto;max-height:none;min-height:0;transform:none;background:none;color:#fff;clip-path:none;text-align:center;filter:none;padding:0 30px;font-family:"Hiragino Mincho ProN","Yu Mincho","Noto Serif CJK JP",serif}
#reader.title-scene #dialogue::before,#reader.title-scene #dialogue::after,#reader.title-scene #speaker,#reader.title-scene #next-mark{display:none}
#reader.title-scene #text{position:relative;left:auto;top:auto;width:auto;height:auto;font-size:42px;line-height:1.5;letter-spacing:.2em;text-shadow:0 2px 9px #000}
/* Only slow resource waits show this quiet indicator; scripted Wait/Wipe never does. */
#loading{position:absolute;left:auto;top:auto;right:32px;bottom:118px;width:34px;height:34px;padding:0;border:0;background:none;transform:none;pointer-events:none;z-index:20;font-size:0}
#loading>span{display:block;width:100%;height:100%;border:3px solid #e2d5ab33;border-top-color:#e9d99b;border-radius:50%;animation:loading-turn 1s linear infinite}
@keyframes loading-turn{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){#next-mark,#loading>span{animation:none}}

/* Above the entry wipe, below recoverable errors; no additional assets to fetch. */
#chapter-loading{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);z-index:25;display:flex;align-items:center;justify-content:center;gap:20px;min-width:300px;padding:30px 36px;border:1px solid #bca367b3;background:linear-gradient(115deg,#17222bf5,#0f1922fa);box-shadow:0 10px 36px #0006;color:#efd59a;font-size:29px;letter-spacing:.08em;line-height:1.4;pointer-events:none;opacity:1;transition:opacity .12s ease}
#chapter-loading.is-leaving{opacity:0}
#chapter-loading .chapter-loading-spinner{width:30px;height:30px;flex:0 0 30px;border:3px solid #dec58538;border-top-color:#efd59a;border-radius:50%;animation:loading-turn 1s linear infinite}


/* Settings, dialogue history and chapter end share the catalogue's night-blue / warm-gold palette.
   All sizes remain in the existing 720 x 1280 logical reader frame. */
#settings.modal,#log.modal,#chapter-end.modal{background:#080f15bf}
#settings>.panel,#log>.panel,#chapter-end>.panel{
 position:relative;background:linear-gradient(110deg,#17212bfa,#101821fa);
 border:1px solid #d5b36b70;color:#f3ead6;box-shadow:0 14px 50px #0008;
 font-family:var(--panel-font-family);
}
#settings .panel h1,#log .panel h1,#chapter-end .panel h1{color:#eddfc2;font-weight:400}
#settings .panel h1{padding:0 56px}
#settings #audio-controls label{color:#eddfc2;opacity:1}
#settings #audio-controls:disabled label{opacity:.42}
#settings .panel input{accent-color:#d2b168}
#settings .panel button,#log .panel button,#chapter-end .panel button{
 background:#c9a05216;border:1px solid #c8aa6566;color:#f2d89c;
}
#settings .panel button:active,#log .panel button:active,#chapter-end .panel button:active{background:#d4b36930}
#settings #settings-close{
 position:absolute;top:8px;right:8px;display:flex;align-items:center;justify-content:center;
 width:80px;min-height:80px;height:80px;margin:0;padding:0;
 border:0;background:transparent;color:#ddc28c;font:48px/1 Arial,sans-serif;
}
#settings #settings-close:active{background:#c9a05216}
#chapter-end #end-title{display:flex;justify-content:center;align-items:baseline;gap:18px;margin:22px 0 24px;padding:20px 0;color:#ede1c6;font-size:32px;line-height:1.5;text-align:center;white-space:normal;overflow-wrap:anywhere}
#chapter-end #end-name{min-width:0}
#chapter-end #end-heading{padding:0 56px;font-size:36px}
#chapter-end #end-close{position:absolute;top:8px;right:8px;display:flex;align-items:center;justify-content:center;width:80px;min-height:80px;height:80px;margin:0;padding:0;border:0;background:transparent;color:#ddc28c;font:48px/1 Arial,sans-serif}
#chapter-end #end-close:active{background:#c9a05216}
#chapter-end #end-number{white-space:nowrap}
/* Two exact source/display-guarded repeated lines; fixed box and line-height stay native. */
#dialogue[data-kind="speech"][data-locale-fit="repeat-30"] #text{font-size:17.4px}

/* Reader controls use the catalogue palette, retaining their original touch targets. */
#reading-tools #log-button,#reading-tools #auto-button,#settings-button{
 color:#f2d89c;border-color:#c8aa6580;
 background:linear-gradient(110deg,#17212bf2,#101821f2);text-shadow:none;
}
#reading-tools #log-button:active,#reading-tools #auto-button[aria-pressed="false"]:active,#settings-button:active{
 background:linear-gradient(110deg,#26303bfa,#1b2631fa);border-color:#edcf8c;
}
#reading-tools #auto-button[aria-pressed="true"]{
 color:#101821;background:#d2b168;border-color:#efd082;box-shadow:0 0 0 2px #10182199;
}
#log .log-row{border-bottom-color:#ad915735;color:#f3ead6}
#log .log-row strong{color:#d2b168}

#settings-button{
 right:18px;bottom:16px;width:96px;height:96px;min-width:96px;padding:9px;
 border-width:2px;border-style:solid;border-radius:50%;font-family:Arial,sans-serif;
 font-size:23px;line-height:1.15;box-shadow:0 2px 6px #0003;
}
#settings-button::before{
 content:"";display:block;width:38px;height:32px;margin:0 auto 2px;background:currentColor;
 mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath fill-rule='evenodd' d='M13 2h6l1 4 3 2 4-1 3 5-3 3v3l3 3-3 5-4-1-3 2-1 4h-6l-1-4-3-2-4 1-3-5 3-3v-3l-3-3 3-5 4 1 3-2zM16 11a5 5 0 1 0 0 10 5 5 0 0 0 0-10z'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* iOS WebViews need both prefixed selection and callout rules on descendants.
   Keep native scrolling, chapter swipes, taps and audio sliders unchanged. */
#phone-frame,#phone-frame *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
#phone-frame img,#phone-frame canvas{-webkit-user-drag:none}
#phone-frame input:not([type=range]),#phone-frame textarea,#phone-frame [contenteditable="true"]{-webkit-user-select:text;user-select:text;-webkit-touch-callout:default}

#startup-loading{position:absolute;left:50%;bottom:300px;transform:translateX(-50%);z-index:25;display:flex;align-items:center;gap:14px;padding:20px 28px;background:#101c26ed;border:1px solid #c8aa6577;color:#efd59a;font-size:25px;pointer-events:none;white-space:nowrap}
#startup-loading>span:first-child{width:25px;height:25px;border:3px solid #dec58538;border-top-color:#efd59a;border-radius:50%;animation:loading-turn 1s linear infinite}

/* Save feedback stays outside the reader controls and does not intercept reading. */
#save-status{margin:18px 0 10px;font-size:var(--panel-status-size);line-height:1.45;text-align:center;color:#d7c79f}
#save-retry{font-size:22px;padding:10px;margin:0 0 12px}
#save-notice{position:absolute;left:20px;right:20px;top:24px;z-index:45;display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid #9e8655;background:rgba(12,25,34,.96);color:#eddbaf;font-size:21px;line-height:1.4;pointer-events:none}
#save-notice[hidden]{display:none}#save-notice span{flex:1}#save-notice button{pointer-events:auto;width:auto;flex:none;margin:0;padding:8px 14px;font-size:21px}

#save-notice{flex-wrap:wrap}#save-notice-text{min-width:300px}#save-notice-retry[hidden],#save-retry[hidden]{display:none}

#account-gate{position:absolute;top:0;right:0;bottom:0;left:0;inset:0;z-index:60;display:grid;place-items:center;padding:34px;background:rgba(5,12,18,.68)}
#account-gate[hidden],#account-gate [hidden]{display:none!important}
#account-gate>div{width:min(100%,570px);padding:32px 36px;border:1px solid #a88750;background:#111d28f5;color:#f6e3bd;text-align:center}
#account-gate h1{font-size:30px;letter-spacing:.12em;margin:0 0 18px}#account-gate p{font-size:22px;line-height:1.6;margin:0 0 22px;color:#dbd7cf}
#account-gate button,#account-gate a{display:block;width:100%;padding:12px;margin:9px 0 0;border:1px solid #967749;color:#f2d392;background:#222a31;text-decoration:none;font:inherit;font-size:22px;cursor:pointer}

#settings .panel{max-height:90%;overflow-y:auto}#settings #legacy-open{font-size:18px;padding:6px;border:0;margin:4px 0 12px;background:transparent;text-decoration:underline;text-underline-offset:3px}
#legacy-panel{border:1px solid #967749;padding:12px;margin:8px 0 16px;text-align:left;font-size:18px}#legacy-panel[hidden]{display:none!important}#legacy-panel .legacy-row{display:flex;gap:10px;align-items:center;margin:8px 0;padding:6px 0;border-top:1px solid #96774955}#legacy-panel .legacy-list{list-style:none;padding:0}#legacy-panel input{width:22px;height:22px}#legacy-panel .legacy-detail{display:grid;gap:3px}#legacy-panel .legacy-help,#legacy-panel .legacy-status,#legacy-panel .legacy-comparison{color:#d0c7b4;line-height:1.5;font-size:17px}
