/* Universal phone layout: 320px through large phones and phone landscape. */
@media (max-width: 767px) {
  :root {
    --phone-gutter: clamp(8px, 3.6vw, 18px);
    --phone-gap: clamp(8px, 2.6vw, 13px);
    --phone-nav-height: 76px;
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-x: none;
  }

  img,
  svg,
  video {
    max-width: 100%;
  }

  button,
  a,
  input {
    -webkit-tap-highlight-color: transparent;
  }

  .app-shell {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    padding-bottom: calc(var(--phone-nav-height) + env(safe-area-inset-bottom) + 12px) !important;
    overflow-x: clip;
  }

  .topbar {
    width: 100%;
    height: 72px !important;
    min-height: 72px !important;
    padding: env(safe-area-inset-top) var(--phone-gutter) 0 !important;
  }

  .topbar .brand {
    max-width: calc(100vw - (var(--phone-gutter) * 2));
    gap: clamp(8px, 2.8vw, 13px) !important;
  }

  .topbar .brand-mark {
    width: clamp(42px, 12vw, 50px) !important;
    height: clamp(42px, 12vw, 50px) !important;
    flex: 0 0 clamp(42px, 12vw, 50px) !important;
  }

  .topbar .brand b {
    max-width: calc(100vw - 82px);
    overflow: hidden;
    font-size: clamp(15px, 4.6vw, 20px) !important;
    line-height: 1.1;
    letter-spacing: clamp(0px, 0.12vw, 0.4px) !important;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .hero.ad-hero {
    width: 100%;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
  }

  .hero.ad-hero .hero-slide img {
    left: var(--phone-gutter) !important;
    width: calc(100% - (var(--phone-gutter) * 2)) !important;
    max-height: calc(100% - 25px) !important;
  }

  .hero.ad-hero .carousel-arrow {
    width: clamp(30px, 8vw, 36px) !important;
    height: clamp(38px, 10vw, 44px) !important;
  }

  .hero.ad-hero .carousel-dots {
    bottom: 7px !important;
  }

  .quick-grid,
  .home-contact-actions {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: var(--phone-gap) !important;
    padding-left: var(--phone-gutter) !important;
    padding-right: var(--phone-gutter) !important;
  }

  .quick-grid .quick-card,
  .home-contact-actions #homeTelegram,
  .home-contact-actions #homeContactUs {
    min-width: 0;
    min-height: clamp(62px, 17vw, 72px) !important;
    padding: 11px clamp(8px, 3vw, 15px) !important;
  }

  .quick-grid .quick-card {
    gap: clamp(7px, 2.3vw, 11px) !important;
  }

  .quick-grid .quick-card b,
  .home-contact-actions #homeTelegram,
  .home-contact-actions #homeContactUs {
    overflow-wrap: anywhere;
    font-size: clamp(13px, 3.8vw, 16px) !important;
  }

  .quick-grid .quick-card i,
  .quick-grid .quick-card i svg {
    width: clamp(22px, 6.8vw, 27px) !important;
    height: clamp(22px, 6.8vw, 27px) !important;
    flex-basis: clamp(22px, 6.8vw, 27px) !important;
  }

  .section,
  .ongoing-section,
  .events-gallery-section {
    width: 100%;
    padding-left: var(--phone-gutter) !important;
    padding-right: var(--phone-gutter) !important;
  }

  .ongoing-title,
  .events-gallery-title {
    max-width: 100% !important;
    font-size: clamp(23px, 7vw, 30px) !important;
    line-height: 1.25 !important;
    letter-spacing: clamp(0.5px, 0.38vw, 1.5px) !important;
  }

  .events-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: clamp(5px, 1.8vw, 9px) !important;
  }

  .event-poster {
    min-width: 0;
  }

  .event-poster b {
    font-size: clamp(9px, 3vw, 12px) !important;
  }

  .event-poster small {
    font-size: clamp(6px, 1.85vw, 8px) !important;
  }

  .help-contact {
    width: 100%;
    padding: clamp(20px, 6vw, 36px) var(--phone-gutter) 0 !important;
  }

  .help-contact .support-panel {
    width: 100%;
    padding: clamp(14px, 4.5vw, 22px) !important;
  }

  .help-contact .support-panel > p {
    font-size: clamp(14px, 4vw, 16px) !important;
  }

  .help-contact-card {
    min-width: 0;
    min-height: clamp(68px, 19vw, 78px) !important;
    grid-template-columns: clamp(30px, 9vw, 38px) minmax(0, 1fr) clamp(22px, 7vw, 27px) !important;
    gap: clamp(5px, 2vw, 10px);
    padding: 11px clamp(10px, 3.5vw, 15px) !important;
  }

  .help-contact-card b {
    font-size: clamp(14px, 4.2vw, 17px) !important;
  }

  .help-contact-card small {
    font-size: clamp(11px, 3.5vw, 14px) !important;
  }

  .help-contact > .telegram-standalone {
    margin-top: clamp(80px, 25vw, 110px) !important;
  }

  #profile {
    width: 100%;
    min-height: calc(100dvh - 72px) !important;
  }

  #profile .profile-copy-hero,
  #profile .profile-copy-menu,
  .menu-list {
    width: 100%;
    padding-left: var(--phone-gutter) !important;
    padding-right: var(--phone-gutter) !important;
  }

  .bottom-nav {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    height: calc(var(--phone-nav-height) + env(safe-area-inset-bottom)) !important;
    padding: 7px var(--phone-gutter) max(7px, env(safe-area-inset-bottom)) !important;
    border-radius: 18px 18px 0 0 !important;
  }

  .bottom-nav button {
    min-width: 0;
    min-height: 48px;
  }

  .bottom-nav b {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(10px, 3vw, 12px) !important;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  #authModal {
    top: 72px !important;
    width: 100% !important;
    height: calc(100dvh - 72px) !important;
  }

  #authModal .modal,
  #authModal .modal.register,
  #authModal .modal:not(.register) {
    width: 100% !important;
    min-height: 100% !important;
    padding-left: var(--phone-gutter) !important;
    padding-right: var(--phone-gutter) !important;
    padding-bottom: calc(var(--phone-nav-height) + env(safe-area-inset-bottom) + 28px) !important;
  }

  #authModal #modalTitle {
    font-size: clamp(27px, 8vw, 34px) !important;
  }

  #authModal .modal input {
    width: 100%;
    min-height: 54px !important;
  }

  .coming-soon-box {
    width: min(calc(100vw - (var(--phone-gutter) * 2)), 360px) !important;
    max-height: calc(100dvh - 32px);
  }
}

@media (max-width: 359px) {
  :root {
    --phone-gutter: 8px;
    --phone-gap: 7px;
  }

  .topbar .brand b {
    font-size: 14px !important;
  }

  .quick-grid .quick-card,
  .home-contact-actions #homeTelegram,
  .home-contact-actions #homeContactUs {
    min-height: 60px !important;
    padding-left: 7px !important;
    padding-right: 7px !important;
  }

  .quick-grid .quick-card b,
  .home-contact-actions #homeTelegram,
  .home-contact-actions #homeContactUs {
    font-size: 12px !important;
  }

  .help-contact-card b {
    font-size: 13px !important;
  }

  .help-contact-card small {
    font-size: 10px !important;
  }
}

/* Keep the mobile authentication screen visually identical to the original
   dark desktop authentication design.  The auth backdrop previously covered
   the header and Chromium's saved-value paint replaced the dark inputs. */
@media (max-width: 600px) {
  body.auth-open::before {
    z-index: 0 !important;
  }

  body.auth-open .app-shell {
    isolation: isolate;
  }

  body.auth-open .topbar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 30 !important;
  }

  #authModal .modal input,
  #authModal .modal input:focus {
    border-color: #4b5a70 !important;
    background: #202b3b !important;
    color: #fff !important;
    color-scheme: dark;
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff !important;
  }

  #authModal .modal input::placeholder {
    color: #a9b2c1 !important;
    -webkit-text-fill-color: #a9b2c1 !important;
  }

  #authModal .modal input:-webkit-autofill,
  #authModal .modal input:-webkit-autofill:hover,
  #authModal .modal input:-webkit-autofill:focus,
  #authModal .modal input:-webkit-autofill:active {
    -webkit-text-fill-color: #fff !important;
    caret-color: #fff !important;
    -webkit-box-shadow: 0 0 0 1000px #202b3b inset !important;
    box-shadow: 0 0 0 1000px #202b3b inset !important;
    transition: background-color 9999s ease-out 0s;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 932px) {
  :root {
    --phone-nav-height: 66px;
    --phone-gutter: clamp(10px, 2.4vw, 18px);
  }

  html,
  body,
  .app-shell {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden;
  }

  .app-shell {
    min-height: 100dvh !important;
    padding-bottom: calc(var(--phone-nav-height) + env(safe-area-inset-bottom) + 8px) !important;
  }

  .topbar {
    height: 62px !important;
    min-height: 62px !important;
  }

  .topbar .brand-mark {
    width: 40px !important;
    height: 40px !important;
    flex-basis: 40px !important;
  }

  .hero.ad-hero {
    aspect-ratio: 21 / 9 !important;
  }

  .bottom-nav {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    height: calc(var(--phone-nav-height) + env(safe-area-inset-bottom)) !important;
  }

  #authModal {
    top: 62px !important;
    height: calc(100dvh - 62px) !important;
  }

  .coming-soon-box {
    max-height: calc(100dvh - 20px);
    padding-top: 20px;
    padding-bottom: 18px;
  }

  .coming-soon-icon {
    width: 62px;
    height: 62px;
    margin-bottom: 7px;
  }

  .lux-hourglass {
    width: 34px;
    height: 38px;
  }
}

/* Saved login values must keep the original dark authentication field on
   both desktop and mobile instead of Chromium's pale autofill surface. */
#authModal .modal input {
  color-scheme: dark;
}

#authModal .modal input:-webkit-autofill,
#authModal .modal input:-webkit-autofill:hover,
#authModal .modal input:-webkit-autofill:focus,
#authModal .modal input:-webkit-autofill:active {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff !important;
  -webkit-box-shadow: 0 0 0 1000px #202b3b inset !important;
  box-shadow: 0 0 0 1000px #202b3b inset !important;
}
