/* pack19 AA (2026-11-05): the mobile-native shell. Loaded after main.css. Everything here applies to screens up to
   1024 px wide (phones and portrait tablets); desktop output is untouched. Plan: audit19/AA-mobile-sound-plan.md */
:root {
  --m-gutter: 16px; --m-topbar: 56px; --m-tabbar: 64px;
  --m-safe-b: env(safe-area-inset-bottom, 0px); --m-safe-t: env(safe-area-inset-top, 0px);
  --m-radius: 16px; --m-radius-sm: 12px; --m-cta: 52px; --m-sticky: 0px;
  --m-surface: rgba(255,255,255,.04); --m-surface-2: rgba(255,255,255,.07); --m-line: rgba(255,255,255,.08);
  --m-gold: #FFCE00; /* 2026-11-13 games audit C8: the one gold (was #FFCE00); modes.css --mg-gold is the same value */ --m-green: #4AF65B; --m-bg: #04060b; /* DESIGN-1204B */
}
@media (max-width: 1024px) {
  html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
  body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
  button, a, [role="button"], .ripple-button, .kd-cursor { touch-action: manipulation; }
  /* iOS zooms into inputs under 16 px */
  input, select, textarea, .form-control { font-size: 16px !important; }
  input[type="number"] { -moz-appearance: textfield; }
  img, video, canvas, svg { max-width: 100%; }

  /* ---- shell: top bar + tab bar ---- */
  #app { padding-bottom: calc(var(--m-tabbar) + var(--m-safe-b) + var(--m-sticky)) !important; min-height: 100vh; min-height: 100dvh; }
  .kd-main-nav { position: sticky; top: 0; z-index: 1200; min-height: calc(var(--m-topbar) + var(--m-safe-t)); padding-top: var(--m-safe-t) !important; padding-left: var(--m-gutter) !important; padding-right: var(--m-gutter) !important; background: rgba(6,8,14,.97) /* DESIGN-1204B (owner): the phone top bar = the rails */; /* 2026-11-09 perf: no backdrop blur (re-blurred on every scroll frame; invisible at this opacity) */   border-bottom: 1px solid rgb(25, 25, 27); }
  .kd-main-nav .kd-logo { width: 132px; height: auto; }
  /* the old 7-item phone bar, its deposit bar and the drawer are replaced by the tab bar (MobileNav.vue) */
  .kd-bt-nav-wrap, .kd-mobile-deposit-bar, .kd-mobile-bt-nav { display: none !important; }
  .kd-main-nav-sect-left > .d-flex { display: none !important; }
  /* the compact balance pill */
  .kd-balance-box { gap: 8px; }
  .kd-balance-box .kd-balance-wrap { margin-right: 0 !important; }
  .kd-balance-box .kd-btn-small { min-height: 40px; padding: 0 14px !important; border-radius: 12px !important; }

  /* ---- content width & gutters ---- */
  .kd-content-max, .container-fluid.kd-page-opening { padding-left: var(--m-gutter) !important; padding-right: var(--m-gutter) !important; }
  .kd-app-side { padding-bottom: 8px; }

  /* ---- Bootstrap modals become bottom sheets ---- */
  .modal { padding: 0 !important; }
  .modal .modal-dialog { position: fixed; left: 0; right: 0; bottom: 0; top: auto; margin: 0 !important; width: 100% !important; max-width: none !important; transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.9,.3,1) !important; display: flex; align-items: flex-end; min-height: 0; }
  .modal.show .modal-dialog, .modal.in .modal-dialog { transform: none; }
  .modal .modal-content { width: 100%; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; border-radius: 22px 22px 0 0 !important; border: 1px solid var(--m-line) !important; border-bottom: 0 !important; padding-bottom: calc(var(--m-safe-b) + 6px) !important; overflow: hidden; box-shadow: 0 -20px 60px rgba(0,0,0,.6); }
  .modal .modal-content::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.22); margin: 10px auto 2px; flex: none; }
  .modal .modal-header { flex: none; padding: 8px 16px 10px !important; }
  .modal .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 12px 16px 16px !important; }
  .modal .modal-footer { flex: none; padding: 10px 16px !important; }
  .modal .close, .modal [data-dismiss="modal"] { min-width: 44px; min-height: 44px; }
  .modal-open { overflow: hidden; } /* no position:fixed here: it would scroll the page to the top behind every sheet */
  .modal-backdrop { -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }

  /* ---- chat and rewards as full-height sheets (components keep their markup) ---- */
  .kd-ecommerce-cht:not(.kd-ecommerce-hidcht) { position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; height: 92vh !important; height: 92dvh !important; max-height: 92vh; max-height: 92dvh; z-index: 1950 !important; border-radius: 22px 22px 0 0; overflow: hidden; box-shadow: 0 -20px 60px rgba(0,0,0,.6); padding-bottom: var(--m-safe-b); background: #06080e; } /*DESIGN-1204B:460c8b0e*/
  .kd-chat { height: 100% !important; display: flex; flex-direction: column; }
  .kd-chat-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .kd-chat-box-wrap { flex: none; padding-bottom: calc(var(--m-safe-b) + 6px); }
  .kd-chat-input { font-size: 16px !important; min-height: 44px; }

  /* ---- toasts above the tab bar ---- */
  .tst-stack, .p19-toasts, .kd-toasts, #toast-container { bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 12px) !important; top: auto !important; left: var(--m-gutter) !important; right: var(--m-gutter) !important; width: auto !important; max-width: none !important; }

  /* ---- generic helpers pages may use ---- */
  .m-scroll-x { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .m-scroll-x::-webkit-scrollbar { display: none; }
  .m-scroll-x > * { scroll-snap-align: start; flex: none; }
  .m-sticky-bar { position: fixed; left: 0; right: 0; bottom: calc(var(--m-tabbar) + var(--m-safe-b)); z-index: 1100; padding: 10px var(--m-gutter) 10px; background: linear-gradient(180deg, rgba(6, 8, 14,0), rgba(6, 8, 14,.96) 30%); display: flex; gap: 10px; align-items: center; } /*DESIGN-1204B:16314755*/
  .m-sticky-bar > .kd-btn-primary, .m-sticky-bar > button, .m-sticky-bar > a { flex: 1; min-height: var(--m-cta); border-radius: 12px; font-weight: 800; }
  .m-sticky-bar > .kd-btn-primary::before { border-radius: inherit; }
  .m-card { background: var(--m-surface); border: 1px solid var(--m-line); border-radius: var(--m-radius); padding: 14px; }
  .m-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
  .m-seg { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px; }
  .m-seg::-webkit-scrollbar { display: none; }
  .m-seg > * { flex: none; scroll-snap-align: start; min-height: 40px; padding: 0 14px; border-radius: 10px; }
  .m-hide { display: none !important; }
  .m-show { display: block !important; }
  .kd-btn-primary, .kd-btn-green, .kd-btn-small, .btn { min-height: 44px; }
  .kd-btn-primary:active, .kd-btn-green:active, .btn:active, .ripple-button:active { transform: scale(.97); transition: transform .12s; }

  /* ---- tables degrade to stacked rows unless a page opts out with .m-table-keep ---- */
  table.kd-table:not(.m-table-keep), .table-responsive table:not(.m-table-keep) { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 767px) {
  :root { --m-topbar: 52px; }
  .kd-main-nav .kd-logo { width: 116px; }
  .modal .modal-content { max-height: 94vh; max-height: 94dvh; }
  h1 { font-size: 24px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
}
@media (max-width: 400px) {
  :root { --m-gutter: 12px; }
  .kd-main-nav .kd-logo { width: 104px; }
}
/* landscape phones: keep the tab bar but tighten it */
@media (max-width: 1024px) and (max-height: 480px) and (orientation: landscape) {
  :root { --m-tabbar: 52px; --m-topbar: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .modal .modal-dialog { transition: none !important; }
  .kd-btn-primary:active, .kd-btn-green:active, .btn:active, .ripple-button:active { transform: none; }
}
/* standalone (home-screen) mode: no browser chrome, give the top bar a little more room */
@media all and (display-mode: standalone) and (max-width: 1024px) {
  .kd-main-nav { padding-top: max(var(--m-safe-t), 8px) !important; }
}

/* ---- compact top bar (the tab bar owns Rewards / Me / Games; the header keeps logo, balance, Deposit, Chat) ---- */
@media (max-width: 1024px) {
  .kd-main-nav-sect-right { display: flex; align-items: center; gap: 8px; }
  .kd-main-nav-sect-right .kd-btn-green { display: none !important; }          /* Inventory lives in the Me sheet */
  .kd-main-nav-sect-right .rw-bell, .kd-main-nav-sect-right .kd-sound-toggle { display: none !important; } /* Rewards tab + Me sheet */
  .kd-balance-box { margin: 0 !important; padding: 0 !important; }
  .kd-balance-wrap { margin: 0 !important; padding: 6px 10px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); }
  .kd-balance-wrap .kd-vs-color { display: none; }
  .kd-balance-stacked { margin-right: 8px !important; }
  .kd-balance-money { font-size: 14px !important; }
  .kd-main-nav-sect-right .kd-btn-primary.kd-btn-small { min-width: 0; }
  .kd-main-nav-sect-right .kd-btn-primary.kd-btn-small p { font-size: 13px; }
  .kd-main-nav-sect-right .kd-notify-bell { margin-left: 0 !important; }
  .kd-main-nav-sect-right .kd-notification { width: 40px; height: 40px; }
}
@media (max-width: 400px) {
  .kd-balance-stacked { display: none !important; }   /* points / diamonds stay in the Me sheet and the Quests hub */
  .kd-balance-wrap { padding: 6px 8px; }
}

/* ---- rewards drawer as a full-height sheet on mobile (same hide class as the chat: .kd-ecommerce-hidcht) ---- */
@media (max-width: 1024px) {
  .kd-shoprightsidebar, .kd-notifright { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; height: 92vh !important; height: 92dvh !important; max-height: 92vh; max-height: 92dvh; z-index: 1950 !important; border-radius: 22px 22px 0 0; overflow: hidden; box-shadow: 0 -20px 60px rgba(0,0,0,.6); padding-bottom: var(--m-safe-b) !important; transition-property: transform, opacity; }
  .kd-shoprightsidebar.kd-ecommerce-hidcht, .kd-ecommerce-cht.kd-ecommerce-hidcht, .kd-notifright.kd-ecommerce-hidcht { transform: translateY(100%); opacity: 1; }
  .kd-shoprightsidebar > *, .kd-notifright > * { max-height: 100%; }
  .kd-notifright .kd-chat { display: flex; flex-direction: column; height: 100%; width: 100%; background: #06080e; } /*DESIGN-1204B:877becab*/
  .kd-notifright .kd-chat-header-wrap { position: static; flex: none; padding: 10px 12px 0; width: auto; }
  /* a dim backdrop behind an open chat / rewards sheet */
}

/* ---- the page-in keyframe (main.css) scales the page container for 0.6 s; while it runs, every fixed bar inside the
   page is positioned against the scaled container. On mobile the page just fades in. ---- */
@media (max-width: 1024px) {
  .kd-page-opening { animation-name: m-page-fade !important; animation-duration: .18s !important; transform: none !important; }
  @keyframes m-page-fade { from { opacity: 0; } to { opacity: 1; } }
}

/* ---- late fixes from the review pass ---- */
@media (max-width: 1024px) {
  .kd-main-nav-sect-right .kd-notify-bell { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  /* toasts rise above a page's sticky action bar so they never cover the primary button */
  body:has(.m-sticky-bar) .tst-stack, body:has(.m-sticky-bar) .p19-toasts, body:has(.m-sticky-bar) .kd-toasts, body:has(.m-sticky-bar) #toast-container { bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 88px) !important; }
}

/* ---- soft keyboard open (MobileNav sets html.m-kb from visualViewport): bars step aside, the field has the screen ---- */
@media (max-width: 1024px) {
  html.m-kb .mnav, html.m-kb .m-sticky-bar { display: none !important; }
  html.m-kb #app { padding-bottom: 12px !important; }
  html.m-kb .tst-stack { bottom: 12px !important; }
}

/* ---- popups without a .modal-body (20 of them) scroll as a whole instead of being clipped by the sheet frame ---- */
@media (max-width: 1024px) {
  .modal .modal-content:not(:has(.modal-body)) { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
}
/* F7 H2 (2026-11-17, older devices): without :has() (Chrome < 105, Safari < 15.4, Firefox < 121) the rule above is
   dropped and those 20 popups were clipped by the 92vh sheet with no way to scroll. There every sheet scrolls as a whole
   (a sheet with a .modal-body never overflows: its body scrolls inside it). */
@supports not selector(:has(a)) {
  @media (max-width: 1024px) {
    .modal .modal-content { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  }
}

/* ---- pack19 AA review group B (2026-11-05: home / packs / case / mini-games / multipack / popups): shared fixes ----
   - page-level fixed bars (pack Open bar + result sheet, Bundle Deal/Draw, Upgrader roll, Multipack footer) step aside
     while the soft keyboard is open, like .m-sticky-bar
   - the price-sort / volatility dropdown rows, the price inputs and the sort buttons of the shared filter bar are 44 px
   - the @vueform price-range handles are 24 px with a 44 px touch area ---- */
@media (max-width: 1024px) {
  html.m-kb .m-open-bar, html.m-kb .kd-open-win-box, html.m-kb .bd-go, html.m-kb .up-go, html.m-kb .mpx-stage__foot { display: none !important; }
  .kd-sort-menu-98 .dropdown-item { min-height: 44px; display: flex; align-items: center; padding: 0 12px !important; }
  .kd-catg-sort-btn { min-height: 44px; }
  .kd-catg-price-in { min-height: 44px; font-size: 16px; }
  .kd-catg-search input { min-height: 28px; }
  .kd-catg-slider-wrap { padding: 0 12px; }
  .kd-catg-slider-wrap .slider-handle { width: 24px; height: 24px; }
  .kd-catg-slider-wrap .slider-horizontal .slider-handle { right: -12px; top: -8px; }
  .kd-catg-slider-wrap .slider-touch-area { position: relative; }
  .kd-catg-slider-wrap .slider-touch-area::before { content: ''; position: absolute; inset: -10px; }
}

/* ---- AB final mobile review (layout / popups / account+info pages), 2026-11-05. Append-only group; ≤ 1024 px only. ---- */
@media (max-width: 1024px) {
  /* iOS keeps the layout viewport under the soft keyboard: HeaderLayout writes the hidden strip to --m-kb while
     html.m-kb is on, so an open Bootstrap sheet (login, deposit, promo, seed, wallet, username, exchange, reset) is
     lifted above the keys and its sticky button stays reachable. Android shrinks the viewport itself (--m-kb = 0). */
  html.m-kb .modal .modal-dialog { bottom: var(--m-kb, 0px) !important; }
  html.m-kb .modal .modal-content { max-height: calc(100dvh - var(--m-kb, 0px) - 8px); }
  /* the 20 popups without .modal-body scroll in their own body element; the two modals that live in pages do not */
  .modal .hub-modal, #quest-modal .modal-content > .p-3 { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  /* the header's profile menu (avatar tap): 44 px rows, scrolls on a short landscape screen */
  #kd-profile-drop-avatar { min-width: 44px; min-height: 44px; display: flex; align-items: center; }
  #kd-profile-drop-body { max-height: calc(100dvh - var(--m-topbar) - var(--m-safe-t) - 16px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  #kd-profile-drop-body .kd-profile-menu li .kd-web3-item { min-height: 44px; align-items: center; }
  #kd-profile-drop-body .kd-profile-menu li .kd-web3-item p { font-size: 15px; }
  #kd-profile-drop-body .pd-claim, #kd-profile-drop-body .pd-all { display: inline-flex; align-items: center; min-height: 40px; }
  /* F7 H2 (2026-11-17, older devices): the two dvh + var() heights above turn "unset" without dvh (Safari < 15.4,
     Chrome < 108), so the sheet with the keyboard open and the profile menu had no height cap; the same caps in vh */
  @supports not (height: 1dvh) {
    html.m-kb .modal .modal-content { max-height: calc(100vh - var(--m-kb, 0px) - 8px); }
    #kd-profile-drop-body { max-height: calc(100vh - var(--m-topbar) - var(--m-safe-t) - 16px); }
  }
  /* code samples on the Provably Fair / Authenticity pages: the site font, never monospace (desktop keeps its inline style) */
  .pf-body pre, .ip-body pre, .pf-body span[style*="Courier"] { font-family: 'Sora', sans-serif !important; font-variant-numeric: normal; }
  /* footer: 44 px social icons and link rows, the iOS / Android install tiles as buttons */
  .kd-foot-social a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
  .kd-foot-social a img { margin: 0 !important; }
  .kd-footer-mbtn { min-height: 44px; }
  .kd-app-install-btn { min-height: 48px; min-width: 140px; cursor: pointer; }
  /* long addresses, hashes and e-mails never widen a sheet or a card */
  .modal code, .modal .lp-card-v, .gp-seed code, #deposit-address-input, .kd-chat-text { overflow-wrap: anywhere; }
}
@media (max-width: 1024px) and (max-height: 480px) and (orientation: landscape) {
  /* landscape phones: the sheet takes the whole height so its header, one row of content and the primary button fit */
  .modal .modal-content { max-height: 100vh; max-height: 100dvh; border-radius: 0 !important; }
  .modal .modal-content::before { margin: 6px auto 0; }
  .modal .modal-header { padding-top: 4px !important; padding-bottom: 6px !important; }
  .kd-ecommerce-cht:not(.kd-ecommerce-hidcht), .kd-shoprightsidebar, .kd-notifright { height: 100vh !important; height: 100dvh !important; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
  /* popups without .modal-body: on a 360 px tall screen the inner scroller would shrink to a sliver under a tall head
     (gems stats + tabs, deposit header). It keeps a usable height, the whole sheet scrolls (generic rule above) and a
     footer stays pinned at the bottom of that scroll */
  .modal .modal-content:not(:has(.modal-body)) > .kd-p4, .modal .gp-body, .modal .dp-body, .modal .wn-body, #quest-modal .modal-content > .p-3 { min-height: 200px; flex-shrink: 0; }
  .modal .modal-content:not(:has(.modal-body)) > .modal-footer { position: sticky; bottom: 0; z-index: 3; background: #0e111a; } /*DESIGN-1204B:493fd5d8*/
}

/* ---- pack19 AA final review, games group (Mines / Tower / Plinko / Mario / Battles / Fights / Oripa / Scratch) ---- */
@media (max-width: 1024px) {
  /* the game "provably fair" and win sheets put their content in .kd-p4, not .modal-body: let it scroll inside the sheet */
  #minesVerifyModal .modal-content > .kd-p4, #minesWinModal .modal-content > .kd-p4,
  #towerVerifyModal .modal-content > .kd-p4, #towerWinModal .modal-content > .kd-p4,
  #plinkoVerifyModal .modal-content > .kd-p4, #marioVerifyModal .modal-content > .kd-p4 {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 12px 16px 16px !important;
  }
  #fight-page #boxes-modal .info, #fight-page #boxes-modal .modal-body { overflow-wrap: anywhere; }
  /* Fight: the gun / muzzle-flash sprites (injected by jQuery, 150-415 px wide) and the pan (300 px) were drawn for a
     ~260 px desktop avatar. FightPage sets --fgs = avatar width / 260 on #fight-page; the 0x0 gun anchors scale around
     their own point, so the barrel still starts at the fighter. `scale` composes with the existing transforms. */
  #fight-page .gun-wrap-0, #fight-page .gun-wrap-1 { scale: var(--fgs, 1); }
  #fight-page .pan-0, #fight-page .pan-1 { width: calc(300px * var(--fgs, 1)); height: calc(200px * var(--fgs, 1)); top: calc(50% - 100px * var(--fgs, 1)); }
  #fight-page .pan-0 { left: calc(50% - 100px * var(--fgs, 1)); }
  #fight-page .pan-1 { right: calc(50% - 100px * var(--fgs, 1)); }
  #fight-page .bullet-hole { width: calc(25px * max(var(--fgs, 1), .6)); }
  #fight-page .bullet-hole-big { width: calc(40px * max(var(--fgs, 1), .6)); }
  #fight-page .avatar-wrap { overflow: visible; }
}

/* ---- brand (all widths, 2026-11-05): the 19mansion wordmark replaces the template's "keydrop" SVG / "CS2SKIN" GIF.
   The SVG keeps its own aspect ratio; the loader shows the mark with a thin gold progress sweep instead of the GIF. ---- */
.kd-logo, .kd-foot-logo { height: auto; }
.kd-load-mark { width: 200px; max-width: 60vw; height: auto; animation: kd-load-breathe 1.6s ease-in-out infinite; }
.kd-load-bar { display: block; width: 120px; height: 3px; margin-top: 18px; border-radius: 2px; background: rgba(255,255,255,.08); overflow: hidden; }
.kd-load-bar i { display: block; width: 40%; height: 100%; border-radius: 2px; background: var(--m-gold, #FFCE00); animation: kd-load-sweep 1.1s cubic-bezier(.45,0,.2,1) infinite; }
@keyframes kd-load-breathe { 0%, 100% { opacity: .78; } 50% { opacity: 1; } }
@keyframes kd-load-sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { .kd-load-mark, .kd-load-bar i { animation: none; } }

/* ---- 2026-11-13 games audit C4: every fixed / sticky mobile bar steps aside while a Bootstrap modal is open, on every
   page (it covered the deposit, login, pack picker and Provably fair sheets on the lobbies, the battle / fight rooms and
   Multipack). One rule here; the per-page copies (BattleCreate, Upgrader, Oripa, Keno, Case, Scratch, ...) can go. ---- */
@media (max-width: 1024px) {
  body.modal-open .m-sticky-bar, body.modal-open .m-bt-result, body.modal-open .mpx-stage__foot,
  body.modal-open .m-open-bar { display: none !important; }
}
