:root{color-scheme:dark;font-family:-apple-system,BlinkMacSystemFont,"Noto Sans JP","Yu Gothic",Meiryo,sans-serif;--ink:#f2eee3;--gold:#f4d7a1;--edge:#b99b67;--navy:rgba(14,25,41,.94)}
*{box-sizing:border-box}body{margin:0;background:#050a11;color:var(--ink);width:100vw;height:100dvh;overflow:hidden;touch-action:manipulation}button{appearance:none;border:1px solid #b69b74;color:#fff0d0;background:linear-gradient(180deg,#40586c,#23364c);box-shadow:0 2px 0 #101620;border-radius:9px;padding:10px 16px;font-size:16px;font-weight:750;cursor:pointer;touch-action:manipulation;user-select:none;-webkit-tap-highlight-color:transparent}button:hover{filter:brightness(1.16)}button:active,.holding{background:#ab8751!important;color:#0a1b2c!important;transform:translateY(1px)}button:disabled{opacity:.4;pointer-events:none}
.hidden{display:none!important}#shell{display:flex;justify-content:center;align-items:center;width:100%;height:100%;background:#070d15}#stage{position:relative;width:min(100vw,177.7777778dvh);height:min(56.25vw,100dvh);overflow:hidden;background:#1a2827;box-shadow:0 0 50px rgba(0,0,0,.65)}canvas{position:absolute;inset:0;width:100%;height:100%;image-rendering:auto}
#titleScreen{position:absolute;inset:0;z-index:20;background:#050b17} .titleback{position:absolute;inset:0;background:url('assets/title.png') center center/contain no-repeat;opacity:.94}.titlegradient{position:absolute;inset:0;background:linear-gradient(90deg,rgba(4,11,19,.55),transparent 72%),linear-gradient(0deg,#090f1c 0%,rgba(3,8,16,.2) 46%,rgba(0,0,0,.15))}.titleui{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:space-between;align-items:center;padding:3.5%}.edition{font-size:clamp(12px,2.2vw,18px);color:#d1e5ee;text-shadow:1px 1px 6px #000;font-weight:700;letter-spacing:.14em}.edition span{font-size:.65em;color:#d9c089}.titlebuttons{display:flex;flex-direction:column;align-items:center;gap:9px;width:min(340px,75%)}.titlebuttons button{width:100%;font-size:18px;box-shadow:0 2px 18px #05090d}.titlebuttons p{font-size:10px;text-align:center;margin:0;color:#dfd4c4;text-shadow:0 2px 4px #000}.titlebuttons p.tiny{opacity:.76}
#hud{position:absolute;inset:0;pointer-events:none;z-index:2}.topbar{display:flex;gap:9px;align-items:center;position:absolute;top:7px;left:9px;right:9px;height:39px;pointer-events:none}.topbar #location{font-weight:900;letter-spacing:.13em;background:var(--navy);padding:7px 12px;border:1px solid #9a865c;border-radius:7px;box-shadow:0 2px 10px #0006}.topbar #gold{margin-left:auto;color:#f5d49a;font-weight:800;background:var(--navy);padding:7px 11px;border-radius:6px}.topbar button{pointer-events:auto;font-size:13px;padding:6px 12px;height:38px}.mission{position:absolute;top:52px;left:10px;max-width:65%;background:rgba(16,31,45,.88);border:1px solid #8e865d;padding:5px 10px;border-radius:7px;font-size:13px;text-shadow:0 1px 2px #000}.mission b{color:#f2c57e}.mission small{display:block;color:#bcd3d7;font-size:11px}
#controls{position:absolute;inset:0;z-index:3;pointer-events:none}#action{position:absolute;right:22px;bottom:20px;pointer-events:auto;border-radius:50%;width:90px;height:90px;padding:0;font-size:19px;background:linear-gradient(145deg,#a98555,#63492b);border:3px solid #e6c58d;box-shadow:0 3px 15px #0a0f19}#action small{font-size:10px}.pulse{box-shadow:0 0 0 5px rgba(241,203,113,.28)!important}
#dialog{position:absolute;inset:0;z-index:6;pointer-events:none;display:flex;align-items:flex-end;justify-content:center;padding:0 12px 8px}.dialogframe{pointer-events:auto;width:min(800px,96%);min-height:125px;background:linear-gradient(165deg,#13273b,#0e1828);border:2px solid #c1a26a;border-radius:11px;padding:10px 14px;box-shadow:0 4px 28px #060c15ef}.dialogframe strong{color:var(--gold);font-size:13px}.dialogline{display:flex;align-items:flex-end;gap:12px;min-height:70px}.dialogline span{flex:1;font-size:17px;line-height:1.7;white-space:pre-wrap;word-break:break-word}.dialogline button{flex-shrink:0;align-self:flex-end;padding:9px 15px;font-size:14px}
#battle{position:absolute;inset:0;z-index:7;display:flex;flex-direction:column;background:linear-gradient(160deg,#142136,#283749 42%,#181c2d);padding:4px 14px 10px}.battlefield{display:flex;align-items:center;justify-content:space-around;flex:1;min-height:0}.battleenemy{display:flex;align-items:center;flex-direction:column;gap:6px;width:32%;text-shadow:0 2px 3px #000}.enemyicon{font-size:96px;line-height:1.22;filter:drop-shadow(0 0 23px var(--aura));animation:float 1.8s ease-in-out infinite alternate}.hpbar{background:#111c2d;border:1px solid #bfb395;width:145px;height:11px;border-radius:8px;overflow:hidden}.hpbar i{background:linear-gradient(90deg,#b63d5f,#f0bb77);height:100%;display:block;transition:width .3s}.partyBattlers{display:flex;flex-direction:column;align-items:flex-end;gap:6px;width:42%;justify-content:center}.battlehero{display:flex;gap:8px;align-items:center;min-width:210px;background:rgba(12,24,38,.7);border:1px solid #526479;border-radius:8px;padding:2px 5px}.battlehero.turn{border-color:#e5ca83;box-shadow:0 0 9px #d5a75f66}.battlehero img{height:55px;width:55px;object-fit:contain}.battlehero b{flex:1;font-size:14px}.battlehero small{font-size:11px;color:#cbd4de;white-space:nowrap;line-height:1.5}.battlebottom{border:1px solid #a28b63;background:var(--navy);padding:8px 10px;border-radius:12px;flex-shrink:0}.battlebottom p{font-size:15px;margin:3px 0 9px;min-height:23px}.battleactions{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px}.battleactions button{font-size:15px;padding:7px 3px}.battleactions small{display:block;font-size:10px;color:#cfc9bb}
#modal{position:absolute;inset:0;background:rgba(4,8,18,.68);z-index:9;display:flex;align-items:center;justify-content:center}.panel{width:min(700px,92%);max-height:90%;overflow-y:auto;padding:14px 18px;background:linear-gradient(145deg,#1b2f43,#0f1d30);border:2px solid #ba9f75;border-radius:15px;box-shadow:0 5px 35px #000c}.panel.small{width:min(450px,85%)}.panel h2{font-size:20px;color:#f0d4a2;margin:0 0 9px}.panel p{font-size:14px;line-height:1.6;margin:7px 0}.menutabs{display:flex;gap:6px}.menutabs button{flex:1;padding:7px 2px;font-size:13px}.menutabs .active{background:#94704b}.menucontent{height:min(255px,47vh);overflow:auto;padding:12px 3px}.choices{display:flex;flex-wrap:wrap;gap:10px}.choices button{min-width:160px;text-align:left}.actions{display:flex;gap:9px;justify-content:flex-end;padding-top:10px}.smallnote{font-size:11px!important;color:#b7babc}.statusrow{display:flex;gap:8px;align-items:center;border-bottom:1px solid #7895a148;margin-bottom:5px}.statusrow img{width:52px;height:52px;object-fit:contain}.statusrow small{display:block;font-size:11px;color:#bbcbdc}
#toast{position:absolute;top:23%;left:50%;transform:translateX(-50%);z-index:12;padding:8px 17px;border:1px solid #d9c096;background:#182539;color:#f9e9c3;font-size:14px;font-weight:650;border-radius:12px;opacity:0;pointer-events:none;transition:opacity .2s;white-space:nowrap}#toast.on{opacity:1}
@keyframes float{from{transform:translateY(-5px)}to{transform:translateY(6px)}}
@media(max-width:700px){.edition{font-size:11px}.titlebuttons{gap:5px;width:min(280px,75%)}.titlebuttons button{font-size:14px;padding:5px 10px}.titlebuttons p{font-size:8px}.topbar{top:3px;height:29px}.topbar #location,.topbar #gold{font-size:10px;padding:4px 6px}.topbar button{height:28px;font-size:11px;padding:3px 8px}.mission{top:36px;font-size:10px;padding:2px 5px;max-width:79%}.mission small{font-size:9px}.dialogframe{min-height:92px;padding:5px 9px}.dialogline{min-height:60px;gap:6px}.dialogline span{font-size:12px;line-height:1.5}.dialogline button{padding:5px 9px;font-size:11px}.dialogframe strong{font-size:10px}#action{right:9px;bottom:9px;width:65px;height:65px;font-size:14px;border-width:2px}#action small{font-size:8px}.panel{padding:8px 12px;max-height:96%}.panel h2{font-size:16px}.panel p{font-size:11px;margin:3px 0}.menutabs button{font-size:10px}.menucontent{height:min(155px,44vh);padding:5px 2px}.choices button{font-size:11px;padding:5px 8px}.battleenemy .enemyicon{font-size:65px}.battlehero{min-width:160px}.battlehero img{width:38px;height:38px}.battlehero b{font-size:11px}.battlehero small{font-size:9px}.battlebottom p{font-size:11px;margin:0 0 4px}.battleactions{gap:4px}.battleactions button{font-size:11px;padding:4px 1px}.battleactions small{font-size:9px}.battlebottom{padding:4px}}
@media(max-height:440px){.dialogframe{min-height:76px}.dialogline{min-height:45px}.dialogline span{font-size:13px}.battlehero img{height:38px;width:38px}.battlebottom{padding:4px}.battlebottom p{margin:0 0 3px}}

.battlesprite{width:74px;height:74px;flex-shrink:0;background-repeat:no-repeat;background-size:222px 296px;background-position:-74px -74px;image-rendering:auto;filter:drop-shadow(0 3px 3px #0008);animation:fighter 1.25s ease-in-out infinite alternate}@keyframes fighter{to{transform:translateY(-3px)}}
@media(max-width:700px){.battlesprite{width:46px;height:46px;background-size:138px 184px;background-position:-46px -46px}}
/* Dedicated 9x6 battle art, using the original character sheets. */
.battlesprite{height:86px;width:86px;background-size:258px 344px;background-position:-86px -86px;image-rendering:auto;animation:fighter 1.25s ease-in-out infinite alternate}
.battlesprite.sheet9{height:86px;width:86px;background-size:774px 516px;background-position:0 0}
@media(max-width:700px){.battlesprite{height:48px;width:48px;background-size:144px 192px;background-position:-48px -48px}.battlesprite.sheet9{height:48px;width:48px;background-size:432px 288px;background-position:0 0}}

.importLabel{display:inline-flex;align-items:center;justify-content:center;min-width:160px;background:#304b60;border:1px solid #b69b74;color:#fdf1d5;border-radius:9px;padding:9px;font-size:13px;cursor:pointer}.importLabel input{display:none}

/* v0.4: movable thumb-stick for smartphone-first navigation */
#joystick {position:absolute;bottom:12px;left:16px;width:132px;height:132px;border-radius:50%;pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;outline:none;background:radial-gradient(circle at 32% 26%,rgba(112,156,179,.22),rgba(8,21,34,.80) 73%);border:3px solid rgba(229,199,141,.70);box-shadow:inset 0 1px 12px #d9bb7450,inset 0 -6px 18px #030a14b0,0 6px 16px #040810bb;}
#joystick:focus-visible {outline:3px solid #fae5ab;outline-offset:4px}
.joystick-ring{position:absolute;inset:21%;border:2px dashed rgba(202,213,217,.22);border-radius:50%;pointer-events:none;}
.joystick-ring:after{content:'✦';position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:18px;color:rgba(220,229,228,.26)}
#joystick-knob{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:54px;height:54px;border-radius:50%;pointer-events:none;background:radial-gradient(circle at 31% 26%,#adc3d0 0%,#5c8196 43%,#24465d 75%,#142b3d 100%);border:3px solid #d4e2e6;box-shadow:inset 0 0 11px #0e2339,0 3px 10px #020912b3;will-change:transform;}
#joystick.engaged{border-color:#f5d394;box-shadow:inset 0 0 18px #a9c5d24d,0 0 0 3px rgba(224,177,89,.13),0 5px 16px #000a;}
@media(max-width:700px){#joystick{width:102px;height:102px;bottom:6px;left:8px;border-width:2px}#joystick-knob{width:42px;height:42px;border-width:2px}}
@media(max-height:350px){#joystick{width:88px;height:88px}#joystick-knob{width:38px;height:38px}}

/* Full route edition */
.partbuttons{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;margin:10px 0}.partbuttons button{font-size:13px;padding:7px 8px;min-width:0;text-align:left}
.endingpanel{text-align:center;max-height:92%;overflow:auto}.endingpanel .endstars{font-size:20px;color:#fbe1a9;letter-spacing:.13em}.endingpanel p{font-size:14px;line-height:1.8}.endingcredit{color:#e7d7b3;padding:8px;border-top:1px solid #bd9a61}.enemyArt{width:98px;height:122px;position:relative;display:block;font-size:0;background-image:var(--sprite);background-size:294px 392px;background-position:-98px -4px;background-repeat:no-repeat;filter:drop-shadow(0 0 18px var(--aura));animation:float 1.8s ease-in-out infinite alternate;}
.titleback{background-size:contain;background-position:center}.titlegradient{background:linear-gradient(0deg,rgba(5,11,24,.94),transparent 55%),linear-gradient(90deg,#080d1b4d,transparent,#080d1b4d)}.titleui{padding:2.5% 6%;}.titlebuttons{max-width:290px;gap:5px}.titlebuttons button{font-size:14px;padding:6px 8px}.titlebuttons p{font-size:9px}.mission{max-width:80%}
@media(max-width:700px){.partbuttons{gap:4px}.partbuttons button{font-size:11px;padding:5px 6px}.titlebuttons{max-width:210px;gap:3px}.titlebuttons button{font-size:11px;padding:4px}.titlebuttons p{font-size:8px}.enemyArt{width:67px;height:84px;background-size:201px 268px;background-position:-67px 0}.endingpanel p{font-size:11px}}

/* Properly typeset title, since the old baked title image was cropped at both edges. */
.titleback{filter:brightness(.50) saturate(.90)}.titlegradient{background:linear-gradient(180deg,rgba(5,12,28,.82) 0%,rgba(4,9,23,.69) 49%,rgba(5,10,25,.80) 100%)}
.trueTitle{position:absolute;z-index:1;top:23%;left:7%;right:7%;font-family:"Noto Serif CJK JP",serif;font-size:clamp(32px,5.3vw,66px);font-weight:900;letter-spacing:.08em;color:#f8ecce;text-align:center;white-space:nowrap;text-shadow:0 2px #372a18,0 3px 8px #000,0 0 13px #b89c68;}
.titleui{z-index:2}.titlebuttons{background:rgba(6,16,31,.78);padding:10px;border:1px solid #8f7b53;border-radius:12px}.titlebuttons button{padding:5px 10px}
.endingpanel{display:flex;flex-direction:column;gap:3px}.endingpanel p{margin:1px 0;line-height:1.46}.endingpanel h2{margin:3px 0}.endingpanel .actions{position:sticky;bottom:-14px;background:#122236;padding:8px 0 0;justify-content:center}.endingpanel .actions button{font-size:12px;padding:6px 9px}
@media(max-width:700px){.trueTitle{top:16%;font-size:clamp(24px,5vw,42px)}.titlebuttons{padding:5px}.titleui{padding:1.5% 5%}.endingpanel{gap:1px}.endingpanel p{font-size:10px;line-height:1.25}.endingpanel .actions{bottom:-8px}}

/* Rebuild pass: use the clean lower sky of the existing painting as a backdrop.
   The original artwork contains baked, horizontally cropped title lettering;
   show only its landscape section and typeset the title as accessible HTML. */
#titleScreen{background:radial-gradient(ellipse at 50% 70%,#31344c 0,#0a1324 50%,#040711 100%)}
.titleback{top:42%;bottom:0;left:0;right:0;opacity:.85;filter:brightness(.92) saturate(.95);background-size:cover;background-position:center bottom}
.titlegradient{background:linear-gradient(to bottom,#050c1b 0%,#050c1be5 25%,#050c1b7d 57%,#050c1ba8 86%,#050c1bf5 100%)}
.trueTitle{top:16%;font-size:clamp(22px,5.3vw,64px);left:8%;right:8%;letter-spacing:.04em}
@media(max-width:700px){.trueTitle{top:14%;font-size:clamp(22px,5vw,38px)}}
/* QA16: six party members must fit a landscape phone without covering commands. */
.partyBattlers{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 align-content:center;align-items:center;justify-items:stretch;
 width:55%;gap:5px;min-height:0;max-height:100%;
}
.battleenemy{width:32%}
.battlehero{min-width:0;width:100%;gap:5px;padding:2px 4px;min-height:0}
.battlehero small{flex:0 0 auto;line-height:1.35}
.battlehero.ko{opacity:.56;filter:grayscale(.8);border-style:dashed}
@media(max-width:700px), (max-height:440px){
 .partyBattlers{gap:3px;width:58%}
 .battleenemy{width:29%}
 .battlehero{gap:3px;padding:1px 3px}
 .battlehero b{font-size:10px}
 .battlehero small{font-size:8px}
 .battlesprite,.battlesprite.sheet9{width:39px;height:39px}
 .battlesprite{background-size:117px 156px;background-position:-39px -39px}
 .battlesprite.sheet9{background-size:351px 234px;background-position:0 0}
}
/* QA16: NPC walk sheets are 3 by 4 frames. Never display more than one enemy frame. */
.enemyArt{width:96px;height:96px;background-size:288px 384px;background-position:-96px 0;overflow:hidden}
@media(max-width:700px), (max-height:440px){.enemyArt{width:68px;height:68px;background-size:204px 272px;background-position:-68px 0}}
/* Six-character combat status: avoid unreadably small numbers on phones. */
@media(max-width:700px), (max-height:440px){
 .battlehero b{font-size:12px}
 .battlehero small{font-size:10px}
}

/* QA22: properly isolated pixel-art enemies, never glyphs or neighboring frames */
.enemyicon.has-enemy-art {background:none!important;width:clamp(100px,15vw,160px);height:clamp(100px,17vw,175px);display:flex;align-items:center;justify-content:center;font-size:0;line-height:1;animation:float 1.8s ease-in-out infinite alternate;}
.qa22-enemy-art{display:block;width:100%;height:100%;object-fit:contain;image-rendering:pixelated;filter:drop-shadow(0 7px 6px #05080dcc)}
@media(max-width:700px), (max-height:440px){.enemyicon.has-enemy-art{width:clamp(68px,15vw,105px);height:clamp(66px,19vh,104px)}}
/* Additional unique ally artwork, without substituting other characters. */
.battlesprite.sheet9{--frame-step:86px;background-position:0 0;image-rendering:pixelated}
.battlehero.turn .battlesprite.sheet9.qa24-idle{animation:qa24-battle-frame 1.1s steps(1,end) infinite}
@keyframes qa24-battle-frame{
 0%,24%{background-position:0 0;transform:translateY(0)}
 25%,49%{background-position:calc(-1 * var(--frame-step)) 0;transform:translateY(-2px)}
 50%,74%{background-position:calc(-2 * var(--frame-step)) 0;transform:translateY(0)}
 75%,100%{background-position:calc(-1 * var(--frame-step)) 0;transform:translateY(-1px)}
}
@media(max-width:700px), (max-height:440px){.battlesprite.sheet9{--frame-step:39px}}
@media(prefers-reduced-motion:reduce){.battlehero.turn .battlesprite.sheet9.qa24-idle{animation:none}}
/* QA28: tap to destination, optional on-screen joystick kept for precision. */
#game{cursor:crosshair;touch-action:manipulation}
#joystick{opacity:.55;transition:opacity .15s ease}
#joystick.engaged{opacity:1}
.walk-target{position:fixed;z-index:80;pointer-events:none;width:28px;height:28px;border:2px solid #f6d393;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 10px #ffe1a9cc,inset 0 0 4px #efba62;animation:walk-target-pop .58s ease-out forwards}
@keyframes walk-target-pop{0%{opacity:.0;transform:translate(-50%,-50%) scale(.48)}20%{opacity:1}100%{opacity:0;transform:translate(-50%,-50%) scale(1.3)}}

/* QA29: specific monster hierarchy. Previously the final boss used a tiny
   goblin and the sewer boss reused the harmless forest creature. */
.enemyicon[data-enemy-type="sewerBeast"] .qa22-enemy-art {filter:hue-rotate(118deg) saturate(.85) drop-shadow(0 7px 6px #040910);}
.enemyicon[data-enemy-type="ancientWarden"] .qa22-enemy-art {filter:sepia(.36) saturate(1.25) drop-shadow(0 7px 6px #05080d);}
.enemyicon[data-enemy-type="towerSentinel"] .qa22-enemy-art {filter:hue-rotate(35deg) drop-shadow(0 7px 6px #05080d);}
.enemyicon[data-enemy-type="sealKeeper"] .qa22-enemy-art {filter:hue-rotate(155deg) saturate(1.4) drop-shadow(0 7px 6px #05080d);}
.enemyicon[data-enemy-type="lastObserver"] .qa22-enemy-art {filter:hue-rotate(55deg) saturate(1.2) brightness(1.15) drop-shadow(0 8px 9px #090414);}
.enemyicon[data-enemy-type="lastObserver"] {transform:scale(1.12);}
