/* Mobile width guard for the restored auth/onboarding shell.
   Keeps the current production auth build inside the PWA viewport. */

@media (max-width: 899px) {
  html,
  body,
  #root {
    max-width: 100%;
    overflow-x: hidden;
  }

  #root .nv-auth-v4.nv-screen {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow-x: hidden !important;
    padding-inline: 0 !important;
  }

  #root .nv-auth-v4__header {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    padding-inline: 16px;
  }

  #root .nv-auth-v4__header > * {
    min-width: 0;
  }

  #root .nv-auth-v4 .nv-auth__body {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 12px;
    align-items: center;
    overflow-x: hidden;
    padding:
      calc(54px + env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      calc(104px + env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left)) !important;
  }

  #root .nv-auth-v4 .nv-auth-art {
    box-sizing: border-box;
    width: min(100%, 286px) !important;
    max-width: calc(100vw - 44px) !important;
    height: clamp(108px, 18dvh, 142px) !important;
    max-height: clamp(108px, 18dvh, 142px) !important;
    margin: 0 auto !important;
    overflow: hidden !important;
    display: grid;
    place-items: center;
  }

  #root .nv-auth-v4 .nv-auth-art svg {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    padding: 0 !important;
    transform: none !important;
    overflow: hidden !important;
  }

  #root .nv-auth-v4 .nv-auth__heading,
  #root .nv-auth-v4 .nv-auth__form,
  #root .nv-auth-v4 .nv-auth__footer {
    box-sizing: border-box;
    width: 100%;
    max-width: min(100%, 350px);
    min-width: 0;
    margin-inline: auto;
  }

  #root .nv-auth-v4 .nv-auth__heading {
    position: relative;
    z-index: 1;
    justify-items: center;
    text-align: center;
    margin-top: 0;
  }

  #root .nv-auth-v4 .nv-auth__heading h1,
  #root .nv-auth-v4 .nv-auth__heading p {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    letter-spacing: 0;
    white-space: normal;
    overflow-wrap: normal;
  }

  #root .nv-auth-v4 .nv-auth__heading h1 {
    margin: 3px 0 4px !important;
    font-size: clamp(20px, 5.5vw, 22px) !important;
    line-height: 1.45 !important;
  }

  #root .nv-auth-v4 .nv-auth__heading p {
    font-size: 11px !important;
    line-height: 1.8 !important;
  }

  #root .nv-auth-v4 .nv-auth__form {
    gap: 10px;
    margin-top: 14px !important;
  }

  #root .nv-auth-v4 .nv-field,
  #root .nv-auth-v4 .nv-field__control,
  #root .nv-auth-v4 .nv-field__control input {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #root .nv-auth-v4 .nv-field__control {
    min-height: 58px;
  }

  #root .nv-auth-v4 .nv-otp-input {
    width: 100%;
    max-width: 350px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
  }

  #root .nv-auth-v4 .nv-otp-input input {
    width: 100% !important;
    min-width: 0 !important;
  }

  #root .nv-auth-v4 .nv-auth__fixed-action {
    box-sizing: border-box;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    transform: none !important;
    padding:
      12px
      max(18px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left)) !important;
  }

  #root .nv-auth-v4 .nv-auth__fixed-action .nv-button {
    width: 100% !important;
    max-width: 350px;
    min-width: 0;
    margin-inline: auto;
  }

  #root .nv-auth-v4 .nv-auth__footer {
    padding-top: 10px;
  }

  #root .nv-auth-v4 .nv-auth-v4__security {
    justify-content: center;
    white-space: normal;
  }
}

@media (max-width: 390px), (max-height: 720px) {
  #root .nv-auth-v4 .nv-auth__body {
    gap: 10px;
  }

  #root .nv-auth-v4 .nv-auth-art {
    width: min(100%, 256px) !important;
    height: clamp(100px, 16dvh, 124px) !important;
    max-height: clamp(100px, 16dvh, 124px) !important;
  }

  #root .nv-auth-v4 .nv-auth__heading,
  #root .nv-auth-v4 .nv-auth__form,
  #root .nv-auth-v4 .nv-auth__footer,
  #root .nv-auth-v4 .nv-auth__fixed-action .nv-button {
    max-width: min(100%, 326px);
  }
}
