:root { font-family: Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-weight: 500; font-variant-numeric: tabular-nums; color: #F1E3C4; background: #211B18; color-scheme: dark; --ink: #211B18; --leather: #49362C; --iron: #34383B; --text: #F1E3C4; --blue: #254A60; --red: #8A392F; --gold: #D0AD64; --paper: #34383B; --gray: #B8AF9A; }
* { box-sizing: border-box; }
body { margin: 0; }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
#home { display: grid; gap: 12px; padding-bottom: 20px; }
#home[hidden], #chapters[hidden], #dialogue[hidden] { display: none; }
.story-map-cover { height: clamp(170px, 40dvh, 310px); background: url('./assets/story-river.webp') center / cover; border-block: 2px solid #504735; margin: 10px 0; }
#home h2 { margin-bottom: 12px; font-size: 1.4rem; }
#home button { min-height: 58px; }
#chapters h2 { font-size: 1.15rem; margin-block: 12px; }
#story-complete { color: var(--blue); font-weight: 700; }
#chapter-list { padding: 0; list-style: none; display: grid; gap: 6px; margin-block: 12px; }
#chapter-list button { width: 100%; text-align: left; padding: 8px 12px; background: var(--paper); }
#chapter-list small { display: block; font-size: .8rem; font-weight: 400; margin-top: 3px; }
#chapter-list button:disabled { color: #626262; background: #e3e1da; opacity: 1; }
#dialogue { padding-block: 12px; }
#dialogue-title { font-size: 1.15rem; margin-bottom: 12px; }
#dialogue-stage { position: relative; overflow: hidden; height: clamp(190px, 42dvh, 330px); border-block: 2px solid #504735; background: var(--paper); }
#dialogue-map { position: absolute; width: 100%; height: 100%; object-fit: cover; opacity: .35; }
#dialogue-portraits { position: relative; height: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr); gap: 12px; align-items: end; padding: 12px 8px 0; }
#dialogue-portraits figure { margin: 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: stretch; }
#dialogue-portraits figure img { opacity: .65; }
#dialogue-portraits figure.speaking img { opacity: 1; }
#dialogue-portraits img { width: 100%; min-height: 0; height: 0; flex: 1; object-fit: cover; object-position: top; border: 1px solid #766347; }
#dialogue-portraits.phase2-portraits img { object-fit: contain; background: var(--paper); }
#dialogue-portraits figcaption { flex: 0 0 auto; min-height: 32px; line-height: 1.4; font-size: .9rem; padding: 4px; text-align: center; color: #202a32; background: var(--paper); }
#dialogue-next { width: 100%; text-align: left; display: grid; gap: 12px; min-height: 150px; padding: 16px; margin-top: 12px; background: var(--paper); border: 2px solid #504735; }
#dialogue-text { font-weight: 400; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; }
#dialogue-position { font-size: .8rem; text-align: right; color: #50575b; }
#dialogue-skip { display: block; margin: 8px 0 0 auto; }
#tutorial { padding: 6px 8px; background: var(--paper); border: 2px solid var(--blue); display: flex; align-items: center; gap: 8px; }
#tutorial[hidden] { display: none; }
#tutorial p { flex: 1; font-size: .85rem; line-height: 1.4; }
#tutorial button { flex: 0 0 72px; font-size: .8rem; }
.tutorial-focus { outline: 3px solid #79551f; outline-offset: -3px; }
main { width: min(100%, 44rem); margin: auto; padding: 6px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 30px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1rem; }
header > span { font-size: .875rem; }
#restart { margin: 4px; }
button, summary, select { min-height: 44px; min-width: 44px; border: 1px solid var(--gray); border-radius: 4px; padding: 5px; font: inherit; font-size: 1rem; color: inherit; background: #fff; font-weight: 700; touch-action: manipulation; overflow-wrap: anywhere; }
button:active { background: #e4edf6; }
button:disabled { color: #626c73; background: #e8ecef; }
button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid #8b3e00; outline-offset: 2px; }
.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.player { color: var(--blue); }
.opponent { color: var(--red); }
.icon { width: 24px; height: 24px; display: inline-block; flex-shrink: 0; vertical-align: middle; }
#selection { padding-top: 2rem; }
#selection p { margin-bottom: 1rem; }
#nation-selection { padding: 20px 0; }
#nation-title { font-size: 1.25rem; margin-bottom: 12px; }
.nation-choices { display: grid; gap: 12px; }
.nation-choice { display: grid; grid-template-columns: minmax(96px, 34%) 1fr; padding: 0; text-align: left; background: var(--paper); border: 2px solid #596354; overflow: hidden; }
.nation-choice[data-nation="sabelu"] { border-color: #85412e; }
.nation-portrait { width: 100%; height: 206px; object-fit: cover; object-position: center 20%; }
.nation-copy { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; line-height: 1.4; }
.nation-copy > strong { font-size: 1.125rem; }
.nation-copy > span, .nation-copy > small { font-size: .875rem; font-weight: 500; word-break: keep-all; overflow-wrap: anywhere; }
.nation-copy > small { margin-top: auto; }
#nation-change { display: block; margin-bottom: 20px; }
.war-card.legendary { outline: 2px solid #8e651d; outline-offset: -3px; }
.war-card .legend-portrait { width: 100%; height: 100%; object-fit: cover; object-position: center 14%; }
.war-card .nation-crest { position: absolute; right: 8px; top: 8px; width: 18px; height: 18px; background: var(--paper); }
.enemy-hud { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; min-height: 32px; font-size: .875rem; }
.enemy-hud > strong { margin-left: auto; }
#enemy-hand { display: flex; align-items: center; padding-left: 5px; }
.card-back { width: 24px; height: 32px; margin-left: -5px; border-radius: 3px; background: url('./assets/card-back.svg') center / 100% 100%; position: relative; }
.deck-count::before { content: ''; display: inline-block; vertical-align: middle; width: 15px; height: 21px; margin-right: 3px; background: url('./assets/card-back.svg') center / 100% 100%; }
#enemy-deck, #own-deck { min-width: 0; }
#enemy-deck { flex: 1 1 7rem; }
.enemy-hud:has(.deck-warning) { flex-wrap: wrap; }
.deck-warning { display: block; max-width: 10rem; color: #8d2921; font-size: .875rem; font-weight: 600; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
.end-reason { display: block; margin-bottom: .5rem; }
#war-log { display: block; width: 100%; text-align: left; padding: 5px 8px; background: var(--paper); border-left: 4px solid var(--gold); font-size: 1rem; margin: 3px 0; }
#battlefield { padding: 4px; border-radius: 5px; background: linear-gradient(#f3dfdc 0 32%, #dedfd8 32% 67%, #dce7f5 67%); }
#battlefield[data-theme]:not(.scene-active) { background-color: var(--theme-ground); background-image: var(--theme-edge), var(--theme-edge); background-position: left, right; background-size: 7px 100%; background-repeat: no-repeat; }
#battlefield[data-theme="river"] { --theme-ground: #70836a; --theme-edge: repeating-linear-gradient(0deg,#a99b59 0 12px,#648b8c 12px 20px); }
#battlefield[data-theme="steppe"] { --theme-ground: #b4b07c; --theme-edge: repeating-linear-gradient(35deg,#827857 0 2px,#c3b983 2px 14px); }
#battlefield[data-theme="ford"] { --theme-ground: #8a9e9c; --theme-edge: repeating-linear-gradient(0deg,#c6b992 0 7px,#68898d 7px 19px); }
.map-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
#battlefield[data-layout="two"] .map-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#battlefield[data-layout="hourglass"] #sites { grid-template-columns: 1fr; }
#battlefield[data-layout="sea"] :is(#player-chokes,#opponent-chokes) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.paths { display: grid; grid-template-columns: repeat(3, 1fr); height: 3px; }
.paths i { justify-self: center; height: 100%; border-left: 3px solid var(--gray); }
.node { position: relative; min-width: 0; min-height: calc(3.625rem + 4px); padding: 1px 3px; display: grid; grid-template-rows: auto auto; border: 1px solid var(--gray); background: var(--paper); border-radius: 4px; }
.node[data-owner="player"] { border-color: var(--blue); background: #edf3fc; }
.node[data-owner="opponent"] { border-color: var(--red); background: #fcf0ee; }
.node.target { outline: 3px solid var(--gold); outline-offset: -2px; }
.node.pressed { box-shadow: inset 0 0 0 3px #79551f; }
.map-attack-marker { position: absolute; top: 0; right: 0; z-index: 2; color: #a22c32; background: #faf7ee; }
.node.target::after { content: ''; position: absolute; inset: 3px; border: 1px dashed var(--gold); pointer-events: none; }
.cell-target { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 44px; border: 0; padding: 0; background: transparent; }
.cell-target:disabled { color: inherit; background: transparent; }
.terrain-mark { display: flex; align-items: center; height: 14px; pointer-events: none; }
.terrain-mark .icon { width: 14px; height: 14px; }
.site-supply { display: inline-flex; align-items: center; color: #f1e3c4; font-size: .8rem; line-height: 1; text-shadow: 0 1px 2px #1b1510, 1px 0 2px #1b1510; }
.site-supply .site-gem { width: 13px; height: 13px; object-fit: contain; }
.site-supply.river-bonus .site-gem { filter: hue-rotate(150deg) saturate(1.3); }
.canyon-rock { width: 10px; height: 13px; background: #626c73; clip-path: polygon(30% 0,80% 10%,100% 80%,15% 100%,0 40%); }
.canyon-rock + .canyon-rock { margin-left: 14px; transform: scaleX(-1); }
.units { position: relative; display: flex; gap: 2px; min-height: max(44px, 2.75rem); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; pointer-events: none; }
.unit { position: relative; flex: 0 0 auto; min-width: 64px; max-width: 100%; min-height: max(44px, 2.75rem); padding: 1px 3px; border: 2px solid currentColor; border-radius: 3px; background: #fff; pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.unit:disabled { color: inherit; background: #fff; }
.unit.selected { outline: 3px solid #202a32; outline-offset: 1px; }
.unit.target { outline: 3px solid var(--gold); outline-offset: 1px; }
.unit.spent { border-style: dashed; }
.unit.legendary { box-shadow: inset 0 0 0 2px #c69b42; }
.unit-count { max-width: 100%; overflow-wrap: anywhere; font-size: 1.125rem; font-weight: 900; line-height: 1.1; }
.formation { display: flex; justify-content: center; max-width: 78px; gap: 0; min-height: 12px; }
.formation .icon { width: 22px; height: 18px; margin-right: 0; }
.formation .more { font-size: 1rem; line-height: 16px; }
.unit.concealed, .unit.concealed:disabled { background: url('./assets/card-back.svg') center / 100% 100%; }
.unknown { display: block; width: 24px; font-size: 1.25rem; line-height: .9; font-weight: 900; background: #f9e8e8; }
.concealed .unit-count { background: #fff; }
.trap-mark { display: inline-flex; align-items: center; gap: 1px; }
.trap-mark .card-back { width: 15px; height: 16px; margin: 0; border-width: 1px; }
.trap-mark .card-back::before { inset: 2px; }
.trap-mark .card-back::after { width: 5px; height: 5px; top: 4px; left: 4px; border-width: 1px; }
.own-hud { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 3px 8px; min-height: 28px; font-size: .875rem; }
#supply { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; color: var(--gold); }
.gem { width: 10px; height: 13px; clip-path: polygon(50% 0,100% 35%,75% 100%,25% 100%,0 35%); background: var(--gold); }
.gem.empty { background: #fff; border: 2px solid var(--gold); clip-path: none; transform: scale(.75) rotate(45deg); }
#supply strong { margin-right: 3px; font-size: 1rem; }
#notice { min-height: 20px; font-size: .875rem; line-height: 1.4; }
#hand { display: flex; align-items: end; padding: 16px 10px 6px; min-height: 160px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.war-card { position: relative; flex: 0 0 132px; min-height: 132px; width: 132px; margin-left: -12px; padding: 3px; color: #202a32; border: 3px solid #79551f; border-radius: 6px; background: var(--paper); transform: rotate(var(--angle)); transform-origin: center bottom; display: grid; grid-template-rows: 40px auto auto; align-content: start; text-align: center; touch-action: pan-x; }
.war-card:first-child { margin-left: 0; }
.war-card.selected, .war-card:focus-visible { z-index: 3; transform: translateY(-9px) rotate(0deg); }
.war-card:disabled { color: #626c73; background: #e8ecef; border-color: #626c73; }
.war-card { --frame: url('./assets/frame-unit.svg'); --frame-color: #164d88; border-image-source: var(--frame); border-image-slice: 28; border-image-width: 5px; background-image: var(--frame); background-size: 100% 100%; }
.war-card[data-type="tactic"] { --frame: url('./assets/frame-tactic.svg'); --frame-color: #79551f; }
.war-card[data-type="trap"] { --frame: url('./assets/frame-trap.svg'); --frame-color: #842c36; }
.war-card .card-name { border-block: 1px solid var(--frame-color); color: var(--frame-color); background: #faf7ee; }
.war-card :is(.card-effect,.card-force) { background: #faf7ee; }
.war-card:disabled :is(.card-effect,.card-force) { background: #e8ecef; }
.war-card:disabled .card-name { color: #626c73; border-color: #626c73; background: #e8ecef; }
.card-cost { position: absolute; top: 3px; left: 3px; z-index: 1; display: flex; align-items: center; justify-content: center; width: 27px; height: 28px; color: #fff; background: var(--gold); clip-path: polygon(50% 0,100% 28%,85% 80%,50% 100%,15% 80%,0 28%); font-size: 1.125rem; }
.war-card .art { display: flex; align-items: center; justify-content: center; height: 40px; border-bottom: 1px solid currentColor; margin-bottom: 3px; background: #e9e4d6; }
.war-card .art .icon { width: 43px; height: 43px; }
.card-name { font-size: 1rem; line-height: 1.3; padding-top: 3px; margin-right: 18px; }
.card-effect { font-size: 1rem; font-weight: 500; line-height: 1.15; margin-right: 18px; }
.card-force { position: relative; z-index: 1; min-width: 64px; padding: 1px 3px; justify-self: end; margin-right: 18px; font-size: 1.125rem; line-height: 1.1; font-weight: 900; color: var(--blue); }
.war-card.selected :is(.card-name,.card-effect,.card-force) { margin-right: 0; }
.trap-face { margin: 8px auto; transform: none; }
.turn-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .875rem; }
#end-turn { margin-left: auto; min-width: 98px; }
#outcome { font-size: 1.5rem; font-weight: 900; padding: 12px 0; }
#settings { margin-top: 6px; }
summary { display: list-item; cursor: pointer; background: transparent; }
label { display: inline-flex; align-items: center; min-height: 44px; gap: 5px; font-size: 1rem; padding: 3px; }
input[type="checkbox"] { width: 22px; height: 22px; }
#storage-status { font-size: .875rem; }
#storage-status:empty { display: none; }
#turn-banner { position: fixed; top: 35%; left: 0; right: 0; max-width: 44rem; margin: auto; z-index: 7; padding: 18px; text-align: center; background: #fff; border-block: 4px solid currentColor; font-weight: 900; font-size: 1.5rem; pointer-events: none; animation: banner-in .2s ease-out; }
dialog { border: 3px solid var(--gray); border-radius: 6px; color: #202a32; background: #faf7ee; width: min(calc(100% - 20px), 36rem); max-height: calc(100dvh - 20px); padding: 10px; overflow: auto; }
dialog::backdrop { background: #202a327d; }
#battle-panel h2 { font-size: 1.125rem; text-align: center; }
.battle-armies { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin: 8px 0; }
.battle-army { position: relative; display: flex; flex-direction: column; align-items: center; padding: 9px 3px; background: #e4edf6; min-width: 0; }
.battle-army.opponent { background: #f9e8e8; }
.battle-army.defeated { color: #626c73; background: #e8ecef; }
.battle-army .formation { flex-wrap: wrap; max-width: 130px; min-height: 52px; }
.battle-army .formation .icon { width: 24px; height: 27px; margin-right: -1px; }
.battle-formation { position: relative; width: 100%; height: 58px; }
.battle-formation .formation { position: absolute; inset: 0; margin: auto; align-content: center; }
.battle-composition { font-size: .875rem; line-height: 1.3; overflow-wrap: anywhere; text-align: center; }
.battle-army > strong { font-size: 2rem; overflow-wrap: anywhere; }
.before-force { font-size: 1rem; }
.battle-army .loss { color: var(--red); font-weight: 900; font-size: 1.5rem; max-width: 100%; overflow-wrap: anywhere; text-align: center; animation: loss-rise 1.5s ease-out; }
.battle-before { opacity: 0; }
.battle-army.player .battle-before { animation: army-left .9s ease-out; }
.battle-army.opponent .battle-before { animation: army-right .9s ease-out; }
.battle-after { animation: army-settle .9s ease-out; }
.battle-power { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 4px; font-size: 1.5rem; font-weight: 900; }
#battle-close { display: block; width: 100%; margin-top: 12px; }
.wall-track { height: 24px; border: 2px solid var(--gray); background: #fff; margin: 12px 0; }
.wall-track > i { display: block; height: 100%; background: var(--red); width: var(--to); animation: wall-shrink 1s ease-out; }
.wall-numbers { font-size: 1.5rem; font-weight: 900; text-align: center; }
.wall-hit { animation: wall-hit .3s ease-out; }
#records { font-size: 1rem; }
#records-list { padding-left: 1.5rem; }
#records-list li { margin: 8px 0; overflow-wrap: anywhere; }
#flight { position: fixed; z-index: 10; pointer-events: none; border: 3px solid var(--gold); background: var(--paper); padding: 5px; color: var(--blue); font-weight: 900; animation: card-flight .4s ease-in forwards; }
#battlefield.scene-active { position: relative; height: 20.625rem; padding: 0; overflow: hidden; background: #e4dfcf; }
#battlefield.scene-active > :is(.node,.map-row,.paths) { display: none; }
.scene-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scene-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.scene-cell-target { position: absolute; transform: translate(-50%,-50%); width: 44px; height: 44px; padding: 0; opacity: 0; pointer-events: none; }
.scene-cell-target:focus-visible { opacity: 1; background: #faf7ee80; }
.scene-attack-marker { position: absolute; transform: translate(-50%,-50%); pointer-events: auto; color: #a22c32; background: #faf7ee; border: 2px solid #a22c32; font-size: 1.5rem; z-index: 2; }
.scene-loss { position: absolute; transform: translate(-50%,-50%); color: #a22c32; background: #faf7ee; border: 1px solid #a22c32; padding: 2px 4px; font-size: 1.25rem; font-weight: 900; animation: scene-loss-rise var(--loss-duration) ease-out forwards; pointer-events: none; }
@keyframes scene-loss-rise { from { transform: translate(-50%,0); } to { transform: translate(-50%,-24px); } }
@keyframes card-flight { to { transform: translate(var(--dx),var(--dy)) scale(.35); opacity: .2; } }
@keyframes army-left { 0% { opacity: 1; } 50% { transform: translateX(15px); opacity: 1; } 100% { opacity: 0; } }
@keyframes army-right { 0% { opacity: 1; } 50% { transform: translateX(-15px); opacity: 1; } 100% { opacity: 0; } }
@keyframes army-settle { 0%, 70% { opacity: 0; } 100% { opacity: 1; } }
@keyframes loss-rise { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(-3px); opacity: 1; } }
@keyframes wall-shrink { from { width: var(--from); } to { width: var(--to); } }
@keyframes wall-hit { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes banner-in { from { transform: scaleY(.8); } }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.playing main { padding-top: 4px; padding-bottom: 4px; }
.playing header { display: none; }
#war { display: flex; flex-direction: column; min-height: calc(100dvh - 8px); position: relative; }
.enemy-hud { flex-wrap: nowrap; min-height: 44px; gap: 5px; }
#enemy-hand { flex-shrink: 0; }
#enemy-hand .card-back { width: 14px; height: 22px; margin-left: -7px; }
#enemy-hand strong { margin-left: 3px; }
#menu-open { flex: 0 0 44px; font-size: 1.4rem; }
#war-log { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 0 44px; margin: 0; }
#battlefield, #battlefield.scene-active { flex: 1 0 400px; min-height: 400px; height: auto; position: relative; }
#war:has(#tutorial:not([hidden])) #battlefield { flex-basis: 330px; min-height: 330px; }
#battlefield:not(.scene-active) { display: grid; grid-template-rows: 1fr 3px 1fr 3px 1fr 3px 1fr 3px 1fr; }
.scene-canvas { position: absolute; inset: 0; }
.own-hud { min-height: 24px; gap: 2px 5px; flex-wrap: wrap; }
#supply .gem { display: none; }
#own-deck { margin-left: auto; }
#turn-count { font-size: .875rem; }
#notice { font-size: .875rem; min-height: 0; line-height: 1.2; }
#hand { min-height: 128px; padding: 7px 6px 2px; padding-right: 8px; }
.war-card { min-height: 112px; grid-template-rows: 28px auto auto; }
.war-card .art { height: 28px; position: relative; overflow: hidden; }
.war-card .card-illustration { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; opacity: 0; }
.war-card .art-loaded .card-illustration { opacity: 1; }
.war-card .art-loaded .icon { visibility: hidden; }
.war-card .art .icon { width: 30px; height: 30px; }
.turn-actions { position: absolute; bottom: 6px; right: 5px; z-index: 3; }
#end-turn { border-radius: 50%; min-width: 60px; width: 60px; min-height: 60px; padding: 5px; }
#tactic { margin-right: 5px; }
#unit-panel { position: absolute; bottom: 6px; left: 6px; right: 70px; z-index: 3; padding: 6px; max-height: 150px; overflow: auto; background: #faf7ee; border: 1px solid #626c73; font-size: 1rem; }
#unit-panel p { margin-bottom: 3px; line-height: 1.3; }
.unit-option { margin: 2px; }
#menu { max-width: 340px; }
#menu button { display: block; width: 100%; margin: 5px 0 0; }
#menu label { display: flex; }
@media (max-width: 22rem) { .enemy-hud { gap: 3px 6px; } .unit { min-width: 60px; } }
@media (min-width: 40rem) { main { padding-top: 12px; } }
[hidden] { display: none !important; }

#game-over button { display: block; width: 100%; margin-top: 10px; min-height: 52px; }
#update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 20; background: #faf7ee; color: #202a32; padding: 8px; border-bottom: 2px solid #164d88; }
#release-version { display: block; margin-top: 8px; }

.hand-card { flex: 0 0 132px; width: 132px; margin-left: -12px; position: relative; }
.hand-card:first-child { margin-left: 0; }
.hand-card .war-card { margin-left: 0; }
#tactic { position: fixed; width: 88px; z-index: 5; background: #faf7ee; color: #202a32; border: 2px solid #79551f; }
.unit-option[aria-pressed="true"] { border: 3px solid #164d88; background: #e9eff6; }
#tactic-cast { position: fixed; top: 38%; left: calc(50% - 66px); width: 132px; min-height: 150px; background: #faf7ee; border: 3px solid #79551f; z-index: 8; display: grid; place-items: center; animation: tactic-cast .6s ease-out; pointer-events: none; }
#tactic-cast .card-back { width: 80px; height: 100px; }
@keyframes tactic-cast { from { transform: translateY(120px) rotateY(180deg); } 55% { transform: translateY(0) rotateY(360deg); } to { transform: rotateY(360deg); } }
#end-turn { white-space: nowrap; width: max-content; min-width: 76px; font-size: 1rem; }
.card-effect { word-break: keep-all; overflow-wrap: anywhere; }


#skip-battle { position: absolute; bottom: 8px; right: 8px; z-index: 6; color: #202a32; background: #faf7ee; }

/* Public effects do not expose the approaching unit's identity. */
.node.dusk { outline: 2px solid #b36b2d; outline-offset: -3px; background-color: #80613d; }
.shadow-card { position: absolute; left: 42%; top: 12%; width: 23px; height: 34px; border: 2px dashed #c5bba3; background: #22272bcc; transform: skewY(-12deg); pointer-events: none; z-index: 3; }
.unit.velkasu .formation { color: #161f25; filter: drop-shadow(1px 0 #83928d); }
.scene-active .shadow-card { visibility: hidden; }
.scene-active .node.dusk { outline: none; background: transparent; }

#story-phases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 12px; }
#story-phases button { padding: 10px 8px; min-height: 60px; font-size: .9rem; white-space: normal; word-break: keep-all; overflow-wrap: anywhere; }
#story-phases [aria-selected="true"] { border: 3px solid #245789; text-decoration: underline; text-underline-offset: 4px; }
#phase-locked { font-size: .9rem; }
#dialogue-portraits .portrait-missing::before { content: ''; flex: 1; min-height: 0; background: #dad8cc; border: 1px solid #766347; }
#dialogue-portraits img[hidden] { display: none; }
#battlefield[data-theme="salt"] { background-color: #cfccb6; --theme-edge: #a3997b; }
#battlefield[data-theme="mountain"] { background-color: #acb7b1; --theme-edge: #718179; }
#battlefield[data-theme="harbor"] { background-color: #8aada8; --theme-edge: #71664e; }
.terrain-mark.lens-core { background: #202e35; border: 2px solid #84948e; transform: rotate(45deg); width: 28px; height: 28px; margin: 6px auto; }
.terrain-mark.vault { border: 3px solid #696f64; background: #b9b4a1; border-radius: 2px; }

#title-bg { width: 100%; height: 100%; object-fit: cover; }
#title-bg[hidden], .result-art[hidden] { display: none; }
.result-art { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
#result-context { font-weight: 700; overflow-wrap: anywhere; }
#result-summary { list-style: none; padding: 0; line-height: 1.6; }
#result-summary li + li { margin-top: 6px; }
#result-summary li { overflow-wrap: anywhere; }

#home.title-art-loaded { position: relative; isolation: isolate; min-height: calc(100svh - 52px); align-content: start; padding: 16px 12px 24px; }
#home.title-art-loaded .story-map-cover { position: absolute; inset: 0; height: auto; margin: 0; border: 0; background: #e8d9b8; z-index: -1; pointer-events: none; }
#home.title-art-loaded #title-bg { object-position: center top; }
#home.title-art-loaded h2 { margin: 0; padding: 12px; background: rgb(250 247 238 / 90%); line-height: 1.4; }
@media (min-aspect-ratio: 3/4) { #home.title-art-loaded #title-bg { object-fit: contain; } }

#deck-open { width: 100%; margin-block: 10px; }
#deck-editor h2 { margin-block: 12px; }
#deck-nation { max-width: 100%; }
.deck-summary { position: sticky; top: 0; z-index: 4; background: var(--paper); padding: 8px; border-bottom: 1px solid var(--gray); }
#deck-types { margin-block: 4px; }
#deck-costs { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; text-align: center; font-size: .875rem; }
.deck-cost-column > div { height: 42px; display: flex; align-items: end; background: #d6d9d8; }
.deck-cost-column i { display: block; width: 100%; background: var(--blue); }
#deck-reason { min-height: 1.5em; margin-block: 4px 0; font-size: .875rem; }
#deck-list { list-style: none; margin: 0; padding: 0; }
.deck-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding-block: 8px; border-bottom: 1px solid #b5b5a8; }
.deck-card { display: flex; align-items: center; gap: 6px; min-width: 0; text-align: left; font-size: .875rem; font-weight: 700; }
.deck-card .art { position: relative; inset: auto; flex: 0 0 64px; width: 64px; height: 40px; overflow: hidden; }
.deck-card .card-illustration { width: 100%; height: 100%; object-fit: cover; }
.deck-quantity { display: flex; align-items: center; gap: 4px; }
.deck-quantity button { width: 44px; min-height: 44px; }
.deck-quantity span { min-width: 34px; text-align: center; font-size: .875rem; }
.deck-effect { grid-column: 1 / -1; margin: 0; padding: 6px; background: var(--paper); line-height: 1.5; }
#deck-actions { position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding-block: 8px; background: var(--paper); }
#deck-reset, #deck-save-status { grid-column: 1 / -1; }
#deck-save-status { margin: 0; }
@media (max-width: 22rem) { .deck-row { grid-template-columns: minmax(0, 1fr); } .deck-quantity { justify-content: end; } }

#battlefield .units { align-items: center; align-content: center; min-height: 20px; flex-wrap: wrap; overflow: visible; pointer-events: none; justify-content: center; }
.force-badge, #battlefield .unit.force-badge { display: inline-block; min-width: 0; min-height: 0; width: auto; max-width: 100%; padding: 1px 3px; border: 1px solid currentColor; border-radius: 3px; background: var(--paper); font-size: .75rem; font-weight: 800; line-height: 1.2; pointer-events: none; white-space: nowrap; }
.force-badge.legendary { box-shadow: inset 0 0 0 1px #c69b42; }
.scene-badges { position: absolute; display: flex; gap: 2px; transform: translate(-50%,0); pointer-events: none; }
.rain-damage { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); font-size: .75rem; font-weight: 800; background: var(--paper); color: var(--red); padding: 1px 3px; pointer-events: none; }
.node.rain-selected { outline: 3px solid var(--gold); outline-offset: -3px; }
.scene-cell-target.rain-selected { opacity: 1; background: #79551f22; border: 2px solid var(--gold); pointer-events: none; }
#battlefield :is(.units,.terrain-mark,.force-badge,.rain-damage) * { pointer-events: none; }

.war-card.unavailable:not(:disabled) { opacity: .65; }
#battlefield.scene-active[data-terrain-detail="full"]::after { content: ''; position: absolute; inset: 0; border: 6px solid transparent; border-image: url('./assets/battlefield/table-edge.webp') 16 / 6px; pointer-events: none; z-index: 1; }
