.playing { overflow: hidden; }
.playing main { width: min(100%, 44rem); height: 100dvh; padding: 0; overflow: hidden; }
#war { width: 100%; height: 100%; min-height: 0; overflow: hidden; align-items: center; }
#war > :not(#battlefield) { align-self: stretch; }
#war #tutorial:not([hidden]) { position: absolute; z-index: 8; top: 78px; left: 4px; right: 4px; max-height: 72px; overflow: auto; }
.battle-hud { width: 100%; flex: 0 0 37px; display: flex; gap: 3px; min-height: 0; padding: 0 2px 0 5px; }
.battle-hud #turn-count { flex: 0 0 41px; white-space: nowrap; font-size: 12px; }
.hud-icon { display: block; flex: 0 0 auto; width: 19px; height: 19px; object-fit: contain; }
.battle-hud #turn-count .hud-icon { width: 23px; height: 23px; }
.battle-hud .enemy-hud { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: flex-end; gap: clamp(2px, 1vw, 7px); padding: 0; white-space: nowrap; }
.enemy-hud :is(#enemy-hand,#enemy-deck,#own-deck,#timer) { flex: 0 1 auto; display: flex; align-items: center; min-width: 0; gap: 1px; font-size: 12px; }
.enemy-hud :is(#enemy-hand,#enemy-deck,#own-deck,#timer) .hud-icon { width: 18px; height: 18px; }
.enemy-hud #enemy-deck { flex: 0 1 auto; }
.enemy-hud #own-deck { margin: 0; }
.enemy-hud .deck-count::before { content: none; }
.battle-hud #menu-open { flex: 0 0 36px; width: 36px; min-width: 36px; min-height: 36px; }
.battle-status { flex: 0 0 38px; display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; background: #34383B; border-bottom: 1px solid #817455; padding: 0 5px; }
.battle-status #supply { flex: 0 0 125px; min-width: 0; display: grid; grid-template-columns: 24px auto; grid-template-rows: 24px 10px; align-items: center; gap: 0 3px; }
.battle-status #supply .supply-gem { width: 24px; height: 24px; }
.battle-status #supply .supply-value { font-size: 20px; line-height: 24px; color: #F1E3C4; }
.battle-status .gem-track { grid-column: 1 / -1; height: 10px; gap: 0; }
.battle-status .gem-track .gem { display: block; flex: 1; height: 10px; background: url('./assets/ui/gem-cost.webp') center / contain no-repeat; }
.battle-status .gem-track .gem.empty { opacity: .28; }
.battle-status .gem-track .gem.cost-selected { filter: brightness(1.5) drop-shadow(0 0 2px #F1E3C4); }
.battle-status #war-log { flex: 1 1 auto; display: block; width: auto; min-width: 0; min-height: 32px; max-height: 32px; padding: 0 2px; margin: 0; border: 0; border-image: none; background: transparent; color: #F1E3C4; font-size: 12px; line-height: 32px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.battle-status #notice:not([hidden]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#battlefield, #battlefield.scene-active { flex: 0 0 auto; width: min(100%, calc(65dvh - 129px)); min-height: 0; max-height: calc(100dvh - 199px); aspect-ratio: 1170 / 1800; height: min(calc(153.846vw + 20px), calc(100dvh - 199px)); margin: 0; }
#war:has(#tutorial:not([hidden])) #battlefield { flex-basis: auto; min-height: 0; }
#battlefield .wall-overlay { position: absolute; z-index: 4; top: 3px; left: 3px; right: 3px; height: 26px; display: flex; justify-content: space-between; gap: 3px; pointer-events: none; }
.wall-overlay > strong { flex: 0 1 45%; min-width: 0; height: 25px; display: flex; align-items: center; gap: 2px; padding: 1px 3px; background: #211B18C9; color: #F1E3C4; font-size: 11px; line-height: 1; text-shadow: 0 1px 2px #211B18; }
.wall-overlay .hud-icon { width: 22px; height: 22px; }
.wall-bar { position: relative; display: block; flex: 1; height: 19px; padding: 5px 6px; background: url('./assets/ui/hud/bar-frame.webp') center / 100% 100% no-repeat; }
.wall-fill { display: block; height: 9px; background: url('./assets/ui/hud/bar-fill-blue.webp') left center / auto 100% repeat-x; }
#enemy-wall .wall-fill { background-image: url('./assets/ui/hud/bar-fill-red.webp'); }
.wall-overlay b { min-width: 2ch; text-align: right; }
#battlefield .turn-actions { bottom: 3px; right: 2px; }
#end-turn, #end-turn:disabled { width: 116px; height: 46px; min-width: 116px; min-height: 46px; padding: 0; border: 0; border-image: none; border-radius: 0; background: transparent url('./assets/ui/hud/btn-end-turn.webp') center / 100% 100% no-repeat; color: #F1E3C4; -webkit-text-fill-color: #F1E3C4; font-size: 15px; text-shadow: 0 1px 2px #211B18; }
#end-turn::before, #end-turn:disabled::before { display: none; }
#end-turn:active:not(:disabled) { border: 0; border-image: none; background-image: url('./assets/ui/hud/btn-end-turn-pressed.webp'); transform: translateY(1px); }
#end-turn:disabled { background-image: url('./assets/ui/hud/btn-end-turn-disabled.webp'); opacity: 1; }
#end-turn > span, #end-turn:disabled > span { color: #F1E3C4; -webkit-text-fill-color: #F1E3C4; text-shadow: 0 1px 2px #211B18; }
#unit-panel { right: 118px; }
#unit-panel .trap-detail { color: #F1E3C4; padding-left: 6px; border-left: 3px solid #254A60; }
#unit-panel .trap-detail.opponent { border-left-color: #8A392F; }
.node.sluice-locked, .node.sluice-selected { outline: 3px solid #83c8c1; outline-offset: -3px; box-shadow: inset 0 0 18px #3c9b9b99; }
.node.sluice-selected { outline-color: #c4eee0; }
.map-unit.steppe-surge { filter: drop-shadow(-5px 2px 3px #c49b6877); }
#tactic-cast.nation-trump { left: calc(50% - 145px); top: 38%; width: 290px; min-height: 90px; padding: 16px 22px; border: 0; background: url('./assets/ui/hud3/topbar.webp') center / 100% 100% no-repeat; color: #f1e3c4; animation: nation-trump-cast .6s ease-out both; }
#tactic-cast.nation-trump strong { font-family: 'Kerbaon Serif', serif; font-size: 24px; text-shadow: 0 2px 4px #211b18; }
@keyframes nation-trump-cast { from { opacity: 0; transform: translateY(28px) scale(.92); } 45% { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 1; transform: none; } }
#hand { flex: 0 0 124px; width: 100%; height: 124px; min-height: 0; align-items: center; gap: 3px; padding: 4px 2px; overflow-x: auto; }
#hand .hand-card { flex: 0 0 75px; width: 75px; }
#hand .war-card { width: 75px; height: 112px; min-height: 112px; }
#hand .war-card .card-cost { font-size: 13px; }
#hand .war-card .card-name { font-size: 10px; }
.war-card[data-type="tactic"] { --frame: url('./assets/ui/hud/card-frame-tactic.webp'); }
.war-card[data-type="trap"] { --frame: url('./assets/ui/hud/card-frame-trap.webp'); }
.war-card .card-troop { display: none; }
.troop-badge { position: absolute; z-index: 5; top: 1.5%; right: 1.5%; width: 25%; aspect-ratio: 1; background: var(--badge) center / contain no-repeat; pointer-events: none; }
.troop-badge.spear { --badge: url('./assets/ui/hud/badge-spear.webp'); }
.troop-badge.cavalry { --badge: url('./assets/ui/hud/badge-cavalry.webp'); }
.troop-badge.archer { --badge: url('./assets/ui/hud/badge-archer.webp'); }
.troop-badge.shield { --badge: url('./assets/ui/hud/badge-shield.webp'); }
.troop-badge.siege { --badge: url('./assets/ui/hud/badge-siege.webp'); }
.troop-badge.commander { --badge: url('./assets/ui/hud/badge-commander.webp'); }
.troop-badge.velkasu { --badge: url('./assets/ui/hud/badge-velkasu.webp'); }
.card-back-face { gap: 5px; padding: 15px 12px 12px; overflow: hidden; }
.card-back-face .troop-badge { top: 2%; right: 2%; width: 20%; }
.card-back-face .back-name { max-width: 72%; font-size: 15px; line-height: 1.2; }
.card-back-face .card-back-effect { font-size: 13px; line-height: 1.35; }
.card-back-face .card-movement, .card-back-face .card-matchup { font-size: 11px; line-height: 1.3; }
.card-back-face .card-matchup .icon { width: 18px; height: 18px; }
.card-back { background-image: url('./assets/ui/hud/card-back.webp'); }
.map-attack-marker, .battle-attack-marker { width: 46px; height: 46px; min-width: 46px; min-height: 46px; border: 0; border-image: none; background: url('./assets/ui/hud/attack-marker.webp') center / contain no-repeat; color: transparent; animation: attack-pulse 1.1s ease-in-out infinite; }
#battlefield .battle-attack-marker { position: absolute; z-index: 5; transform: translate(-50%,-50%); pointer-events: auto; padding: 0; border: 0; border-image: none; background: url('./assets/ui/hud/attack-marker.webp') center / contain no-repeat; }
@keyframes attack-pulse { 50% { filter: brightness(1.35) drop-shadow(0 0 5px #F1E3C4); } }
.reduce-motion .map-attack-marker, .reduce-motion .battle-attack-marker { animation: none; }
@media (prefers-reduced-motion: reduce) { .map-attack-marker, .battle-attack-marker { animation: none; } }

.playing main, #war { width: 100%; height: 100dvh; min-height: 0; padding: 0; }
.battle-hud { flex: 0 0 46px; width: 100%; display: flex; align-items: center; gap: 3px; padding: 2px 5px; min-width: 0; overflow: hidden; background: #34383B url('./assets/ui/hud3/topbar.webp') center / 100% 100% no-repeat; color: #F1E3C4; font-variant-numeric: tabular-nums; }
.battle-hud #supply { flex: 0 0 93px; width: 93px; min-width: 0; display: grid; grid-template-columns: 26px 1fr; grid-template-rows: 27px 8px; align-items: center; column-gap: 2px; }
.battle-hud #supply .supply-gem { width: 26px; height: 26px; background: url('./assets/ui/gem-cost.webp') center / contain no-repeat; }
.battle-hud #supply .supply-value { font-size: 19px; line-height: 27px; color: #F1E3C4; white-space: nowrap; }
.battle-hud #supply .gem-track { grid-column: 1 / -1; height: 8px; display: flex; }
.battle-hud #supply .gem-track .gem { flex: 1; height: 8px; background: url('./assets/ui/gem-cost.webp') center / contain no-repeat; }
.battle-hud #supply .gem-track .gem.empty { opacity: .27; }
.battle-hud #supply .gem-track .gem.cost-selected { filter: brightness(1.5) drop-shadow(0 0 2px #F1E3C4); }
.battle-hud #turn-count { flex: 0 0 32px; display: flex; align-items: center; gap: 0; font-size: 12px; }
.battle-hud #turn-count .hud-icon { width: 17px; height: 17px; }
.battle-hud #war-log { flex: 1 1 32px; width: auto; min-width: 0; min-height: 34px; max-height: 34px; margin: 0; padding: 0 2px; border: 0; border-image: none; background: transparent; color: #F1E3C4; font-size: 11px; line-height: 34px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-hud .enemy-hud { flex: 0 0 auto; width: auto; gap: 2px; min-height: 0; }
.battle-hud .enemy-hud :is(#enemy-hand,#enemy-deck,#own-deck,#timer) { font-size: 11px; }
.battle-hud .enemy-hud .hud-icon { width: 14px !important; height: 14px !important; }
.battle-hud #menu-open { flex: 0 0 32px; width: 32px; min-width: 32px; min-height: 40px; padding: 0; background: transparent; border: 0; border-image: none; color: #F1E3C4; }
.battle-hud #notice:not([hidden]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#battlefield, #battlefield.scene-active, #war:has(#tutorial:not([hidden])) #battlefield { flex: 1 1 0; width: 100%; max-width: none; min-height: 0; max-height: none; height: auto; aspect-ratio: auto; margin: 0; overflow: hidden; }
#hand { flex: 0 0 122px; width: 100%; height: 122px; min-height: 0; gap: 5px; padding: 5px 4px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; }
#hand .hand-card { flex: 0 0 92px; width: 92px; scroll-snap-align: start; }
#hand .war-card { width: 92px; height: 107px; min-height: 107px; aspect-ratio: 6 / 7; }
#hand .war-card { --frame: url('./assets/ui/hud3/card-short-unit.webp'); }
#hand .war-card[data-type="tactic"] { --frame: url('./assets/ui/hud3/card-short-tactic.webp'); }
#hand .war-card[data-type="trap"] { --frame: url('./assets/ui/hud3/card-short-trap.webp'); }
#hand .war-card.legendary { --frame: url('./assets/ui/hud3/card-short-legend.webp'); }
#hand .war-card .art { left: 8.889%; top: 8.571%; width: 82.222%; height: 67.143%; }
#hand .war-card .card-name { left: 8.889%; top: 82.857%; width: 82.222%; height: 9.524%; font-size: 11px; line-height: 1; letter-spacing: -.045em; text-overflow: clip; }
#hand .war-card .card-cost { font-size: 14px; }
#battlefield .wall-overlay { top: 2px; left: 2px; right: 2px; height: 30px; }
.wall-overlay > strong { flex: 0 1 49%; height: 30px; padding: 0; background: none; border: 0; }
.wall-overlay .wall-bar { position: relative; display: block; width: 100%; height: 30px; padding: 0; background: none; }
.wall-bar .wall-fill { position: absolute; top: 25%; bottom: 25%; left: 14%; height: auto; max-width: 82%; background: url('./assets/ui/hud3/wallbar-fill-blue.webp') left center / auto 100% repeat-x; }
#enemy-wall .wall-fill { left: auto; right: 14%; background-image: url('./assets/ui/hud3/wallbar-fill-red.webp'); }
.wall-bar::after { content: ''; position: absolute; inset: 0; background: url('./assets/ui/hud3/wallbar-frame-blue.webp') center / 100% 100% no-repeat; }
#enemy-wall .wall-bar::after { background-image: url('./assets/ui/hud3/wallbar-frame-red.webp'); }
.wall-overlay .wall-bar b { position: absolute; z-index: 1; left: 13%; right: 4%; top: 0; height: 100%; display: grid; place-items: center; color: #F1E3C4; font-size: 10px; font-variant-numeric: tabular-nums; text-shadow: -1px -1px 1px #211B18, 1px 1px 1px #211B18, 0 0 3px #211B18; }
#enemy-wall .wall-bar b { left: 4%; right: 13%; }
#battlefield .turn-actions { right: 3px; bottom: 3px; }
#end-turn, #end-turn:disabled { display: inline-grid; place-items: center; width: 145px; min-width: 145px; height: 58px; min-height: 58px; padding: 0; margin: 0; appearance: none; -webkit-appearance: none; border: 0; border-image: none; border-radius: 0; outline: none; box-shadow: none; background-color: transparent; -webkit-tap-highlight-color: transparent; font-size: 17px; line-height: 1; }
#end-turn > span { display: block; width: 100%; text-align: center; }
#end-turn:focus-visible { outline: 2px solid #D0AD64; outline-offset: -4px; }
#end-turn:active:not(:disabled) { filter: none; box-shadow: none; }
#unit-panel { position: absolute; z-index: 6; left: 4px; right: auto; bottom: auto; width: min(252px, calc(100% - 8px)); max-height: min(180px, calc(100% - 8px)); padding: 12px 14px 16px; overflow: visible; color: #211B18; background: #F1E3C4 url('./assets/ui/hud3/tooltip-panel.webp') center / 100% 100% no-repeat; border: 0; border-image: none; filter: drop-shadow(0 3px 5px #211B1888); font-size: 12px; pointer-events: none; }
#unit-panel .tooltip-main { display: grid; grid-template-columns: 54px minmax(0,1fr); gap: 7px; align-items: center; min-height: 68px; }
#unit-panel .tooltip-badge { display: block; width: 54px; height: 54px; background: var(--badge) center / contain no-repeat; }
#unit-panel .tooltip-unknown-art { display: block; width: 38px; height: 54px; margin-inline: auto; background: url('./assets/ui/hud/card-back.webp') center / 100% 100% no-repeat; }
#unit-panel .tooltip-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#unit-panel .tooltip-copy strong { font-size: 14px; line-height: 1.15; overflow-wrap: anywhere; }
#unit-panel .tooltip-copy small { font-size: 11px; line-height: 1.15; }
#unit-panel .tooltip-tail { position: absolute; top: calc(100% - 10px); left: var(--tail-x,50%); width: 36px; height: 18px; transform: translateX(-50%); background: url('./assets/ui/hud3/tooltip-tail.webp') center / contain no-repeat; pointer-events: none; }
#unit-panel.tooltip-below .tooltip-tail { top: -12px; transform: translateX(-50%) rotate(180deg); }
#unit-panel .unit-option { min-height: 32px; padding: 3px 5px; background: #E7D8B6; color: #211B18; pointer-events: auto; }
#unit-panel .tooltip-options { max-height: 72px; overflow-y: auto; }
#unit-panel .trap-detail { color: #211B18; border-left-color: #254A60; }
#unit-panel .trap-detail.opponent { border-left-color: #8A392F; }
@media (max-width: 400px) { .battle-hud #supply { flex-basis: 85px; width: 85px; } .battle-hud #supply .supply-value { font-size: 17px; } .battle-hud .enemy-hud { gap: 1px; } .battle-hud #menu-open { flex-basis: 29px; width: 29px; min-width: 29px; } }

/* 25-G: unit info as a compact docked strip — never over the tapped tiles, taps pass through */
#unit-panel { left: 6px; right: auto; top: auto; bottom: 8px; width: auto; min-width: 0; max-width: calc(100% - 140px); max-height: none; padding: 7px 12px 8px 9px;
  background: transparent url('./assets/ui/hud3/tooltip-panel.webp') center / 100% 100% no-repeat; background-color: transparent; border: 0; border-image: none; box-shadow: none; pointer-events: none; }
#unit-panel .tooltip-main { grid-template-columns: 36px minmax(0,1fr); gap: 7px; min-height: 0; }
#unit-panel .tooltip-badge { width: 36px; height: 36px; }
#unit-panel .tooltip-unknown-art { width: 26px; height: 38px; }
#unit-panel .tooltip-copy { gap: 1px; }
#unit-panel .tooltip-copy strong { font-size: 13px; }
#unit-panel .tooltip-copy b { font-size: 12px; font-variant-numeric: tabular-nums; }
#unit-panel .tooltip-copy small { font-size: 10.5px; color: #5a4a36; }
#unit-panel .tooltip-tail { display: none; }
#unit-panel .tooltip-options { display: flex; flex-wrap: wrap; gap: 4px; max-height: none; overflow: visible; margin-top: 5px; }
#unit-panel .unit-option, #unit-panel .unit-option:disabled { min-height: 28px; min-width: 0; padding: 2px 8px; border: 0; border-image: none; border-radius: 3px; background: #211B1814; background-image: none; color: #211B18; font-size: 11px; font-weight: 700; box-shadow: inset 0 0 0 1px #8A6A3A66; filter: none; pointer-events: auto; -webkit-tap-highlight-color: transparent; }
#unit-panel .unit-option[aria-pressed="true"] { background: #254A60; color: #F1E3C4; box-shadow: none; }
#unit-panel .trap-detail { margin: 4px 0 0; font-size: 11px; }
/* 25-H interim: hand card names were clipped vertically (box 10px for 11px Korean glyphs) */
#hand .war-card .card-name { top: 80.5%; height: auto; min-height: 12%; line-height: 1.3; overflow: visible; display: flex; align-items: center; justify-content: center; white-space: nowrap; }
/* 25-I: card back text was mirrored (back face lacked its own 180° turn) */
.card-flip-inner > .card-back-face { transform: rotateY(180deg); }
/* 25-I: dialogs focus their heading on open — no ring on the first button */
dialog [autofocus]:focus { outline: none; }
/* 25-I: end-turn label centred on the art's red plate (plate centre is 53.9% across, not 50%) */
#end-turn > span, #end-turn:disabled > span { box-sizing: border-box; padding-left: 7.8%; }
/* 25-H: hand cards back to a true 2:3 card (card-tall frames: art 40,23..320,409 · name plate 428..515 of 360×540) */
#hand { flex: 0 0 132px; height: 132px; padding: 4px 4px; }
#hand .hand-card { flex: 0 0 82px; width: 82px; }
#hand .war-card { width: 82px; height: 123px; min-height: 123px; aspect-ratio: 2 / 3; --frame: url('./assets/ui/hud3/card-tall-unit.webp'); }
#hand .war-card[data-type="tactic"] { --frame: url('./assets/ui/hud3/card-tall-tactic.webp'); }
#hand .war-card[data-type="trap"] { --frame: url('./assets/ui/hud3/card-tall-trap.webp'); }
#hand .war-card.legendary { --frame: url('./assets/ui/hud3/card-tall-legend.webp'); }
#hand .war-card .art { left: 6.111%; top: 4.259%; width: 87.778%; height: 71.481%; }
#hand .war-card .card-name { left: 11.111%; top: 79.259%; width: 77.778%; height: 16.111%; min-height: 0; font-size: 11px; line-height: 1.3; }
#hand .war-card .card-cost { width: 30%; height: 20%; }
#hand .war-card { box-sizing: border-box; margin: 0; }
/* 26-J: one typeface for the whole game — the card-name serif (Kerbaon Serif); Pretendard only as a glyph fallback */
:root, body, button, select, input, summary, dialog, #hand .war-card .card-name { font-family: 'Kerbaon Serif', Pretendard, 'Noto Serif KR', serif; }
