: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}

#screen { touch-action:none }
.choice[data-choice], #field-tools button { min-height:44px;min-width:44px;cursor:pointer }
.choice.disabled { cursor:default }
.intro,.ending,.story,.prep { pointer-events:auto }
.commander-info,.matchup-preview,#readout,#notice { pointer-events:none }
.system-menu { max-height:86%;overflow-y:auto;overscroll-behavior:contain }
#field-tools { position:absolute;right:1%;bottom:8%;display:flex;gap:4px }
#field-tools[hidden] { display:none }
#field-tools button { border:1px solid #c5ac78;background:#172947ee;color:#fff2ce;border-radius:4px;font:13px system-ui;padding:0 9px }
.projection { grid-column:1/-1;border-top:1px solid #b7aa76;display:grid;grid-template-columns:1fr 1fr;gap:1em;text-align:left }
.projection>div:last-child { text-align:right }
body[data-pad="false"] #dpad,body[data-pad="false"] .action-buttons,body[data-pad="false"] #controller [data-action="system"] {display:none}
@media (max-width:600px) and (orientation:portrait) {
 #game { align-content:start;background:#111b29 }
 #screen { margin-top:0;width:100vw;height:100dvh;aspect-ratio:auto;overflow:hidden }
 #board { position:absolute;top:6vh;width:100%;height:70vw }
 #overlay,#menu { top:6vh;height:70vw;bottom:auto }
 #readout { position:absolute;top:calc(6vh + 70vw);bottom:auto;min-height:44px;font:13px/1.5 system-ui }
 #field-tools { right:8px;top:6px;bottom:auto }
 #menu .command-menu,#menu .system-menu,#menu .panel,#menu .matchup-preview { top:calc(70vw + 60px)!important;bottom:auto!important;left:3%!important;right:3%;width:auto;max-height:42vh;overflow:auto }
 #menu .commander-info {top:0!important;bottom:auto!important;pointer-events:none;opacity:.94}
 #menu .system-menu {display:grid;grid-template-columns:1fr 1fr}
 .choice[data-choice] {font-size:14px;min-height:44px}
 .prep {min-height:calc(100dvh - 6vh);grid-template-rows:42px 24% auto;align-content:start;gap:10px}
 .prep-orders {justify-content:start}
 .prep .roster .choice,.prep .prep-orders .choice {min-height:44px}
 .prep .prep-hint {display:none}
 .prep .troop-data,.prep .commander .stats {font-size:12px}
 .intro,.ending {min-height:80vh}
 .intro>p,.intro-objective,.intro-key,.story p,.matchup-preview {font-size:14px}
 .story .next {font-size:10px}
 .projection {font-size:12px}
}

#mobile-info {display:none}
@media (max-width:600px) and (orientation:portrait){
 #screen {--map-height:70vw;background:#111a24}
 #screen:is([data-scene="player"],[data-scene="move"],[data-scene="command"],[data-scene="spell"],[data-scene="attack"],[data-scene="opposition"]) {--map-height:min(58dvh,152vw)}
 #board,#overlay,#menu {top:54px;height:var(--map-height)}
 #readout {top:calc(54px + var(--map-height));min-height:36px;background:#222d38}
 #menu .command-menu,#menu .system-menu,#menu .panel,#menu .matchup-preview {top:calc(var(--map-height) + 42px)!important;max-height:calc(100dvh - var(--map-height) - 106px)}
 .matchup-preview {font:12px/1.35 system-ui;gap:7px}
 .matchup-preview strong {font:600 13px system-ui}
 .projection {gap:8px;padding-top:4px}
 #mobile-info:not(:empty){display:block;position:absolute;left:4%;right:4%;top:calc(103px + var(--map-height));font:14px/1.55 system-ui;color:#eadfc6}
 #mobile-info h2 {font-size:21px;margin:5px 0;font-weight:600}
 #mobile-info h2 small {font-size:12px;margin-left:10px;color:#bac9cc;font-weight:400}
 #mobile-info p {margin:4px 0}
 #mobile-info .terrain-line {color:#d5bc82}
 #mobile-info .field-hint {color:#a7b7bf;margin-top:10px}
 #field-tools {left:4%;right:4%;top:4px;justify-content:flex-end}
}

@media (max-width:600px) and (orientation:portrait) {
 body[data-pad="true"] #screen { --map-height:70vw;height:calc(100dvh - 200px); }
 body[data-pad="true"] #menu .system-menu {max-height:24vh}
}

@media (max-width:600px) and (orientation:portrait) {
 body[data-pad="true"] #screen {width:100vw;height:70vw;aspect-ratio:10/7;margin-top:3vh;overflow:visible}
 body[data-pad="true"] #board, body[data-pad="true"] #overlay,body[data-pad="true"] #menu {top:0;height:100%}
 body[data-pad="true"] #readout {top:100%}
 body[data-pad="true"] #mobile-info {display:none}
 body[data-pad="true"] .intro,body[data-pad="true"] .ending,body[data-pad="true"] .prep {min-height:100%}
 body[data-pad="true"] #field-tools {top:auto;bottom:-90px}
 body[data-pad="true"] #menu .system-menu {top:3%!important;max-height:92%}
}

/* The opening uses the original 320 × 224 composition on every viewport. */
#screen[data-scene="intro"] #board {image-rendering:auto;background:#000}
.md-opening {position:absolute;inset:0;pointer-events:auto;color:#fff9df;font:4.5cqw/1.08 "Songti SC",SimSun,serif;text-shadow:1px 1px #191022}
.md-title-menu,.md-name-head,.md-letters {background:#07094c;border:.55cqw ridge #b99a55;box-shadow:0 0 0 .32cqw #100c22}
.md-title-menu {position:absolute;top:61%;left:34%;width:32%;padding:.9cqw 1cqw}
.md-opening button {border:0;background:transparent;color:inherit;text-shadow:inherit;cursor:pointer;padding:0;font:inherit}
.md-title-menu button {display:block;width:100%;text-align:left;padding:.1em 0 .1em 1.05em;position:relative}
.md-title-menu .selected:before {content:'▸';position:absolute;left:0;color:#fff4ce}
.md-name {position:absolute;inset:0;background:repeating-linear-gradient(0deg,#60482e 0 1cqw,#a38353 1cqw 1.4cqw,#372e25 1.4cqw 1.6cqw);padding:2cqw;display:grid;grid-template-rows:26% 1fr;gap:2cqw}
.md-name-head {display:flex;align-items:center;justify-content:space-around}.md-name-head strong {font-weight:normal;min-width:5em;text-align:center;border:.4cqw ridge #c7a25c;padding:.3em}
.md-letters {display:grid;grid-template-columns:repeat(15,1fr);grid-template-rows:repeat(7,1fr);padding:2cqw;align-items:stretch}
.md-letters button.selected {color:#fff1a4;background:#323a79;outline:1px solid #b79b5c}
@media (max-width:600px) and (orientation:portrait) {
 #screen[data-scene="intro"] #board,#screen[data-scene="intro"] #overlay {top:50%;transform:translateY(-50%);height:70vw}
}
.prep-hint {display:flex;justify-content:flex-end;gap:1cqw;pointer-events:none}
.prep-hint button {pointer-events:auto;border:1px solid #b69e66;background:#111644;color:#fff2cf;cursor:pointer}
#field-tools button[hidden] {display:none}
.prep-orders {min-height:0;overflow-y:auto;justify-content:safe center}
.md-question {padding:.5em;border-bottom:1px solid #9e8957}
@media (max-width:600px) and (orientation:portrait) {
 .prep .prep-hint {display:flex;top:0;bottom:auto;left:auto;right:2%;height:32px;align-items:center}
 .prep .chapter .caption {display:none}
}
.md-records {position:absolute;top:10%;left:24%;width:52%;padding:1.2cqw 2cqw;background:#08094b;border:.5cqw ridge #c19e56}
.md-records button {display:block;font-size:.9em;padding:.3em 0}
.md-formation {position:absolute;inset:0;pointer-events:auto;background:repeating-linear-gradient(0deg,#6a512e 0 1cqw,#9d8053 1cqw 1.3cqw,#3b3024 1.3cqw 1.5cqw)}
.army-map {position:absolute;inset:5% 3% 4% 32%;border:.7cqw ridge #be9d62;background:#232329;display:grid;place-items:center}
.army-map>div {position:relative;width:58%;aspect-ratio:30/22;background:url('./assets/battlefield/terrain.webp') center/100% 100%}
.army-mark {position:absolute;width:5%;aspect-ratio:1;background:#d14935;border:1px solid #4a2b1e;transform:translate(-50%,-50%)}
.army-mark.player {width:9%;background:#172b75;color:#fff69a;font:bold 2.6cqw/1 monospace;text-align:center}.army-mark.npc {background:#72ac67}
.formation-choices {position:absolute;top:7%;left:4%;padding:.8cqw;min-width:36%;font-size:3cqw}
.formation-choices .choice {min-height:6cqw}
.scenario-number {position:absolute;bottom:6%;left:10%;text-align:center;font-size:3cqw}
.md-formation>button {position:absolute;right:5%;bottom:6%;background:#101340;border:1px solid #c1a16a;padding:.45em;cursor:pointer}
@media (min-width:601px),(orientation:landscape) {
 .system-menu[aria-label="system"],.system-menu[aria-label="save-query"],.system-menu[aria-label="records"],.system-menu[aria-label="settings"] {left:50%;right:auto;top:14%;transform:translateX(-50%);min-width:32%;background:#08094b;border:.45cqw ridge #bfa368}
 .system-menu[aria-label="system"] .choice,.system-menu[aria-label="settings"] .choice {min-height:6.9cqw;font-size:4cqw}
}
@media (min-width:601px),(orientation:landscape) {
 .prep {padding:1.7cqw 2.5cqw;grid-template-columns:44% 56%;grid-template-rows:50% 50%;gap:0;background-color:#785331;background-image:repeating-linear-gradient(0deg,transparent 0 1.1cqw,#30271e 1.1cqw 1.4cqw,#caa36b 1.4cqw 1.65cqw),repeating-linear-gradient(90deg,transparent 0 4cqw,#473328 4cqw 4.4cqw)}
 .prep .chapter {display:none}
 .prep .box {border:.45cqw ridge #c6a564;background:#08094a;box-shadow:inset 0 0 0 1px #302a61}
 .prep .roster,.prep .commander {grid-row:1}.prep .assigned,.prep .prep-orders {grid-row:2}
 .prep .commander {grid-template-columns:40% minmax(0,1fr);gap:1.7cqw;padding:1.5cqw}
 .prep .commander .name,.prep .roster .choice {font-size:3.7cqw}
 .prep .commander p {font-size:2.5cqw}.prep .commander .stats {font-size:2.15cqw}
 .prep .prep-orders .choice {min-height:6cqw;font-size:3.7cqw}.prep .prep-orders .choice small {font-size:2cqw}
 .prep .assigned {font-size:3cqw}.prep .assigned .caption {font-size:2.8cqw}
 .prep-hint {left:2.8%;right:auto;bottom:2%;font-size:1.7cqw;transform:translateY(25%)}
}
#screen:not([data-scene]) {background:#000}
