:root{color-scheme:dark;font-family:"Songti SC","SimSun",serif;color:#fff2ce;background:#090d18;font-synthesis:none}*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}button{font:inherit;color:inherit}#game{width:100vw;height:100dvh;display:grid;place-items:center;background:#090d18}#screen{position:relative;width:min(100vw,calc(100dvh * 10 / 7));height:min(100dvh,calc(100vw * 7 / 10));overflow:hidden;background:#203824;container-type:inline-size;font-size:2.35cqw}#board{display:block;width:100%;height:100%;image-rendering:auto}#overlay,#menu{position:absolute;inset:0;pointer-events:none}.box{background:#0c1059;border:2px solid #d6b767;box-shadow:inset 0 0 0 2px #33366b,0 0 0 1px #1a1929,3px 4px 0 #15212490;padding:2.1cqw;pointer-events:auto}.box h1,.box h2,.box p{margin:0}.box h2{font-size:1.1em;color:#e8c978;font-weight:normal}.choice{display:flex;align-items:center;gap:1cqw;min-height:4.3cqw;padding:.45cqw 1.3cqw .45cqw 2.8cqw;position:relative;white-space:nowrap}.choice.active{color:#fff8be;background:#292f79}/* Draw the pointer geometrically: Unicode play triangles become emoji on iOS. */
.choice.active:before{content:'';position:absolute;left:.3cqw;top:50%;width:0;height:0;border-top:.3em solid transparent;border-bottom:.3em solid transparent;border-left:.45em solid #fff7bc;transform:translateY(-50%);pointer-events:none}.choice.disabled{color:#9295af}.choice small{font-size:.7em;color:#c2c4dc;margin-left:auto}.choice strong{font-weight:normal}.caption{color:#b9bccc;font:1.45cqw system-ui,sans-serif;letter-spacing:.04em}.prep{position:absolute;inset:0;background:repeating-linear-gradient(0deg,#222751 0 2px,#1d224c 2px 4px);padding:3cqw;display:grid;grid-template-columns:43% 57%;grid-template-rows:8% 59% 24%;gap:1.5cqw 0}.chapter{grid-column:1/3;display:flex;justify-content:space-between;align-items:center;padding:0 1cqw}.chapter h1{font-size:2.8cqw;font-weight:normal;letter-spacing:.2em}.prep .roster{grid-row:2/4}.prep .roster .choice{border-bottom:1px solid #34396f;padding-top:1.8cqw;padding-bottom:1.8cqw}.commander{display:grid;grid-template-columns:46% 54%;gap:1.5cqw;align-items:center;padding:2cqw}.commander img{width:100%;aspect-ratio:1;object-fit:cover;object-position:top;border:2px solid #d2b16a;background:#243c4e}.commander .name{font-size:3.5cqw;letter-spacing:.2em}.commander .stats{font:1.8cqw/1.7 monospace;margin-top:1.5cqw}.prep-orders{margin-top:1.5cqw}.prep-hint{position:absolute;bottom:1.5cqw;left:4.7cqw;right:4.7cqw;display:flex;justify-content:space-between}.command-menu{position:absolute;top:8%;left:4%;min-width:17%;padding:.8cqw}.system-menu{position:absolute;top:7%;right:5%;min-width:27%;padding:.8cqw}.panel{position:absolute;top:7%;left:10%;width:80%;max-height:80%;overflow:hidden}.panel p{font-size:2.1cqw;line-height:1.8;margin-top:1.8cqw}.panel .caption{margin-top:1.8cqw}.story{position:absolute;left:3%;right:3%;bottom:7%;min-height:29%;display:grid;grid-template-columns:18% 1fr;gap:2cqw;padding:1.5cqw}.story img{width:100%;aspect-ratio:1;object-fit:cover;object-position:top;border:1px solid #bc9d5f;align-self:center}.story .speaker{color:#ffe6a2;font-size:2.3cqw;margin:0 0 1cqw}.story p{font-size:2.65cqw;line-height:1.6}.story .next{position:absolute;right:1.8cqw;bottom:1cqw;color:#e9cf79;font-size:1.3cqw}.anonymous{display:grid;place-items:center;width:100%;aspect-ratio:1;background:#192b59;border:1px solid #92834f;font-size:5cqw}.ending{position:absolute;inset:0;background:#0e1744;display:grid;place-content:center;text-align:center}.ending h1{font-size:6cqw;color:#f0cf7a;font-weight:normal;letter-spacing:.2em}.ending p{font-size:2.3cqw;margin:2cqw}.ending .choices{margin:2cqw auto;text-align:left;min-width:32cqw}#readout{position:absolute;bottom:0;left:0;right:0;height:6.5%;background:#10134c;border-top:2px solid #c6a95d;display:flex;align-items:center;padding:0 2cqw;gap:2cqw;font-size:1.8cqw}#readout:empty{display:none}.hp-bar{display:inline-block;width:8cqw;height:.8cqw;background:#303653;vertical-align:middle}.hp-bar i{display:block;height:100%;background:#f3ca60}.readout-unit{margin-left:auto}#notice{position:absolute;top:2%;left:50%;transform:translateX(-50%);background:#111852e8;padding:.6cqw 1.7cqw;font-size:1.7cqw;pointer-events:none}#notice:empty{display:none}.battle-head{position:absolute;inset:0 0 auto;display:flex;justify-content:space-between;padding:2.5cqw;background:#0b124de8;border-bottom:2px solid #d0b26a}.battle-name{min-width:29%;font-size:2.6cqw}.battle-name:last-child{text-align:right}.battle-name small{display:block;font:1.7cqw monospace;margin-top:.7cqw}.battle-cue{position:absolute;bottom:7%;left:0;right:0;text-align:center;font-size:2.4cqw;color:#fff3b9;text-shadow:2px 2px #182338}.battle-help{position:absolute;bottom:2%;left:0;right:0;text-align:center;font:1.3cqw system-ui;color:#c5cee1}.unit-title{display:flex;align-items:center;gap:2cqw;margin:1cqw 0}.unit-title img{width:15cqw;height:15cqw;object-fit:cover;object-position:top}.feed{font-size:1.8cqw;line-height:1.7;padding:1cqw;border-bottom:1px solid #33396c}

.commander-info{position:absolute;right:4%;top:8%;display:flex;align-items:center;gap:1.5cqw;font-size:2.2cqw;line-height:1.5;min-width:33%;padding:1.2cqw}.commander-info img{width:10cqw;height:12cqw;object-fit:cover;object-position:top;border:1px solid #cbb372}.commander-info small{font:1.7cqw/1.6 monospace}
.command-menu{min-width:25%}.command-menu .choice{font-size:3.3cqw;min-height:6.4cqw;padding-left:3.4cqw}.commander-info{min-width:45%;font-size:3cqw}.commander-info img{width:16cqw;height:18cqw}.commander-info small{font-size:2.1cqw}.story p{font-size:3.3cqw}

/* Chapter-sized screens retain the MD viewport, including the preparation footer. */
.prep{grid-template-columns:43% 57%;grid-template-rows:8% 49% 31%;gap:1.5cqw 0}
.commander{grid-template-columns:minmax(0,34%) minmax(0,1fr);gap:1.2cqw}
.commander .name{font-size:3.1cqw;letter-spacing:.08em}.commander .stats{font-size:1.85cqw;line-height:1.6}
.prep-orders{margin:0;display:flex;flex-direction:column;justify-content:center;padding:1cqw 1.8cqw}
.prep-orders .choice{min-height:4.7cqw}.prep-orders .caption{margin-top:1.1cqw;font-size:1.7cqw;white-space:nowrap}
.story{left:7.5%;right:7.5%;bottom:25%;min-height:36%;display:block;padding:1.7cqw 2cqw 3.3cqw}
.story img{position:absolute;left:0;bottom:calc(100% + 1cqw);width:17.5cqw;height:17.5cqw;object-fit:cover;border:2px solid #c4bb98;background:#22515a}
.story .speaker{display:inline;font-size:3.5cqw;margin-right:1cqw}.story p{display:inline;font-size:3.7cqw;line-height:1.65}.story .next{font-size:1.2cqw}
.intro{position:absolute;inset:0;background:repeating-linear-gradient(0deg,#101943 0 2px,#131d49 2px 4px);display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:4cqw;gap:2.8cqw}
.intro-kicker{font:1.5cqw monospace;letter-spacing:.5em;color:#b2a980}.intro h1{font-size:5.2cqw;font-weight:normal;letter-spacing:.3em;margin:0;color:#ffe5a6}.intro-rule{height:1px;width:56%;background:#ba9b59}.intro>p{font-size:2.6cqw;line-height:1.9;margin:0}.intro-objective{font-size:2.3cqw;color:#e9c981}.intro-objective p{margin:.9cqw}.intro-key{font-size:2.6cqw;color:#fff2bf}.intro .caption{line-height:1.9}
.battle-head{top:66.964286%;bottom:0;left:0;right:0;display:grid;grid-template-columns:1fr 1fr;gap:6cqw;padding:1.8cqw 3cqw 2.6cqw;background:linear-gradient(120deg,#182638,#101b2d 50%,#182638);border-top:1px solid #c6ad78;border-bottom:0;box-shadow:inset 0 3px 0 #293d4c}
.battle-name{display:flex;align-items:center;gap:1.8cqw;min-width:0;font-size:2.5cqw}.battle-name:nth-child(2){flex-direction:row-reverse;text-align:right}
.battle-name img{width:15cqw;height:15cqw;object-fit:cover;border:2px solid #c7b481}.battle-numbers{min-width:0}.battle-numbers>div{white-space:nowrap;font-size:2.25cqw}.battle-numbers strong{display:block;color:#f4dc73;font:bold 7cqw/1.1 serif}.battle-name small{font:1.8cqw/1.5 monospace;white-space:nowrap;margin-top:.5cqw}
.battle-vs{position:absolute;left:46.5%;top:10.5cqw;font:3.4cqw serif;color:#ead7a0}.battle-cue{top:50%;bottom:auto;font-size:1.8cqw}.battle-help{font-size:1.1cqw;bottom:1%}.magic-cue{position:absolute;top:3%;left:5%;right:5%;padding:1cqw;background:#101952dd;border:1px solid #d1b66e;text-align:center;font-size:2.2cqw}

/* Separate panes reproduce the original recruiting hierarchy. */
.prep{grid-template-columns:43% 57%;grid-template-rows:8% 40% 40%;gap:1.5cqw 0}
.prep .roster{grid-row:2;grid-column:1}.prep .commander{grid-row:2;grid-column:2}
.prep .assigned{grid-row:3;grid-column:1;display:flex;flex-direction:column;justify-content:space-evenly}
.prep .prep-orders{grid-row:3;grid-column:2}.prep .focused{border-color:#fff3a3;box-shadow:inset 0 0 0 2px #7175b0,0 0 0 1px #fff3a3}
.prep .commander .stats{font-size:1.8cqw;line-height:1.65}.prep .commander p{font-size:2cqw;margin-top:.6cqw}
.troop-slots{display:grid;grid-template-columns:repeat(3,1fr);gap:1.6cqw;color:#7e85a1}.troop-slots .filled{color:#f3dc91}
.assigned .caption{font-size:2.4cqw;color:#fff2bc}.troop-data{display:flex;align-items:center;gap:1.5cqw;font:2cqw/1.6 monospace;margin-bottom:1cqw}
.troop-data img{width:8cqw;height:8cqw;object-fit:none;object-position:left top;background:#587956;border:1px solid #c9b278;image-rendering:auto}
.prep-orders .choice small{font-size:1.1cqw}.prep-hint{font-size:1.4cqw}
.story{bottom:0;min-height:30%;padding-bottom:3cqw}.story p{font-size:3.1cqw;line-height:1.6}.story .speaker{font-size:3.1cqw}.story .next{font-size:1.15cqw}
#controller{position:fixed;inset:0;pointer-events:none;z-index:10}
#controller button,#dpad{pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
#controller button{border:2px solid #e7ddaf;background:#172849c9;box-shadow:0 2px 6px #0009;text-shadow:0 1px 2px #000;display:flex;flex-direction:column;align-items:center;justify-content:center}
#controller button.pressed{background:#697baccf;transform:translateY(2px);border-color:white}
#controller button small{font:12px system-ui;margin-top:2px;color:#ebe2c7}
#dpad,.action-buttons,#controller [data-action="system"]{display:none}
.aux-controls{position:absolute;right:max(8px,env(safe-area-inset-right));top:max(8px,env(safe-area-inset-top));display:flex;gap:8px}
#controller #skip-scene{font:12px system-ui;padding:6px 10px;border-radius:8px}
#controller [hidden]{display:none!important}
@media (pointer:coarse), (max-width:600px){
 #game{padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);align-content:start}
 #screen{width:min(100vw,calc((100dvh - 185px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 10 / 7));height:auto;aspect-ratio:10/7;margin-top:3vh}
 #dpad{display:grid;position:absolute;left:max(16px,env(safe-area-inset-left));bottom:calc(24px + env(safe-area-inset-bottom));width:140px;height:140px;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);border-radius:50%;border:2px solid #e7ddaf;background:#152743b8;box-shadow:0 2px 8px #000b;font:20px system-ui;color:white;text-shadow:0 1px 3px black}
 #dpad span{display:grid;place-items:center}.up{grid-area:1/2}.left{grid-area:2/1}.neutral{grid-area:2/2}.down{grid-area:3/2}.right{grid-area:2/3}
 #dpad[data-direction="up"] .up,#dpad[data-direction="left"] .left,#dpad[data-direction="down"] .down,#dpad[data-direction="right"] .right{background:#97add199;border-radius:12px}
 .action-buttons{display:flex;position:absolute;right:max(14px,env(safe-area-inset-right));bottom:calc(55px + env(safe-area-inset-bottom));gap:8px}
 .action-buttons button{width:52px;height:62px;border-radius:50%;font:25px system-ui}
 #controller [data-action="system"]{display:flex;font:12px system-ui;border-radius:16px;padding:6px 12px}
 .aux-controls{top:auto;bottom:calc(150px + env(safe-area-inset-bottom));right:max(16px,env(safe-area-inset-right))}
}
@media (pointer:coarse) and (orientation:landscape), (max-width:600px) and (orientation:landscape){
 #game{align-content:center}
 #screen{width:min(calc(100vw - 310px - env(safe-area-inset-left) - env(safe-area-inset-right)),calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 10 / 7));height:auto;margin:0}
 #dpad{width:126px;height:126px;left:max(8px,env(safe-area-inset-left));bottom:calc(28px + env(safe-area-inset-bottom))}
 .action-buttons{right:max(8px,env(safe-area-inset-right));bottom:calc(45px + env(safe-area-inset-bottom));gap:5px;flex-wrap:nowrap}
 .action-buttons button{width:43px;height:54px;font-size:22px}
 .aux-controls{bottom:auto;top:max(12px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));flex-direction:column;align-items:end}
}

/* The full game is an input surface: rapid taps and two thumbs must not zoom or select. */
#game{touch-action:none;overscroll-behavior:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}

/* HD edition: shared indigo enamel, inset metal highlights, restrained decoration. */
.box{background:linear-gradient(135deg,#171e55,#0d1544 65%);border-color:#b9a16c;box-shadow:inset 0 0 0 1px #f0d9a3,inset 0 0 0 3px #35436d,0 2px 8px #0a132b66}
.prep{background:radial-gradient(ellipse at 70% 30%,#344367,#171f41 70%)}
.prep .commander img,.story img,.battle-name img{image-rendering:auto;background:#263c50;box-shadow:0 0 0 1px #26304a}
.troop-data img{object-fit:contain;image-rendering:auto}
.ending{background:radial-gradient(ellipse at 50% 30%,#334760,#111a3d 70%)}
.ending:before,.ending:after{content:'';position:absolute;left:10%;right:10%;height:1px;background:linear-gradient(90deg,transparent,#d1bb7d,transparent);top:20%}.ending:after{top:auto;bottom:20%}
.ending h1{text-shadow:0 2px 0 #50472f}
/* Keep tactical figures readable at the actual phone display size. */
.prep .commander .stats{font-size:clamp(9px,1.8cqw,18px)}
.prep .commander p,.troop-data{font-size:clamp(9px,2cqw,20px)}
.battle-numbers>div{font-size:clamp(10px,2.25cqw,24px)}
.battle-name small{font-size:clamp(9px,1.8cqw,19px)}
.commander-info small{font-size:clamp(9px,2.1cqw,22px)}
#readout{font-size:clamp(8px,1.8cqw,19px)}
.story .next,.prep-hint,.intro .caption{font-size:clamp(8px,1.4cqw,15px)}
.prep-orders .choice small{font-size:clamp(7px,1.1cqw,12px)}
/* Read-only status details share the same character artwork as other game windows. */
.unit-profile{display:flex;align-items:center;gap:3cqw;min-width:0}
.unit-profile>img{flex:none;width:22cqw;height:22cqw;object-fit:cover;object-position:center;border:1px solid #cbb372;background:#263c50;image-rendering:auto}
.unit-profile>div{min-width:0}.panel .unit-profile h2{font-size:3.4cqw;line-height:1.3}.panel .unit-profile p{font-size:2.6cqw;line-height:1.7;margin-top:1.4cqw}
.matchup-preview{position:absolute;top:3%;left:4%;right:4%;display:grid;grid-template-columns:1fr 1fr;gap:3cqw;font:2.1cqw/1.6 monospace;padding:1.2cqw 2cqw;pointer-events:none}
.matchup-preview>div:last-child{text-align:right}.matchup-preview strong{color:#ffe6a2;font:2.5cqw/1.5 "Songti SC","SimSun",serif}
#readout{height:auto;min-height:6.5%;flex-wrap:wrap;row-gap:.3cqw;padding:.6cqw 2cqw}

/* Pixel troop icons use their own sampler; portrait and text layers retain smooth sampling. */
.troop-data img{image-rendering:auto}

/* Painted close combat: keep the scene large and the two stat panels compact. */
.battle-name{gap:1.6cqw;border-top:2px solid var(--battle-color);padding-top:1cqw;--battle-color:#8abce0}
.battle-name[data-side="enemy"]{--battle-color:#d28a77}.battle-name[data-side="npc"]{--battle-color:#8fc9a0}
.battle-name img{width:11.5cqw;height:11.5cqw;flex:none;border:1px solid #9c8c6b;box-shadow:0 2px 6px #0005}
.battle-name img.battle-unit-icon{object-fit:contain;background:radial-gradient(ellipse at 50% 60%,#465153,#1d2a36 75%);padding:.2cqw}
.battle-numbers{flex:1}.battle-numbers>div:first-child{font-size:clamp(10px,2.15cqw,26px);color:#f3e7ca}
.battle-vital{display:flex;align-items:center;gap:1cqw;margin:.2cqw 0}.battle-name:nth-child(2) .battle-vital{justify-content:flex-end}
.battle-vital>span:first-child{font:1.1cqw system-ui;color:#b5bdc5;letter-spacing:.12em}
.battle-numbers .battle-vital strong{font:5cqw/1.05 Georgia,serif;color:#f4dc9a}
.battle-health{height:.6cqw;min-height:2px;flex:1;max-width:9cqw;background:#050d1699;border:1px solid #6c6b5b}
.battle-health i{display:block;height:100%;background:var(--battle-color);transition:width 80ms linear}
.battle-name small{font-size:clamp(8px,1.45cqw,18px);line-height:1.5;color:#d1d7dc;white-space:normal}
.battle-vs{left:50%;top:50%;transform:translate(-50%,-50%);font:2cqw Georgia,serif;color:#ac9b77;letter-spacing:.15em}
.battle-cue{top:61%;font-size:1.5cqw;letter-spacing:.2em;text-shadow:0 1px 4px #000}
.battle-help{font-size:clamp(7px,1cqw,13px);bottom:1%;color:#9ba9b8}
