/**
 * iOS-style shell for small screens only (max-width: 768px).
 * Opt out: add class `no-ios-mobile-shell` to <body>.
 */

@media (max-width: 768px) {
  body:not(.no-ios-mobile-shell) {
    -webkit-tap-highlight-color: rgba(250, 204, 21, 0.12);
  }

  /* Shell tokens (dialogs / flash align with Settings cards) */
  body:not(.no-ios-mobile-shell) {
    --zwarah-shell-card-radius: 16px;
    --radius-md: 13px;
    --radius-lg: 14px;
    --radius-xl: 18px;
  }

  /* Top bar */
  body:not(.no-ios-mobile-shell) .navbar-modern {
    background: rgba(15, 23, 42, 0.72);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  }

  body:not(.no-ios-mobile-shell) .navbar-menu-toggle {
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.5);
  }

  /* Slide-out menu: grouped “Settings” rows */
  body:not(.no-ios-mobile-shell) .navbar-mobile-menu {
    width: min(100%, 340px);
    border-left: none;
    background: rgba(15, 23, 42, 0.94);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
    box-shadow: -12px 0 48px rgba(0, 0, 0, 0.45);
  }

  body:not(.no-ios-mobile-shell) .navbar-mobile-header {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 14px;
    border-bottom-color: rgba(148, 163, 184, 0.12);
  }

  body:not(.no-ios-mobile-shell) .navbar-mobile-links {
    padding: 12px 14px max(20px, env(safe-area-inset-bottom));
    gap: 8px;
  }

  body:not(.no-ios-mobile-shell) .navbar-mobile-link {
    border-radius: 13px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(30, 41, 59, 0.75);
    padding: 15px 14px;
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0;
  }

  body:not(.no-ios-mobile-shell) .navbar-mobile-link:hover {
    transform: none;
    background: rgba(51, 65, 85, 0.85);
  }

  body:not(.no-ios-mobile-shell) .navbar-mobile-credits {
    border-radius: 13px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    margin: 4px 0 0;
  }

  /* Primary buttons — touch-first, less “marketing hover” */
  body:not(.no-ios-mobile-shell) .btn-modern {
    min-height: 48px;
    border-radius: 13px;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
  }

  body:not(.no-ios-mobile-shell) .btn-modern::before {
    display: none;
  }

  body:not(.no-ios-mobile-shell) .btn-gold:hover,
  body:not(.no-ios-mobile-shell) .btn-blue:hover {
    transform: none;
  }

  body:not(.no-ios-mobile-shell) .btn-modern:active {
    transform: scale(0.98);
    opacity: 0.94;
  }

  body:not(.no-ios-mobile-shell) .btn-sm {
    min-height: 40px;
    border-radius: 11px;
  }

  body:not(.no-ios-mobile-shell) .btn-outline {
    border-width: 1px;
  }

  /* Form controls */
  body:not(.no-ios-mobile-shell) input[type="text"],
  body:not(.no-ios-mobile-shell) input[type="email"],
  body:not(.no-ios-mobile-shell) input[type="password"],
  body:not(.no-ios-mobile-shell) input[type="search"],
  body:not(.no-ios-mobile-shell) input[type="tel"],
  body:not(.no-ios-mobile-shell) input[type="url"],
  body:not(.no-ios-mobile-shell) input[type="number"],
  body:not(.no-ios-mobile-shell) textarea,
  body:not(.no-ios-mobile-shell) select {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.28) !important;
    background: rgba(15, 23, 42, 0.55) !important;
  }

  body:not(.no-ios-mobile-shell) textarea {
    min-height: 120px;
  }

  /* Cards */
  body:not(.no-ios-mobile-shell) .modern-card {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.22);
  }

  /* Flash */
  body:not(.no-ios-mobile-shell) .flash-modern {
    border-radius: 16px;
    border: 1px solid rgba(250, 204, 21, 0.22);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  }

  /* Main column breathing room */
  body:not(.no-ios-mobile-shell) main.container {
    padding-left: max(var(--spacing-md), env(safe-area-inset-left)) !important;
    padding-right: max(var(--spacing-md), env(safe-area-inset-right)) !important;
  }

  /* ——— Game host (standalone page) ——— */
  body:not(.no-ios-mobile-shell) .question-display {
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.12);
  }

  body:not(.no-ios-mobile-shell) .choice-display {
    border-radius: 14px !important;
    min-height: 48px;
  }

  body:not(.no-ios-mobile-shell) .control-btn {
    border-radius: 13px;
    min-height: 48px;
  }

  /* ——— Quiz player ——— */
  body:not(.no-ios-mobile-shell) .team-info-modern {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
  }

  body:not(.no-ios-mobile-shell) .choice-button-modern {
    border-radius: 14px !important;
    min-height: 52px !important;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .choice-button-modern::before {
    opacity: 0.35;
  }

  body:not(.no-ios-mobile-shell) .powerup-btn-modern {
    border-radius: 13px;
    min-height: 48px !important;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .quiz-timer-card,
  body:not(.no-ios-mobile-shell) .quiz-powerups-card {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
  }

  /* ——— Lobbies (session / spy / harf / top10) ——— */
  body:not(.no-ios-mobile-shell) .team-card-modern,
  body:not(.no-ios-mobile-shell) .lobby-wrapper .team-card-modern {
    border-radius: 14px;
    border-width: 1px;
    border-color: rgba(148, 163, 184, 0.16);
  }

  body:not(.no-ios-mobile-shell) .back-button-modern {
    border-radius: 12px !important;
  }

  /* ——— Home screen ——— */
  body:not(.no-ios-mobile-shell) .player-card,
  body:not(.no-ios-mobile-shell) .leaderboard-card {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
  }

  body:not(.no-ios-mobile-shell) .leaderboard-card-toggle {
    border-radius: 12px;
  }

  /* ——— Host-as-player / Spy / Top 10 player UIs ——— */
  body:not(.no-ios-mobile-shell) .host-control-btn {
    border-radius: 13px;
    min-height: 46px;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .spy-request-vote-btn {
    border-radius: 12px;
    min-height: 48px;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .host-spy-wrapper .btn-gold,
  body:not(.no-ios-mobile-shell) .host-spy-wrapper button {
    border-radius: 13px;
    min-height: 48px;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .spy-vote-box .vote-option,
  body:not(.no-ios-mobile-shell) .spy-guess-box .guess-option {
    border-radius: 12px;
    min-height: 48px;
  }

  body:not(.no-ios-mobile-shell) .choice-card-modern,
  body:not(.no-ios-mobile-shell) .t10p-wrap,
  body:not(.no-ios-mobile-shell) .t10-host-wrap {
    border-radius: 14px;
  }

  body:not(.no-ios-mobile-shell) #t10p-submit-btn,
  body:not(.no-ios-mobile-shell) .t10h-guess-submit {
    border-radius: 13px;
    min-height: 48px;
    font-weight: 700;
  }

  /* ——— حرف حرف ——— */
  body:not(.no-ios-mobile-shell) .hrf-wrap .btn-gold,
  body:not(.no-ios-mobile-shell) .hrf-wrap .btn-modern,
  body:not(.no-ios-mobile-shell) .hrf-compact-rail button {
    border-radius: 13px;
    min-height: 48px;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .hrf-mobile-shell,
  body:not(.no-ios-mobile-shell) .hrf-wrap.hrf-wof {
    border-radius: 14px;
  }

  /* ——— App pages (base.html): forms, modals, cards ——— */
  body:not(.no-ios-mobile-shell) .form-container-modern,
  body:not(.no-ios-mobile-shell) .login-card-modern,
  body:not(.no-ios-mobile-shell) .join-card-modern,
  body:not(.no-ios-mobile-shell) .choice-card-modern,
  body:not(.no-ios-mobile-shell) .stats-card-modern,
  body:not(.no-ios-mobile-shell) .friend-card-modern,
  body:not(.no-ios-mobile-shell) .dash-card-modern,
  body:not(.no-ios-mobile-shell) .credit-card-modern,
  body:not(.no-ios-mobile-shell) .note-modern,
  body:not(.no-ios-mobile-shell) .gift-card-modern,
  body:not(.no-ios-mobile-shell) .purchase-card-modern {
    border-radius: 14px !important;
    border: 1px solid rgba(148, 163, 184, 0.14) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2) !important;
  }

  body:not(.no-ios-mobile-shell) .dash-card-modern:hover,
  body:not(.no-ios-mobile-shell) .friend-card-modern:hover,
  body:not(.no-ios-mobile-shell) .stats-card-modern:hover,
  body:not(.no-ios-mobile-shell) .credit-card-modern:hover {
    transform: none !important;
  }

  body:not(.no-ios-mobile-shell) .modal-modern .modal-content-modern {
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  }

  body:not(.no-ios-mobile-shell) .modal-close-modern {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
  }

  body:not(.no-ios-mobile-shell) .pagination-modern a,
  body:not(.no-ios-mobile-shell) .pagination a {
    border-radius: 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  body:not(.no-ios-mobile-shell) .filter-btn-modern,
  body:not(.no-ios-mobile-shell) .filter-btn {
    border-radius: 12px;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border-width: 1px;
  }

  body:not(.no-ios-mobile-shell) .back-button-modern {
    border-radius: 12px !important;
  }

  body:not(.no-ios-mobile-shell) .avatar-modal-content {
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.18);
  }

  /* ——— Admin & minimal standalone pages ——— */
  body:not(.no-ios-mobile-shell) .form-add {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(30, 41, 59, 0.85) !important;
  }

  body:not(.no-ios-mobile-shell) .form-add input,
  body:not(.no-ios-mobile-shell) .form-add select,
  body:not(.no-ios-mobile-shell) .form-add textarea {
    min-height: 48px;
    border-radius: 12px !important;
  }

  body:not(.no-ios-mobile-shell) .filters a,
  body:not(.no-ios-mobile-shell) a.nav {
    border-radius: 12px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
    border: 1px solid rgba(148, 163, 184, 0.15);
  }

  body:not(.no-ios-mobile-shell) .flash:not(.flash-modern) {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
  }

  body:not(.no-ios-mobile-shell) .back-link {
    border-radius: 13px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    border-width: 1px !important;
  }

  body:not(.no-ios-mobile-shell) .card {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
  }

  body:not(.no-ios-mobile-shell) .btn-sm:not(.btn-modern) {
    min-height: 40px;
    border-radius: 10px;
    padding: 0.35rem 0.65rem;
  }

  /* Splash / minimal full-screen */
  body:not(.no-ios-mobile-shell) .splash-container {
    border-radius: 16px;
    padding: 1.5rem;
  }

  body:not(.no-ios-mobile-shell) .login-redirect-box {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 16px;
    padding: 1.75rem 1.5rem;
    max-width: min(420px, 92vw);
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  }

  /* ——— تغيير كلمة المرور / تعديل البيانات (مثل إعدادات iOS) ——— */
  body:not(.no-ios-mobile-shell):has(.ios-account-page) {
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }

  body:not(.no-ios-mobile-shell):has(.ios-account-page)::before {
    animation: none;
    opacity: 0.45;
  }

  body:not(.no-ios-mobile-shell) main.container:has(.ios-account-page) {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding-top: max(8px, env(safe-area-inset-top)) !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    min-height: 100vh !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-page {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right));
    box-sizing: border-box;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card {
    background: rgba(15, 23, 42, 0.82) !important;
    border: 1px solid rgba(148, 163, 184, 0.14) !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.22) !important;
    padding: 1rem 0.95rem 1.15rem !important;
    animation: none !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-logo {
    width: 64px !important;
    height: 64px !important;
    margin: 0 auto 0.65rem !important;
    animation: none !important;
    filter: none !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-title {
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    text-align: right !important;
    margin-bottom: 0.85rem !important;
    line-height: 1.25 !important;
    padding: 0 0.15rem;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card .form-label-modern {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(226, 232, 240, 0.52);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.35rem;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card .form-input-modern {
    border: 1px solid rgba(148, 163, 184, 0.22) !important;
    border-radius: 12px !important;
    background: rgba(15, 23, 42, 0.55) !important;
    min-height: 48px;
    padding: 0.65rem 0.85rem !important;
    box-shadow: none !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card .form-input-modern:focus {
    border-color: rgba(250, 204, 21, 0.45) !important;
    background: rgba(15, 23, 42, 0.72) !important;
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.1) !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card .form-group-modern {
    margin-bottom: 0.85rem !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card .password-rules-modern,
  body:not(.no-ios-mobile-shell) .ios-account-card .phone-note-modern {
    background: rgba(30, 41, 59, 0.55) !important;
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px !important;
    padding: 0.65rem 0.75rem !important;
    margin-top: 0.35rem !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card .btn-modern.btn-gold {
    width: 100%;
    border-radius: 13px;
    min-height: 50px;
    font-weight: 800;
  }

  body:not(.no-ios-mobile-shell) .ios-account-card a.btn-modern.btn-ghost {
    margin-top: 0.65rem !important;
    border-radius: 13px !important;
    min-height: 48px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.18) !important;
    background: rgba(30, 41, 59, 0.45) !important;
    font-weight: 700;
  }

  body:not(.no-ios-mobile-shell) .ios-account-avatar-row {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
    gap: 0.65rem !important;
  }

  body:not(.no-ios-mobile-shell) .ios-account-avatar-row .btn-modern {
    flex: none !important;
    width: 100%;
    max-width: 100%;
  }

  body:not(.no-ios-mobile-shell):has(.ios-account-page) .avatar-modal-content {
    width: min(100%, 380px);
    max-height: min(88vh, 640px);
    padding: 1rem !important;
    border-radius: 16px !important;
    border: 1px solid rgba(148, 163, 184, 0.16) !important;
  }

  body:not(.no-ios-mobile-shell):has(.ios-account-page) .avatar-selection-grid {
    border-width: 1px;
    border-radius: 12px !important;
  }

  body:not(.no-ios-mobile-shell):has(.ios-account-page) .avatar-modal-close {
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
  }
}
