/* Battle controls fit inside the visible viewport, including short windows. */
body:not(.hq-home)>.app{height:100dvh;overflow:hidden;display:flex;flex-direction:column;padding:0}
body:not(.hq-home) .layout{flex:1;min-height:0;padding:0;display:flex;justify-content:center;align-items:stretch}
body:not(.hq-home) .game-shell{height:100%;max-height:100%;width:min(100vw,calc((100dvh - 48px)*.69));max-width:100vw;aspect-ratio:auto;flex:none}
body:not(.hq-home)>.app>.desktop-toolbar{flex:none;min-height:40px;padding:2px 8px;font-size:12px;gap:8px;display:flex;align-items:center;justify-content:center}
body:not(.hq-home)>.app>.desktop-toolbar :is(button,select,summary){min-height:44px;padding:6px 8px;font:inherit}
body:not(.hq-home) :is(.left-rail,.right-rail,.topbar,.footer){display:none}
.game-shell .combat-dock{bottom:max(8px,env(safe-area-inset-bottom));gap:5px}
.game-shell .weapon-slot-name{font-size:11px;line-height:1.15}
.game-shell .weapon-slot-state,.game-shell .combat-dock[data-ammo-totals="true"] .weapon-slot-state{font-size:10px;line-height:1.15}
.game-shell .weapon-slot-total{font-size:11px}
.game-shell .weapon-slot{min-height:49px}
.game-shell .ability-button{height:46px;min-height:44px}
.game-shell .ability-name{font-size:11px}
.game-shell .ability-state{font-size:10px}
.game-shell .hud-top{top:10px;left:10px;right:10px}
.game-shell .hud-stats{top:65px;font-size:13px;background:#10252cde;border-radius:5px;padding:4px 6px;left:10px;right:10px}
.game-shell #objective-hud{font-size:12px;line-height:1.3;background:#10252cf0;color:#edffcf}
.game-shell .mission-hud>span{font-size:11px;letter-spacing:0}
.game-shell .battle-economy{font-size:11px;background:#10252ccc;border-radius:4px}
.game-shell:has(.co-road-threat) .combat-combo{visibility:hidden}
#checkpoint-plans{margin:10px 0;border:1px solid #8ca883;border-radius:8px;padding:8px;display:grid;gap:6px;text-align:left;background:#122d35}
#checkpoint-plans[hidden]{display:none}
#checkpoint-plans legend{font-size:14px;color:#e8ffca;font-weight:700}
#checkpoint-plans label{display:flex;align-items:center;gap:8px;padding:8px;min-height:48px;border:1px solid #57727a;border-radius:5px;cursor:pointer}
#checkpoint-plans label:has(input:checked){border-color:#dded9a;background:#304a3e}
#checkpoint-plans strong,#checkpoint-plans small{display:block;font-size:13px;line-height:1.35}
#checkpoint-plans small{color:#d3e0dd;font-size:12px}
@media(max-height:600px){.game-shell .combat-dock{gap:3px;bottom:4px}.game-shell .leader-skill{min-height:32px}.game-shell .hud-stats{top:52px}.game-shell .hud-top{top:5px}.game-shell .ability-button{height:44px}.game-shell .weapon-slot-total{display:none}.game-shell .combat-dock[data-ammo-totals="true"] .weapon-slot{grid-template-rows:13px 12px;min-height:44px}}
.game-shell #leader-skill[data-command-support=true]{min-height:44px;font-size:11px}
.game-shell #leader-skill[data-command-support=true]{width:min(280px,100%);justify-self:center;margin:0 auto;height:44px;min-height:44px;max-height:44px;display:grid;grid-template-rows:24px 12px;align-content:center;justify-items:center;gap:0;padding:2px 7px 4px;line-height:14px}
.leader-skill-name{display:flex;align-items:center;justify-content:center;width:100%;min-width:0;height:24px;font-size:10.5px;line-height:12px;white-space:normal;text-align:center}
.leader-skill-state{display:block;width:100%;min-width:0;height:12px;font-size:10px;line-height:12px;white-space:nowrap;text-align:center}
/* Keep the requested action readable instead of cutting its final word. */
.game-shell #objective-hud{white-space:normal;align-items:flex-start}
.game-shell #objective-text{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25}
.game-shell #checkpoint-rescue-count{white-space:nowrap}
@media(min-width:701px){
 body[data-desktop-size="compact"]:not(.hq-home) .game-shell{width:min(405px,100vw,calc((100dvh - 56px)*.69));max-height:720px;align-self:center}
}
@media(pointer:coarse) and (max-width:700px){
 body:not(.hq-home)>.app>.desktop-toolbar{display:none}
 body:not(.hq-home) .game-shell{width:min(100vw,calc(100dvh*.69))}
}

/* The same compact campaign language carries briefings into real results. */
#result-mission-position{margin:12px 0 5px;font-size:11px;letter-spacing:.04em;color:#b8d8d1}
#result-next-mission{padding:12px 14px;margin:7px 0 12px;border:1px solid #71978c;border-left:3px solid #cbdc8b;border-radius:8px;background:#17343d;color:#e3edcf;font-size:13px;line-height:1.5;text-align:left}
#objective-hud[data-cue=convoy]{border-left:3px solid #b8d7a8}
@media(max-height:600px){#result-next-mission{padding:8px 10px;font-size:12px;margin:5px 0 8px}}

/* First victory: an optional, real route choice and one clear primary action. */
#result-continuation{margin:0 0 10px;padding:10px;border:1px solid #71978c;border-radius:8px;background:#17343d;text-align:left}
#result-continuation[hidden]{display:none}
#result-next-title{margin:0 0 5px;color:#ecf4cb;font-size:16px;line-height:1.25}
#result-next-goal{margin:0 0 6px;font-size:13px;line-height:1.4;color:#e0ece9}
#result-continuation #result-next-mission{margin:0 0 7px;padding:0;border:0;background:none;font-size:12px;line-height:1.35;color:#b9d8ce}
#result-continuation #evacuation-support-status{margin:0;font-size:11px;line-height:1.3;color:#cedcd4}
#result-continuation #evacuation-support button{min-height:44px;font-size:12px;line-height:1.25;padding:7px}
#result-card.first-continuation>.result-actions{margin:0 0 12px}
#result-secondary-actions{display:grid;gap:6px;margin:0 0 8px}
#result-secondary-actions:empty{display:none}
#result-secondary-actions>button{width:100%;min-height:44px;white-space:normal;padding:9px;font-size:13px}
@media(max-height:600px){#result-card.first-continuation{padding:12px}#result-card.first-continuation h2{font-size:22px;margin-bottom:8px}#result-continuation{padding:8px;margin-bottom:7px}#result-next-title{font-size:15px}#result-next-goal{font-size:12px}#result-continuation #result-next-mission{font-size:11px}}

#result-save-error{padding:10px;margin:0 0 10px;border:1px solid #e8b581;border-radius:8px;background:#44372a;color:#ffe1b3;text-align:left;font-size:13px}
#result-save-error[hidden]{display:none}
#result-save-error p{margin:0 0 8px}
#result-save-retry{min-height:44px;width:100%;white-space:normal}
/* Results use the whole device viewport, including landscape phones. */
#overlay:has(#result-card:not([hidden])){position:fixed;inset:0;z-index:100}
#result-card.first-continuation>.result-actions{position:sticky;bottom:0;z-index:2;padding:6px 0;background:#142a32}

/* A real preview of the next setting; no extra download until the result opens. */
#result-next-image{float:right;width:94px;height:66px;object-fit:cover;margin:0 0 6px 10px;border-radius:6px;border:1px solid #6a8b8b}
#result-next-support{clear:both}
#result-next-kit{margin:6px 0;padding:5px 7px;background:#254436;border-radius:5px;color:#e5f4c8;font-size:12px;line-height:1.35}
#result-next-kit[hidden]{display:none}
@media(max-width:360px),(max-height:450px){#result-next-image{width:76px;height:54px}#result-next-title{font-size:14px}}

/* Optional preparation stays below the primary sortie action. */
.campaign-plans{margin:10px 0;max-width:100%;font-size:13px}.campaign-plans summary{min-height:44px;padding:12px;cursor:pointer}.campaign-plans>p{padding:0 12px;line-height:1.4}.campaign-plans>button{display:flex;flex-direction:column;gap:5px;align-items:flex-start;text-align:start;white-space:normal;min-height:64px;width:100%;padding:12px;margin:5px 0}.campaign-plans button span{font-size:12px;font-weight:400;line-height:1.4}.first-entry .campaign-plans{display:none}

.campaign-selection>.campaign-plans{grid-column:1/-1;min-width:0;width:100%;box-sizing:border-box;overflow-wrap:anywhere}.campaign-plans>button>*{min-width:0;max-width:100%;overflow-wrap:anywhere}
#result-next-experience{font-size:12px;font-weight:750;line-height:1.5;color:#94e2cf;margin:8px 0;overflow-wrap:anywhere;max-width:100%}

/* Text must fit its own hit target in all six languages. */
.game-shell .ability-controls{grid-template-columns:repeat(3,minmax(0,1fr))}
.game-shell .ability-button{gap:4px;padding:5px 5px 9px;height:58px}
.game-shell .ability-button>svg{width:20px;height:20px}
.game-shell .ability-copy{flex:1;min-width:0;gap:3px}
.game-shell .ability-name,.game-shell .ability-state{white-space:normal;overflow-wrap:anywhere;line-height:1.1}
.game-shell .ability-name{font-size:10px}
.game-shell .ability-state{font-size:9px}
.game-shell .weapon-slot{min-width:0}
.game-shell .weapon-slot-name,.game-shell .weapon-slot-state{min-width:0;white-space:normal;overflow-wrap:anywhere}
.game-shell .weapon-slot{grid-template-rows:minmax(14px,auto) minmax(12px,auto)}
@media(max-width:700px){
 body:not(.hq-home)>.app>.desktop-toolbar{display:none}
 body:not(.hq-home) .game-shell{width:100%;max-width:540px}
}
/* Short landscape windows use a side dock instead of a 220 px portrait strip. */
@media(min-width:560px) and (max-height:500px){
 body:not(.hq-home)>.app>.desktop-toolbar{display:none}
 body:not(.hq-home) .game-shell{width:min(100vw,1000px);max-width:100vw;border:0;border-radius:0}
 body:not(.hq-home) #game{width:calc(100% - 280px);height:100%}
 .game-shell .combat-dock{left:auto;right:max(8px,env(safe-area-inset-right));width:264px;bottom:max(8px,env(safe-area-inset-bottom))}
 .game-shell .hud-top,.game-shell .hud-stats,.game-shell #objective-hud,.game-shell #boss-hud{right:290px}
 .game-shell .vignette{right:280px;bottom:0}
 .game-shell .ability-button{height:62px}
 .game-shell #leader-skill{min-height:44px}
 .game-shell .movement-controls{gap:4px}
 .game-shell .movement-controls button{font-size:10px;gap:3px}
}

.game-shell .combat-dock[data-ammo-totals="true"] .weapon-slot{grid-template-rows:minmax(14px,auto) minmax(12px,auto) minmax(12px,auto)}
.game-shell .weapon-slot>svg{align-self:center}
@media(min-width:560px) and (max-height:500px){
 .game-shell .weapon-controls{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .game-shell .combat-dock[data-ammo-totals="true"] .weapon-slot{grid-template-rows:minmax(14px,auto) minmax(12px,auto)}
 .game-shell .ability-button{height:78px;flex-direction:column;gap:3px}
 .game-shell .ability-button>svg{width:16px;height:16px}
 .game-shell .ability-copy{flex:0 1 auto;width:100%;align-items:center;text-align:center}
}
/* Notices sit above the measured dock, including a two-row weapon rack. */
.game-shell.abilities-visible #notices{bottom:calc(var(--combat-hud-height) + 8px)}
@media(min-width:560px) and (max-height:500px){
 .game-shell.abilities-visible #notices{left:10px;right:290px;bottom:8px}
}

/* Restore the reference portrait controls: readable labels and two columns. */
@media(max-width:700px) and (min-height:501px){
 .game-shell .weapon-controls{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .game-shell .weapon-slot-name{font-size:11px;line-height:1.15}
 .game-shell .weapon-slot-total{font-size:11px;line-height:1.15}
}

/* One shared grid: weapons/support align with ice/grenade/dodge below. */
.game-shell .combat-dock{--combat-control-height:64px;--combat-control-gap:6px;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--combat-control-gap)}
.game-shell .combat-dock>.weapon-controls{grid-column:1/span 2;grid-row:1;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:var(--combat-control-gap)}
.game-shell .combat-dock>#leader-skill{grid-column:3;grid-row:1;align-self:start;justify-self:stretch;letter-spacing:0;white-space:normal;overflow-wrap:anywhere;font-size:10px;line-height:12px}
.game-shell .combat-dock>:is(.dock-lower,.movement-controls,#first-action-hint){grid-column:1/-1}
.game-shell .combat-dock .ability-controls{grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--combat-control-gap)}
.game-shell .combat-dock :is(.weapon-slot,.ability-button,#leader-skill){box-sizing:border-box;width:100%;min-width:0;height:var(--combat-control-height);min-height:var(--combat-control-height);max-height:var(--combat-control-height);margin:0;border-radius:8px}
.game-shell .combat-dock>.weapon-controls .weapon-slot{padding:5px 4px;column-gap:3px;grid-template-columns:16px minmax(0,1fr)}
.game-shell .combat-dock>.weapon-controls .weapon-slot>svg{width:16px;height:16px}
.game-shell .combat-dock .weapon-slot-name,.game-shell .combat-dock .weapon-slot-total,.game-shell .combat-dock .ability-name{font-size:10px;line-height:1.1}
.game-shell .combat-dock>.weapon-controls .weapon-slot-state{font-size:8px;line-height:1.1}
.game-shell .combat-dock>#leader-skill{padding:5px 4px;display:grid;grid-template-rows:auto auto;align-content:center;gap:2px}
.game-shell .combat-dock .leader-skill-name{display:block;min-width:0;height:auto;font-size:10px;line-height:12px;white-space:normal;overflow-wrap:anywhere}
.game-shell .combat-dock .leader-skill-state{height:auto;min-height:12px;font-size:9px;line-height:12px;white-space:normal;overflow-wrap:anywhere}
.game-shell .combat-dock:has(>#leader-skill[hidden])>.weapon-controls{grid-column:1/-1;grid-template-columns:repeat(3,minmax(0,1fr))!important}

/* Cinematics have no control strip. Fill the frame before the resize observer
   runs, and restore the measured combat area when controls return. */
.game-shell:has(>#combat-dock[hidden])>#game,
body:has(#checkpoint-brief[open][data-cinematic]) .game-shell>#game{width:100%;height:100%}
.game-shell:has(>#combat-dock[hidden])>.vignette,
body:has(#checkpoint-brief[open][data-cinematic]) .game-shell>.vignette{right:0;bottom:0}

/* Readable damage without covering the entire battlefield. */
#hero-damage-feedback{font-size:12px;line-height:1.35;border-width:2px;background:#291b20f5;max-width:min(330px,calc(100vw - 44px))}
#result-desc{font-size:14px;line-height:1.45;font-weight:700;overflow-wrap:anywhere}
#result-card[inert]{pointer-events:none}

/* Shared combat pictograms: outline art, fixed icon column, readable cooldown. */
.game-shell .combat-dock>.weapon-controls .weapon-slot{grid-template-columns:20px minmax(0,1fr);column-gap:5px}
.game-shell .combat-dock>.weapon-controls .weapon-slot>svg,.game-shell .combat-dock .ability-button>svg,.game-shell .combat-dock .leader-skill-icon svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.game-shell .combat-dock>#leader-skill:has(.leader-skill-icon){grid-template-columns:20px minmax(0,1fr);grid-template-rows:minmax(14px,auto) minmax(12px,auto);column-gap:5px;row-gap:0;align-content:start;text-align:left;justify-items:stretch;align-items:center}
.game-shell .combat-dock .leader-skill-icon{position:absolute;left:5px;top:50%;transform:translateY(-50%);width:20px;height:20px;display:flex;color:#edcf8d}
.game-shell .combat-dock .leader-skill-name{grid-column:2;grid-row:1;text-align:left;text-transform:uppercase;font-weight:800;line-height:11px}
.game-shell .combat-dock .leader-skill-state{grid-column:2;grid-row:2;text-align:left;line-height:11px}
.game-shell .combat-dock>#leader-skill:disabled{opacity:1;color:#d8dfd4;background:#233a40;border-color:#78908b}
.game-shell .combat-dock>#leader-skill:disabled .leader-skill-state{color:#c7d6d1}

.game-shell .combat-dock .weapon-slot-name,.game-shell .combat-dock>#leader-skill:has(.leader-skill-icon) .leader-skill-name{align-self:start}
