:root {
    color-scheme: dark;
    --bg: #080f19;
    --panel: #101a27;
    --edge: #735c40;
    --gold: #efc787;
    --paper: #fff2dc;
    --muted: #b7beca;
    --jade: #a2e4ce;
    --game-width: clamp(340px,calc((100dvh - 176px) * .82),500px);
    --heading: Georgia, "Times New Roman", serif;
    font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
    display: grid; grid-template-rows: auto minmax(0,1fr);
    margin: 0; height: 100dvh; min-height: 560px; color: var(--paper);
    background: radial-gradient(ellipse at 50% 0%, #254050, #101b2a 46%, var(--bg) 83%);
}
button, input, summary { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
button {
    min-height: 42px; border: 1px solid #425363; border-radius: 9px;
    background: linear-gradient(#26384a,#131f30); color: var(--paper);
    padding: 8px 13px; cursor: pointer; transition: background .18s, border-color .18s, box-shadow .18s, transform .18s;
    box-shadow: inset 0 1px #bfdcfa15,0 2px 4px #0004;
}
button:hover:enabled, summary:hover { border-color: var(--gold); color: #fff7df; }
button:active:enabled { transform: translateY(1px); }
button:disabled { opacity: .48; cursor: not-allowed; }
button:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button.primary {
    border-color: #f0ca81; background: linear-gradient(#fff0bc,#deb476 49%,#b2793e 97%);
    color: #321b13; font-weight: 800; box-shadow: inset 0 0 0 2px #72502859, inset 0 0 0 3px #ffe2a96b, 0 5px 18px #1b0d08ad;
}
button.primary:hover:enabled { color: #241910; background: linear-gradient(#fff6d4,#d8a15a); box-shadow: inset 0 0 0 3px #8f653871,0 0 24px #f6ce8685; }
svg { width: 22px; height: 22px; vertical-align: middle; flex: none; }
[data-icon] { display: inline-grid; place-items: center; }
[hidden] { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.masthead {
    width: min(100%,var(--game-width)); margin-inline: auto; container-type: inline-size;
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
    min-height: 59px; padding: calc(6px + env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 6px max(12px,env(safe-area-inset-left));
    background: linear-gradient(90deg,#0c1520,#172636 53%,#0c1520); border-bottom: 1px solid #a6865554;
    box-shadow: 0 6px 28px #02071067;
}
.brand { display: inline-flex; flex: none; align-items: center; gap: 13px; color: var(--gold); font: 700 17px/1.04 var(--heading); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.brand b { display: block; margin-top: 5px; color: #fff0cc; font-size: 14px; letter-spacing: .17em; }
.brand-mark, .lobby-mark {
    border: 1px solid #f2cc87; color: #ffedb7;
    background: radial-gradient(at 50% 28%,#418074,#1d433e 58%,#0e252d);
    box-shadow: inset 0 0 0 3px #12252bd4,inset 0 0 0 4px #c5a3706b,0 0 16px #9af7d136;
}
.brand-mark { width: 43px; height: 46px; border-radius: 9px 9px 19px 19px; }
.brand-mark svg { width: 28px; height: 28px; }
.resources, .balance, .realm { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.resources { min-width: 0; flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; font-size: 13px; }
.realm, .balance { flex: none; min-height: 35px; padding: 5px 12px; border: 1px solid #ab8a5e55; border-radius: 7px; background: #0a1521b0; }
.realm { color: #eee0c7; }
.realm svg { width: 16px; height: 16px; color: #d6ab74; }
.balance { color: #ffe5ad; }
.balance svg { color: var(--jade); width: 18px; height: 18px; filter: drop-shadow(0 0 4px #94dec2a0); }
main {
    display: grid; width: min(100%,var(--game-width)); min-height: 0; margin-inline: auto;
    padding: 8px max(7px,env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(7px,env(safe-area-inset-left));
}
.layout {
    position: relative; display: grid; grid-template-rows: auto minmax(0,1fr); min-height: 0; container-type: inline-size;
    border: 1px solid #8f7150; border-radius: 15px; background: var(--panel);
    box-shadow: 0 22px 75px #0008, 0 0 0 3px #0c1722, 0 0 0 4px #b8935846;
}
.layout[data-screen="home"] { grid-template-rows: minmax(0,1fr); }
#lobby { display: grid; grid-template-rows: minmax(0,1fr) auto; min-height: 0; }
.game { display: grid; grid-template-rows: minmax(0,1fr) auto auto auto; min-width: 0; min-height: 0; overflow: hidden; border-radius: 0 0 14px 14px; }
.hall-dock {
    display: flex; justify-content: center; gap: clamp(18px,6vw,66px); padding: 9px 10px 10px;
    border-top: 1px solid #a58453; border-radius: 0 0 14px 14px; background: linear-gradient(#233b39,#101e23);
}
.hall-dock button {
    display: grid; align-content: center; justify-items: center; gap: 5px; min-height: 63px; min-width: 84px;
    padding: 3px 6px; border-color: transparent; background: none; box-shadow: none;
    color: #f6e9cd; font-size: 13px; font-weight: 700;
}
.hall-dock button [data-icon] {
    width: 40px; height: 40px; border: 1px solid #bd9b655c; border-radius: 11px;
    color: var(--gold); background: radial-gradient(at 50% 0%,#83623fbb,#222834 94%);
}
.hall-dock svg { width: 25px; height: 25px; }
.hall-dock #roster [data-icon] { color: #c8f5dd; border-color: #97d7b86b; background: radial-gradient(at 50% 0%,#458573,#193340 93%); }
.hall-dock #trainingOpen [data-icon] { color: #f4deba; border-color: #c9a77b80; background: radial-gradient(at 50% 0%,#886c60,#372f3d 93%); }
.hall-dock #questsOpen [data-icon] { color: #ffe1a8; border-color: #dfaa6885; background: radial-gradient(at 50% 0%,#9c6543,#392a37 93%); }
.quest-mark { position: relative; }
#questBadge, #giftsBadge {
    position: absolute; top: -4px; right: -7px; display: grid; place-items: center; min-width: 18px; height: 18px;
    padding-inline: 3px; border: 1px solid #ffdfaa; border-radius: 12px; background: #873a31; color: #fff8e8; font-size: 11px;
}
.gift-list { margin: 8px 0 14px; padding: 0; list-style: none; display: grid; gap: 7px; }
.gift-list li { padding: 9px; background: #1b2b3d; border: 1px solid #425363; border-radius: 7px; }
.gift-list strong { display: block; margin-bottom: 3px; color: var(--gold); }
#giftClaim, #randomRecruit { width: 100%; }
#giftExpedition {
    display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px;
    width: 100%; min-height: 58px; margin-top: 10px; text-align: left;
}
#giftExpedition[data-ready="true"] { border-color: #b2b879; }
#giftExpedition svg { color: var(--gold); width: 19px; height: 19px; }
#giftExpedition small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
#giftExpedition[data-ready="true"] small { color: var(--jade); }
#randomRecruitPanel { margin: 6px 0; }
#recruitResult {
    display: grid; grid-template-columns: 52px minmax(0,1fr) auto; align-items: center; gap: 8px;
    width: 100%; min-height: 58px; margin-top: 6px; text-align: left; border-color: #9c8259;
    background: linear-gradient(100deg,#352e3d,#122833 82%);
}
#recruitResult .recruit-sprite { height: 52px; }
#recruitResult .sprite { transform: scale(.48); }
#recruitResult strong, #recruitResult small { display: block; }
#recruitResult small { margin-top: 2px; color: var(--jade); }
#recruitResult > svg { width: 18px; height: 18px; color: var(--gold); }
.battlehead {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; padding: 7px 16px;
    background: linear-gradient(100deg,#243342,#131d2b 65%); border-radius: 14px 14px 0 0;
}
.stage-heading, .controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stage-heading { color: var(--gold); }
.stage-heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; font: 700 clamp(17px,4.8cqi,24px) var(--heading); color: var(--paper); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 6px; min-width: 42px; }
.controls { flex-shrink: 0; }
.options-trigger {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; color: #f3dbb1; font-size: 12px; font-weight: 650;
    border: 1px solid transparent; background: none; box-shadow: none; white-space: nowrap;
}
.options-trigger svg { width: 17px; height: 17px; }
#battleSpeed { display: grid; gap: 2px; width: 140px; }
#battleSpeed .speed-choices { gap: 4px; }
#battleSpeedLock { color: var(--muted); font-size: 10px; text-align: center; }
[data-screen="battle"] #options { min-width: 44px; min-height: 44px; justify-content: center; }
[data-screen="battle"] .options-label { display: none; }
[data-screen="home"] .battlehead {
    position: absolute; top: 12px; right: 14px; z-index: 2;
    min-height: 0; padding: 0; background: none; border-radius: 0;
}
[data-screen="home"] .options-trigger { background: #16201ee8; border-color: #e6c78989; box-shadow: 0 2px 9px #16100e45; }
.village {
    position: relative; isolation: isolate; overflow: hidden; border-radius: 14px 14px 0 0;
    display: grid; grid-template-rows: minmax(54px,1fr) auto;
    background: linear-gradient(180deg,#142a2aa6,transparent 28%,transparent 56%,#141c1ada 100%),
        url('./art/van-khe-village.jpg') center 54%/cover, #314d41;
}
#lobby:has(.hall-dock[hidden]) .village { border-radius: 14px; }
.village-title { position: absolute; top: 25px; left: 30px; right: 144px; z-index: 1; }
.village-title h1 {
    margin: 0; color: #fff5d9; font: 750 clamp(27px,4.6vw,56px)/1.07 var(--heading);
    text-shadow: 0 2px 3px #1c251b, 0 4px 18px #121b16b3; text-wrap: balance;
}
#giftsOpen {
    position: absolute; top: 56px; right: 12px; z-index: 2;
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 10px;
    border-color: #d2bd828c; background: linear-gradient(#314c40ed,#142d27ed); color: var(--paper);
    font-size: 13px; font-weight: 700;
}
#giftsOpen svg { width: 20px; height: 20px; color: var(--gold); }
#giftsOpen:has(#giftsBadge:not([hidden])) { border-color: #e4c883; }
#giftsBadge { top: -6px; right: -5px; }
#villageHero {
    position: relative; justify-self: center; width: 108px; height: 108px;
    transform: scale(1.38); transform-origin: center bottom; pointer-events: none;
}
#villageHero::before {
    content: ''; position: absolute; inset: auto 21px 4px; height: 19px; border-radius: 50%;
    background: #182d236b; filter: blur(4px);
}
#villageHero .sprite { position: relative; filter: drop-shadow(1px 3px 2px #10221c70); animation: village-idle 2.8s ease-in-out infinite; transform-origin: 50% 92%; }
@keyframes village-idle { 50% { transform: scale(1.018,.985) translateY(-1px); } }
.village-actions {
    position: relative; grid-row: 2; z-index: 1; display: grid; gap: 9px;
    align-content: end; width: min(100% - 24px,440px); margin: 0 auto 12px;
}
.home-guide {
    position: relative; grid-column: 1/-1;
    display: grid; grid-template-columns: 46px minmax(0,1fr) auto; align-items: center; gap: 8px;
    min-height: 72px; padding: 8px 9px; border: 1px solid #d4ab61; border-radius: 12px;
    background: #fff1d4; color: #302a21; box-shadow: 0 4px 17px #221c1b66;
}
.home-guide::after {
    content: ''; position: absolute; top: 100%; right: 65px;
    border: 5px solid transparent; border-top-color: #fff1d4;
}
.home-guide strong { display: block; color: #275950; font: 800 15px var(--heading); margin-bottom: 2px; }
.home-guide p { margin: 0; font-size: 12px; line-height: 1.4; }
#homeEquipReward {
    display: inline-flex; align-items: center; gap: 5px; min-height: 44px;
    margin-top: 5px; padding: 5px 8px; border-color: #a97b45; background: #f7dca2;
    color: #412a17; box-shadow: none; font-size: 12px; font-weight: 750;
}
#homeEquipReward:hover:enabled { border-color: #6a431f; color: #2c1b0e; background: #fbe8bf; }
#homeEquipReward svg { width: 16px; height: 16px; }
#skipHomeGuide {
    padding-inline: 5px; min-height: 44px; color: #634c35; background: transparent; border-color: transparent; box-shadow: none;
    font-size: 11px; text-decoration: underline; white-space: nowrap;
}
#skipHomeGuide:hover:enabled { color: #2c251b; border-color: #c59350; }
.mentor-portrait {
    position: relative; width: 46px; height: 46px; border: 1px solid #99733d; border-radius: 10px; overflow: hidden;
    background: radial-gradient(#75b7a0,#2a514a);
}
.mentor-portrait .sprite { position: absolute; left: -39px; top: -16px; transform-origin: top center; transform: scale(1.2); }
.challenge-panel {
    position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto;
    align-items: center; gap: 6px 8px; padding: 9px;
    border: 1px solid #c09c63; border-radius: 13px; background: linear-gradient(155deg,#233c39,#122322 70%);
    box-shadow: 0 6px 22px #100e0bbf, inset 0 0 0 3px #122320;
}
.challenge-stage { grid-area: 1 / 1; display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 3px; }
.challenge-stage > [data-icon] { color: #ebd1a0; }
.challenge-stage small { display: block; color: #f6cc86; font-size: 11px; font-weight: 700; }
.challenge-stage strong { display: block; color: #fff3d8; font: 700 clamp(13px,3.7vw,16px)/1.2 var(--heading); margin-top: 3px; }
.village-primary-actions { grid-column: 1/-1; display: flex; gap: 6px; }
#start { flex: 1; min-width: 0; min-height: 52px; padding: 7px 12px; font: 800 18px var(--heading); }
#prepGuideOpen { display: inline-flex; align-items: center; gap: 4px; padding-inline: 7px; font-size: 12px; white-space: nowrap; }
#prepGuideOpen svg { width: 17px; height: 17px; color: var(--gold); }
#start svg { width: 21px; height: 21px; margin-right: 4px; }
#homeStageRewards {
    grid-column: 1/-1; display: flex; align-items: center; justify-content: space-between; gap: 6px;
    border-top: 1px solid #e8c78449; padding-top: 6px;
}
#homeRewardTitle { display: block; color: #e6d0a4; font-size: 11px; }
.stage-rewards ul { margin: 5px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; list-style: none; }
.stage-rewards li { display: flex; gap: 4px; align-items: center; font-size: 11px; color: var(--paper); }
.stage-rewards svg { width: 14px; height: 14px; color: var(--jade); }
.stage-reward-gear {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px;
    border-color: #8f794f; color: var(--gold); padding: 2px 7px; font-size: 11px;
}
.stage-reward-gear svg { flex: 0 0 auto; color: currentColor; }
.stage-rewards .stage-reward-companions { flex-basis: 100%; flex-wrap: wrap; }
.stage-reward-companions > span { display: inline-flex; flex-basis: 100%; align-items: center; gap: 4px; }
.stage-reward-companions button {
    min-height: 44px; padding: 2px 6px; border-color: #68918a; font-size: 11px; color: var(--jade);
}
#homeScout {
    display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; min-height: 44px; padding: 5px 7px;
    border-color: #8a9c81; background: #23413a; color: var(--paper); font-size: 12px; white-space: nowrap;
}
#homeStageMechanic { grid-column: 1/-1; min-width: 0; }
.stage-mechanic {
    display: flex; align-items: flex-start; gap: 6px; width: 100%; margin: 0;
    padding: 5px 7px; border: 1px solid #a98d625e; border-radius: 6px; background: #213744;
    color: #ffe2ae; font-size: 12px; line-height: 1.35;
}
.stage-mechanic svg { width: 15px; height: 15px; }
#homeGuardRoster { min-height: 44px; text-align: left; align-items: center; }
#homeGuardRoster strong { color: #bce9d8; text-decoration: underline; white-space: nowrap; }
.stage-story { grid-area: 1 / 2; text-align: left; justify-self: end; }
.stage-story p { position: absolute; z-index: 1; inset: auto 0 100%; max-height: min(150px,26dvh); overflow: auto; }
#retryAction { min-height: 42px; font-size: 12px; white-space: nowrap; padding-inline: 9px; }
.viewport {
    position: relative; display: grid; place-items: center; container-type: size;
    overflow: hidden; background: radial-gradient(ellipse,#1c3745,#0b1724 75%);
    border-block: 1px solid #9e8053; isolation: isolate;
}
.viewport::after {
    position: absolute; inset: 3px; z-index: 2; pointer-events: none; content: "";
    border: 1px solid #e1c18e41; box-shadow: 0 0 0 3px #06111a7d, inset 0 0 35px #06111aa6;
}
canvas {
    display: block; width: 100%; width: min(100%,calc(100cqh * 920 / 1080)); height: auto;
    touch-action: manipulation; box-shadow: 0 0 24px #06111a90;
}
.battle-target-picker {
    position: absolute; z-index: 3; inset: 5px 8px auto;
    display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 7px;
    width: min(340px,calc(100% - 16px)); margin-inline: auto; padding: 3px 7px;
    border: 1px solid var(--edge); border-radius: 9px; background: #0b1927; color: var(--paper);
}
.battle-target-picker label { font-size: 12px; font-weight: 700; color: var(--gold); }
.battle-target-picker:has(#battleTargetDetails:not([hidden])) { grid-template-columns: auto minmax(0,1fr) auto; }
.battle-target-picker:has(#battleTargetFixed:not([hidden])) { grid-template-columns: minmax(0,1fr) auto; }
#battleTargetFixed { padding-inline-start: 4px; color: var(--gold); font-size: 13px; }
#battleTargetDetails { width: 44px; min-height: 44px; color: var(--gold); }
#battleTargetDetails svg { width: 18px; height: 18px; }
.battle-target-picker select {
    min-width: 0; min-height: 44px; padding: 4px 6px; border: 1px solid var(--edge); border-radius: 5px;
    font: inherit; font-size: 13px; color: var(--paper); background: #173043;
}
.battle-target-picker select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#battleTargetVitals {
    display: flex; grid-column: 1/-1; align-items: center; flex-wrap: wrap; gap: 3px 10px;
    color: var(--jade); font-size: 11px; font-variant-numeric: tabular-nums;
}
#battleTargetVitals > span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#battleTargetVitals svg { width: 13px; height: 13px; }
#battleTargetVitals .target-health { flex: 1 1 auto; min-width: 0; }
#battleTargetMeter { flex: 1; min-width: 12px; max-width: 72px; height: 5px; margin-left: 3px; accent-color: var(--jade); }
#battleTargetWard { color: var(--gold); }
#battleTargetEffects { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; margin: 0; padding: 0; list-style: none; }
#battleTargetEffects li { padding: 1px 3px; border-radius: 4px; background: #243643; white-space: nowrap; }
#battleTargetEffects li > [aria-hidden] { display: flex; align-items: center; gap: 2px; }
#battleTargetEffects svg { width: 12px; height: 12px; }
#battleTargetEffects b { font-size: 10px; line-height: 1; }
#battleTargetEffects:has(li:nth-child(8)) b { display: none; }
#result { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 12px; }
.lobby-mark { width: 65px; aspect-ratio: 1; border-radius: 15px 15px 24px 24px; }
.lobby-mark svg { width: 58%; height: 58%; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
.stage-story summary {
    display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 4px 8px;
    border: 1px solid #f4d6a345; border-radius: 7px; background: #0b182573; color: #ffe7b8; font-size: 12px;
}
.stage-story summary svg { width: 16px; height: 16px; }
.stage-story p { color: var(--paper); background: #0a1e29fd; border: 1px solid #c19857; margin: 0 0 6px; padding: 10px 12px; border-radius: 7px; font-size: 12px; line-height: 1.45; }
#result { background: #061b27db; backdrop-filter: blur(3px); gap: 8px; align-content: safe center; overflow: auto; }
#result h2 { font: 500 clamp(30px,5vw,52px) Georgia,serif; margin: 0; color: var(--gold); }
#result p { margin: 0; color: var(--muted); }
#escortResultReward { color: var(--jade); }
#result #defeatHint { max-width: 31ch; color: #ffe0b4; font-size: 14px; line-height: 1.45; }
#result :is(#defeatRestartNotice,#resultLeaveNotice) { max-width: 31ch; color: var(--gold); font-size: 13px; line-height: 1.4; }
#result button { margin-top: 8px; }
#result #resultLeaveRetry { min-height: 44px; margin: 0; }
.boss-breakdown { width: min(300px,100%); text-align: left; }
.boss-breakdown h3 { margin: 2px 0 5px; color: var(--gold); font-size: 13px; }
.boss-damage-list { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.boss-damage-list li {
    display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 5px;
    padding: 4px 7px; border: 1px solid #55716c; border-radius: 5px;
    background: linear-gradient(90deg,#2b5049 var(--damage-share),#142e36 var(--damage-share));
    font-size: 12px; line-height: 1.2;
}
.boss-damage-list small { margin-right: 5px; color: var(--gold); }
.boss-damage-list strong { color: var(--jade); font-variant-numeric: tabular-nums; }
#result .boss-unattributed { margin-top: 5px; font-size: 11px; }
#result .recruits-result { color: var(--jade); font-weight: 750; }
.recruits-result:has(.recruit-cards) { width: min(100%,354px); }
.recruits-heading { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 5px; }
#result .recruits-heading p { color: var(--jade); font-size: 13px; }
#result #formationAfterBattle {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: 0; padding: 4px 8px;
    border-color: #68918a; color: var(--jade); font-size: 12px;
}
#formationAfterBattle svg { width: 16px; height: 16px; }
.recruit-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
#result .recruit-cards button {
    position: relative; display: flex; gap: 4px; align-items: center; flex: 0 1 calc(50% - 3px);
    min-width: 0; min-height: 63px; margin: 0; padding: 19px 5px 3px;
    border-color: #68918a; text-align: left; font-size: 12px;
}
.recruit-sprite { display: block; flex: 0 0 42px; height: 42px; overflow: hidden; }
.recruit-sprite .sprite { transform: scale(.39); transform-origin: top left; }
.recruit-cards strong { display: block; overflow-wrap: anywhere; line-height: 1.15; }
.recruit-cards small { display: block; margin-top: 2px; color: var(--jade); font-size: 11px; }
#result .equipment-result { color: var(--gold); }
#result button.equipment-result {
    display: inline-flex; align-items: center; gap: 6px; min-height: 42px; max-width: 100%; margin: 0;
    border-color: #8f794f; font-size: 13px;
}
#result button.equipment-result svg:last-child { width: 17px; height: 17px; }
#result .ore-reward, .materials-summary strong, #equipmentEnhancement strong { color: #ffc387; }
.result-actions, .story-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.result-shortcuts { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; }
#result .result-shortcuts button { margin-top: 0; padding-inline: 9px; font-size: 12px; }
.result-shortcuts svg { width: 17px; height: 17px; }
#result #resultStoryOpen { min-height: 44px; margin: 0; color: var(--gold); font-size: 13px; }
#resultStoryOpen svg { width: 17px; height: 17px; }
.match-guide {
    display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 4px 10px;
    color: #ffedce; background: #293b37; border-bottom: 1px solid #d4ac6859; font-size: 12px;
}
.match-guide svg { width: 17px; height: 17px; color: var(--gold); }
.match-guide p { margin: 0; line-height: 1.35; }
.match-guide.required-lesson { grid-template-columns: auto 1fr; border-color: #c29d64; }
.combat-button.lesson-action:enabled { border-color: #ffe4a1; box-shadow: 0 0 11px #ebb46566; }
.modalhead .lesson-step { margin: 0 0 4px; color: var(--gold); font-size: 12px; }
#guideTrainAction { width: 100%; }
#guideTrainNotice:empty { margin: 0; }
#dismissMatchGuide { white-space: nowrap; min-height: 44px; padding-inline: 6px; font-size: 11px; }
.commandbar {
    display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center;
    gap: clamp(8px,2vw,26px); min-height: 95px; padding: 8px 16px 10px;
    background: radial-gradient(ellipse at 88% 0,#243b4d,#101a27 74%); border-radius: 0 0 14px 0;
}
.turn { display: flex; align-items: center; gap: 10px; min-width: 0; }
.skill-spread-preview {
    grid-column: 1/-1; display: flex; align-items: center; gap: 6px; margin: 0; padding: 5px 7px;
    border-radius: 6px; background: #233747; color: #fff0ca; font-size: 12px; line-height: 1.35;
}
.skill-spread-preview svg { width: 16px; height: 16px; color: var(--gold); }
.skill-spread-preview[data-restricted="true"] { background: #322740; color: #f3dfff; }
.skill-spread-preview[data-restricted="true"] svg { color: #e2bbff; }
#actorPortrait {
    width: 59px; height: 59px; flex: 0 0 59px; overflow: hidden; display: grid; place-items: start center;
    border-radius: 13px; border: 1px solid #b89762; background: radial-gradient(at top,#355f62,#122638 82%);
    box-shadow: inset 0 0 0 3px #09142088,0 0 12px #92cfb52b;
}
#actorPortrait .sprite { transform: scale(.62); transform-origin: 0 0; margin-left: -5px; }
.turn-copy { display: grid; gap: 4px; min-width: 0; }
#round { color: var(--gold); font-size: 11px; font-variant-numeric: tabular-nums; }
#actor { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 700 17px var(--heading); }
#nextActor { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--jade); font-size: 10px; }
#nextActor[data-side="enemy"] { color: #ffc1ac; }
.actions, .manual-actions { display: flex; gap: clamp(6px,1vw,13px); }
.combat-button {
    min-width: 72px; min-height: 62px; padding: 5px 8px; border-radius: 11px; display: grid; place-content: center; justify-items: center;
    position: relative; border-color: #ad8d60; background: radial-gradient(at 40% 28%,#4b6976,#1c3040 64%,#142030);
    box-shadow: inset 0 0 0 2px #09131c9c,0 4px 11px #0006; white-space: nowrap; color: #fff0ce;
}
.combat-button b { font-size: 12px; line-height: 1.2; }
.combat-button svg { width: 26px; height: 26px; color: #ffe5ac; filter: drop-shadow(0 0 4px #e7c07b8b); }
.combat-button.power-button { background: radial-gradient(at 50% 25%,#735397,#28213b 84%); border-color: #bd9bcc; }
.power-button:disabled:not(.charged) { opacity: .79; }
.charge-ring {
    position: absolute; width: 32px; height: 32px; top: 7px; left: calc(50% - 16px); border-radius: 50%; padding: 1px; pointer-events: none;
    background: conic-gradient(#ffe8a7 var(--charge,0%),#e2c0fc26 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
}
.power-button.charged { opacity: 1; border-color: #ffe3a2; box-shadow: 0 0 15px #e8b4658c,inset 0 0 14px #e8b46570; }
#skillQi { font-size: 10px; color: #e8d4ff; }
#auto { min-width: 110px; border-color: #5c8c90; color: #eaf8e9; display: inline-flex; align-items: center; gap: 6px; }
#auto[aria-pressed="true"] { background: radial-gradient(at 38% 20%,#357962,#17383f 86%); border-color: #a8edce; }
#auto svg { width: 18px; height: 18px; color: #cbfae8; }
dialog {
    width: min(var(--game-width),calc(100% - 26px));
    max-height: min(92dvh,calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px));
    inset-block: env(safe-area-inset-top) env(safe-area-inset-bottom); padding: 12px;
    color: var(--paper); background: radial-gradient(ellipse at 30% 0%,#263746,#101b2a 70%);
    border: 1px solid #b29060; border-radius: 13px; box-shadow: 0 26px 95px #000a;
}
dialog::backdrop { background: #07141dd1; backdrop-filter: blur(4px); }
#welcome {
    max-width: 600px; padding: 0; border-color: #ad8c5a;
    background: #142431; box-shadow: 0 27px 95px #000c,0 0 0 4px #0b1725,0 0 0 5px #b894585b;
}
.dialogintro {
    min-height: 405px; display: grid; justify-items: center; align-content: end; gap: 16px;
    padding: 74px 22px 31px; text-align: center;
    background: linear-gradient(#0b172417 18%,#0b172442 45%,#0b1724f5 93%), url('./art/moon-gate.jpg') center 20%/cover;
}
.dialogintro .lobby-mark { width: 60px; }
.dialogintro h2, .modalhead h2 { font-family: var(--heading); margin: 0; }
.dialogintro h2 { font-size: clamp(30px,6vw,48px); text-wrap: balance; color: #ffe8b6; text-shadow: 0 3px 12px #09121c,0 0 24px #eebc7377; }
.welcome-actions { width: min(350px,100%); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.welcome-actions button { min-height: 49px; padding-inline: 5px; }
.dialogintro button svg { margin-right: 4px; width: 19px; height: 19px; }
.modalhead { display: flex; align-items: start; justify-content: space-between; margin-bottom: 8px; }
.modalhead h2 { font-size: 25px; }
#heroes .modalhead {
    position: sticky; top: -12px; z-index: 2;
    margin: -12px -12px 8px; padding: 12px 12px 8px; background: #1b2a3a;
}
.roster-heading { display: flex; align-items: center; gap: 9px; }
.roster-heading .icon-button { flex: none; }
#heroes:has(#heroDetail:not([hidden])) { max-height: min(96dvh,calc(100dvh - 12px)); }
#heroes:has(#heroDetail:not([hidden])) .modalhead h2 { font-size: clamp(19px,6.1vw,25px); }
#formationHint { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
dialog.sheet { max-width: 476px; }
#equipmentPopup { max-width: 372px; padding: 15px; }
#equipmentPopup::backdrop { background: #07141da8; backdrop-filter: blur(1px); }
.equipment-popup-heading { display: flex; align-items: center; gap: 9px; min-width: 0; }
.equipment-popup-heading h2 { font-size: clamp(18px,5.8vw,23px); line-height: 1.16; }
#equipmentPopupGrade { margin: 4px 0 0; color: var(--gold); font-size: 12px; }
#equipmentPopupIcon {
    display: grid; place-items: center; flex: 0 0 45px; height: 45px; border-radius: 9px;
    border: 1px solid #b58e52; background: #302a2e; color: var(--gold);
}
#equipmentPopupIcon svg { width: 26px; height: 26px; }
#equipmentPopup .modalhead { gap: 7px; }
#equipmentPopup .icon-button { width: 42px; min-width: 42px; }
#equipmentPopupStats { display: grid; gap: 5px; margin: 13px 0 10px; }
#equipmentPopupStats > span {
    display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 6px;
    padding: 8px 10px; border-radius: 7px; background: #0d1d2b; font-size: 13px;
}
#equipmentPopupStats svg { width: 17px; height: 17px; color: var(--gold); }
#equipmentPopupStats strong { color: var(--jade); }
#equipmentPopupStatus { margin: 11px 0; color: var(--muted); font-size: 13px; }
#equipmentPopupManage, #equipmentPopupStage, #equipmentPopupSources { width: 100%; }
#equipmentPopupSources { min-height: 44px; }
#equipmentPopupAlternatives { margin: 0 0 8px; }
#equipmentPopupAlternatives summary {
    display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px;
    border: 1px solid #6f8992; border-radius: 7px; background: #18323e; color: var(--paper); font-size: 13px;
}
#equipmentAlternativesCount { margin-left: auto; color: var(--jade); font-weight: 700; }
#equipmentPopupAlternatives summary::after {
    content: ''; width: 6px; height: 6px; border: solid var(--jade); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
#equipmentPopupAlternatives[open] summary::after { transform: rotate(225deg); }
#equipmentAlternativeList { display: grid; gap: 5px; padding-top: 6px; }
#equipmentAlternativeList button { min-height: 44px; font-size: 13px; }
#equipmentAlternativeList svg { width: 20px; height: 20px; color: var(--gold); }
#campaignScout { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px); }
:is(#campaignScout,#settings,#formationMoves) .modalhead {
    position: sticky; top: -12px; z-index: 1; gap: 8px;
    margin: -12px -12px 8px; padding: 12px; background: #243544;
}
#scoutStage { margin: 4px 0 0; color: var(--gold); font-size: 13px; }
.scout-grid, #scoutSlots, .arena-preview-slots { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.scout-grid { margin-block: 8px; }
.scout-grid > strong { text-align: center; color: var(--muted); font-size: 12px; }
#scoutSlots, .arena-preview-slots { grid-column: 1/-1; }
:is(#scoutSlots,.arena-preview-slots) > * {
    display: flex; align-items: center; gap: 4px; min-height: 46px; padding: 3px 4px; text-align: left;
    border: 1px solid #465d66; border-radius: 7px; background: #142631; font-size: 12px; line-height: 1.15;
}
#scoutSlots button[aria-pressed="true"] { border-color: #d3a768; background: #31433e; color: #ffebba; }
.scout-number { flex: 0 0 17px; text-align: center; color: var(--gold); font-size: 11px; }
.scout-portrait {
    position: relative; flex: 0 0 27px; height: 32px; overflow: hidden;
    border-radius: 4px; background: radial-gradient(#54736b,#1a3038);
}
.scout-portrait .sprite {
    position: absolute; top: -4px; left: -40px; transform-origin: top center; transform: scale(.69);
}
:is(#scoutSlots,.arena-preview-slots) small { display: block; margin-top: 2px; color: #bce9d8; font-size: 10px; }
.scout-empty { color: var(--muted); }
.scout-skills { padding: 9px 10px; border: 1px solid #647071; border-radius: 8px; background: #142631; }
.scout-skills h3 { display: inline; margin: 0; color: var(--gold); font-family: var(--heading); }
#scoutRole { margin-left: 5px; color: var(--jade); font-size: 12px; }
.scout-skills dl { margin: 7px 0 0; }
.scout-skills dt { display: flex; align-items: center; gap: 7px; color: var(--paper); font-size: 13px; font-weight: 750; }
.scout-skills dt > span { min-width: 0; overflow-wrap: anywhere; }
.scout-skills dt .icon-button { flex: 0 0 44px; min-height: 44px; margin-inline-start: auto; }
.scout-skills dt .icon-button svg { width: 17px; height: 17px; color: var(--gold); }
.scout-move-icon { display: flex; flex: none; }
.scout-move-icon .hero-skill-icon { width: 31px; height: 31px; }
#scoutScope { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--jade); font-size: 11px; }
#scoutScope svg { width: 14px; height: 14px; }
.scout-skills dd { margin: 4px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
#scoutOpeningTargets strong { display: flex; align-items: center; gap: 4px; color: #ffca9a; }
#scoutOpeningTargets svg { width: 14px; height: 14px; }
#scoutOpeningSlots { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0; padding: 0; list-style: none; }
#scoutOpeningSlots li { padding: 3px 6px; border: 1px solid #936042; border-radius: 5px; background: #3b2a2b; color: #ffead5; }
.ultimate-effects { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 2px; padding: 0; list-style: none; }
.ultimate-effects li {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 5px; border-radius: 4px;
    background: #20313d; color: var(--effect-color); font-size: 11px; line-height: 1.35;
}
.ultimate-effects li svg { width: 13px; height: 13px; color: inherit; }
.scout-skills dd:last-child { margin-bottom: 0; }
#scoutBasicTip[hidden] + dt { margin-top: 6px; }
#scoutTactic { margin-top: 8px; }
#scoutFormation { width: 100%; min-height: 44px; margin-top: 8px; }
.training-status { padding: 16px 0 8px; text-align: center; color: var(--gold); }
.training-status [data-icon] { display: grid; margin: 0 auto 8px; }
.training-status [data-icon] svg { width: 35px; height: 35px; }
.training-status strong { font: 800 29px var(--heading); }
.training-status p { color: var(--muted); font-size: 13px; }
#cultivate { display: block; width: 100%; }
#cultivateCost { margin-left: .35em; font-size: 12px; }
#trainingReward { width: 100%; margin-top: 12px; }
.training-heroes { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid #4a616c; }
.training-heroes p, .roster-note { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.training-heroes button { flex-shrink: 0; }
.training-equipment {
    width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 8px;
    align-items: center; text-align: left; margin-top: 12px;
}
.training-equipment svg, .equipment-item svg { color: var(--gold); }
.training-equipment.materials-entry svg { color: #ffc387; }
.training-equipment small, #equipmentSlot, .equipment-item small { color: var(--muted); }
.expedition-card {
    display: grid; justify-items: center; gap: 5px; padding: 12px; margin-bottom: 12px;
    border: 1px solid #648388; border-radius: 10px; background: radial-gradient(at 50% 15%,#355456,#192d3b 78%);
    text-align: center;
}
.expedition-card p { margin: 0; color: var(--muted); font-size: 13px; }
.expedition-card strong { color: var(--gold); }
.expedition-card svg { width: 22px; height: 22px; vertical-align: middle; }
#expeditionTitle { font-size: clamp(21px,6.8vw,25px); }
#expeditionPicker { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
#expeditionHero { width: 100%; min-height: 42px; }
#expeditionAction { width: 100%; margin-top: 12px; }
#expeditionNotice:empty { display: none; }
#trialsTitle { font-size: clamp(20px,6.7vw,25px); }
#escortTitle { font-size: clamp(19px,6vw,26px); }
.trial-info { padding: 12px 5px; display: grid; gap: 6px; }
.trial-info h3, .trial-info p { margin: 0; }
.trial-info h3 { font: 700 21px var(--heading); }
.trial-info p { color: var(--muted); font-size: 14px; }
.trial-info strong { color: var(--gold); }
.trial-info small { color: var(--muted); }
.trial-info svg { width: 18px; height: 18px; vertical-align: middle; }
.trial-actions { display: flex; gap: 7px; }
.trial-actions button { flex: 1; }
#trialNotice:empty { display: none; }
#escortTeam { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; margin: 4px 0 0; padding: 0; list-style: none; }
#escortTeam li { display: grid; gap: 2px; border: 1px solid var(--edge); border-radius: 7px; padding: 6px; font-size: 12px; }
#escortNotice:empty { display: none; }
.activity-art { display: block; width: 100%; height: clamp(122px,22vw,190px); object-fit: cover; border: 1px solid #9b8f73; border-radius: 10px; }
.materials-art { border-color: #aa7653; }
#materialsOpening, #towerOpening { color: var(--muted); font-size: 14px; line-height: 1.5; }
.materials-summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; font-size: 13px; }
.materials-summary svg, #equipmentEnhancement svg { width: 17px; height: 17px; }
#materialsStart, #towerStart { width: 100%; margin-top: 12px; }
#towerFloors { margin-top: 10px; }
#towerReward, #towerGuard { margin: 6px 0 0; font-size: 13px; line-height: 1.45; }
#towerReward { color: var(--gold); }
#towerGuard { color: #ffdbad; }
#battleCondition {
    display: grid; grid-template-columns: 18px minmax(0,1fr); align-items: start; gap: 4px 8px;
    padding: 8px 10px; border-block-end: 1px solid #856544; background: #342d30; color: #ffdbad;
    font-size: 13px; line-height: 1.38;
}
#battleCondition p { margin: 0; }
#battleCondition svg { width: 17px; height: 17px; }
#battleCondition small { display: block; margin-top: 3px; color: var(--paper); font-size: 11px; }
#battleCondition[data-status="threat"] { color: #ffe0c2; background: #482c35; border-color: #a55d53; }
#battleCondition[data-status="shield"] { color: #cce9ff; background: #1f3347; border-color: #557ca0; }
#battleCondition[data-status="cleared"] { color: var(--jade); background: #203633; border-color: #4f7767; }
#battleConditionTarget { grid-column: 2; justify-self: start; margin-top: 3px; padding: 5px 9px; min-height: 42px; font-size: 12px; color: var(--gold); }
#bossProgress { padding: 7px 10px; background: #272139; border-bottom: 1px solid #6d557a; }
.boss-progress-scores { display: flex; justify-content: space-between; align-items: center; gap: 4px 12px; flex-wrap: wrap; font-size: 13px; }
.boss-progress-scores strong { color: var(--paper); }
.boss-progress-scores > span { color: var(--gold); }
.boss-progress-scores svg { width: 15px; height: 15px; vertical-align: middle; }
#bossTierMeter { display: block; appearance: none; width: 100%; height: 5px; margin: 5px 0; border: 0; border-radius: 3px; overflow: hidden; background: #503d60; }
#bossTierMeter::-webkit-progress-bar { background: #503d60; }
#bossTierMeter::-webkit-progress-value { background: #efc577; }
#bossTierMeter::-moz-progress-bar { background: #efc577; }
#bossNextTier { margin: 0; color: var(--muted); font-size: 12px; }
.boss-retreat-actions { display: flex; gap: 8px; }
.boss-retreat-actions button { flex: 1; }
#bossRetreatNotice:empty { display: none; }
#equipmentList { display: grid; gap: 6px; }
.equipment-item {
    display: grid; grid-template-columns: 26px minmax(0,1fr) auto; gap: 8px;
    align-items: center; text-align: left;
}
.equipment-item[aria-pressed="true"] { border-color: var(--gold); background: #293b46; }
.equipment-item small { line-height: 1.25; }
.equipment-item svg:last-child { width: 16px; height: 16px; color: var(--muted); }
.equipment-detail { margin-top: 14px; padding: 12px; border: 1px solid #495966; border-radius: 9px; background: #132531; }
.equipment-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; justify-content: space-between; }
.equipment-heading h3 { margin: 0; color: var(--gold); font: 700 18px var(--heading); }
#equipmentStatus, #equipmentNotice, #equipmentSlot, .equipment-controls label { font-size: 13px; }
#equipmentStatus { margin: 8px 0 0; color: var(--muted); }
.equipment-controls { display: flex; align-items: end; gap: 8px; }
.equipment-controls:has(button:not([hidden])) { margin-top: 10px; }
.equipment-controls label { display: grid; gap: 4px; flex: 1; min-width: 0; }
.equipment-controls select {
    width: 100%; min-height: 42px; padding: 6px 8px; border: 1px solid #617386; border-radius: 7px;
    background: #203341; color: var(--paper); font: inherit;
}
.equipment-controls select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.equipment-controls button { flex-shrink: 0; }
#equipmentRecipientPreview { margin-top: 8px; padding: 7px 8px; border-radius: 6px; background: #203443; font-size: 13px; }
#equipmentRecipientPreview p { margin: 0 0 4px; color: var(--muted); }
#equipmentRecipientStats { margin: 0; display: grid; gap: 4px; }
#equipmentRecipientStats > div { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 8px; }
#equipmentRecipientStats dt { display: inline-flex; align-items: center; gap: 4px; }
#equipmentRecipientStats svg { width: 14px; height: 14px; color: var(--gold); }
#equipmentRecipientStats dd { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
#equipmentRecipientStats strong { color: var(--jade); }
#equipmentRecipientStats .stat-loss { color: #ffc5a8; }
#equipmentRecipientPower { border-top: 1px solid #697986; padding-top: 4px; }
#equipmentRecipientPower dt { color: var(--gold); font-weight: 700; }
#equipmentRecipientEven { margin: 0; }
#equipmentEnhancement {
    display: flex; gap: 9px; justify-content: space-between; align-items: center; flex-wrap: wrap;
    border-top: 1px solid #4c5966; margin-top: 12px; padding-top: 10px; font-size: 13px;
}
#enhanceSummary { color: var(--muted); margin: 3px 0 0; line-height: 1.4; }
#enhanceAction { flex-shrink: 0; padding-inline: 8px; }
#enhanceCost { display: block; margin-top: 2px; color: var(--muted); }
#equipmentNotice { margin: 8px 0 0; color: var(--gold); }
#equipmentNotice:empty { display: none; }
#equipmentRetry { margin-top: 8px; }
.roster-note:empty { display: none; }
#storyModal[open] { display: flex; flex-direction: column; overflow: hidden; }
#storyModal > :not(#storyReader) { flex-shrink: 0; }
#storyModal .modalhead { gap: 8px; }
#storyModal .text-close, .story-actions button { min-height: 44px; }
#storyReader { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#storyReader:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 9px; }
#storyOpening { margin: 0 0 12px; color: var(--muted); line-height: 1.5; font-size: 14px; text-wrap: pretty; }
#storyStageNumber, #resultEndingLabel { margin: 0 0 4px; color: var(--gold); font-size: 12px; }
#resultEnding .modalhead {
    position: sticky; top: -12px; z-index: 1; gap: 8px;
    margin: -12px -12px 8px; padding: 12px; background: #243544;
}
#resultEndingClose { min-height: 44px; white-space: nowrap; }
#resultEndingText { margin: 10px 0 0; padding: 12px; border: 1px solid #ab895d; border-radius: 9px; background: #172b32; font-size: 15px; line-height: 1.65; text-wrap: pretty; }
#resultEndingActions {
    position: sticky; bottom: -12px; z-index: 1;
    margin: 0 -12px -12px; padding: 10px 12px 12px; background: #243544;
}
#resultEndingNext { width: 100%; min-height: 44px; }
#storyLine { display: grid; grid-template-columns: 74px minmax(0,1fr); align-items: center; gap: 10px; padding: 8px; min-height: 102px; border: 1px solid #ab895d; background: #172b32; border-radius: 9px; }
#storyPortrait { width: 73px; height: 78px; overflow: hidden; border-radius: 8px; background: radial-gradient(at top,#497369,#152938); }
#storyPortrait .sprite { transform: scale(.72); transform-origin: 0 0; }
#storySpeaker { color: var(--gold); }
#storySpeech { margin: 3px 0; line-height: 1.4; font-size: 14px; }
#storyAftermath {
    padding: 12px;
    border: 1px solid #ab895d; border-radius: 9px; background: #172b32;
}
#storyAftermath strong { color: var(--gold); }
#storyAftermath p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; }
#storyRewards { margin-top: 8px; border: 1px solid #a98d625e; border-radius: 8px; background: #182c38; }
#storyRewards summary {
    display: flex; min-height: 44px; align-items: center; gap: 6px; padding: 6px 8px;
    color: var(--gold); font-size: 13px; font-weight: 700;
}
#storyRewards summary span:last-child { margin-left: auto; }
#storyRewards[open] summary span:last-child { transform: rotate(90deg); }
#storyRewardList { margin: 0; padding: 0 8px 8px; }
#storyScout { align-self: flex-start; min-height: 44px; margin-top: 10px; }
.story-actions { justify-content: flex-end; margin-top: 12px; }
.story-actions button { min-width: 90px; }
.story-actions:has(#previousStory:not([hidden])):has(#skipStory:not([hidden])) {
    display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px;
}
.story-actions:has(#previousStory:not([hidden])):has(#skipStory:not([hidden])) button {
    min-width: 0; padding-inline: 3px;
}
#storyNotice { margin: 8px 0 0; font-size: 13px; color: var(--gold); }
#storyNotice:empty { display: none; }
#progress { font: 600 12px system-ui; color: var(--gold); }
.text-close { display: flex; gap: 5px; align-items: center; font-size: 12px; padding-inline: 8px; }
.text-close svg { width: 16px; height: 16px; }
.encounter-list, .setting-rows { display: grid; gap: 5px; }
.encounter-list button, .setting-rows > button, .setting-rows summary {
    display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center;
    gap: 9px; min-height: 45px; text-align: left; padding: 6px 9px; font-size: 13px;
}
.encounter-list button b { font-weight: 650; }
.encounter-list svg, .setting-rows svg { width: 17px; height: 17px; color: var(--gold); }
.encounter-list button[aria-pressed="true"] { border-color: #c49a61; background: #443a32; }
.campaign-stage-row { display: flex; gap: 5px; }
#campaignChapter {
    width: 100%; min-height: 44px; margin: 8px 0; padding: 5px 9px;
    border: 1px solid #8f794f; border-radius: 8px; background: #192d3b; color: var(--paper); font: inherit; font-size: 13px;
}
.campaign-stage-row > [data-stage] { flex: 1; min-width: 0; }
#stages button { min-height: 44px; }
#stages .stage-replay { display: inline-flex; color: var(--gold); white-space: nowrap; }
#campaignFrontier { width: 100%; min-height: 44px; margin: 0 0 9px; }
#campaignFrontier svg { width: 18px; height: 18px; }
#summaryOpen { width: 100%; margin: 0 0 9px; text-align: left; color: var(--gold); }
#summaryOpen svg { width: 18px; height: 18px; }
#journalOpen { width: 100%; margin: 0 0 9px; text-align: left; }
#journalOpen svg, #journalEnding svg { width: 19px; height: 19px; color: var(--gold); }
#storyJournal .modalhead h2 { font-size: clamp(20px,6.6vw,25px); }
#storyJournal .text-close { white-space: nowrap; }
#journalChapters { display: flex; gap: 5px; margin: 8px 0 14px; }
#journalChapters button { flex: 1; padding-inline: 4px; }
#journalChapters [aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: #443a32; }
.journal-chapter { display: flex; justify-content: space-between; align-items: baseline; gap: 7px; margin-bottom: 8px; }
.journal-chapter h3 { margin: 0; font: 700 17px var(--heading); }
#journalProgress { color: var(--jade); font-size: 12px; white-space: nowrap; }
#journalEnding {
    display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: center;
    width: 100%; margin-top: 12px; padding: 9px; text-align: left; border-color: #a38358;
}
#journalEnding small { display: block; color: var(--gold); margin-bottom: 3px; }
#summaryProgress { margin: 0 0 4px; color: var(--jade); font-size: 12px; }
#summaryTitle { color: var(--gold); }
#campaignSummary .text-close, #storyModal .text-close { white-space: nowrap; }
.summary-scene {
    position: relative; height: clamp(146px,30vw,206px); overflow: hidden;
    border: 1px solid #ae8a61; border-radius: 10px;
    background: linear-gradient(0deg,#15233282,transparent 68%), url('./art/van-khe-village.jpg') center 56%/cover;
}
#summaryHero { position: absolute; bottom: 4px; right: 15%; transform: scale(1.28); transform-origin: center bottom; filter: drop-shadow(2px 3px 6px #09151bdc); }
#summaryEnding { margin: 11px 0; color: var(--paper); font-size: 14px; line-height: 1.52; }
.summary-chronicle { margin: 0 0 12px; color: var(--gold); font-size: 13px; }
.summary-chronicle summary { padding: 4px 0; }
.summary-chronicle svg { width: 17px; height: 17px; }
#summaryChronicle { max-height: 156px; overflow: auto; margin: 7px 0 0; padding: 8px 9px; color: var(--muted); border: 1px solid #4b5968; border-radius: 7px; line-height: 1.5; }
.summary-links { display: grid; gap: 6px; }
.summary-links button {
    display: grid; grid-template-columns: 19px minmax(0,1fr) auto; align-items: center; gap: 7px;
    min-height: 45px; padding: 7px 9px; text-align: left; font-size: 13px;
}
.summary-links svg { width: 18px; height: 18px; color: var(--gold); }
.summary-links small { color: var(--muted); text-align: right; }
#questsProgress { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
#questsProgress.lesson-step { color: var(--gold); }
#questList { display: grid; gap: 5px; }
.quest-row {
    display: grid; grid-template-columns: 18px minmax(0,1fr) auto; gap: 7px; align-items: center;
    min-height: 44px; padding: 6px 8px; text-align: left; font-size: 13px;
}
.quest-row svg { width: 17px; height: 17px; color: var(--gold); }
.quest-row small { color: var(--muted); white-space: nowrap; }
.quest-row[aria-pressed="true"] { border-color: #c49a61; background: #443a32; }
.quest-row[data-status="ready"] small, .quest-row[data-status="claimed"] svg { color: var(--jade); }
.quest-detail { margin-top: 12px; padding: 11px; border: 1px solid #536069; border-radius: 9px; background: #132531; }
#questObjective { margin: 0 0 8px; color: var(--paper); font-size: 14px; line-height: 1.45; }
.quest-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.quest-actions strong, #questNotice { color: var(--gold); font-size: 13px; }
.quest-actions svg { width: 17px; height: 17px; }
.quest-actions button { padding-inline: 9px; }
#questNotice { margin: 8px 0 0; }
#questNotice:empty { margin: 0; }
#questRetry { margin-top: 8px; }
.stage-number { min-width: 33px; color: var(--gold); font-weight: 750; }
.setting-rows b { color: var(--jade); }
#speed { padding: 8px; background: #142632; border: 1px solid #496273; border-radius: 8px; }
.speed-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 6px; }
#speedTitle { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
#speedLock { color: var(--muted); }
.speed-choices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.speed-choices button { min-height: 44px; padding: 3px; font-variant-numeric: tabular-nums; }
.speed-choices button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: #3b342a; opacity: 1; }
.prep-guide-links { display: grid; gap: 7px; }
.prep-guide-links button {
    display: grid; grid-template-columns: 26px minmax(0,1fr) 16px; gap: 8px;
    align-items: center; padding: 8px; border-color: #76674e; text-align: left;
}
.prep-guide-links strong, .prep-guide-links small { display: block; }
.prep-guide-links small { margin-top: 3px; color: var(--muted); line-height: 1.4; }
.prep-guide-links [data-icon] { color: var(--gold); }
.prep-guide-links [data-icon="forward"] svg { width: 15px; height: 15px; }
.prep-hint {
    margin: 6px 0; padding: 6px 8px; border-left: 2px solid #b59159;
    background: #192e3b; color: var(--muted); font-size: 12px; line-height: 1.4;
}
.prep-hint strong { color: var(--gold); }
@media (max-width: 380px) {
    .battlehead:has(#retryAction:not([hidden])):has(#battleSpeed:not([hidden])) { flex-wrap: wrap; }
}
.setting-rows .leave-match { color: #ffd4c9; }
.setting-rows .leave-match svg { color: #f2a28e; }
.battle-guide { border: 1px solid #425363; border-radius: 9px; }
.guide-card { padding: 0 10px 10px; color: var(--muted); font-size: 12px; }
.guide-card p { margin: 2px 0 9px; }
#actorEffectCount { color: var(--jade); white-space: nowrap; }
.battle-effects { margin: 0 0 10px; padding: 8px; border-radius: 7px; background: #0e1e2a; }
.battle-effects h3 { margin: 0 0 6px; color: var(--paper); font-size: 13px; }
.battle-effects p { margin: 0 0 6px; }
.battle-ultimate-header { display: flex; align-items: center; gap: 8px; }
.battle-ultimate-header h3 { margin: 0 0 2px; }
.battle-ultimate-header small { color: var(--jade); font-size: 11px; }
#actorUltimateDescription { margin: 6px 0 0; }
.battle-effect-list { display: grid; gap: 5px; padding: 0; margin: 0; list-style: none; }
.battle-effect-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 3px 8px; }
.battle-effect-list span { display: inline-flex; align-items: center; gap: 5px; }
.battle-effect-list svg { color: currentColor; }
.battle-effect-list strong { color: var(--paper); font-weight: 600; }
#statusLegend { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
#statusLegend > span { display: flex; align-items: center; gap: 5px; }
.formation-ranks { display: grid; grid-template-columns: repeat(2,1fr); text-align: center; color: var(--gold); font-size: 12px; }
:is(#formation,#defenseFormation) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: repeat(3,minmax(68px,auto)); grid-auto-flow: column; gap: 5px; margin: 5px 0; }
:is(#formation,#defenseFormation) .slot { display: flex; position: relative; align-items: center; text-align: left; padding: 4px 6px 4px 52px; font-size: 12px; font-weight: 600; }
:is(#formation,#defenseFormation) .slot-copy { display: grid; gap: 4px; min-width: 0; }
:is(#formation,#defenseFormation) .slot strong { min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
:is(#formation,#defenseFormation) .slot-skill {
    display: inline-flex; align-items: center; justify-self: start; gap: 3px; white-space: nowrap;
    color: #ead9ff; background: #2d2342; border: 1px solid #a48ac263; border-radius: 4px;
    padding: 1px 3px; font-size: 10px; line-height: 1.15;
}
:is(#formation,#defenseFormation) .slot-skill svg { width: 12px; height: 12px; flex: 0 0 12px; }
#formation .slot-charge { color: #ffedbd; background: #453625; border-color: #c79f67; }
#formation .slot-poison { color: #e2f2b6; background: #2d3d2a; border-color: #839858; }
:is(#formation,#defenseFormation) .slot .sprite { transform: scale(.43); transform-origin: left top; position: absolute; left: 4px; top: 18px; pointer-events: none; }
:is(#formation,#defenseFormation) .slot.empty { color: var(--muted); border-style: dashed; }
:is(#formation,#defenseFormation) .empty-icon { position: absolute; left: 17px; top: 31px; opacity: .65; }
:is(#formation,#defenseFormation) .slot.selected { border-color: var(--gold); background: linear-gradient(#4d5440,#242e3d); }
.slot-number { color: var(--gold); background: #17232e; border: 1px solid #a88c5570; border-radius: 50%; position: absolute; top: 5px; left: 12px; width: 20px; height: 20px; display: grid; place-items: center; font-size: 10px; }
#formation .slot.under-threat { outline: 2px solid #e0917c; outline-offset: -3px; }
#formation .slot.under-threat .slot-number { color: #ffe0c2; background: #692f3e; border-color: #e0917c; }
.formation-controls, .filters { display: flex; gap: 6px; }
.formation-controls { flex-wrap: wrap; }
#formSwap, #formationMovesOpen { padding-inline: 8px; font-size: 13px; white-space: nowrap; }
#formSwap svg, #formationMovesOpen svg { width: 17px; height: 17px; }
#formSwap { min-height: 44px; }
#formation[data-swapping] { scroll-margin-block-start: 72px; }
#formation[data-swapping] .slot:not(.selected), #formation[data-swapping] + .formation-controls #formSwap {
    border-color: var(--gold);
}
#formationMovesOpen { margin-inline-start: auto; min-height: 42px; }
#rosterRetry, #rosterRetryBattle { min-height: 44px; margin-bottom: 8px; scroll-margin-block-start: 72px; }
#formationMovesTitle { font-size: clamp(18px,6vw,25px); }
#formationMoves { scroll-padding-block-start: 84px; }
#formationMoves .text-close { min-height: 44px; white-space: nowrap; }
.formation-move-switch { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.formation-move-switch button { min-height: 44px; padding-inline: 4px; }
.formation-move-switch button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); background: #3a3b32; }
.formation-move-name { display: grid; grid-template-columns: 38px minmax(0,1fr) 44px; align-items: center; gap: 8px; margin-top: 12px; }
#formationMoveIcon { display: flex; }
#formationMoveIcon .hero-skill-icon { width: 38px; height: 38px; }
#formationMoveHear { width: 44px; height: 44px; }
.formation-move-name h3 { margin: 0 0 3px; font-size: 19px; }
.formation-move-name small, #formationMoveEffects p { color: var(--muted); }
#formationMovePreview { padding-top: 7px; }
#formationMovePreview .skill-target-grid > .move-preview-affected {
    display: grid; place-items: center; min-height: 42px; border: 1px solid var(--jade); border-radius: 7px;
    background: #223b3f; color: var(--paper); font-size: 12px;
}
#formationMovePreview .skill-target-grid > .move-preview-affected.random { border-style: dashed; }
#formationMovePreview :is(.move-preview-ally,[data-enemy-slot]) { align-content: center; padding: 3px 5px; }
#formationMovePreview :is(.move-preview-ally,[data-enemy-slot]) small { font-size: 10px; }
#formationMovePreview :is(.move-preview-ally,[data-enemy-slot]) strong { overflow-wrap: anywhere; font-size: 12px; }
#formationMovePreview [data-enemy-slot] .move-preview-defense { color: #bee9ff; }
#formationMovePreview [data-enemy-guard] .move-preview-defense { color: #f9d893; }
.move-preview-defense svg { width: 11px; height: 11px; margin-inline-end: 3px; vertical-align: -2px; }
#formationMovePreview .move-preview-empty {
    display: grid; place-items: center; min-height: 42px;
    border: 1px dashed #465d66; border-radius: 7px; background: #142631;
}
#formationMoveEffects {
    margin-top: 6px; padding-inline: 8px; border: 1px solid #455b6b; border-radius: 7px;
    background: #172734; font-size: 13px;
}
#formationMoveEffects summary { display: flex; align-items: center; gap: 6px; min-height: 44px; }
#formationMoveEffects[open] summary svg { transform: rotate(180deg); }
#formationMoveEffects p { margin: 0 0 8px; line-height: 1.45; white-space: pre-line; }
.filters { margin: 12px 0 8px; flex-wrap: wrap; }
.filters button { font-size: 12px; min-height: 40px; }
.filters .selected { color: var(--gold); border-color: #b39b6a; }
.search, .role-select { display: flex; align-items: center; gap: 7px; padding: 0 8px; background: #0d202b; color: var(--muted); border: 1px solid var(--edge); border-radius: 8px; }
.search { min-width: 125px; flex: 2 1 125px; }
.role-select { min-width: 118px; flex: 1 1 118px; }
.role-select svg { width: 17px; height: 17px; color: var(--gold); }
.role-select select { min-width: 0; width: 100%; height: 39px; font: 600 12px system-ui; border: 0; background: #0d202b; color: var(--paper); }
.role-select:focus-within { border-color: var(--gold); }
.filters { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); }
.filters button { padding-inline: 5px; white-space: nowrap; }
.filters .search, .filters .role-select { grid-column: span 2; min-width: 0; padding-inline: 6px; }
.filters .search input { font-size: 13px; }
.filters .role-select select { font-size: 11px; }
.search input { min-width: 0; width: 100%; height: 39px; padding: 0; background: none; border: 0; color: var(--paper); }
#heroGrid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 6px; max-height: 31vh; overflow: auto; padding: 2px; }
.heroCard { position: relative; min-width: 0; min-height: 131px; overflow: hidden; padding: 0 4px 6px; display: grid; justify-items: center; align-content: end; }
.heroCard { --role-light: #4c9992; background: radial-gradient(ellipse at 50% 20%,color-mix(in srgb,var(--role-light) 60%,#172638),#111b29 79%); }
.heroCard[data-role="sword"] { --role-light: #aa7554; }
.heroCard[data-role="spear"] { --role-light: #487ca2; }
.heroCard[data-role="skill"] { --role-light: #8662ad; }
.heroCard[data-role="heart"] { --role-light: #528a69; }
.heroCard[data-role="target"] { --role-light: #8e536d; }
.heroCard[aria-pressed="true"] { border-color: #ffdc9b; box-shadow: inset 0 0 0 2px #c99e65a0,0 0 9px #ffd08745; }
.heroCard .sprite { filter: drop-shadow(0 3px 4px #061321b0); position: absolute; top: 1px; left: calc(50% - 43px); transform: scale(.80); transform-origin: left top; }
.hero-card-caption { z-index: 1; border-radius: 4px; width: 100%; padding: 2px 0; text-align: center; background: #0d1523ef; }
.hero-card-caption strong { display: block; font-size: 11px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.hero-duty { display: block; font-size: 10px; line-height: 1.3; color: var(--muted); }
.hero-duty[data-duty="deployed"] { color: var(--jade); }
.hero-duty[data-duty="away"] { color: var(--gold); }
.heroCard.locked { opacity: .67; }
.hero-role, .hero-lock { position: absolute; top: 5px; left: 4px; color: var(--gold); }
.hero-lock { left: auto; right: 4px; color: var(--muted); }
.hero-role svg, .hero-lock svg { width: 14px; height: 14px; }
#heroDetail { margin-top: 9px; font-size: 12px; color: var(--muted); }
#heroDetail:empty { display: none; }
.detail-title { text-align: center; color: var(--gold); }
.detail-title h3 { margin: 0 0 4px; color: var(--paper); font: 700 clamp(22px,7vw,32px)/1.16 var(--heading); }
.detail-title span { display: inline-flex; align-items: center; gap: 4px; margin-inline: 5px; }
.detail-title svg { width: 15px; height: 15px; }
.profile-equipment {
    display: grid; grid-template-columns: minmax(76px,1fr) minmax(0,1.35fr) minmax(76px,1fr);
    gap: 6px; padding: 7px; margin-top: 9px; border: 1px solid #8e795576; border-radius: 10px;
    background: linear-gradient(180deg,#10203299,#1121321c 43%,#0d182bed), url('./art/moon-gate.jpg') 50% 57%/cover;
}
.profile-equipment > div:not(.profile-portrait) { display: grid; gap: 4px; }
.profile-gear-slot {
    display: grid; min-width: 0; min-height: 54px; align-content: center; justify-items: center; gap: 1px; padding: 4px 2px;
    border-color: #72848a; border-style: dashed; background: #132233f0; font-size: 10px; line-height: 1.2;
}
.profile-gear-slot.filled { border-color: #e4c385; border-style: solid; background: #332c2de8; }
.profile-gear-slot svg { width: 19px; height: 19px; color: var(--gold); }
.profile-gear-slot small { max-width: 100%; color: #d8c8ab; font-size: 9px; overflow-wrap: anywhere; }
.profile-portrait { position: relative; display: grid; place-items: center; min-width: 0; }
.profile-portrait::after {
    content: ''; position: absolute; inset: auto 2px 20%; height: 16%; border-radius: 50%;
    border: 1px solid #ffe19f90; background: #ebc87a32; box-shadow: 0 0 21px #eeca7772;
}
.profile-portrait .sprite {
    position: absolute; z-index: 1; bottom: 15%; scale: 1.38; transform-origin: center 85%;
    animation: village-idle 2.8s ease-in-out infinite;
}
.hero-statline {
    display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; color: var(--paper); margin: 7px 0;
}
.companion-tip { margin: 7px 0; color: var(--jade); font-size: 12px; }
.profile-slot-picker, .recruit-preference {
    display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center;
    gap: 8px; margin-top: 7px; color: var(--paper); font-weight: 600;
}
.recruit-preference { margin-bottom: 5px; }
#profileFormationSlot, #recruitPreferredHero {
    min-height: 44px; min-width: 0; padding: 4px 8px; border: 1px solid #8f794f;
    border-radius: 8px; color: var(--paper); background: #192d3b; font: inherit;
}
:is(#profileFormationSlot,#recruitPreferredHero):focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#profileFormationEffects { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
#profileFormationEffects span {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px;
    border: 1px solid #936042; border-radius: 5px; background: #3b2a2b; color: #ffead5; font-size: 12px;
}
#profileFormationEffects svg { width: 14px; height: 14px; flex: none; }
#profileFormationPowerPreview { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 4px; color: var(--gold); }
#profileFormationPowerPreview svg { width: 14px; height: 14px; }
#profileFormationPowerPreview .stat-loss { color: #ffc5a8; }
.hero-statline > span { display: inline-flex; align-items: center; gap: 3px; padding: 4px; border-radius: 4px; background: #203443; }
.hero-statline svg { width: 14px; height: 14px; color: var(--gold); }
#profileCombatPower { color: var(--gold); background: #3b322c; }
.profile-section-title { margin: 16px 0 4px; color: var(--paper); font: 700 20px var(--heading); }
.profile-copies { margin-bottom: 2px; }
.opening-ultimate {
    display: flex; align-items: center; gap: 6px; margin: 7px 0; padding: 5px 8px;
    border-radius: 6px; background: #2a2241; color: #eddcff; font-size: 12px; line-height: 1.3;
}
.opening-ultimate svg { width: 15px; height: 15px; color: #d2b4ff; }
.skill-row { display: grid; grid-template-columns: minmax(0,1fr) 42px; gap: 5px; align-items: start; margin: 5px 0; }
.skill-row details { border: 1px solid #3f555d; border-radius: 7px; padding: 4px 6px; background: #0a202a; }
.skill-row details[open] { border-color: #b29466; }
.skill-row summary { display: flex; gap: 6px; align-items: center; min-height: 42px; color: var(--paper); cursor: pointer; }
.skill-row svg { width: 16px; height: 16px; color: var(--gold); }
:is(.skill-row,.scout-skills) button[aria-pressed="true"] { border-color: var(--gold); background: #3a302a; }
.skill-row summary strong { display: block; min-width: 0; overflow-wrap: anywhere; }
.skill-row summary small { color: var(--gold); }
.move-cost { margin-left: auto; text-align: right; min-width: 37px; }
.move-cost svg { width: 13px; height: 13px; margin-inline-end: 3px; vertical-align: middle; }
.skill-row p { margin: 6px 0 2px; line-height: 1.55; }
.hero-skill-icon {
    display: inline-block; flex: none; width: 37px; height: 37px; border-radius: 6px;
    background-color: #383452; background-repeat: no-repeat; background-size: 1200% 3200%;
}
.profile-talent-group h4 { color: var(--muted); margin: 9px 0 4px; font-size: 12px; }
.profile-talent-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 4px; }
.profile-talent-grid button { position: relative; display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 4px 1px; }
.profile-talent-grid button[aria-pressed="true"] { border-color: var(--gold); background: #3a302a; }
.profile-talent-grid button:not(.unlocked) .hero-skill-icon { filter: brightness(.7); }
.talent-lock { position: absolute; top: 4px; right: 3px; line-height: 0; color: var(--paper); }
.talent-lock svg { width: 13px; height: 13px; }
.profile-talent-detail { margin: 5px 0; border: 1px solid #8e7955; padding: 8px; border-radius: 6px; }
.profile-talent-detail strong { color: var(--gold); }
.profile-talent-detail p { margin: 4px 0 0; color: var(--paper); line-height: 1.45; }
#profileTalentUpgrade { min-height: 44px; margin-top: 8px; padding-inline: 8px; font-size: 13px; }
.skill-target-preview { margin-top: 9px; border-top: 1px solid #3f555d; padding-top: 3px; }
.skill-target-preview p { font-size: 12px; }
.skill-target-preview small { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; }
.skill-target-preview [role="status"] { color: var(--gold); }
.skill-target-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; text-align: center; }
.skill-target-grid > span { color: var(--muted); font-size: 11px; }
.skill-target-grid button { min-height: 42px; font-size: 12px; transition: none; }
.skill-target-grid button[aria-pressed="true"] { background: #584327; border-color: var(--gold); color: #fff1ca; }
.skill-target-grid button.linked { background: #34264a; border-color: #b695dd; color: #ead9ff; opacity: 1; }
.hero-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 5px; }
.hero-controls button { font-size: 12px; padding-inline: 7px; }
#trainHero, #rankHero { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; text-align: left; }
#profileUpgradePowerGain { display: block; margin-top: 2px; font-size: 11px; }
.hero-controls .primary { order: -1; }
#heroUnlockStage, #profileSpiritGifts { min-height: 44px; }
#profileCopySearch { margin: 8px 0; padding: 8px; background: #172937; border: 1px solid #8f794f; border-radius: 8px; }
#profileCopySearch summary { display: flex; align-items: center; min-height: 42px; gap: 5px; color: var(--paper); cursor: pointer; }
#profileCopySearch summary svg { width: 17px; height: 17px; color: var(--gold); }
#profileCopySearch summary small { margin-left: auto; color: var(--gold); text-align: right; }
#profileCopySearch p { margin: 6px 0; line-height: 1.35; }
#profileCopySearch > button { display: block; width: 100%; margin: 6px 0 3px; font-size: 12px; }
#profileSealStage { min-height: 44px; }
#profileCopyResult { color: var(--jade); }
.sprite { width: 108px; height: 108px; background-repeat: no-repeat; }
#toast { display: none; position: fixed; bottom: max(20px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 12; padding: 11px 16px; max-width: 88vw; border-radius: 7px; background: var(--gold); color: #1a2830; box-shadow: 0 10px 30px #0007; font-size: 12px; pointer-events: none; }
body:has([data-screen="battle"]) #toast { inset-block: calc(116px + env(safe-area-inset-top)) auto; }
.brand { font-size: 13px; gap: 8px; }
.brand b { font-size: 11px; }
.brand-mark { width: 35px; height: 38px; border-radius: 8px 8px 14px 14px; }
.brand-mark svg { width: 23px; height: 23px; }
.hall-dock { padding: 4px 7px 6px; }
.hall-dock button { min-height: 59px; }
.hall-dock button [data-icon] { width: 34px; height: 34px; border-radius: 8px; }
.hall-dock svg { width: 21px; height: 21px; }
.battlehead { min-height: 49px; padding: 3px 9px; }
.controls { gap: 4px; }
.stage-heading svg { width: 17px; height: 17px; }
.stage-heading h1 { white-space: normal; line-height: 1.15; }
.commandbar { min-height: 69px; padding: 6px 7px; gap: 5px; border-radius: 0; }
.turn { gap: 5px; }
#actorPortrait { flex-basis: 36px; width: 36px; height: 36px; }
#actorPortrait .sprite { transform: scale(.39); margin-left: -3px; }
#actor { font-size: 12px; }
#round { font-size: 9px; }
.combat-button { min-width: 50px; min-height: 48px; padding: 3px 5px; }
.combat-button svg { width: 21px; height: 21px; }
.combat-button b { font-size: 11px; }
.charge-ring { width: 25px; height: 25px; top: 5px; left: calc(50% - 12.5px); }
#auto { min-width: 82px; gap: 3px; }
#auto svg { width: 18px; height: 18px; }
#heroGrid { grid-template-columns: repeat(3,minmax(0,1fr)); }

.village { background-position: center,51% 50%,center; }
.village-title { left: 15px; top: 18px; right: 122px; }
.village-title h1 { font-size: clamp(22px,6.5vw,30px); }
[data-screen="home"] .battlehead { top: 9px; right: 10px; }
.hall-dock { gap: clamp(4px,2vw,14px); }
.hall-dock button { flex: 1; min-width: 0; padding-inline: 3px; white-space: nowrap; }
@media (max-width: 540px) and (orientation: portrait) {
    :root { --game-width: 100%; }
    main { padding-block: 0 env(safe-area-inset-bottom); padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
    .layout { border: 0; border-radius: 0; box-shadow: none; }
    .village, #lobby:has(.hall-dock[hidden]) .village, .hall-dock, .battlehead, .game { border-radius: 0; }
    .viewport::after { inset: 0; border: 0; }
}
@media (min-width: 780px) {
    body {
        background: radial-gradient(ellipse at center,#0b182551,#080f19ed 73%),
            linear-gradient(#101b2aba,#080f19e8), url('./art/van-khe-village.jpg') center 45%/cover fixed, var(--bg);
    }
    body:has([data-screen="battle"]) {
        background-image: radial-gradient(ellipse at center,#0b182551,#080f19ed 73%),
            linear-gradient(#101b2aba,#080f19e8), url('./art/moon-gate.jpg');
    }
}
@media (max-height: 700px) {
    #villageHero { transform: scale(1); }
    .village-actions:has(#homeStageMechanic:not([hidden])) #villageHero { height: 78px; transform: scale(.75); }
}
@media (max-height: 640px) {
    .village-actions:has(#homeStageRewards:not([hidden])) #villageHero { display: none; }
}
@container (max-width: 356px) {
    .resources { gap: 4px; font-size: 11px; }
    .realm, .balance { min-height: 27px; padding: 3px 6px; gap: 6px; }
    .brand { font-size: 11px; }
}
@container (max-width: 380px) {
    .hall-dock button { padding-inline: 1px; font-size: 12px; }
    #start { padding-inline: 8px; font-size: 17px; }
    .commandbar:has(.manual-actions:not([hidden])) #actorPortrait { display: none; }
    #actor { white-space: normal; line-height: 1.15; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } #villageHero .sprite, .profile-portrait .sprite { animation: none; } }

/* The allied columns match their positions on the battlefield. */
:is(#formation,#defenseFormation) {
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
    background: linear-gradient(#10263152,#101f38a6), url('/art/moon-gate.jpg') center / cover;
}
:is(#formation,#defenseFormation) .slot {
    grid-column: 2;
    min-height: 78px;
    background: #13252da6;
    border-color: #c8bd9e64;
}
:is(#formation,#defenseFormation) .slot:nth-child(n+4) { grid-column: 1; }
:is(#formation,#defenseFormation) .slot:nth-child(3n+1) { grid-row: 1; }
:is(#formation,#defenseFormation) .slot:nth-child(3n+2) { grid-row: 2; }
:is(#formation,#defenseFormation) .slot:nth-child(3n+3) { grid-row: 3; }
:is(#formation,#defenseFormation) .slot.selected { background: #564726db; }
:is(#formation,#defenseFormation) .slot .sprite { top: 27px; }
:is(#formation,#defenseFormation) .slot:has(.hero-progress) .slot-copy { margin-top: 13px; }
@media (max-width: 380px) {
    :is(#formation,#defenseFormation) .slot { padding-inline: 42px 3px; }
    :is(#formation,#defenseFormation) .slot .sprite { transform: scale(.37); }
    :is(#formation,#defenseFormation) .slot-skill { margin-inline-start: -7px; padding-inline: 2px; gap: 2px; font-size: 9.5px; }
}
.hero-progress {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    inset: 3px 3px auto;
    padding: 2px 4px;
    border-radius: 4px;
    background: #111d2def;
    color: var(--paper);
    font: 700 10px system-ui;
    white-space: nowrap;
}
.hero-progress b, .gear-grade { color: var(--gold); }
.heroCard .sprite { top: 16px; }
.hero-role, .hero-lock { top: 23px; }
:is(#formation,#defenseFormation) .hero-progress { inset-inline-start: 39px; inset-inline-end: 5px; }

#gearSummon, .gear-loadout {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--edge);
    border-radius: 9px;
    background: #142733;
}
#gearSummon summary { color: var(--gold); cursor: pointer; padding-block: 4px; min-height: 34px; font-weight: 700; }
#gearSummon summary svg, #gearSlots svg { width: 19px; height: 19px; vertical-align: middle; }
.gear-reveal {
    display: grid;
    justify-items: center;
    gap: 4px;
    margin: 6px 0 9px;
    padding: 14px 6px;
    border: 1px solid #9a7c57;
    border-radius: 8px;
    background: radial-gradient(ellipse at center top,#5e486a,#232b3b 78%);
    color: var(--gold);
    text-align: center;
}
.gear-reveal svg { width: 33px; height: 33px; }
#gearRevealContent { display: grid; justify-items: center; gap: 4px; }
#equipFromGearReveal { min-height: 44px; }
#gearBalance { display: inline-block; margin: 4px 0 0 6px; color: var(--muted); }
.gear-loadout { display: grid; }
#gearSlots { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; }
#gearSlots button { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 5px 2px; font-size: 11px; }
#gearSlots button:not(.filled) { border-style: dashed; }
#gearSlots button.filled { border-color: #b79b60; color: var(--gold); }
#gearSlots small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#equipmentList { max-height: 12rem; overflow: auto; }
#equipmentStars {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--gold);
}

#competitionIdentity { margin-bottom: 8px; color: var(--jade); font-size: 13px; }
.competition-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; }
.competition-tabs button { white-space: nowrap; padding-inline: 4px; }
.competition-tabs button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
#competitionContent > p, #competitionContent details { margin-block: 10px; font-size: 13px; }
.power-actions { display: flex; gap: 7px; margin-top: 12px; }
.power-actions button { flex: 1; padding-inline: 5px; }
.power-actions svg, #openFormationPower svg { width: 18px; height: 18px; vertical-align: middle; }
.power-slots { list-style: none; padding: 0; display: grid; gap: 7px; }
.power-slots li { padding: 8px; border: 1px solid #476474; border-radius: 8px; background: #142733; }
.power-slot-head { display: flex; align-items: center; gap: 7px; }
.power-slot-number { width: 24px; min-height: 24px; display: grid; place-items: center; background: #304757; color: var(--gold); border-radius: 5px; }
.power-slot-art { width: 36px; height: 40px; flex: 0 0 auto; overflow: hidden; }
.power-slot-art .sprite { transform: scale(.38); transform-origin: top left; }
.power-slot-hero { flex: 1; min-width: 0; }
.power-slot-hero small { display: block; color: var(--muted); margin-top: 2px; }
.power-slot-score { color: var(--gold); font-variant-numeric: tabular-nums; }
.power-slot-stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 4px; margin-top: 6px; font-size: 12px; }
.power-slot-stats span { display: inline-flex; align-items: center; gap: 3px; }
.power-slot-stats svg { width: 14px; height: 14px; flex: 0 0 auto; color: var(--jade); }
.power-slot-bonus { font-size: 12px; color: var(--muted); margin-top: 5px; }
.power-empty .power-slot-hero, .power-empty .power-slot-score { color: var(--muted); }
.competition-list { list-style: none; padding: 0; margin: 8px 0; }
.competition-list li {
    display: flex;
    gap: 7px;
    align-items: center;
    margin-bottom: 4px;
    padding: 7px;
    background: #142738;
    border: 1px solid var(--edge);
    border-radius: 7px;
    font-size: 12px;
}
.competition-list li.is-self { border-color: var(--gold); }
.competition-list span { flex: 1; }
.competition-list small { display: block; color: var(--muted); margin-top: 3px; }
.competition-list strong { color: var(--gold); white-space: nowrap; }
.competition-list button { min-height: 38px; padding-inline: 8px; }
.boss-panel {
    margin-block: 10px;
    padding: 15px 9px;
    text-align: center;
    border: 1px solid #98685f;
    border-radius: 8px;
    background: linear-gradient(120deg,#2c1c30e8,#37243cc8),url('/assets/tower.png') center / cover;
}
.boss-panel h3 { margin: 0; color: #ffe0b6; }
.boss-panel p { font-size: 12px; }
.boss-board-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.boss-board-actions button { min-height: 44px; padding-inline: 7px; font-size: 12px; }
.arena-board-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.arena-board-actions button { min-height: 44px; padding-inline: 8px; }
.arena-defense-head, .arena-defense-controls { display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.arena-defense-head h3 { margin: 0; }
.arena-defense-head button, .arena-defense-controls button { min-height: 44px; flex: none; padding-inline: 8px; }
.arena-defense-controls { align-items: end; margin-block: 8px; }
.arena-defense-picker { display: grid; gap: 4px; min-width: 0; flex: 1; font-size: 13px; color: var(--muted); }
.arena-defense-picker select {
    min-width: 0; min-height: 44px; width: 100%; padding: 6px 8px;
    border: 1px solid var(--edge); border-radius: 8px; background: #0d202b; color: var(--paper);
    font: 600 14px system-ui;
}
.arena-board-actions svg, :is(#backArenaDefense,#backArenaRival,#confirmArenaRival) svg,
.boss-board-actions svg, :is(.boss-history-list,.arena-history-list) svg,
:is(#historyToBoss,#backBossHistory,#historyToArena,#backArenaHistory,#arenaHistoryButton) svg {
    width: 16px; height: 16px; vertical-align: middle;
}
:is(.boss-history-list,.arena-history-list) { display: grid; gap: 6px; margin: 9px 0 0; padding: 0; list-style: none; }
:is(.boss-history-list,.arena-history-list) button {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; min-height: 53px; text-align: left;
}
:is(.boss-history-list,.arena-history-list) small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
:is(.boss-history-list,.arena-history-list) svg { flex-shrink: 0; color: var(--gold); }
.arena-history-score { color: var(--gold); font-weight: 750; }
#arenaRivalName { color: var(--gold); }
#arenaOwnTeam summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; }
#arenaOwnTeam summary svg { width: 14px; height: 14px; color: var(--gold); }
#arenaOwnTeam[open] summary svg { transform: rotate(180deg); }
#confirmArenaRival { width: 100%; min-height: 44px; }
.arena-preview-slots > div > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.arena-history-score small { display: block; margin-top: 3px; color: var(--muted); font-weight: 500; }
.arena-history-teams { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.arena-history-teams h4 { margin: 0 0 3px; color: var(--gold); }
.arena-history-teams small { color: var(--muted); font-size: 11px; }
.arena-history-teams ol { display: grid; gap: 3px; padding: 0; margin: 6px 0 0; list-style: none; }
.arena-history-teams li {
    display: grid; grid-template-columns: 13px minmax(0,1fr); align-items: center; gap: 4px; min-height: 30px;
    padding: 4px 5px; border: 1px solid #486360; border-radius: 5px; background: #182e36; font-size: 12px;
}
.arena-history-teams li b { color: var(--gold); }
.boss-history-detail .boss-history-total { color: var(--gold); font-weight: 700; }
.boss-history-detail .boss-unattributed { margin-top: 6px; color: var(--muted); font-size: 12px; }

#quests:has(#dailyQuestsPanel:not([hidden])) .modalhead h2 { font-size: clamp(19px,6vw,25px); }
.quest-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-block: 9px; }
.quest-tabs button { min-height: 40px; }
.quest-tabs button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.quest-tabs svg { width: 15px; height: 15px; vertical-align: middle; }
.daily-chest {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px;
    padding: 10px; border: 1px solid #9a7d54; border-radius: 9px;
    background: linear-gradient(130deg,#43342c,#192c37);
}
.daily-chest-symbol { color: var(--gold); }
.daily-chest h3 { margin: 0 0 2px; font: 700 16px var(--heading); color: var(--paper); }
.daily-chest p { margin: 0; color: var(--jade); font-size: 12px; }
.daily-chest button { min-height: 40px; padding-inline: 6px; font-size: 12px; }
#dailyProgress, #dailyHint { grid-column: 1/-1; }
#dailyProgress { width: 100%; height: 9px; accent-color: var(--gold); }
#dailyHint { color: var(--muted); }
#dailyTaskList { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 5px; }
.daily-task {
    display: grid; grid-template-columns: 19px minmax(0,1fr) auto; align-items: center; gap: 6px;
    background: #182c38; border: 1px solid var(--edge); border-radius: 8px; padding: 6px;
    font-size: 13px;
}
.daily-task p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.3; }
.daily-task-icon { color: var(--gold); }
.daily-task svg { width: 16px; vertical-align: middle; }
.daily-task button { min-height: 42px; padding: 4px 5px; font-size: 12px; }
.daily-task[data-completed="true"] .daily-task-icon, .daily-task small { color: var(--jade); }

#materialsSweepPanel {
    display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center;
    gap: 8px; margin-top: 10px; padding: 8px;
    border: 1px solid #806047; border-radius: 8px; background: #2d292c;
}
#materialsSweepPanel strong { color: var(--gold); font-size: 13px; }
#materialsSweepHint, #materialsNotice { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
#materialsSweep { padding-inline: 5px; min-height: 40px; font-size: 12px; }

.gear-source {
    display: flex; flex: 1 0 100%; align-items: center; justify-content: space-between;
    gap: 7px; padding: 6px; border-radius: 6px; background: #192e3b;
}
.gear-source p { margin: 0; color: var(--muted); font-size: 12px; }
.gear-source button { min-height: 42px; flex: none; padding-inline: 7px; font-size: 12px; }
#equipmentStars { flex-wrap: wrap; }
#gearCopySearch { margin-top: 8px; }
#equipment .modalhead {
    position: sticky; top: -12px; z-index: 3;
    margin: -12px -12px 8px; padding: 12px 12px 8px; background: #1b2a3a;
}
#gearSummon, .equipment-detail { scroll-margin-top: 69px; }

#gearReveal { scroll-margin-top: 69px; }
#gearExchange {
    margin-top: 10px; padding: 7px; border-radius: 7px;
    border: 1px solid #7f6851; background: #283037;
}
#gearExchange summary { font-size: 13px; min-height: 35px; }
#gearExchange p { margin: 2px 0 7px; color: var(--muted); font-size: 12px; }
#gearExchange button { padding-inline: 6px; font-size: 12px; }


#summaryContinue { width: 100%; margin-top: 9px; }
