body { background: var(--leather) url('./assets/ui/bg-leather.webp') repeat; }
strong, b, .unit-count, .force-badge, .card-cost, .card-force, .battle-power, .battle-army > strong, .scene-loss, #outcome, #turn-banner { font-weight: 600; }
h1, h2, h3, .card-name { font-family: 'Kerbaon Serif', Georgia, 'Times New Roman', serif; font-weight: 700; }
.nation-copy > strong { font-family: 'Kerbaon Serif', Georgia, serif; font-weight: 700; }
button, select, summary { font-weight: 600; border-radius: 0; background: var(--iron); color: var(--text); }
button:not(.war-card,.cell-target,.scene-cell-target,.unit,.nation-choice), select, summary {
  border: 8px solid transparent; border-image: url('./assets/ui/btn-iron.webp') 16 fill / 8px;
  padding: 3px 8px; background-color: #34383B;
}
button.primary, #story-open, #end-turn, #tactic {
  border: 8px solid transparent; border-image: url('./assets/ui/btn-brass.webp') 16 fill / 8px;
  background: #D0AD64; color: #211B18; text-shadow: none;
}
.primary:not(#tactic), #story-open, #end-turn { position: relative; isolation: isolate; }
#tactic { isolation: isolate; }
:is(button.primary,#story-open,#end-turn,#tactic)::before { content: ''; position: absolute; inset: 8px; background: rgb(208 173 100 / 82%); z-index: -1; pointer-events: none; }
button.primary:active:not(:disabled), #story-open:active:not(:disabled), #end-turn:active:not(:disabled), #tactic:active:not(:disabled) {
  border-image-source: url('./assets/ui/btn-brass-pressed.webp'); transform: translateY(1px);
}
button:active:not(:disabled,.war-card,.cell-target) { filter: brightness(.88); }
button:disabled { color: #B8AF9A; background-color: #34383B; border-image-source: url('./assets/ui/btn-iron.webp'); }
:is(.primary,#end-turn,#tactic):disabled { color: #B8AF9A; background-color: #34383B; border-image-source: url('./assets/ui/btn-iron.webp'); }
:is(.primary,#end-turn,#tactic):disabled::before { background: #34383B; }
#end-turn > span { position: relative; z-index: 1; }
#end-turn:disabled { color: #F1E3C4; -webkit-text-fill-color: #F1E3C4; opacity: 1; border-image: none; border: 2px solid #D0AD64; background: #34383B; }
#end-turn:disabled::before { display: none; }
#end-turn:disabled > span { color: #F1E3C4; -webkit-text-fill-color: #F1E3C4; text-shadow: 0 1px 2px #111; }
#skip-battle { color: #F1E3C4; -webkit-text-fill-color: #F1E3C4; text-shadow: 0 1px 2px #111; }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
dialog, #selection, #nation-selection, #chapters, #dialogue, #deck-editor {
  color: var(--text); background: #34383B;
  border: 12px solid transparent; border-image: url('./assets/ui/panel-iron.webp') 24 / 12px;
  padding: 10px;
}
dialog::backdrop { background: #100D0BCC; }
header { color: var(--gold); padding: 5px 2px 10px; }
#home.title-art-loaded { border: 2px solid #A88A4B; padding: 20px 14px; align-content: start; gap: 14px; }
#home.title-art-loaded h2 { background: #F1E3C4F2; color: #211B18; border-bottom: 2px solid #A88A4B; padding: 16px 10px; }
#home.title-art-loaded .story-map-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(#211B1820, transparent 45%, #211B1840); }
#home button { min-height: 58px; }
.nation-choice { color: var(--text); background: #34383B; border: 2px solid #6D99AD; }
.nation-choice[data-nation="sabelu"] { border-color: #D79786; border-style: double; border-width: 4px; }
.nation-copy { padding: 12px 9px; }
#story-complete { color: var(--gold); }
#chapter-list button { background-color: #34383B; }
#chapter-list button:disabled { background-color: #34383B; color: #B8AF9A; }
#story-phases [aria-selected="true"] { border-color: var(--gold); }
#dialogue-next { background: #34383B; color: var(--text); padding: 16px; }
#dialogue-position { color: #D4C8B0; }
#dialogue-portraits figcaption { color: var(--text); background: #34383B; }
#dialogue-portraits.phase2-portraits img { background: #34383B; }
#settings label { line-height: 1.5; }
input[type="checkbox"] { accent-color: var(--gold); }
#release-version { color: #D4C8B0; }
#result-summary { padding-block: 10px; border-block: 1px solid #817455; }
#result-context { margin-top: 10px; }
.battle-army { color: var(--text); background: #254A60; border-top: 3px solid #6D99AD; }
.battle-army.opponent { color: var(--text); background: #8A392F; border-top: 3px double #F1E3C4; }
.battle-army.defeated { color: #B8AF9A; background: #34383B; }
.battle-army .loss { color: #FFD3B9; }
#turn-banner, #tactic-cast { color: var(--text); background: #34383B; }
#flight { color: var(--text); }
.battle-hud { display: grid; grid-template-columns: 40px minmax(110px,1.8fr) minmax(58px,1fr) minmax(58px,1fr) 44px; align-items: center; gap: 4px; min-height: 48px; padding: 0 2px; background: #34383B; border-block: 1px solid #817455; }
.battle-hud > * { min-width: 0; font-size: 13px; line-height: 1.4; white-space: nowrap; letter-spacing: -.35px; }
.battle-hud #supply { color: var(--text); display: grid; grid-template-columns: 27px 1fr; gap: 1px 3px; align-items: center; }
.battle-hud #supply strong { font-size: 22px; line-height: 1.2; margin: 0; background: transparent; border: 0; text-shadow: 0 1px 2px #211B18; letter-spacing: -1px; }
.supply-gem, .battle-hud #supply .gem { background: url('./assets/ui/gem-cost.webp') center / contain no-repeat; border: 0; clip-path: none; transform: none; }
.supply-gem { width: 27px; height: 28px; }
.gem-track { display: flex; grid-column: 1 / -1; gap: 1px; width: 100%; height: 13px; }
.battle-hud #supply .gem { display: block; flex: 1; max-width: 14px; height: 13px; }
.battle-hud #supply .gem.empty { opacity: .28; filter: grayscale(1); }
.battle-hud #supply .gem.cost-selected { filter: brightness(1.45) drop-shadow(0 0 2px #F1E3C4); }
.battle-hud #turn-count { display: flex; gap: 2px; align-items: center; }
.enemy-hud :is(#timer,#own-deck,#enemy-deck) { display: flex; gap: 3px; align-items: center; }
.enemy-hud .icon { width: 14px; height: 16px; flex-shrink: 0; }
.enemy-hud .deck-count::before { display: none; }
.battle-hud #own-wall { color: var(--text); border-bottom: 3px solid #6D99AD; }
.battle-hud #enemy-wall { color: var(--text); border-bottom: 3px double #D79786; }
.battle-hud :is(#own-wall,#enemy-wall) { display: flex; align-items: center; gap: 2px; }
.battle-hud .icon { width: 12px; height: 14px; }
.battle-hud .hud-label { font-size: 11px; }
.battle-hud #menu-open { width: 44px; padding: 0; font-size: 20px; }
.battle-hud #turn-count { font-size: 13px; }
.battle-meta { position: relative; }
.enemy-hud { color: #D4C8B0; flex-wrap: wrap; gap: 4px 12px; min-height: 26px; font-size: 11px; padding: 2px 4px; }
.battle-meta .enemy-hud { position: absolute; right: 6px; top: 4px; display: grid; grid-template-columns: 44px 56px; gap: 1px 4px; min-height: 0; padding: 0; pointer-events: none; }
.enemy-hud #enemy-deck { flex: 1; }
.enemy-hud .card-back { height: 20px; width: 15px; }
.enemy-hud .deck-count::before { height: 16px; width: 12px; }
.deck-warning { color: #FFD3B9; font-size: 12px; }
#war-log { font-size: 12px; min-height: 44px; padding: 3px 122px 3px 6px; margin: 0; color: #F1E3C4; background: #34383B; }
#notice { color: var(--text); padding: 3px 6px; }
#tutorial { color: #F1E3C4; background: #34383B; border-color: var(--gold); }
#unit-panel { color: #F1E3C4; background: #34383B; border-color: var(--gold); }
.unit-option[aria-pressed="true"] { background: #254A60; border-color: #D0AD64; }
#end-turn { border-radius: 0; min-height: 52px; min-width: 82px; padding: 3px 5px; border-color: transparent; }
#unit-panel { right: 96px; }
.force-badge, #battlefield .unit.force-badge, .rain-damage { background: #F1E3C4; }
.force-badge.player { color: #254A60; }
.force-badge.opponent, .rain-damage { color: #8A392F; }
#battlefield:not(.scene-active) .node { background: #34383B; color: #F1E3C4; border-color: #B8AF9A; }
#battlefield:not(.scene-active) .node[data-owner="player"] { background: #29353B; border-color: #254A60; }
#battlefield:not(.scene-active) .node[data-owner="opponent"] { background: #3E2E29; border-color: #8A392F; }
#battlefield:not(.scene-active) .node.dusk { background: #49362C; outline-color: #E8A96F; box-shadow: inset 0 0 0 2px #E8A96F; }
#battlefield:not(.scene-active) .node.rain-selected { outline-color: #D0AD64; }
#battlefield:not(.scene-active) .shadow-card { border-color: #F1E3C4; background: #211B18; }
#battlefield:not(.scene-active) .canyon-rock { background: #B8AF9A; }
#card-detail-open { position: fixed; width: 88px; min-height: 44px; z-index: 5; font-size: 12px; margin: 0; }
#hand { flex: 0 0 auto; gap: 6px; padding: 6px 3px; min-height: 180px; background: #211B18A6; border-top: 1px solid #817455; }
.hand-card { flex: 0 0 112px; width: 112px; margin: 0; }
.war-card {
  --frame: url('./assets/ui/card-frame-unit.webp'); position: relative; display: block;
  width: 112px; height: 168px; min-height: 0; aspect-ratio: 2 / 3; padding: 0; margin: 0;
  border: 0; border-image: none; border-radius: 0; background: transparent; color: #F1E3C4;
  background-image: none; overflow: visible; isolation: isolate;
}
.war-card[data-type="tactic"] { --frame: url('./assets/ui/card-frame-tactic.webp'); }
.war-card[data-type="trap"] { --frame: url('./assets/ui/card-frame-trap.webp'); }
.war-card.legendary { --frame: url('./assets/ui/card-frame-legend.webp'); outline: none; }
.card-front::after { content: ''; position: absolute; inset: 0; background: var(--frame) center / 100% 100% no-repeat; z-index: 2; pointer-events: none; }
.war-card:disabled { color: #F1E3C4; background: transparent; border: 0; border-image: none; }
.war-card.unavailable { opacity: 1; }
.war-card.selected, .war-card:focus-visible { transform: translateY(-6px); outline: 2px solid var(--gold); outline-offset: 2px; }
.war-card .art { position: absolute; left: 5.556%; top: 3.704%; width: 88.889%; height: 56.667%; margin: 0; overflow: hidden; background: #49362C; border: 0; z-index: 0; display: flex; justify-content: center; align-items: center; }
.war-card .card-illustration, .war-card .legend-portrait { width: 100%; height: 100%; object-fit: cover; }
.war-card .art .icon { width: 45%; height: 60%; color: #F1E3C4; }
.war-card .card-name, .war-card:disabled .card-name {
  position: absolute; left: 8.889%; top: 63.334%; width: 82.222%; height: 8.148%;
  margin: 0; padding: 0; border: 0; z-index: 3; background: transparent; color: #F1E3C4; text-shadow: -1px -1px #211B18, 1px -1px #211B18, -1px 1px #211B18, 1px 1px #211B18;
  font-size: 12px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.war-card .card-cost { position: absolute; left: 1%; top: 1%; width: 26.667%; height: 17.778%; z-index: 4; background: url('./assets/ui/gem-cost.webp') center / contain no-repeat; color: #F1E3C4; clip-path: none; font-size: 16px; line-height: 1; }
.card-digit { display: inline-flex; align-items: center; justify-content: center; min-width: 1ch; padding: 1px; line-height: 1; background: transparent; border: 0; text-shadow: -1px -1px #211B18, 1px -1px #211B18, -1px 1px #211B18, 1px 1px #211B18; }
.war-card .nation-crest { top: 6%; right: 9%; z-index: 3; width: 16px; height: 16px; background: #F1E3C4; }
.deck-row { grid-template-columns: minmax(0, 1fr) 126px; align-items: center; padding: 12px 8px; border-color: #817455; }
.deck-card { width: 144px; height: 216px; justify-self: center; text-align: center; }
.deck-card .card-effect { font-size: 12px; }
.deck-card .card-force { font-size: 16px; }
.deck-quantity { justify-content: end; gap: 0; }
.deck-quantity button { padding: 0; }
.deck-quantity span { min-width: 38px; }
.deck-summary, #deck-actions, .deck-effect { background: #34383B; color: #F1E3C4; }
.deck-cost-column > div { background: #211B18; }
.deck-cost-column i { background: #D0AD64; }
#deck-reason { color: #FFD3B9; }
#card-detail { max-width: 360px; }
#card-detail-name { font-size: 20px; line-height: 1.5; }
#card-detail-face { padding-block: 10px; display: flex; justify-content: center; }
.detail-card, .trap-face { flex: 0 0 240px; max-width: 100%; width: 240px; height: 360px; margin: 10px auto; transform: none; }
.detail-card .card-name, .trap-face .card-name { font-size: 18px; }
.detail-card .card-cost, .trap-face .card-cost { font-size: 24px; }
.detail-card .card-effect, .trap-face .card-effect { font-size: 14px; }
.detail-card .card-force { font-size: 22px; }
#card-detail-effect { line-height: 1.6; padding-block: 8px; word-break: keep-all; }
#card-detail-close { width: 100%; }
@media (max-width: 359px) { .battle-hud { grid-template-columns: 30px minmax(93px,1.6fr) minmax(49px,1fr) minmax(49px,1fr) 44px; gap: 2px; } .battle-hud > * { font-size: 10px; } .battle-hud #supply strong { font-size: 19px; } .deck-row { grid-template-columns: 1fr; gap: 12px; } }
@media (prefers-reduced-motion: reduce) { button:active:not(:disabled) { transform: none; } }

.map-unit { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; max-width: 100%; pointer-events: none; }
.map-unit.player { color: #6D99AD; }
.map-unit.opponent { color: #D79786; }
.map-unit > .icon { width: 12px; height: 16px; }
.map-unit > .unit-mark { width: 24px; height: 28px; }
.map-unit.opponent > .unit-mark { transform: scaleX(-1); }
.map-unit.legendary > .unit-mark { filter: drop-shadow(0 1px #D0AD64) drop-shadow(1px 0 #D0AD64); }
.map-unit .card-back { width: 20px; height: 30px; margin: 0; }

.card-front { position: absolute; inset: 0; background: #49362C url('./assets/ui/bg-leather.webp') repeat; border-radius: 2px; }
.war-card .card-troop { position: absolute; top: 78%; left: 39%; width: 22%; height: 16%; z-index: 3; color: #F1E3C4; filter: drop-shadow(1px 1px #211B18); }
.war-card .card-cost.insufficient { color: #FFB1A1; background-image: none; }
.war-card .card-cost.insufficient::before { content: ''; position: absolute; inset: 0; background: url('./assets/ui/gem-cost.webp') center / contain no-repeat; filter: brightness(.75); z-index: -1; }
.war-card .card-cost.insufficient .card-digit { color: #FFB1A1; }
.flip-card { perspective: 900px; touch-action: pan-y; }
.card-flip-inner { position: absolute; inset: 0; display: block; transform-style: preserve-3d; transition: transform .3s ease-in-out; }
.flip-card.is-back .card-flip-inner { transform: rotateY(180deg); }
.card-flip-inner > :is(.card-front,.card-back-face) { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-back-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: stretch; gap: 9px; padding: 18px 16px; background: #34383B; border: 9px solid transparent; border-image: url('./assets/ui/panel-iron.webp') 24 / 9px; color: #F1E3C4; transform: rotateY(180deg); overflow-y: auto; text-align: left; }
.card-back-face .back-name { font-size: 16px; line-height: 1.3; color: #D0AD64; text-shadow: 0 1px #211B18; }
.war-card .card-back-face .card-force { position: static; display: block; width: 100%; min-height: 28px; padding: 4px 0; margin: 0; border: 0; background: url('./assets/ui/ribbon-troops.webp') center / 100% 100% no-repeat; color: #211B18; font-size: 20px; line-height: 1.1; text-align: center; text-shadow: 0 0 1px #211B18; }
.card-back-effect { display: block; font-size: 15px; line-height: 1.5; word-break: keep-all; color: #F1E3C4; text-shadow: 0 1px #211B18; }
.card-movement { display: block; font-size: 12px; line-height: 1.5; color: #F1E3C4; text-shadow: 0 1px #211B18; }
.card-matchup { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #F1E3C4; }
.card-matchup .icon { width: 22px; height: 22px; }
.flip-card.instant-flip .card-flip-inner, .reduce-motion .card-flip-inner { transition: none; }
.deck-row:has(.deck-card.is-back) { grid-template-columns: minmax(0,1fr) 58px; }
.deck-card.is-back { width: min(220px,100%); height: auto; min-height: 330px; aspect-ratio: 2 / 3; }
.deck-row:has(.is-back) .deck-quantity { flex-direction: column; align-items: center; gap: 6px; }
#card-detail-effect { padding: 18px 16px; }
@media (prefers-reduced-motion: reduce) { .card-flip-inner { transition: none; } }

.detail-card.war-card:first-child, .trap-face.war-card:first-child { margin: 10px auto; }
#card-detail-name { text-align: center; }
.card-back-face .back-name { font-family: 'Kerbaon Serif', Georgia, serif; font-weight: 700; }
