/* Compact mobile battle UI. Shared with Captains and Team Wars; no mobile combat fork. */
.app.battle-mode #battle-clear-selection:not(.hidden) {
  color:#baffd0; border-color:#4a9d69; background:#123426;
}
@media (max-width:600px) {
  .app.battle-mode .battle-hud { right:6px; left:6px; max-width:none; align-items:flex-end; gap:4px; }
  .app.battle-mode .battle-status { padding:5px 8px; max-width:100%; }
  .app.battle-mode #page-battle #battle-phase { font-size:.88rem; letter-spacing:.015em; }
  .app.battle-mode #page-battle #battle-next-phase { font-size:.6rem; margin-top:2px; }
  .app.battle-mode .team-wars-panel { width:auto; max-width:min(310px,calc(100vw - 12px)); gap:5px 7px; padding:6px 8px; font-size:.64rem; }
  .app.battle-mode .team-wars-panel strong { font-size:.68rem; }
  .app.battle-mode .team-wars-panel #team-wars-message { font-size:.61rem; }
  .app.battle-mode .team-wars-panel .team-wars-side { gap:4px; }
  .app.battle-mode .team-wars-panel .team-wars-side button { padding:5px 7px; font-size:.63rem; min-height:27px; }
  .app.battle-mode .battle-view-actions { max-width:100%; flex-wrap:wrap; justify-content:flex-end; gap:3px; }
  .app.battle-mode .battle-view-actions > button { min-height:26px; padding:5px 6px; font-size:.55rem; }
  .app.battle-mode .battle-deck .picker { gap:5px; padding:4px 6px 6px; }
  .app.battle-mode .battle-unit-card { flex:0 0 116px; height:158px; }
  .app.battle-mode .battle-unit-card > button[data-pick] { padding:10px 4px 2px; gap:2px; }
  .app.battle-mode .battle-card-art { width:92px; height:70px; }
  .app.battle-mode .battle-card-art > .pawn-preview { width:70px; height:70px; transform:none; }
  .app.battle-mode .battle-unit-card strong { font-size:.64rem; }
  .app.battle-mode .battle-unit-card small { font-size:.59rem; }
  .app.battle-mode .battle-consumables { gap:2px; height:30px; padding:0 2px 2px; }
  .app.battle-mode .battle-consumables > button { width:26px; height:27px; }
  .app.battle-mode .battle-consumables img { width:24px; height:25px; }
  .app.battle-mode .battle-zoom { right:7px; bottom:calc(var(--battle-deck-height, 196px) + 9px); gap:3px; padding:3px; }
  .app.battle-mode .battle-zoom button { width:34px; height:34px; min-height:34px; }
  .app.battle-mode .battle-zoom #zoom-reset { width:48px; }
  .app.battle-mode .battle-roster { width:min(77vw,270px); }
  .app.battle-mode .battle-roster .roster-row { padding:5px; font-size:.67rem; }
  /* Unit Info stays fully scrollable instead of filling the phone with owner art. */
  .unit-inspector { max-width:calc(100vw - 16px); max-height:calc(100dvh - 16px); }
  .unit-inspector .inspector-head { padding:6px 10px; }
  .unit-inspector .inspector-scroll { padding:9px 11px; }
  .unit-inspector .inspector-content { gap:9px; }
  .unit-inspector .inspector-identity { display:grid; grid-template-columns:76px minmax(0,1fr); gap:8px; align-items:center; }
  .unit-inspector #inspector-art { width:76px; height:76px; margin:0; }
  .unit-inspector .inspector-owner { flex-direction:row; flex-wrap:wrap; justify-content:flex-start; align-items:center; gap:4px 7px; text-align:left; min-width:0; }
  .unit-inspector .inspector-avatar { width:38px; height:38px; font-size:1rem; flex:none; }
  .unit-inspector #inspector-badge img { width:23px; height:23px; }
  .unit-inspector #inspector-owner { font-size:.69rem; }
  .unit-inspector .inspector-stats { gap:4px; }
  .unit-inspector .inspector-stats > div { padding:5px; gap:2px; }
  .unit-inspector .inspector-stats strong { font-size:.7rem; }
  .unit-inspector .inspector-stats small { font-size:.5rem; }
  .unit-inspector section { margin-top:6px; padding-top:3px; }
}
@media (max-width:390px) {
  .app.battle-mode .battle-unit-card { flex-basis:108px; height:152px; }
  .app.battle-mode .battle-card-art { height:65px; }
  .app.battle-mode .battle-card-art > .pawn-preview { width:65px; height:65px; }
  .app.battle-mode .team-wars-panel { max-width:calc(100vw - 12px); }
  .app.battle-mode .battle-view-actions > button { padding:4px 5px; font-size:.52rem; }
}


/* V29.5: At phone widths the profile shortcut uses display:contents.
   Move its real grid children with the header; the parent has no box to animate. */
@media (max-width:750px) {
  .app.battle-mode .topbar .profile-shortcut > .wallet,
  .app.battle-mode .topbar .profile-shortcut > .identity-copy,
  .app.battle-mode .topbar .profile-shortcut > .account-menu-wrap {
    transition:transform .35s cubic-bezier(.22,.7,.26,1), opacity .22s ease,
               visibility 0s linear .35s;
  }
  .app.battle-mode.battle-header-hidden .topbar .profile-shortcut > .wallet,
  .app.battle-mode.battle-header-hidden .topbar .profile-shortcut > .identity-copy,
  .app.battle-mode.battle-header-hidden .topbar .profile-shortcut > .account-menu-wrap {
    transform:translateY(-155px);
    opacity:0;
    visibility:hidden;
    pointer-events:none;
  }
}

/* Small, unobtrusive Team Wars team counts on phones. Join buttons stay tappable. */
@media (max-width:600px) {
  .app.battle-mode .team-wars-panel {
    max-width:min(270px,calc(100vw - 12px));
    gap:3px 7px;
    padding:4px 7px;
    font-size:.56rem;
    line-height:1.2;
    letter-spacing:0;
    border-color:#55765b55;
    background:#081810cc;
  }
  .app.battle-mode .team-wars-panel > div:first-child {
    flex-direction:row;
    align-items:center;
    flex-wrap:wrap;
    gap:2px 6px;
  }
  .app.battle-mode .team-wars-panel strong {
    font-size:.57rem;
    letter-spacing:.025em;
  }
  .app.battle-mode .team-wars-panel #team-wars-score {
    font-size:.56rem;
    white-space:nowrap;
    font-variant-numeric:tabular-nums;
  }
  .app.battle-mode .team-wars-panel #team-wars-message {
    font-size:.53rem;
    line-height:1.15;
  }
  .app.battle-mode .team-wars-panel .team-wars-side {
    gap:4px;
  }
  .app.battle-mode .team-wars-panel .team-wars-side button {
    min-height:30px;
    padding:4px 7px;
    font-size:.61rem;
  }
}

/* V29.6: Five compact resources. The old nowrap wallet caused JOINTS/MASH to
   overflow the phone viewport. The five counts are retained, and only the
   visible labels are abbreviated on phones. */
.wallet-short { display:none; }
@media (max-width:750px) {
  /* Explicit rows prevent the five-item wallet overlapping the avatar row. */
  .app.battle-mode .topbar { grid-template-rows:52px 34px 16px; }
  .app.battle-mode .topbar > .battle-location { transform:translateY(5px); }
  .app.battle-mode .topbar .profile-shortcut > .wallet {
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    grid-auto-rows:minmax(25px,auto);
    justify-content:stretch;
    align-items:stretch;
    width:100%;
    min-width:0;
    max-width:none;
    gap:2px;
    font-size:inherit;
  }
  .app.battle-mode .topbar .wallet > span {
    display:grid;
    grid-template-columns:13px minmax(0,max-content);
    grid-template-rows:13px 11px;
    place-content:center;
    align-items:center;
    justify-items:center;
    column-gap:2px;
    min-width:0;
    padding:1px 0;
    line-height:1;
    white-space:normal;
    text-align:center;
  }
  .app.battle-mode .topbar .wallet > span > img {
    grid-column:1; grid-row:1;
    width:12px; height:12px;
  }
  .app.battle-mode .topbar .wallet > span > b {
    grid-column:2; grid-row:1;
    font-size:.62rem;
    font-variant-numeric:tabular-nums;
    white-space:nowrap;
  }
  .app.battle-mode .topbar .wallet .wallet-label { display:none; }
  .app.battle-mode .topbar .wallet .wallet-short {
    display:block;
    grid-column:1 / -1; grid-row:2;
    font-size:.48rem;
    font-weight:650;
    letter-spacing:0;
    white-space:nowrap;
  }
}
/* For narrow portrait menu screens the same resource row is used. */
@media (max-width:400px) {
  .app:not(.battle-mode) .topbar .profile-shortcut > .wallet {
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    justify-content:stretch;
    width:100%; min-width:0; max-width:none; gap:2px;
  }
  .app:not(.battle-mode) .topbar .wallet > span {
    display:grid; grid-template-columns:13px minmax(0,max-content); grid-template-rows:13px 11px;
    place-content:center; justify-items:center; align-items:center; column-gap:2px;
    min-width:0; padding:1px 0; line-height:1; text-align:center; white-space:normal;
  }
  .app:not(.battle-mode) .topbar .wallet > span > img { grid-column:1; grid-row:1; width:12px; height:12px; }
  .app:not(.battle-mode) .topbar .wallet > span > b { grid-column:2; grid-row:1; font-size:.62rem; white-space:nowrap; }
  .app:not(.battle-mode) .topbar .wallet .wallet-label { display:none; }
  .app:not(.battle-mode) .topbar .wallet .wallet-short { display:block; grid-column:1/-1; grid-row:2; font-size:.48rem; font-weight:650; white-space:nowrap; }
}
@media (max-width:600px) {
  /* Team choice buttons remain usable; the read-only status is almost a label. */
  .app.battle-mode .team-wars-panel {
    max-width:min(225px,calc(100vw - 12px));
    padding:3px 5px;
    gap:2px 5px;
    line-height:1.05;
    font-size:.5rem;
  }
  .app.battle-mode .team-wars-panel > div:first-child { gap:1px 4px; }
  .app.battle-mode .team-wars-panel strong { font-size:.5rem; }
  .app.battle-mode .team-wars-panel #team-wars-score { font-size:.48rem; letter-spacing:-.012em; }
  .app.battle-mode .team-wars-panel #team-wars-message { font-size:.46rem; }
  .app.battle-mode .team-wars-panel .team-wars-side button { min-height:29px; padding:4px 5px; font-size:.57rem; }
  /* Compact secondary controls, without removing their labels or functions. */
  .app.battle-mode .battle-view-actions { gap:2px; }
  .app.battle-mode .battle-view-actions > button {
    min-height:23px;
    padding:3px 4px;
    font-size:.49rem;
    letter-spacing:0;
  }
  .app.battle-mode .battle-zoom button { width:32px; height:32px; min-height:32px; padding:0; font-size:1.05rem; }
  .app.battle-mode .battle-zoom #zoom-reset { width:46px; font-size:.66rem; }
}
