/* Shared mobile safeguards for every Xeno Prime page. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  overflow-x: hidden;
}

input,
select,
textarea,
button {
  font-size: max(16px, 1em);
}

/* Keep every popup inside the visible mobile viewport. */
.overlay,
.modal-backdrop,
.error-modal,
.testimonial-lightbox,
#paymentModal.modal {
  box-sizing: border-box;
  max-width: 100vw;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  -webkit-overflow-scrolling: touch;
}

.overlay > .modal,
.modal-backdrop > .payment-modal,
.error-modal > .modal-card,
.error-modal > .error-modal-card,
.testimonial-lightbox > .testimonial-lightbox-card,
#paymentModal > .modal-card {
  box-sizing: border-box;
  width: min(100%, 720px);
  max-width: 100%;
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .overlay,
  .modal-backdrop,
  .error-modal,
  .testimonial-lightbox,
  #paymentModal.modal {
    align-items: flex-start !important;
    place-items: start center !important;
  }

  .overlay > .modal,
  .modal-backdrop > .payment-modal,
  .error-modal > .modal-card,
  .error-modal > .error-modal-card,
  .testimonial-lightbox > .testimonial-lightbox-card,
  #paymentModal > .modal-card {
    max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .modal-head,
  .modal-header,
  .error-modal-head {
    align-items: flex-start;
    gap: 12px;
    padding: 18px !important;
  }

  .modal-close,
  .modal-close-icon,
  .testimonial-lightbox-close {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
  }

  .modal-actions,
  .error-modal-actions {
    padding: 16px 18px 18px !important;
  }

  .modal-actions > *,
  .error-modal-actions > * {
    width: 100%;
  }
}
