/* Mobile gameplay layout (landscape phones). Loaded last; only re-sizes/re-anchors the HUD.
   Zones: top-left player card + buffs · top-centre target · top-right minimap ·
   bottom-left chat (joystick floats above it) · bottom-centre menu + wallet · bottom-right action cluster. */
@media (orientation: landscape) and (max-height: 900px) {
  /* player card: compact, bars read at a glance */
  body.mobile #hud-top { width: 176px; gap: 3px; top: calc(6px + env(safe-area-inset-top, 0px)); left: calc(8px + env(safe-area-inset-left, 0px)); }
  body.mobile #hud-top .bar { height: 14px; }
  body.mobile #hud-top .bar.xp { height: 7px; }
  body.mobile #hud-top .bar span { font-size: 10px; line-height: 12px; }
  body.mobile #hud-top .bar.xp span { display: none; }
  body.mobile #hud-name { font-size: 13px; }
  body.mobile #hud-zone { font-size: 12px; padding: 2px 8px; }
  body.mobile #hud-buffs { gap: 3px; margin-top: 3px; }
  body.mobile #hud-buffs .buff-icon { width: 24px; height: 24px; }

  /* target frame slimmer so it never reaches the minimap */
  body.mobile #hud-target { width: 220px; padding: 6px 10px; top: calc(6px + env(safe-area-inset-top, 0px)); }

  /* chat: small, bottom-left, lets touches through to the joystick */
  body.mobile #chat { width: min(32vw, 250px); left: calc(8px + env(safe-area-inset-left, 0px)); bottom: calc(6px + env(safe-area-inset-bottom, 0px)); padding: 4px 6px; opacity: .88; }
  body.mobile #chat-lines { font-size: calc(11px * var(--chat-scale, 1)); max-height: 56px; }
  body.mobile #chat-filters { display: none; }

  /* wallet: one row, centred above the menu button */
  body.mobile #hud-yang, body.mobile #hud-dc { width: 98px; margin-left: 0; font-size: 12px; bottom: calc(54px + env(safe-area-inset-bottom, 0px)); }
  body.mobile #hud-yang { left: calc(50% - 100px); }
  body.mobile #hud-dc { left: calc(50% + 2px); }

  /* menu button: smaller, tucked at the bottom edge */
  body.mobile .mob-topbar { bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  body.mobile .mob-topbar > .mob-menu-btn { width: 40px; height: 40px; }

  /* ping/online pill out of the action cluster's way */
  body.mobile #hud-ping { bottom: calc(4px + env(safe-area-inset-bottom, 0px)); right: calc(6px + env(safe-area-inset-right, 0px)); font-size: 10px; opacity: .7; white-space: nowrap; }

  /* minimap larger (still scalable from the HUD setting) */
  body.mobile #minimap { transform: scale(calc(var(--mob-hud-minimap-scale, 1.45) * var(--mobile-controls-hud-fit, 1))); transform-origin: top right; top: calc(4px + env(safe-area-inset-top, 0px)); right: calc(6px + env(safe-area-inset-right, 0px)); }

  /* pet panels live top-left beside the player card, never over the action cluster */
  html body.mobile #pet-prospecting { right: auto !important; bottom: auto !important; height: auto !important; max-height: none !important; left: calc(190px + env(safe-area-inset-left, 0px)) !important; top: calc(var(--mobile-ui-top, 0px) + 6px) !important; width: 230px; z-index: 40; }
  html body.mobile #pet-prospecting.pp-compact { width: 190px; }
  html body.mobile #pet-prospecting .pp-body { max-height: 200px; overflow-y: auto; scrollbar-width: none; }
  body.mobile #pet-ability-hud { z-index: 40; }

  /* windows: full-bleed, slim title bar so the content gets the height */
  body.mobile #windows > .win { width: 100%; max-width: 100%; border-radius: 0; }
  body.mobile .win > .win-title { min-height: 40px !important; padding-top: 0 !important; padding-bottom: 0 !important; font-size: 13px; }
  body.mobile .win > .win-title .x { flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px !important; min-height: 44px !important; }
  body.mobile .win > .win-title::before, body.mobile .win > .win-title::after { display: none; }
  body.mobile .win > .win-body { padding-top: 6px; }
}

/* Window content on short landscape screens. */
@media (orientation: landscape) and (max-height: 900px) {
  body.mobile .rpg-btn.sm { min-height: 32px; min-width: 32px; }
  /* Inventory: tools in a left rail, item grid fills the rest and scrolls on its own. */
}

/* Skills: banner, ultimates and toolbar collapse into three slim rows so the tree and detail get the height. */

/* Clan, premium, wiki, season: shrink decorative headers. */
@media (orientation: landscape) and (max-height: 400px) {
  html body #screen-chars .char-row { min-height: 38px !important; padding: 3px 6px !important; }
  html body #screen-chars #btn-new-char, html body #screen-chars #btn-char-back { min-height: 34px !important; padding: 2px 8px !important; }
}

/* Round-2 fixes: character sidebar, settings categories, clan nav at 667px, small grid labels. */
@media (orientation: landscape) and (max-height: 900px) {
  html body.mobile .settings-nav { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px !important; align-content: start; }
  html body.mobile .settings-mobile-intro { grid-column: 1 / -1; }
  html body.mobile .settings-tab { height: 52px !important; min-height: 0 !important; }
  html body.mobile #win-materials :is(.inv-slot, .mat-slot) small, html body.mobile .ik-label { font-size: 10px; }
}





/* Boss damage list: under the target frame instead of over the player card; compact. */
@media (orientation: landscape) and (max-height: 900px) {
  html body.mobile #target-contributions { left: 50% !important; right: auto !important; top: calc(92px + env(safe-area-inset-top, 0px)) !important; bottom: auto !important; width: 220px; max-height: 120px; overflow: hidden; transform: translateX(-50%) scale(.9); transform-origin: top center; font-size: 11px; }
}


/* Narrow landscape (<=700px) touch-ups from the last review. */

/* Character select on short landscape screens: list | info card | character model, one row, nothing overlaps. */
@media (orientation: landscape) and (max-height: 900px) {
  html body #screen-chars .chars-panel > h2 { font-size: 11px !important; letter-spacing: 3px; margin: 0 0 4px !important; }
  html body #screen-chars .chars-panel > h2::after { display: none; }
  html body #screen-chars .char-select-layout { grid-template-columns: minmax(0, 27fr) minmax(0, 37fr) minmax(0, 36fr) !important; grid-template-rows: minmax(0, 1fr) !important; height: calc(100% - 22px) !important; gap: 8px !important; }
  html body #screen-chars .char-select-list { grid-column: 1 !important; grid-row: 1 !important; max-height: none !important; overflow-y: auto !important; padding: 2px !important; }
  html body #screen-chars #char-list { display: flex !important; flex-direction: column; gap: 4px; }
  html body #screen-chars .char-row { min-height: 46px !important; }
  html body #screen-chars .char-showcase-info { grid-column: 2 !important; grid-row: 1 !important; height: 100% !important; align-self: stretch !important; padding: 8px !important; overflow: hidden; display: flex; flex-direction: column; gap: 4px; }
  html body #screen-chars #char-showcase { grid-column: 3 !important; grid-row: 1 !important; }
  html body #screen-chars #char-showcase-model { height: min(300px, 80dvh) !important; margin-top: 0 !important; }
  html body #screen-chars #char-showcase-name { font-size: 20px; margin: 0 0 2px; }
  html body #screen-chars #char-showcase-stats { margin-bottom: 2px; gap: 4px; }
  html body #screen-chars #char-showcase-stats span { padding: 3px 5px; font-size: 10px; }
  html body #screen-chars #char-showcase-equipment { flex: 1 1 0 !important; min-height: 0 !important; height: auto !important; max-height: none !important; overflow-y: auto !important; scrollbar-width: none; grid-template-columns: 1fr; }
  html body #screen-chars #btn-enter-char { position: static !important; flex: 0 0 auto; min-height: 40px !important; padding: 6px !important; margin-top: 2px; }
}

/* Notch / Dynamic Island / home indicator: keep bars and chat input out of the cutouts (viewport-fit=cover is set in index.html). */
body.mobile #mob-chat-bar { padding-left: calc(8px + env(safe-area-inset-left, 0px)); padding-right: calc(8px + env(safe-area-inset-right, 0px)); padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
body.mobile #dung-banner { max-width: calc(100vw - 2 * (env(safe-area-inset-left, 0px) + 12px)); }
body.mobile .mob-edit-banner { top: calc(var(--mobile-ui-top, 0px) + 8px); }


/* Interact button: name + action in a readable pill above the button, bigger icon. */
body.mobile .act-interact .lbl { top: auto !important; bottom: calc(100% + 6px) !important; left: 50% !important; right: auto !important; transform: translateX(-50%) !important; width: max-content !important; max-width: 170px !important; padding: 3px 9px !important; border: 1px solid #5ad07a; border-radius: 6px; background: #0f1d14ee; color: #e8fff0; font-size: 12px !important; font-weight: 700; line-height: 1.25 !important; text-align: center; white-space: normal !important; text-overflow: clip; z-index: 3; }
body.mobile .act-interact .lbl::after { content: attr(data-verb); display: block; font-size: 10px; font-weight: 600; color: #8fe3a1; letter-spacing: .3px; }
body.mobile .act-interact .lbl[data-verb=""]::after { display: none; }
body.mobile .act-interact > img { width: 56% !important; height: 56% !important; margin-top: 0 !important; }
