/* UI-only 037: fit actual visible landscape space, not a fixed phone resolution. */
:root { --view-x:0px; --view-y:0px; --hud-edge:62px; }
#battle, #controls {
  inset:auto; left:var(--view-x); top:var(--view-y);
  width:var(--view-w); height:var(--view-h);
}
.veil, .codex-overlay {
  inset:auto; left:var(--view-x); top:var(--view-y);
  width:var(--view-w); height:var(--view-h);
}
#hud { left:calc(var(--view-x) + var(--safe-l)); right:auto;
  width:calc(var(--view-w) - var(--safe-l) - var(--safe-r)); top:calc(var(--view-y) + var(--safe-t)); }
#cornerControls { left:calc(var(--view-x) + var(--view-w)/2 - 45px);
  top:calc(var(--view-y) + var(--view-h) - var(--safe-b) - 34px); bottom:auto; }
.menu-button, .roster-button, .synergy-hud { top:calc(var(--hud-edge) + 6px); }
.combo {
  top:calc(var(--view-y) + var(--hud-edge) + 6px);
  left:calc(var(--view-x) + var(--view-w)/2);
  width:min(640px,calc(var(--view-w) - 204px));
  max-width:calc(var(--view-w) - var(--safe-l) - var(--safe-r) - 96px);
  max-height:calc(var(--view-h) - var(--hud-edge) - 92px);
  overflow-x:hidden; overflow-y:auto;
}
.combo .choice { grid-template-columns:minmax(28px,40px) minmax(0,1fr); gap:3px 6px; }
.combo .choice img { width:40px; height:44px; }
.choice strong { font-size:12px; }
.choice strong, .choice .tier, .choice > small, .v3-mini-unit strong,
.v31-member strong, .upgrade-card strong, .unit-row strong, .v3-detail-hero h3 {
  display:block; min-width:0; max-width:100%; white-space:nowrap;
  text-overflow:clip; overflow-x:auto; overflow-y:hidden; scrollbar-width:none;
}
.choice .combo-synergy { white-space:nowrap; overflow-x:auto; grid-column:1/-1; }
.choices[data-fit-layout="stacked"] .choice {
  grid-template-columns:minmax(0,1fr); text-align:center; gap:2px; padding:5px;
}
.choices[data-fit-layout="stacked"] .choice img {
  grid-row:auto; justify-self:center; width:34px; height:34px;
}
.choices[data-fit-layout="stacked"] .choice strong { font-size:11px; }
.choices[data-fit-layout="stacked"] .choice .tier { font-size:9px; letter-spacing:0; }
.choices[data-fit-layout="stacked"] .choice > small { font-size:10px; }
.merge-feed { top:calc(var(--view-y) + var(--hud-edge) + 58px); }
.merge-feed.mine { left:calc(var(--view-x) + var(--safe-l)); }
.merge-feed.enemy { left:auto; right:calc(100vw - var(--view-x) - var(--view-w) + var(--safe-r)); }
.drawer { left:auto; right:calc(100vw - var(--view-x) - var(--view-w) + var(--safe-r));
  top:calc(var(--view-y) + var(--safe-t)); bottom:auto;
  height:calc(var(--view-h) - var(--safe-t) - var(--safe-b)); }
.toast { top:auto; bottom:calc(100vh - var(--view-y) - var(--view-h) + var(--safe-b) + 42px);
  left:calc(var(--view-x) + var(--view-w)/2); white-space:nowrap;
  max-width:calc(var(--view-w) - 160px); overflow-x:auto; text-overflow:clip; font-size:11px; padding:7px 12px; }
#netStatus { left:calc(var(--view-x) + var(--view-w)/2);
  bottom:calc(100vh - var(--view-y) - var(--view-h) + var(--safe-b) + 42px); }
#aimHint { left:calc(var(--view-x) + var(--view-w)/2); max-width:calc(var(--view-w) - 160px); white-space:nowrap; }
#aimHint small { white-space:nowrap; overflow-x:auto; }
/* Short battle actions do not wrap. Full descriptions remain readable in their panels. */
.home-actions button { display:flex; align-items:center; justify-content:center; gap:8px; }
.home-actions small { display:inline; margin:0; }
.home-actions .primary span { float:none; }
.home-footer { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.home-footer span { float:none; flex:none; }
.v3-recipe { min-width:0; }
.v3-mini-unit strong { width:100%; text-align:center; }
.v3-detail-hero { min-width:0; }
.v3-list .v3-recipe { gap:5px; }
@media (orientation:landscape) and (max-height:500px) {
  .home-card.faction-home {
    width:min(740px,100%); display:grid; grid-template-columns:minmax(170px,.85fr) minmax(260px,1.4fr);
    grid-template-rows:auto auto auto auto 1fr auto auto;
    column-gap:22px; padding:14px 18px; text-align:left;
  }
  .home-card .eyebrow { grid-column:1; grid-row:1; font-size:8px; letter-spacing:.06em; white-space:nowrap; }
  .home-card .eyebrow span { padding:0 4px; }
  .home-card .mini-crest, .home-card .intro, .home-card .race-figures { display:none!important; }
  .home-card h1 { grid-column:1; grid-row:2; font-size:36px!important; margin:10px 0 4px!important; white-space:nowrap; }
  .home-card .subtitle { grid-column:1; grid-row:3; font-size:12px; margin:0 0 8px!important; }
  .home-card .faction-lobby { grid-column:2; grid-row:1/7; min-width:0; margin:0; }
  .home-card .home-actions { grid-column:1; grid-row:4; flex-direction:column; gap:8px; }
  .home-actions button { min-height:40px; padding:8px 9px; font-size:12px; }
  .home-card #resume { grid-column:1; grid-row:5; padding:7px 0; margin:0; text-align:left; }
  .home-footer { grid-column:1/-1; grid-row:7; padding-top:7px; margin-top:8px; font-size:9px; }
  .faction-lobby .race-tabs { display:flex; gap:5px; margin:0 0 6px; }
  .race-tab { flex:1; min-width:0; min-height:36px; padding:6px 7px; font-size:12px; }
  .faction-lobby .race-description { font-size:10px; margin:5px 0; }
  .faction-lobby .wallet { margin:6px 0; }
  .v3-lobby-tools { gap:6px!important; }
  .v3-lobby-tools button { min-height:35px; font-size:11px!important; }
  .v3-loadout-note { font-size:9px; text-align:left; }
  .combo { width:min(550px,calc(var(--view-w) - 184px)); }
}
@media (max-width:700px) and (orientation:landscape) {
  .home-card.faction-home { grid-template-columns:minmax(157px,.8fr) minmax(0,1.3fr); column-gap:12px; padding:12px; }
  .home-card h1 { font-size:30px!important; }
  .home-card .eyebrow { font-size:7px; letter-spacing:0; }
  .combo { width:calc(var(--view-w) - 204px); top:calc(var(--view-y) + var(--hud-edge) + 6px); }
  .combo { max-height:calc(var(--view-h) - var(--hud-edge) - 92px); }
  .combo .choice { min-height:68px; }
  .combo .choice img { width:32px; height:37px; }
  .choices:not([data-fit-layout="stacked"]) .choice { grid-template-columns:32px minmax(0,1fr); }
  .combo .combo-foot { display:none; }
  .v3-atlas-main { grid-template-columns:minmax(0,1fr); }
  .v3-atlas-main:not(.detail-open) .v3-atlas-detail { display:none; }
  .v3-atlas-main.detail-open .v3-atlas-view { display:none; }
  .v3-atlas-main.detail-open .v3-atlas-detail { display:block; width:100%; height:100%; border:0; }
  .mobile-detail-back { display:block!important; }
  .v3-list .v3-recipe { display:grid; grid-template-columns:minmax(0,1fr) 14px minmax(0,1fr); overflow:visible; }
  .v3-list .v3-materials, .v3-list .v3-results { min-width:0; width:100%; overflow:visible; }
  .v3-list .v3-mini-unit, .v3-list .v3-result-choice {
    flex:1 1 0; width:auto; min-width:0; max-width:none;
  }
  .v3-list .v3-result-choice .v3-mini-unit { width:100%; }
  .v3-list .v3-mini-unit strong { font-size:11px; }
  .v3-list .v3-plus { flex:none; font-size:11px; }
}
@media (orientation:landscape) and (max-height:430px) {
  .combo .combo-foot { display:none; }
  .combo header { margin-bottom:3px; }
}

/* Cover browser viewport during iOS toolbar/rotation transitions. */
html{background:#182d31}
