/* Commander instruments sit in the scene; only their controls intercept input. */
:root{--run-hud-height:148px;--commander-health:#86ccf4;--commander-track:#86ccf42b;--commander-badge-fill:linear-gradient(135deg,#b9e5ff,#7fc5ee 48%,#5aa4d4);--commander-badge-ink:#0a2940;--commander-badge-highlight:#d8f2ff}
.run-hud{height:calc(var(--run-hud-height) + var(--safe-bottom));background:none;border:0;box-shadow:none;backdrop-filter:none;overflow:visible;pointer-events:none;isolation:isolate}
.run-hud-inner{height:var(--run-hud-height);max-width:1040px;pointer-events:none}
.run-hud button{pointer-events:auto;touch-action:manipulation}
.run-player{--commander-portrait-size:84px;position:absolute;left:50%;bottom:8px;transform:translateX(-50%);width:104px;height:112px;min-width:0;max-width:none;min-height:0;display:flex;flex-direction:column;justify-content:flex-start;align-items:center;gap:0;margin:0!important;padding:0;border:0;border-radius:0;background:none;cursor:pointer;isolation:isolate;filter:drop-shadow(0 4px 10px #0009)}
.run-player:focus-visible{outline:1px solid #e8f7f3;outline-offset:5px}
.run-player:active{transform:translateX(-50%)}
.run-player-portrait{position:relative;display:block;width:84px;height:84px;flex:0 0 84px;border:0;border-radius:50%;overflow:visible;box-shadow:none}
.run-player-portrait img{position:absolute;inset:9px;width:calc(100% - 18px);height:calc(100% - 18px);border-radius:50%;object-fit:cover;border:1px solid #dce6d66b;box-shadow:0 0 0 5px #07121b85}
.run-health-ring{position:absolute;inset:0;width:100%;height:100%;fill:none;pointer-events:none;overflow:visible}
.run-health-ring circle{stroke-width:4;fill:none;stroke-linecap:butt}
.run-health-orbit{stroke:var(--commander-track)}
.run-health-value{stroke:var(--commander-health);transition:stroke-dasharray .18s ease}
.run-health-repair{stroke:#d4f4ff;stroke-linecap:butt;filter:drop-shadow(0 0 3px #85d4f7);transition:none}
.run-player-info{position:absolute;left:50%;top:calc(var(--commander-portrait-size) - 22px);transform:translateX(-50%);display:block;width:auto;min-width:0;margin:0;gap:0;text-align:center}
.run-health{display:block}
.commander-health-badge{position:relative;display:grid;place-items:center;width:36px;height:34px;padding:0 0 5px;border:0;border-radius:0;clip-path:polygon(0 0,100% 0,100% 65%,50% 100%,0 65%);background:var(--commander-badge-fill);color:var(--commander-badge-ink);font:600 20px/1 var(--font-ui,sans-serif);font-variant-numeric:tabular-nums;text-shadow:0 1px 0 #d5efff80;box-shadow:inset 0 1px 0 var(--commander-badge-highlight)}
.run-health-number{width:40px;height:36px;gap:0;font-family:var(--font-ui,sans-serif);font-size:20px}
.run-health-number b{font:600 22px/1 var(--font-ui,sans-serif);letter-spacing:.02em}
.run-player.is-targetable{background:none;box-shadow:none;filter:drop-shadow(0 0 10px #a1e7d966)}
.run-player.is-targetable .run-player-portrait:after{content:"";position:absolute;inset:-4px;border:1px solid #a1e7d9;border-radius:50%}
.run-player[data-drop-target="true"]{outline:0!important;box-shadow:none;filter:drop-shadow(0 0 14px #f2e3b5)}
.run-player .battle-target-dot{bottom:2px;left:calc(50% - 4px)}
.run-favor{left:15px;top:auto;bottom:77px;gap:6px;font-family:var(--font-ui,sans-serif);font-size:19px;color:#a5d7ee;text-shadow:0 2px 8px #000;pointer-events:none}
.run-favor .icon{width:20px;height:20px}
.run-favor[hidden],.run-hud.is-battle .run-favor{display:none}
.run-battle-piles{position:absolute;left:7px;bottom:13px;display:flex;align-items:flex-end;gap:0;pointer-events:none}
.run-battle-piles[hidden],.run-end-turn[hidden]{display:none}
.run-pile{position:relative;display:grid;place-items:center;width:44px;min-height:45px;padding:0;border:0;border-radius:0;color:#adcbd6;background:none}
.run-pile .icon{width:20px;height:20px}
.run-pile:hover,.run-pile:focus-visible,.run-pile.is-open{color:#f1e3c0}
.run-pile:disabled{opacity:.45;cursor:default}
.run-deck{right:1px;bottom:calc(-22px + min(22px,var(--safe-bottom)));width:83px;height:121px;padding:0;background:none;border:0;border-radius:0}
.run-deck-stack{right:4px;top:0;width:60px;height:88px;transition:transform .16s ease}
.run-deck-count{font-family:var(--font-ui,sans-serif);font-size:14px}
.run-end-turn{position:absolute;right:12px;bottom:116px;display:flex;align-items:center;justify-content:center;gap:9px;min-width:105px;min-height:44px;padding:7px 13px;border:1px solid #dbe4db5c;border-radius:0;background:#07131db3;backdrop-filter:blur(12px);color:#e6eddf;font:500 14px/1 var(--font-ui,sans-serif);letter-spacing:.08em;text-transform:uppercase;box-shadow:0 4px 18px #0003;transition:background .12s,color .12s,opacity .12s}
.run-end-turn .icon{width:16px;height:16px}
.run-end-turn:not(:disabled):hover{background:#e7efe5;color:#0c1c23}
.run-end-turn:disabled{opacity:.35;cursor:default}
.run-hud.is-battle .run-favor,.run-hud.is-battle .run-battle-piles,.run-hud.is-battle .run-deck,.run-hud.is-battle .run-end-turn{animation:command-in .22s ease-out both}
.run-hud.is-battle .run-deck,.run-hud.is-battle .run-end-turn{animation-delay:35ms}
.run-hud.is-hit .run-player{animation:command-hit .22s ease-out}
.run-hud.is-healed .run-player{animation:command-heal .3s ease-out}
@keyframes command-in{from{opacity:0;translate:0 12px}to{opacity:1;translate:0 0}}
@keyframes command-hit{25%{transform:translateX(calc(-50% - 3px));filter:brightness(1.5)}60%{transform:translateX(calc(-50% + 2px))}to{transform:translateX(-50%)}}
@keyframes command-heal{40%{filter:drop-shadow(0 0 14px #91dbc0) brightness(1.25)}}

/* The battlefield and its scenery extend under the persistent instruments. */
.battle-root{padding-bottom:0}
.battle-view{min-height:100dvh;max-width:none;padding-bottom:0;border:0;background:transparent}
.battle-location{position:fixed;inset:0;background-image:linear-gradient(180deg,#06121d9c,#08182294 48%,#06121dc9),var(--battle-location-image)}
.battle-enemy-header{display:flex;justify-content:center;align-items:flex-start;min-height:107px;gap:0;margin-bottom:0;padding-top:2px}
.battle-enemy-header>.battle-commander{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:24px;width:min(80%,300px);max-width:none;min-height:101px;padding:0;background:none;border:0;border-radius:0;filter:drop-shadow(0 3px 8px #0008)}
.battle-commander-medallion{position:relative;width:62px;height:62px;display:block}
.battle-commander-medallion .battle-commander-portrait,.battle-commander-medallion .battle-commander-emblem{position:absolute;inset:7px;width:calc(100% - 14px);height:calc(100% - 14px);border-radius:50%;object-fit:cover;border:1px solid #b6c8cd66;filter:none;background:#07131b;box-shadow:0 0 0 3px #07131b80}
.battle-commander-ring{position:absolute;inset:0;width:100%;height:100%;fill:none;pointer-events:none}
.battle-commander-ring circle{stroke-width:4;fill:none;stroke-linecap:butt}
.commander-health-orbit{stroke:var(--commander-track)}
.commander-health-value{stroke:var(--commander-health);transition:stroke-dasharray .18s ease}
.battle-commander-health{position:absolute;bottom:-12px;left:50%;transform:translateX(-50%);margin:0;white-space:nowrap}
.battle-commander-health strong{font:600 20px/1.15 var(--font-ui,sans-serif);letter-spacing:.01em}
.battle-commander-info{display:block;min-width:0;text-align:center}
.battle-enemy-name{display:block;color:#e3e8df;font:500 clamp(14px,2.5vw,18px)/1.05 var(--font-ui,sans-serif);letter-spacing:.12em;text-transform:uppercase;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.battle-cancel-target{position:absolute;right:0;top:5px;width:40px;height:40px;border-radius:0;z-index:2}
.battle-commander[data-legal="true"] .battle-commander-medallion:after{content:"";position:absolute;inset:-4px;border:1px solid #e8d6a3;border-radius:50%;pointer-events:none}
.battle-commander[data-drop-target="true"]{outline:none!important;filter:drop-shadow(0 0 14px #e8d6a3)}
.battle-enemy-header .battle-target-dot{bottom:0}
.battle-field{width:min(100%,940px);align-self:center;padding-bottom:20px}
.battle-toolbar{margin-bottom:130px}
.battle-mulligan,.battle-sheet-backdrop{position:fixed;inset:0;z-index:220}

@media(min-width:600px){
 :root{--run-hud-height:168px}
 .run-player{--commander-portrait-size:96px;bottom:11px;width:120px;height:124px}
 .run-player-portrait{width:96px;height:96px;flex-basis:96px}
 .run-health-number b{font-size:24px}
 .run-favor{left:25px;bottom:89px;font-size:22px}.run-favor .icon{width:22px;height:22px}
 .run-battle-piles{left:18px;bottom:20px}.run-pile{width:48px;min-height:48px}.run-pile .icon{width:22px;height:22px}
 .run-deck{right:20px;bottom:calc(-24px + min(24px,var(--safe-bottom)));width:100px;height:142px}.run-deck-stack{width:74px;height:106px}.run-deck-count{top:49px}
 .run-end-turn{right:23px;bottom:135px;min-width:127px;min-height:45px;font-size:15px}
 .battle-enemy-header{min-height:114px}.battle-commander-medallion{width:70px;height:70px}
}
@media(max-height:760px) and (max-width:599px){
 :root{--run-hud-height:133px}
 .run-player{--commander-portrait-size:76px;bottom:5px;width:96px;height:104px}.run-player-portrait{width:76px;height:76px;flex-basis:76px}.run-health-number b{font-size:21px}.run-favor{bottom:72px}.run-end-turn{bottom:103px;min-height:44px}
 .run-battle-piles{bottom:8px}.run-deck{bottom:calc(-27px + min(27px,var(--safe-bottom)));height:114px}
 .battle-enemy-header{min-height:102px}.battle-commander-medallion{width:55px;height:55px}.battle-enemy-header>.battle-commander{min-height:98px;gap:24px}
}
@media(max-width:380px){.run-player{width:88px}.run-battle-piles{left:4px}}
@media(max-width:359px){
 .run-battle-piles{left:4px;bottom:8px}.run-pile{min-height:44px}.run-favor{left:11px;bottom:111px}
 .run-end-turn{right:8px;min-width:92px;padding-inline:8px;font-size:12px}.run-deck{right:-6px}
}
@media(prefers-reduced-motion:reduce){.run-hud *,.battle-commander-ring *{animation:none!important;transition:none!important}}
.reduce-motion .run-hud *,.reduce-motion .battle-commander-ring *{animation:none!important;transition:none!important}
.run-hud.is-battle .run-deck{bottom:calc(-22px + min(22px,var(--safe-bottom)))}
.run-hud.is-battle .run-end-turn{bottom:108px;gap:5px;padding-inline:10px}.run-end-turn .icon{width:10px;height:10px}
.run-deck{transition:bottom .22s ease-out}
@media(min-width:600px){.run-hud.is-battle .run-deck{bottom:calc(-24px + min(24px,var(--safe-bottom)))}.run-hud.is-battle .run-end-turn{bottom:130px}}
@media(max-height:760px) and (max-width:599px){.run-hud.is-battle .run-deck{bottom:calc(-27px + min(27px,var(--safe-bottom)))}.run-hud.is-battle .run-end-turn{bottom:103px}}

/* Run progression belongs to the commander, separate from profile Renown. */
.enemy-instruments{position:absolute;top:16px;left:calc(50% + 50px);display:flex;align-items:center;gap:12px;max-width:calc(50% - 55px);color:#abc7d3;font:500 13px/1 var(--font-ui)}
.enemy-matter{display:flex;gap:3px;flex-wrap:wrap;max-width:65px;min-width:8px}
.enemy-matter i{width:6px;height:6px;background:#78b7d329;border:1px solid #78b7d344}
.enemy-matter i.is-filled{background:#8bd8f1;border-color:#bceaff}
.enemy-hand-count{display:flex;align-items:center;gap:4px;white-space:nowrap}
.enemy-hand-count svg{width:17px;height:17px}
.commander-xp-track{height:3px;background:#e8cd8f26;overflow:hidden}
.commander-xp-track i{display:block;height:100%;background:#ecd198;box-shadow:0 0 9px #efcf88;transition:width .3s ease}
.level-up-backdrop{backdrop-filter:blur(14px);background:#051019bb}
.level-up-scene{width:min(420px,90vw);text-align:center;padding:30px;color:#f2e6c8}
.level-up-orbit{position:relative;width:150px;height:150px;margin:0 auto 32px;border:2px solid #e4cc90;border-radius:50%;padding:9px;box-shadow:0 0 0 12px #b9d8e708,0 0 60px #9ee1ef22;animation:level-heal .6s ease-out both}
.level-up-orbit img{width:100%;height:100%;border-radius:50%;object-fit:cover}
.level-up-orbit .commander-health-badge{position:absolute;bottom:-12px;left:calc(50% - 18px)}
.level-up-scene h2{font:400 32px/1.2 var(--font-display);margin:0 0 20px}
.level-up-scene p{font:500 14px/1 var(--font-ui);color:#c6d4d8;margin:12px 0 28px}
.level-up-scene .button{width:100%}
@keyframes level-heal{from{filter:brightness(1.9);transform:scale(.85);opacity:0}to{filter:brightness(1);transform:scale(1);opacity:1}}
@media(max-width:430px){.enemy-instruments{left:auto;right:5px;top:12px;max-width:95px;gap:6px;flex-wrap:wrap;justify-content:flex-end}.enemy-matter{max-width:45px}.enemy-matter i{width:5px;height:5px}}
@media(prefers-reduced-motion:reduce){.level-up-orbit{animation:none}.commander-xp-track i{transition:none}}
.reduce-motion .level-up-orbit{animation:none}
