/* Mobile layout follows the desktop theme without hiding page overflow. */
.header-menu-toggle { display: none; }

@media (max-width: 820px), (max-width: 950px) and (hover: none) and (pointer: coarse) {
  html { scroll-padding-top: 20px; -webkit-text-size-adjust: 100%; }
  .site-page { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); }
  .site-page:not(.page-home) { background-attachment: scroll; }
  .site-header.navigation-ready {
    width: calc(100% - 24px);
    margin-top: 12px;
    padding: 10px 12px;
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-areas: "brand toggle" "navigation navigation" "actions actions";
    gap: 0 12px;
    border-radius: 12px;
  }
  .site-header.navigation-ready > .brand {
    grid-area: brand;
    width: 150px;
    max-width: 100%;
    min-width: 0;
  }
  .navigation-ready .header-menu-toggle {
    grid-area: toggle;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid #ffb8732b;
    border-radius: 9px;
    color: #ffce9d;
    background: #ffb87309;
  }
  .header-menu-toggle .lucide { width: 22px; height: 22px; }
  .header-menu-toggle .menu-close-icon,
  .menu-open .header-menu-toggle .menu-open-icon { display: none; }
  .menu-open .header-menu-toggle .menu-close-icon { display: block; }
  .site-header.navigation-ready > .main-nav {
    grid-area: navigation;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #ffffff12;
  }
  .navigation-ready .main-nav .nav-button {
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px;
    font-size: 13px;
    gap: 8px;
  }
  .navigation-ready .main-nav .nav-button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .navigation-ready .main-nav .lucide { width: 16px; height: 16px; }
  .site-header.navigation-ready > .header-actions {
    grid-area: actions;
    display: flex;
    justify-self: stretch;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    gap: 10px;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid #ffffff12;
  }
  .navigation-ready .header-account { flex: 1 1 auto; min-width: 0; max-width: 100%; }
  .navigation-ready .header-profile,
  .navigation-ready .header-logout { min-height: 44px; }
  .navigation-ready .header-profile { min-width: 0; padding-left: 0; }
  .navigation-ready .header-profile [data-account-nick] { max-width: 130px; }
  .navigation-ready .header-play { flex: 1 1 180px; min-height: 44px; font-size: 13px; }
  .site-header.navigation-ready:not(.menu-open) > .main-nav,
  .site-header.navigation-ready:not(.menu-open) > .header-actions { display: none; }

  .page-home .hero {
    height: auto;
    min-height: min(640px, calc(100svh - 88px));
    padding: 52px 20px 64px;
  }
  .hero-logo.hero-logo-halloween { width: min(560px, 100%); margin: 0 auto 24px; }
  .hero-copy { font-size: 15px; line-height: 1.8; }
  .hero-actions { flex-direction: column; gap: 10px; width: min(320px, 100%); margin-inline: auto; }
  .hero-actions > :is(.primary-action, .secondary-action) { width: 100%; min-height: 50px; font-size: 14px; }
  .hero-bottom { display: none; }
  .server-monitor { max-width: 100%; }
  .site-page .content-section { padding-inline: 20px; }
  .section-heading { gap: 12px; }
  .section-heading :is(h1,h2) { overflow-wrap: anywhere; }
  .inline-panel.entry-layout { padding: 32px 18px 40px; gap: 24px; }
  .entry-layout > .modal-panel { padding: 22px 18px; }
  .entry-intro > p:not(.eyebrow) { font-size: 14px; }

  /* A 16px field font prevents Safari zooming the page when a field is focused. */
  .site-page input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  .site-page textarea,
  .site-page select { min-width: 0; max-width: 100%; font-size: 16px; }
  .site-page input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  .site-page select { min-height: 46px; }
  .site-page textarea { line-height: 1.6; }
  .site-page .admin-workspace :is(textarea, select) { font-size: 16px; }
  .modal { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .modal > .modal-panel { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overscroll-behavior: contain; padding: 24px 18px; }
  .close-button { min-width: 44px; min-height: 44px; }
  .news-card h3, .news-body, .product-body h3, .product-summary, .field-note, .form-message { overflow-wrap: anywhere; }
  .product-card { min-width: 0; }
  .product-footer { flex-wrap: wrap; gap: 12px; }
  .product-details-button { min-height: 44px; }

  .account-tabs { width: 100%; }
  .account-tabs button { min-width: 0; min-height: 46px; }
  .profile-row { gap: 12px; }
  .profile-row > span { min-width: 0; }
  .profile-row strong { overflow-wrap: anywhere; text-align: right; }
  .profile-actions { flex-wrap: wrap; gap: 12px; }
  .profile-actions > :is(a,button) { min-height: 44px; }
  .skin-controls { flex-wrap: wrap; gap: 8px; }
  .skin-tool { min-width: 44px; min-height: 44px; }
  .appearance-stage .skin-preview { height: clamp(280px, 52svh, 380px); }
  .appearance-layout, .account-security-card { gap: 24px; }

  .admin-sidebar :is(button,a) { min-height: 44px; }
  .admin-table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain; scrollbar-width: thin; }
  .admin-workspace .admin-panel-heading { flex-wrap: wrap; }
  .admin-workspace .field-note { font-size: 12px; }
  .site-footer { gap: 18px; }
  .site-footer > a:last-child { display: inline-flex; align-items: center; min-height: 44px; font-size: 12px; }
}

@media (max-width: 480px) {
  .site-page .content-section { padding-top: 32px; padding-bottom: 40px; }
  .account-security-card, .appearance-layout { padding: 16px; }
  .appearance-stage { padding: 16px; }
  .account-tabs { gap: 3px; }
  .account-tabs button { flex: 1; gap: 5px; padding: 10px 6px; font-size: 11.5px; }
  .account-tabs .lucide { width: 15px; height: 15px; }
  .admin-stat-grid { grid-template-columns: minmax(0,1fr); }
  .admin-stat-grid article { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; }
  .admin-stat-grid span { font-size: 12px; }
  .admin-workspace { padding: 16px; }
  .admin-workspace :is(.primary-action,.secondary-action) { min-height: 44px; }
  .portal-header-inner { flex-wrap: wrap; gap: 10px; }
  .portal-owner { min-width: 0; }
}

@media (max-height: 500px) and (max-width: 950px) and (orientation: landscape) {
  .page-home .hero { min-height: 0; padding-block: 32px; }
  .hero-logo.hero-logo-halloween { width: min(360px,100%); margin-bottom: 16px; }
  .modal { align-items: flex-start; }
}
