.captain-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,340px),1fr)); gap:14px }
.captain-card { display:grid; gap:17px; max-width:380px; background:var(--panel); border:1px solid var(--line); padding:17px }
.captain-card-top { display:flex; justify-content:space-between; gap:12px; color:var(--green); font-size:.77rem }
.captain-card-top span { color:var(--gold); flex:none }
.captain-card-top strong { white-space:nowrap; font-size:.74rem; letter-spacing:-.015em }
.captain-card-main { display:flex; align-items:center; gap:15px }
.captain-card-main .captain-avatar { width:66px; height:66px; object-fit:cover; flex:none }
.captain-card-main h2 { color:var(--text); margin:0 0 6px; font-size:1.2rem }
.captain-card-main small { color:var(--muted) }
.captain-card-main .card-timer { display:block; margin-top:6px; color:var(--gold) }
.captain-card > button { width:100% }
.captain-card { gap:12px }
.captain-card-main > div { min-width:0 }
.captain-card-main small { display:block; font-size:.75rem }
.captain-own-units { display:grid; gap:5px; padding:9px 0 }
.captain-own-units > small { color:var(--muted); font-size:.65rem; letter-spacing:.05em }
.captain-unit-icons { display:flex; flex-wrap:wrap; gap:5px; align-items:center; min-height:37px }
.captain-unit-icon { display:grid; place-items:center; width:36px; height:36px; flex:none; border:0; background:transparent; color:var(--green) }
.captain-unit-icon abbr { text-decoration:none; font-size:.72rem; font-weight:700 }
.captain-units-empty { color:var(--muted); font-size:.69rem }
.captain-next-unit { display:flex; justify-content:space-between; align-items:center; gap:10px; border:1px solid var(--line); padding:9px 11px; color:var(--gold); background:#071a12; font-size:.76rem }
.captain-next-unit strong { color:var(--green); font-variant-numeric:tabular-nums }
@media(max-width:440px) { .captain-cards { grid-template-columns:minmax(0,1fr) } .captain-card-top strong { font-size:.68rem } }
.paint-tools { display:flex; flex-wrap:wrap; gap:6px; width:100%; padding:8px 0 }
.paint-brush { display:grid; justify-items:center; gap:3px; min-width:63px; padding:5px 7px; background:#071a12 }
.paint-brush span { display:grid; place-items:center; background:#102c1e; width:29px; height:29px; color:var(--green) }
.paint-brush img { width:100%; height:100%; object-fit:contain; image-rendering:auto }
.paint-brush small { font-size:.57rem; color:var(--muted); white-space:nowrap }
.paint-brush.active { border-color:var(--green); background:#174b2f }
.paint-brush.active small { color:var(--text) }
.battle-status { flex:none; border:1px solid var(--line); background:#07160f; padding:11px 16px; text-align:right }
.battle-location { display:none }
#page-battle #battle-phase { max-width:none; margin:0; color:var(--green); font-size:clamp(1.2rem,2vw,1.75rem); font-weight:850; letter-spacing:.04em; line-height:1.2 }
#page-battle #battle-next-phase { margin:6px 0 0; color:var(--muted); font-size:.87rem }
#battle-timer { color:var(--text); font-variant-numeric:tabular-nums }
#battle-results { margin-bottom:30px }
.battle-result-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:12px }
.battle-result-list .cube-reward { border:1px solid var(--line); padding:15px; background:var(--panel) }
.unit-stats { grid-template-columns:repeat(3,minmax(0,1fr)) }
.unit-stats div { display:grid; justify-items:start; gap:2px; padding:7px }
.unit-stats strong { font-size:.84rem; color:var(--text) }
.unit-stats small { font-size:.65rem }
#page-battle { padding-bottom:154px }
#page-battle .page-heading { margin-bottom:10px }
#page-battle .page-heading h1 { font-size:clamp(1.4rem,2.2vw,2rem) }
#page-battle .battle-controls { margin:4px 0 10px; align-items:center }
.battle-stage { position:relative; height:clamp(380px,calc(100dvh - 380px),900px); min-width:0 }
.battle-stage .canvas-wrap { width:100%; height:100%; display:flex; justify-content:center; align-items:center; border-color:#245b41 }
.battle-stage canvas { width:auto; height:auto; max-width:100%; max-height:100%; aspect-ratio:12 / 7; object-fit:contain; margin:0 }
.battle-roster { position:absolute; right:0; top:0; bottom:0; width:clamp(235px,19vw,310px); overflow:hidden; display:flex; flex-direction:column; background:#080f13ee; border:1px solid #3c5e57; box-shadow:-10px 0 28px #000a; z-index:2 }
.roster-head { display:flex; justify-content:space-between; align-items:center; padding:7px 10px; border-bottom:1px solid #3c5e57; font-size:.7rem; letter-spacing:.08em }
.roster-head button { padding:2px 7px; background:transparent; border:0 }
.roster-list { min-height:0; overflow-y:auto; scrollbar-color:#296a4b #07160f }
.roster-row { display:grid; grid-template-columns:22px minmax(0,1fr) minmax(42px,auto); gap:5px; align-items:center; border-bottom:1px solid #ffffff0b; padding:8px; font-size:.73rem }
.roster-row:nth-child(even) { background:#ffffff08 }
.roster-row strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600 }
.roster-index { color:var(--muted) }
.roster-units { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:3px; max-width:110px }
.roster-units abbr { color:var(--green); border:1px solid #367858; padding:2px; font-size:.57rem; text-decoration:none }
.battle-deck { position:fixed; left:160px; right:0; bottom:0; z-index:6; background:#07130ef5; border-top:2px solid #3c9b67; box-shadow:0 -10px 30px #000a }
.battle-deck .battle-footer { margin:0; padding:5px 12px; min-height:35px; font-size:.72rem }
.battle-deck .battle-footer button { padding:5px 9px; font-size:.68rem }
.battle-deck .picker { display:flex; flex-wrap:nowrap; gap:6px; width:100%; overflow-x:auto; overscroll-behavior-inline:contain; padding:6px 10px 12px; scrollbar-color:#3c9b67 #07160f }
.battle-unit-card { position:relative; display:flex; flex-direction:column; flex:0 0 148px; height:184px; border:1px solid #376b51; background:#0b1a14 }
.battle-unit-card.active { border-color:var(--green); box-shadow:inset 0 0 0 1px var(--green); background:#103622 }
.battle-unit-card.cooling > button[data-pick] { opacity:.65 }
.battle-unit-card > button[data-pick] { display:flex; align-items:center; flex-direction:column; justify-content:flex-end; gap:3px; width:100%; flex:1; min-height:0; border:0; background:transparent; color:var(--text); padding:15px 7px 5px }
.battle-unit-card > button[data-pick]:disabled { opacity:.65 }
.battle-card-level { position:absolute; top:3px; left:4px; font-size:.59rem; color:var(--gold) }
.battle-card-art { display:grid; place-items:center; width:112px; height:92px; flex:none; background:transparent; border:0 }
.battle-card-sprite { width:62px; height:62px; object-fit:contain; image-rendering:auto }
.battle-card-placeholder { font-size:1.2rem; font-weight:850; color:var(--green) }
.battle-unit-card strong { max-width:100%; font-size:.72rem; overflow:hidden; white-space:nowrap; text-overflow:ellipsis }
.battle-unit-card small { color:var(--muted); font-size:.64rem }
body:has(#page-battle:not(.hidden)) main { max-width:none; padding:18px 20px }
@media(max-width:750px) { #page-battle { padding-bottom:142px }.battle-stage { height:clamp(340px,calc(100dvh - 310px),700px) }.battle-deck { left:0; bottom:60px }.battle-unit-card { flex-basis:132px; height:178px }.battle-card-art { width:104px; height:84px }.battle-card-sprite { width:50px; height:52px }.battle-roster { width:min(78vw,310px) } body:has(#page-battle:not(.hidden)) main { padding:12px 8px } }
.app.battle-mode .sidebar { display:none }
.app.battle-mode .layout { grid-template-columns:minmax(0,1fr); padding-bottom:0 }
.app.battle-mode main { margin:0; max-width:none }
.app.battle-mode .battle-deck { left:0; bottom:0 }
.app.battle-mode #page-battle { display:flex; flex-direction:column; height:calc(100dvh - 112px); min-height:0; padding-bottom:171px }
.app.battle-mode #battle-live { display:flex; flex-direction:column; flex:1; min-height:0 }
.app.battle-mode .battle-controls, .app.battle-mode .event-feed { flex:none }
.app.battle-mode .battle-stage { flex:1; height:auto; min-height:0 }
.app.battle-mode #page-battle:has(#unit-picker.hidden) { padding-bottom:37px }
@media(max-width:750px) { .battle-status { margin-top:12px; text-align:left; padding:10px 12px }.app.battle-mode #page-battle { height:calc(100dvh - 89px); padding-bottom:157px } }
/* Keyboard Z/X and cursor-anchored wheel replace the vertical zoom slider.
   Mobile/touch gets three compact buttons as a pinch fallback, above the deck. */
.battle-zoom { display:none; position:absolute; right:10px; bottom:calc(var(--battle-deck-height, 190px) + 12px); top:auto; transform:none; z-index:4;
  flex-direction:row; align-items:center; gap:3px; padding:4px; background:#06140fd9; border:1px solid #31533e; border-radius:5px; box-shadow:0 3px 14px #0007 }
.battle-zoom button { width:36px; height:36px; min-height:36px; padding:0; font-size:1.3rem; line-height:1; background:#10271b; touch-action:manipulation }
.battle-zoom #zoom-reset { width:50px; font-size:.71rem; font-variant-numeric:tabular-nums }
.canvas-wrap canvas.panning { cursor:grabbing }
@media(pointer:coarse), (max-width:750px) {
  .battle-zoom { display:flex }
  .battle-stage:has(.battle-roster:not(.hidden)) .battle-zoom { right:auto; left:10px }
}
/* Battle uses the whole viewport below the account bar. The HUD floats over the map. */
.app.battle-mode { --battle-topbar-height:var(--topbar-height); height:100dvh; overflow:hidden }
body:has(.app.battle-mode) { overflow:hidden }
.app.battle-mode .layout { min-height:0 }
.app.battle-mode main { padding:0!important; margin:0; min-width:0 }
.app.battle-mode #page-battle { --battle-deck-height:202px; position:relative; display:block; height:calc(100dvh - var(--battle-topbar-height)); min-height:0; padding:0; overflow:hidden }
.app.battle-mode #page-battle:has(#unit-picker.hidden) { padding:0 }
.app.battle-mode #battle-live { position:absolute; inset:0; display:block; min-height:0 }
.app.battle-mode .battle-stage { position:absolute; inset:0; width:100%; height:auto; min-height:0 }
.app.battle-mode .battle-stage .canvas-wrap { display:block; border:0; width:100%; height:100%; background:#07110b }
.app.battle-mode .battle-stage canvas { display:block; width:100%; height:100%; max-width:none; max-height:none; aspect-ratio:auto; object-fit:fill; margin:0 }
.app.battle-mode .topbar { position:relative; z-index:8; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.25fr) minmax(0,1fr) }
.app.battle-mode .topbar > .brand-lockup { grid-column:1; grid-row:1 }
.app.battle-mode .topbar > .profile-shortcut { grid-column:3; grid-row:1; min-width:0; justify-content:flex-end }
.app.battle-mode .battle-location { display:block; grid-column:2; grid-row:1; min-width:0; text-align:center }
.battle-location .eyebrow { font-size:.56rem; letter-spacing:.14em }
#battle-location-title { margin:5px 0 0; font-size:clamp(.95rem,1.2vw,1.35rem); line-height:1.2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.app.battle-mode #page-battle > .page-heading { display:none }
.app.battle-mode .battle-hud { position:absolute; top:14px; right:18px; z-index:5; display:flex; flex-direction:column; align-items:flex-end; gap:6px; max-width:calc(100% - 36px); pointer-events:none }
.app.battle-mode .battle-view-actions { display:flex; gap:5px; pointer-events:auto }
.app.battle-mode .battle-view-actions > button { min-height:22px; padding:3px 6px; font-size:.56rem; line-height:1.2; color:var(--muted); background:#06120ebd; border:1px solid #28523c80; white-space:nowrap }
.app.battle-mode .battle-view-actions > button:hover { color:var(--text); border-color:#408b60; background:#103024 }
.app.battle-mode .battle-status { margin:0; background:#06120edb }
.app.battle-mode .battle-controls { position:absolute; z-index:5; top:14px; left:18px; right:320px; margin:0; display:flex; align-items:flex-start; justify-content:flex-start; gap:12px; pointer-events:none }
.app.battle-mode .battle-controls > * { pointer-events:auto }
.app.battle-mode #captain-tools { margin:0; padding:5px; max-width:100%; min-width:0; align-items:center; flex-wrap:nowrap; background:#07160fde }
.app.battle-mode .paint-tools { width:auto; max-width:900px; padding:0; flex-wrap:nowrap; overflow-x:auto }
.app.battle-mode .paint-brush { flex:none }
.app.battle-mode #start-battle { flex:none; white-space:nowrap; font-size:.7rem }
.app.battle-mode .battle-roster { top:138px; right:8px; bottom:8px; z-index:6 }
.app.battle-mode .event-feed { position:absolute; z-index:2; bottom:calc(var(--battle-deck-height) + 5px); left:12px; max-width:65%; max-height:38px; font-size:.65rem; pointer-events:none; text-shadow:0 1px 3px #000 }
.app.battle-mode .battle-deck { background:transparent; border:0; box-shadow:none; pointer-events:none }
.app.battle-mode .battle-deck .picker { background:transparent; scrollbar-color:#3c9b67 transparent }
.app.battle-mode .battle-unit-card { pointer-events:auto }
.app.battle-mode #page-battle:has(#unit-picker.hidden) .event-feed { bottom:10px }
@media(min-width:751px) and (max-width:1100px) {
  .app.battle-mode { --topbar-height:124px }
  .app.battle-mode .topbar { grid-template-columns:minmax(0,1fr) auto; grid-template-rows:minmax(0,1fr) auto; gap:4px 8px; padding:8px 14px }
  .app.battle-mode .topbar > .profile-shortcut { grid-column:2; grid-row:1 }
  .app.battle-mode .battle-location { grid-column:1 / -1; grid-row:2 }
}
@media(max-width:750px) {
  .app.battle-mode { --topbar-height:126px; --battle-topbar-height:var(--topbar-height) }
  .app.battle-mode .topbar { grid-template-columns:minmax(0,1fr) auto auto; grid-template-rows:minmax(0,1fr) auto auto; gap:4px 7px; padding:8px 14px }
  .app.battle-mode .topbar > .profile-shortcut { display:contents }
  .app.battle-mode .topbar .identity-copy { grid-column:2; grid-row:1 }
  .app.battle-mode .topbar .account-menu-wrap { grid-column:3; grid-row:1 }
  .app.battle-mode .topbar .profile-shortcut > .wallet { grid-column:1 / -1; grid-row:2; display:flex; flex-direction:row; flex-wrap:nowrap; justify-content:space-between; width:100%; min-width:0; max-width:none; gap:4px; font-size:.53rem }
  .app.battle-mode .topbar .wallet img { width:12px; height:12px }
  .app.battle-mode .battle-location { grid-column:1 / -1; grid-row:3 }
  .battle-location .eyebrow { font-size:.45rem }
  #battle-location-title { font-size:.8rem; margin-top:2px }
  .app.battle-mode #page-battle { --battle-deck-height:196px; height:calc(100dvh - var(--battle-topbar-height)); padding:0 }
  .app.battle-mode .battle-hud { top:9px; right:9px; max-width:calc(100% - 18px); gap:5px }
  .app.battle-mode .battle-status { padding:7px 8px; text-align:right }
  .app.battle-mode #page-battle #battle-phase { font-size:1rem }
  .app.battle-mode #page-battle #battle-next-phase { font-size:.65rem; margin-top:4px }
  .app.battle-mode .battle-controls { top:94px; left:9px; right:9px; gap:7px }
  .app.battle-mode .battle-view-actions > button { min-height:24px; padding:4px 6px; font-size:.53rem }
  .app.battle-mode #captain-tools { flex:1 1 100%; max-width:100%; min-width:0 }
  .app.battle-mode #page-battle:has(#captain-tools:not(.hidden)) .battle-roster { top:184px }
  .app.battle-mode #start-battle { padding:7px; font-size:.6rem }
}

/* Consumables have their own row; only the PNGs are visible. */
.battle-card-art > .pawn-preview { width:88px; height:88px; transform:translateX(-10px) }
.battle-consumables { display:flex; flex:none; align-items:center; justify-content:center; gap:16px; height:34px; padding:0 4px 3px }
.battle-consumables > button,.battle-consumables > button:hover:not(:disabled) { display:grid; place-items:center; position:static; width:32px; height:31px; padding:0; border:0; background:transparent; box-shadow:none; color:inherit; cursor:url('./assets/ui/greencur.png') 1 1, auto }
.battle-consumables img { display:block; width:28px; height:30px; object-fit:contain; pointer-events:none; user-select:none; -webkit-user-drag:none; transition:filter .15s; cursor:inherit }
.battle-consumables > button:hover:not(:disabled) img { filter:brightness(1.25) }
.battle-consumables > button:disabled { opacity:.28 }
.battle-consumables .battle-nano.armed img { filter:brightness(1.3) drop-shadow(0 0 5px #7bdfff) }
.battle-unit-card [data-pick] small.enhanced-ready { color:#8fefff }
@media(max-width:750px) { .battle-card-art > .pawn-preview { width:80px; height:80px } }

#grid-toggle[aria-pressed="true"] { color:#a2ffc3; border-color:#3b8b5d; box-shadow:inset 0 0 9px #3cff8d10,0 0 8px #3cff8d0b }
#grid-toggle[aria-pressed="false"] { color:var(--muted) }

/* Four readable secondary Barracks stats, including fire resistance. */
#unit-cards .unit-secondary-stats { grid-template-columns:repeat(2,minmax(0,1fr)) }

/* Optional tucked deck: show only each card's top edge, reveal only the hovered/focused card.
   The cards remain mounted and interactive (including Power-Pee and Nano-Hormones). */
.app.battle-mode #cards-toggle[aria-pressed="true"] { color:var(--green); border-color:#3b8b5d; background:#103024 }
.app.battle-mode.battle-cards-tucked .battle-deck .picker { overflow-y:hidden; padding-bottom:0 }
.app.battle-mode .battle-deck .battle-unit-card { transition:transform .38s cubic-bezier(.18,.75,.2,1) }
.app.battle-mode.battle-cards-tucked .battle-deck .battle-unit-card { transform:translateY(calc(100% - 28px)); }
.app.battle-mode.battle-cards-tucked .battle-deck .battle-unit-card:is(:hover,:focus-within) { transform:translateY(0); z-index:2 }
@media(prefers-reduced-motion:reduce) { .app.battle-mode .battle-deck .battle-unit-card { transition:none } }

/* Small unit label on the visible top lip of tucked battle cards only. */
.battle-card-folded-name { display:none; position:absolute; top:3px; right:5px; max-width:calc(100% - 47px); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.59rem; font-weight:700; line-height:1.2; color:#c9e4d3; pointer-events:none; }
.app.battle-mode.battle-cards-tucked .battle-deck .battle-unit-card:not(:hover):not(:focus-within) .battle-card-folded-name { display:block; }

/* ATLAS skull toggles the battle header. Keep the skull fixed while the panel retracts;
   the canvas grows into the vacated height, without touching camera zoom or map coordinates. */
.app.battle-mode .topbar {
  transition:height .35s cubic-bezier(.22,.7,.26,1), padding .35s cubic-bezier(.22,.7,.26,1), border-color .35s;
}
.app.battle-mode #page-battle {
  transition:height .35s cubic-bezier(.22,.7,.26,1);
}
.app.battle-mode .topbar > .brand-lockup {
  position:fixed; left:25px; top:14px; z-index:20;
}
.app.battle-mode .topbar > .brand-lockup .brand,
.app.battle-mode .topbar > .battle-location,
.app.battle-mode .topbar > .profile-shortcut {
  transition:transform .35s cubic-bezier(.22,.7,.26,1),opacity .22s ease;
}
.app.battle-mode.battle-header-hidden { --battle-topbar-height:0px; }
.app.battle-mode.battle-header-hidden .topbar {
  height:0 !important;
  padding-top:0 !important;
  padding-bottom:0 !important;
  border-bottom-width:0;
}
.app.battle-mode.battle-header-hidden .topbar > .brand-lockup .brand,
.app.battle-mode.battle-header-hidden .topbar > .battle-location,
.app.battle-mode.battle-header-hidden .topbar > .profile-shortcut {
  transform:translateY(-160px);
  opacity:0;
  pointer-events:none;
}
/* Keep the existing PNG fully visible as the compact header-reveal control. */
.app.battle-mode.battle-header-hidden .topbar > .brand-lockup {
  top:8px;
  left:12px;
  width:52px;
  height:52px;
}
.app.battle-mode.battle-header-hidden .topbar .atlas-logo { width:52px; height:52px; }
/* Captain paint toolbar should not cover the fixed ATLAS toggle. */
.app.battle-mode.battle-header-hidden .battle-controls { left:78px; }
@media(max-width:750px) {
  .app.battle-mode .topbar > .brand-lockup { left:14px; top:9px; }
  .app.battle-mode.battle-header-hidden .topbar > .brand-lockup { left:8px; top:6px; }
  .app.battle-mode.battle-header-hidden .topbar > .brand-lockup { width:44px; height:44px; }
  .app.battle-mode.battle-header-hidden .topbar .atlas-logo { width:44px; height:44px; }
  .app.battle-mode.battle-header-hidden .battle-controls { left:58px; }
}
@media(prefers-reduced-motion:reduce) {
  .app.battle-mode .topbar,
  .app.battle-mode #page-battle,
  .app.battle-mode .topbar > .brand-lockup .brand,
  .app.battle-mode .topbar > .battle-location,
  .app.battle-mode .topbar > .profile-shortcut { transition:none; }
}

/* Stable battle viewport: the ATLAS header is a visual overlay, not a canvas-size
   control. Neither the canvas dimensions nor its camera fit change on toggle. */
.app.battle-mode #page-battle,
.app.battle-mode #page-battle:has(#unit-picker.hidden) {
  position:fixed;
  inset:0;
  z-index:1;
  width:100vw;
  height:100dvh !important;
  max-height:none;
  transition:none;
}
.app.battle-mode .topbar,
.app.battle-mode.battle-header-hidden .topbar {
  position:fixed;
  top:0;
  left:0;
  right:0;
  width:100%;
  height:var(--topbar-height) !important;
  padding:12px 25px !important;
  background:transparent;
  border:0;
  z-index:8;
  isolation:isolate;
  pointer-events:none;
  transition:none;
}
.app.battle-mode .topbar::before {
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  background:#091b13;
  border-bottom:1px solid var(--line);
  pointer-events:none;
  transform:translateY(0);
  transition:transform .35s cubic-bezier(.22,.7,.26,1);
}
.app.battle-mode.battle-header-hidden .topbar::before {
  transform:translateY(-105%);
}
.app.battle-mode .topbar > .brand-lockup,
.app.battle-mode .topbar > .profile-shortcut,
.app.battle-mode .topbar > .profile-shortcut * {
  pointer-events:auto;
}
.app.battle-mode.battle-header-hidden .topbar > .profile-shortcut,
.app.battle-mode.battle-header-hidden .topbar > .profile-shortcut * {
  pointer-events:none;
}
/* Overlay HUD stays beneath the visible header, then slides up while the
   battlefield itself stays exactly the same size and position. */
.app.battle-mode .battle-hud,
.app.battle-mode .battle-controls {
  transition:top .35s cubic-bezier(.22,.7,.26,1);
}
.app.battle-mode:not(.battle-header-hidden) .battle-hud,
.app.battle-mode:not(.battle-header-hidden) .battle-controls {
  top:calc(var(--topbar-height) + 14px);
}
.app.battle-mode:not(.battle-header-hidden) .battle-roster {
  top:calc(var(--topbar-height) + 26px);
}
@media(max-width:750px) {
  .app.battle-mode .topbar,
  .app.battle-mode.battle-header-hidden .topbar { padding:8px 14px !important; }
  .app.battle-mode:not(.battle-header-hidden) .battle-hud { top:calc(var(--topbar-height) + 9px); }
  .app.battle-mode:not(.battle-header-hidden) .battle-controls { top:calc(var(--topbar-height) + 94px); }
  .app.battle-mode:not(.battle-header-hidden) #page-battle:has(#captain-tools:not(.hidden)) .battle-roster { top:calc(var(--topbar-height) + 184px); }
}
@media(prefers-reduced-motion:reduce) {
  .app.battle-mode .topbar::before,
  .app.battle-mode .battle-hud,
  .app.battle-mode .battle-controls { transition:none; }
}

/* V34.2: Swipe or mouse-drag the entire horizontal battle deck, even while
   cards are tucked. The picker itself must accept pointers (its parent deck
   deliberately does not, so the battlefield remains interactive above it). */
.app.battle-mode .battle-deck #unit-picker {
  pointer-events:auto;
  overflow-x:auto;
  touch-action:pan-x;
  overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
  -ms-overflow-style:none;
  user-select:none;
  -webkit-user-select:none;
  cursor:grab;
}
.app.battle-mode .battle-deck #unit-picker::-webkit-scrollbar {
  display:none;
  width:0;
  height:0;
}
.app.battle-mode .battle-deck #unit-picker.dragging {
  cursor:grabbing;
  scroll-behavior:auto;
}
/* Do not accidentally start browser-native image dragging instead of tray drag. */
.app.battle-mode #unit-picker img { -webkit-user-drag:none; user-select:none; }

/* Keep folded cards folded during a drag, instead of expanding under the cursor. */
.app.battle-mode.battle-cards-tucked .battle-deck #unit-picker.dragging .battle-unit-card:is(:hover,:focus-within) {
  transform:translateY(calc(100% - 28px));
}

/* Captain-only manual start and cancellation; Team Wars retains its own cycle. */
#cancel-captain-battle{flex:none;white-space:nowrap;font-size:.7rem;color:#f6c5ba;border-color:#ae665c}
#cancel-captain-battle:hover{background:#4a201c}
#captain-battle-confirm-dialog .captain-confirm-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px;margin-top:18px}
#captain-battle-confirm-dialog .captain-confirm-actions button{padding:10px 16px;cursor:pointer}
#captain-battle-confirm-dialog #captain-battle-confirm-yes[data-action="cancel"]{background:#7b302d;border-color:#ad5750;color:#fff}
