/* ═══════════════════════════════════════════════════════════════════════
   responsive.css — v158.5 responsive web layer (tablet + desktop + mobile web)
   Loaded right after elevated.css. Inline <style> and the sidecar modules
   inject their CSS later in <head>, so every selector here is prefixed with
   `html.hb-web` (or `html`) for specificity instead of relying on order.

   Gate
     html.hb-web     browser (set by the inline script next to the <link>)
     html.hb-native  Capacitor iOS shell — keeps the phone layout untouched.
     Bug fixes that are correct at every size are NOT gated.

   Breakpoints (CSS has no custom media yet — keep these in sync)
     tablet   ≥ 640px   wider single column, floating dock
     dialog   ≥ 900px   bottom sheets become centred dialogs
     desk     ≥ 1024px  side rail nav + multi-column layouts
                        (desktop browsers, iPad landscape)
     wide     ≥ 1440px  larger content caps

   Tokens
     --hb-rail-w   width of the side rail (0 below desk). Full-screen surfaces
                   that stay under the rail pad their left edge by it.
     --hb-gutter   page side padding.
   ═══════════════════════════════════════════════════════════════════════ */

:root { --hb-rail-w: 0px; --hb-gutter: 16px; }

/* ── Fixes at every size ──────────────────────────────────────────────── */

/* In-game "How to play" card had no padding — the title rendered half
   off the left edge ("ʜOW TO PLAY") on every screen. */
html #gameHelpOverlay .settings-card { padding: 22px 20px 18px; box-sizing: border-box; }

/* Visible keyboard focus on surfaces that reset outlines with `all:unset`. */
html :is(.hb-nav-item, .hb-nav-play, .lobby-corner-btn, .lobby-corner-identity-half,
  .hv2-tile, .hv2-wide, .hv2-ev, .hv2-cta, .hv2-seg button, .hv2-chest, .hv2-foot button,
  .hbs-card, .hbs-tab, .hbs-x, .hbs-pill.gem, .hbs-nav, .hbs-link,
  .pv2-ib, .pv2-row, .pv2-slot, .pv2-badge, .pv2-title, .pv2-sec button,
  .cq-back, .cq-realm, .cq-node, .cq-go, .cq-d-x,
  .rt-x, .rt-cta, .hp-pw-x, .lobby-overflow-item):focus-visible {
  outline: 2px solid #b9b0ff; outline-offset: 2px;
}

/* ═══ TABLET (≥ 640px, web) ═══════════════════════════════════════════ */
@media (min-width: 640px) {
  html.hb-web { --hb-gutter: 24px; }

  /* Bottom tab bar becomes a centred dock instead of a full-bleed strip. */
  html.hb-web .hb-nav {
    max-width: 600px; left: 50%; right: auto; width: 100%;
    transform: translateX(-50%); border-radius: 22px 22px 0 0;
    border: 1px solid rgba(255,255,255,.07); border-bottom: 0;
  }

  /* #lobby is the scroll container and used to be capped at 720–820px, so the
     mouse wheel / trackpad did nothing over the side margins. Let it span the
     window; the content column is capped inside it instead. */
  html.hb-web #lobby.elev-home { max-width: none !important; width: 100%; }
  html.hb-web #hv2Root { max-width: 640px; }
  html.hb-web body.hv2 #lobby #menuCard { max-width: 640px !important; }
  /* Sub-screens (vs Bots, host/join, pass-and-play, browse) are fixed
     full-page overlays; keep their content in a readable centred column
     instead of stretching rows across the whole window. */
  html.hb-web #lobby.elev-home.lobby-in-subcard .lobby-card:not(#menuCard) {
    padding-left: max(var(--hb-gutter), calc((100vw - 760px) / 2));
    padding-right: max(var(--hb-gutter), calc((100vw - 760px) / 2));
  }

  html.hb-web #shopOverlay.hbs .hbs-root { max-width: 760px; }
  html.hb-web .hbs-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  html.hb-web .hbs-grid.three { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  html.hb-web .hbs-grid.four { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  html.hb-web .hbs-rail > .hbs-card { flex-basis: 196px; }

  html.hb-web .pv2-root { max-width: 680px; }

  /* Conquest: centred column and a capped battle sheet in portrait */
  html.hb-web .cq-top, html.hb-web .cq-realms, html.hb-web .cq-scroll {
    padding-left: max(24px, calc(50% - 380px)); padding-right: max(24px, calc(50% - 380px));
  }
  html.hb-web .cq-detail { left: max(0px, calc(50% - 330px)); right: max(0px, calc(50% - 330px)); }
}

/* ═══ DIALOGS (≥ 900px, web) — bottom sheets → centred dialogs ═══════════ */
@media (min-width: 900px) {
  /* shop item sheet */
  html.hb-web #hbsSheet { align-items: center; padding: 24px; }
  html.hb-web #hbsSheet .hbs-sh {
    max-width: 520px; max-height: min(880px, calc(100vh - 48px));
    border-radius: 28px; padding-bottom: 20px;
    box-shadow: var(--elev-5), inset 0 0 0 1px rgba(255,255,255,.08);
  }
  html.hb-web #hbsSheet .hbs-grab { display: none; }

  /* profile sheets (edit / account / achievements) */
  html.hb-web .pv2-sheet { align-items: center; padding: 24px; }
  html.hb-web .pv2-sh { max-width: 560px; max-height: min(860px, calc(100vh - 48px)); border-radius: 26px; padding-bottom: 22px; }

  /* retention sheets (journey / invite) */
  html.hb-web .rt-sheet { align-items: center; padding: 24px; }
  html.hb-web .rt-sh { max-width: 540px; max-height: min(860px, calc(100vh - 48px)); border-radius: 26px; }
  html.hb-web .rt-grab { visibility: hidden; height: 0; margin-top: 4px; }

  /* Hex Pass paywall */
  html.hb-web .hp-pw { align-items: center; padding: 24px; }
  html.hb-web .hp-pw-card { max-height: min(900px, calc(100vh - 48px)); border-radius: var(--r-xl); padding-bottom: 20px; }

  /* title picker */
  html.hb-web .tp-overlay { align-items: center; padding: 24px; }
  html.hb-web .tp-card { border-radius: var(--r-xl); max-height: min(720px, calc(100vh - 48px)); }

  /* Sheets slide up from the bottom edge on phones; a centred dialog rises
     and scales in place instead. (#friendsModal is owned by friends-v2.) */
  html.hb-web :is(#hbsSheet, .pv2-sheet, .rt-sheet, .hp-pw, .tp-overlay).ov-in > * { animation: ovCardIn var(--dur-slow) var(--ease-ios) both; }
  html.hb-web :is(#hbsSheet, .pv2-sheet, .rt-sheet, .hp-pw, .tp-overlay).ov-out > * { animation: ovCardOut var(--dur-fast) var(--ease-exit) both; }

  /* onboarding push soft-ask */
  html.hb-web #hbOnbPush { align-items: center; padding: 24px; }
  html.hb-web #hbOnbPush .onbp-card { border-radius: var(--r-xl); padding-bottom: 18px; }
  html.hb-web #hbOnbPush.ov-in > * { animation: ovCardIn var(--dur-slow) var(--ease-ios) both; }

  /* "More" and Inbox trays → menus anchored under their corner buttons. */
  html.hb-web :is(#lobbyOverflowTray, #notifInbox) { align-items: flex-start; justify-content: flex-end; padding: calc(max(14px, env(safe-area-inset-top, 0px)) + 52px) 16px 0; background: rgba(0,0,0,.28); backdrop-filter: none; -webkit-backdrop-filter: none; }
  html.hb-web :is(#lobbyOverflowTray, #notifInbox) .lobby-overflow-sheet { max-width: 300px; border-radius: var(--r-lg); border: 1px solid rgba(255,255,255,.12); padding: 8px; box-shadow: var(--elev-4); animation: hbMenuIn var(--dur-base) var(--ease-ios) both; transform-origin: top right; }
  html.hb-web .lobby-overflow-tray .lobby-overflow-sheet-handle { display: none; }
  html.hb-web #notifInbox .lobby-overflow-sheet { max-width: 380px; }
  /* "Play with a friend" (opened from the home tile) → centred dialog */
  html.hb-web #playFriendsSheet { align-items: center; padding: 24px; }
  html.hb-web #playFriendsSheet .lobby-overflow-sheet { max-width: 460px; border-radius: var(--r-xl); border: 1px solid rgba(255,255,255,.12); padding-bottom: 18px; box-shadow: var(--elev-5); animation: hbMenuIn var(--dur-base) var(--ease-ios) both; transform-origin: center; }
}
@keyframes hbMenuIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ═══ DESK (≥ 1024px, web) — side rail + multi-column ═══════════════════ */
@media (min-width: 1024px) {
  html.hb-web { --hb-rail-w: calc(88px + env(safe-area-inset-left, 0px)); --hb-gutter: 32px; }

  /* Full-screen shop: fade/rise in place instead of a 100% slide-up. */
  html.hb-web #shopOverlay.ov-in > * { animation: ovCardIn var(--dur-slow) var(--ease-ios) both; }
  html.hb-web #shopOverlay.ov-out > * { animation: ovCardOut var(--dur-fast) var(--ease-exit) both; }

  /* ── Side rail (was the phone tab bar) ── */
  html.hb-web .hb-nav {
    top: 0; bottom: 0; left: 0; right: auto; width: var(--hb-rail-w); max-width: none;
    transform: none; border-radius: 0; border: 0; border-right: 1px solid rgba(255,255,255,.07);
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px;
    padding: calc(max(18px, env(safe-area-inset-top, 0px)) + 4px) 10px calc(18px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
    background: linear-gradient(180deg, rgba(20,20,46,.96), rgba(11,12,28,.98));
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  html.hb-web .hb-nav-play { order: -1; width: 64px; height: 70px; margin: 0 auto 14px; font-size: 10px; box-shadow: 0 8px 24px rgba(124,111,247,.4); }
  html.hb-web .hb-nav-item { flex: 0 0 auto; padding: 11px 0 9px; gap: 5px; border-radius: var(--r-md); font-size: 10.5px; }
  html.hb-web .hb-nav-item.is-active { background: rgba(124,111,247,.16); box-shadow: inset 0 0 0 1px rgba(160,148,255,.26); }
  html.hb-web .hb-nav-badge { top: 6px; right: calc(50% - 22px); }

  /* lobby + its fixed chrome sit to the right of the rail */
  html.hb-web body.hv2 #lobby.elev-home:not(.lobby-in-subcard) {
    padding-left: calc(var(--hb-rail-w) + var(--hb-gutter)) !important;
    padding-right: var(--hb-gutter) !important;
  }
  html.hb-web #lobby.elev-home.lobby-in-subcard .lobby-card:not(#menuCard) {
    padding-left: calc(var(--hb-rail-w) + max(var(--hb-gutter), calc((100vw - var(--hb-rail-w) - 880px) / 2)));
    padding-right: max(var(--hb-gutter), calc((100vw - var(--hb-rail-w) - 880px) / 2));
  }
  html.hb-web #lobby.has-nav, html.hb-web body.hv2 #lobby.has-nav { padding-bottom: 48px !important; }
  html.hb-web .lobby-corner-identity { left: calc(var(--hb-rail-w) + 16px); }
  /* The 200px top / 240px bottom scrims were sized for the phone header and
     tab bar; with the rail they only dimmed content. Keep a short header
     scrim (legibility under the corner controls) and a soft bottom edge. */
  html.hb-web body.home-redesign-v1 #lobby.elev-home::before { height: 92px !important; left: var(--hb-rail-w); }
  html.hb-web body.home-redesign-v1 #lobby.elev-home::after { height: 48px !important; left: var(--hb-rail-w); }
  html.hb-web .active-booster-pill { margin-left: var(--hb-rail-w); }
  html.hb-web body.hb-nav-on #freeChestBtn, html.hb-web body.hb-nav-on .feedback-fab { bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important; }

  /* ── Home: play column + side column ── */
  html.hb-web body.hv2 #lobby #menuCard { max-width: 1120px !important; }
  html.hb-web #hv2Root {
    max-width: 1120px; display: grid; align-items: start;
    grid-template-columns: minmax(0, 1fr) clamp(290px, 29vw, 360px); column-gap: 28px;
  }
  html.hb-web #hv2Root .hv2-col { display: flex; flex-direction: column; min-width: 0; }
  html.hb-web #hv2Side > .hv2-sec:first-of-type,
  html.hb-web #hv2JourneySlot:empty + .hv2-sec { margin-top: 0; }
  html.hb-web #hv2JourneySlot:not(:empty) + .hv2-sec { margin-top: 22px; }
  html.hb-web #hv2Side .hv2-foot { justify-content: flex-start; padding-left: 2px; }
  html.hb-web .hv2-hero-in { padding: 20px 20px 18px; }
  html.hb-web .hv2-stage { height: 104px; }

  /* ── Shop ── */
  html.hb-web body.hb-nav-on #shopOverlay.hbs { padding-left: var(--hb-rail-w) !important; }
  html.hb-web #shopOverlay.hbs .hbs-root { max-width: 1120px; }
  html.hb-web #shopOverlay.hbs .hbs-head { padding-left: var(--hb-gutter); padding-right: var(--hb-gutter); padding-top: calc(env(safe-area-inset-top, 0px) + 20px); }
  html.hb-web #shopOverlay.hbs .hbs-tabs { padding-left: calc(var(--hb-gutter) - 2px); padding-right: var(--hb-gutter); -webkit-mask-image: none; mask-image: none; }
  html.hb-web #shopOverlay.hbs .hbs-scroll { padding-left: var(--hb-gutter); padding-right: var(--hb-gutter); padding-bottom: 48px; }
  /* Horizontal rails are awkward with a mouse wheel — lay them out as a grid. */
  html.hb-web #shopOverlay.hbs .hbs-rail { display: grid; grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: 14px; overflow: visible; margin: 0; padding: 2px 0 4px; scroll-snap-type: none; }
  html.hb-web .hbs-grid { grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: 14px; }
  html.hb-web .hbs-grid.three { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  html.hb-web .hbs-grid.four { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  /* Featured: the daily deal becomes a banner (preview | details) and the
     weekly mythic + Hex Pass tiles sit side by side under it. */
  html.hb-web #shopOverlay .hbs-hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); }
  html.hb-web #shopOverlay .hbs-hero-stage { height: 290px; }
  html.hb-web #shopOverlay .hbs-hero-body { flex-direction: column; align-items: flex-start; justify-content: center; gap: 18px; padding: 28px 30px; }
  html.hb-web #shopOverlay .hbs-hero-txt { flex: 0 0 auto; width: 100%; }
  html.hb-web #shopOverlay .hbs-hero-name { font-size: 40px; white-space: normal; }
  html.hb-web #shopOverlay .hbs-hero-cta { display: flex; align-items: center; gap: 12px; text-align: left; }
  html.hb-web #shopOverlay .hbs-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; align-items: stretch; }
  html.hb-web #shopOverlay .hbs-duo:empty { display: none; }
  html.hb-web #shopOverlay .hbs-duo > :only-child { grid-column: 1 / -1; }
  html.hb-web #shopOverlay .hbs-duo > .hbs-week, html.hb-web #shopOverlay .hbs-duo > .hbs-pass { margin-top: 0; }
  html.hb-web #shopOverlay .hbs-duo > .hbs-pass > * { height: 100%; margin: 0; }
  html.hb-web .hbs-packs { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

  /* ── Profile: player column + collection column ── */
  html.hb-web body.hb-nav-on #profileModal.pv2 { padding-left: var(--hb-rail-w) !important; }
  html.hb-web .pv2-root { max-width: 1080px; }
  html.hb-web .pv2-head { padding-left: var(--hb-gutter); padding-right: var(--hb-gutter); padding-top: calc(env(safe-area-inset-top, 0px) + 20px); }
  html.hb-web .pv2-scroll { padding-left: var(--hb-gutter); padding-right: var(--hb-gutter); padding-bottom: 48px; }
  html.hb-web .pv2-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 28px; align-items: start; }
  html.hb-web .pv2-col { display: block; min-width: 0; }
  html.hb-web .pv2-col > .pv2-sec:first-child { margin-top: 0; }

  /* ── Hex Pass (full-screen takeover) ── */
  html.hb-web .hp-top, html.hb-web .hp-scroll { max-width: 880px; }
  html.hb-web .hp-dock { width: min(880px, 100%); }

  /* ── Conquest: map column + battle panel on the right ── */
  html.hb-web .cq-top, html.hb-web .cq-realms {
    padding-left: max(24px, calc(50% - 560px)); padding-right: max(24px, calc(50% - 560px));
  }
  html.hb-web .cq-scroll {
    padding-left: max(24px, calc(50% - 560px));
    padding-right: calc(max(24px, calc(50% - 560px)) + 404px);
    padding-bottom: 48px;
  }
  html.hb-web .cq-path { max-width: 600px; margin-left: auto; margin-right: auto; }
  html.hb-web .cq-detail {
    left: auto; right: max(24px, calc(50% - 560px)); bottom: 24px; width: 380px;
    max-height: calc(100% - 190px); overflow-y: auto;
    border-radius: var(--r-xl); border: 1px solid color-mix(in srgb, var(--cq) 40%, transparent);
    padding-bottom: 18px;
  }
  html.hb-web .cq-d-grab { display: none; }

  /* ── In-game HUD: a touch larger on big screens (zoom keeps the chips'
     own transforms/animations intact) ── */
  html.hb-web #game :is(.hud-top, .hud-players) { zoom: 1.12; }
}

/* Onboarding intro on a big screen: same canvas, type scaled for distance. */
@media (min-width: 1024px) and (min-height: 700px) {
  html.hb-web #hbOnb .onb-pane { max-width: 680px; }
  html.hb-web #hbOnb .onb-cap h1 { font-size: 44px; }
  html.hb-web #hbOnb .onb-cap p { font-size: 17px; max-width: 420px; }
  html.hb-web #hbOnb .onb-body h2 { font-size: 38px; }
  html.hb-web #hbOnb .onb-body .onb-sub { font-size: 16px; }
}

/* ═══ WIDE (≥ 1440px, web) ═══════════════════════════════════════════ */
@media (min-width: 1440px) {
  html.hb-web { --hb-gutter: 40px; }
  html.hb-web body.hv2 #lobby #menuCard, html.hb-web #hv2Root { max-width: 1180px !important; }
  html.hb-web #shopOverlay.hbs .hbs-root { max-width: 1240px; }
  html.hb-web .pv2-root { max-width: 1140px; }
}

/* ═══ POINTER: hover feedback only where a mouse can hover ═══════════════ */
@media (hover: hover) and (pointer: fine) {
  html.hb-web .hb-nav-item:hover { color: #e6e2ff; background: rgba(255,255,255,.05); }
  html.hb-web .hb-nav-item.is-active:hover { background: rgba(124,111,247,.2); }
  html.hb-web .hb-nav-play:hover { transform: translateY(-1px) scale(1.03); }
  html.hb-web .lobby-corner-btn:hover { background: rgba(255,255,255,.1); }
  html.hb-web :is(.hv2-tile, .hv2-ev, .hv2-wide, .hbs-card, .pv2-slot, .pv2-badge):hover { transform: translateY(-2px); }
  html.hb-web :is(.hv2-tile, .hv2-ev, .hbs-card):hover { box-shadow: inset 0 0 0 1px rgba(185,176,255,.32), var(--elev-3); }
  html.hb-web .hv2-cta:hover { filter: brightness(1.05); }
  html.hb-web .hv2-seg button:not(.on):hover { color: #fff; background: rgba(255,255,255,.06); }
  html.hb-web #shopOverlay.hbs .hbs-tab:not(.active):hover { color: #fff; background: rgba(255,255,255,.05); }
  html.hb-web :is(.pv2-row, .hv2-chest, .cq-realm):hover { background-color: rgba(255,255,255,.06); }
  html.hb-web .cq-node:not(.locked):hover { transform: translate(-50%, -50%) scale(1.05); }
  html.hb-web .lobby-overflow-item:hover { background: rgba(255,255,255,.06); }
}
@media (prefers-reduced-motion: reduce) {
  html.hb-web :is(.hv2-tile, .hv2-ev, .hv2-wide, .hbs-card, .pv2-slot, .pv2-badge, .hb-nav-play):hover { transform: none; }
  html.hb-web .lobby-overflow-sheet { animation: none; }
}

/* ═══ XL (≥ 1800px, web) — 1080p+ monitors ═════════════════════════════ */
@media (min-width: 1800px) {
  html.hb-web body.hv2 #lobby #menuCard, html.hb-web #hv2Root { max-width: 1320px !important; }
  html.hb-web #hv2Root { grid-template-columns: minmax(0, 1fr) 400px; column-gap: 32px; }
  html.hb-web #shopOverlay.hbs .hbs-root { max-width: 1400px; }
  html.hb-web .pv2-root { max-width: 1240px; }
}
