/* ==========================================================================
   RMTG MOBILE RESPONSIVE POLISH (<= 768px & <= 480px)
   Final mobile hardening across public configurators, client space, & admin.
   ========================================================================== */

html,
body {
  overflow-x: clip;
  max-width: 100%;
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .container {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* Ensure touch targets are comfortably >= 44px */
  .btn,
  button.btn,
  a.btn,
  .nav__link,
  .rmtg-mobile-dock__item,
  input[type="submit"] {
    min-height: 42px;
  }

  /* Responsive 3-column configurators -> clean 1-column mobile stack */
  .game-configurator-wrapper {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    padding: 0 !important;
  }

  .game-configurator-wrapper > .gc-sidebar,
  .game-configurator-wrapper > .gc-main,
  .game-configurator-wrapper > .gc-recap,
  .gc-summary-col {
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
    top: auto !important;
  }

  /* Stack inline multi-column grids gracefully */
  .rmtg-support-grid,
  .admin-pro-header,
  .rmtg-profile-grid,
  .rmtg-checkout-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
    gap: 14px !important;
  }

  /* Horizontal scroll safety for dense data tables & SVG diagrams */
  table {
    max-width: 100%;
  }

  .card {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .rmtg-sankey-svg {
    min-width: 560px;
  }

  /* Mobile Dock safe area */
  .rmtg-mobile-dock {
    padding-bottom: max(6px, env(safe-area-inset-bottom, 6px)) !important;
    z-index: 9990 !important;
  }

  /* RM-BEBOT drawer on phone screens */
  #bebotDrawer {
    width: calc(100vw - 20px) !important;
    right: 10px !important;
    left: 10px !important;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px)) !important;
    max-height: 70vh !important;
  }

  #bebotLauncher {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
    right: 12px !important;
  }

  /* Command Palette Modal on phones */
  #rmtgCmdPaletteModal {
    padding: 6vh 10px 12px !important;
  }

  /* Admin mobile top spacing & cards */
  .admin-shell {
    display: block !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .admin-shell .admin-main,
  #adminShellMain {
    width: 100% !important;
    min-width: 0 !important;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: clamp(1.38rem, 6vw, 1.75rem) !important;
    line-height: 1.2 !important;
  }

  h2 {
    font-size: clamp(1.12rem, 4.8vw, 1.38rem) !important;
  }

  .card {
    padding: 16px 14px !important;
    border-radius: 14px !important;
  }

  .gc-plan-grid,
  .gc-grid {
    grid-template-columns: 1fr !important;
  }
}
