/* ================================================================
   MOBILE UX CRITICAL FIXES - 2025 Best Practices
   Based on WCAG Guidelines and Mobile First Design
   ================================================================ */

/* ===== 1. VIEWPORT AND SAFE AREA SUPPORT ===== */
/* Ensure proper viewport scaling and safe area insets for notched devices */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    
    /* Mobile touch target minimum (WCAG 2.5.5) */
    --min-touch-target: 48px;
    
    /* Mobile spacing standards */
    --mobile-spacing-xs: 0.5rem;   /* 8px */
    --mobile-spacing-sm: 0.75rem;  /* 12px */
    --mobile-spacing-md: 1rem;     /* 16px */
    --mobile-spacing-lg: 1.25rem;  /* 20px */
    --mobile-spacing-xl: 1.5rem;   /* 24px */
}

/* ===== 2. CHAT HEADER MOBILE FIXES ===== */
@media (max-width: 767.98px) {
    .chat-header {
        /* Edge-to-edge width with safe area support - OPTIMIZED for more chat space */
        padding: var(--mobile-spacing-xs) 0 !important; /* Reduced from md to xs */
        padding-top: calc(var(--mobile-spacing-xs) + var(--safe-area-top)) !important; /* Reduced from md to xs */
        padding-left: var(--safe-area-left) !important;
        padding-right: var(--safe-area-right) !important;
        
        /* Fix wrapping and alignment issues */
        flex-direction: row !important;
        flex-wrap: nowrap !important; /* Changed to nowrap for compact layout */
        gap: var(--mobile-spacing-xs) !important; /* Reduced from sm to xs */
        min-height: auto !important;
        
        /* Prevent content from being hidden */
        overflow: visible !important;
        align-items: center !important;
    }
    
    /* Header info section - optimize for mobile - COMPACT layout */
    .chat-header-info {
        flex: 0 1 auto !important; /* Changed: allow shrinking, not full width */
        justify-content: flex-start !important;
        gap: var(--mobile-spacing-xs) !important; /* Reduced from sm to xs */
        margin-bottom: 0 !important;
        padding-left: var(--mobile-spacing-sm) !important; /* Reduced from md to sm */
        padding-right: var(--mobile-spacing-xs) !important; /* Reduced padding */
    }
    
    /* Lottery ball in header - reduce size on mobile for space */
    .chat-header-info .lottery-ball {
        width: 28px !important; /* Reduced from 36px */
        height: 28px !important; /* Reduced from 36px */
        min-width: 28px !important;
        flex-shrink: 0 !important;
    }
    
    .chat-header-info .lottery-ball .ball-number {
        font-size: 13px !important; /* Reduced from 16px */
        line-height: 28px !important; /* Match ball size */
    }
    
    /* Header content - COMPACT text sizing for more chat space */
    .chat-header-content {
        flex: 1 !important;
        min-width: 0 !important;
        width: auto !important; /* Let content determine width */
        max-width: 100% !important; /* Prevent overflow */
    }
    
    .chat-header-content h3,
    #lottomuse-title {
        font-size: 1rem !important; /* Reduced from 1.25rem */
        margin: 0 !important;
        line-height: 1.2 !important; /* Tighter line height */
        font-weight: 600 !important;
        white-space: nowrap !important; /* Prevent wrapping */
    }
    
    .chat-subtitle {
        font-size: 0.65rem !important; /* Reduced from 0.75rem */
        line-height: 1.2 !important; /* Tighter */
        margin-top: 0 !important; /* Removed top margin */
        display: none !important; /* Hide on mobile to save space */
    }
    
    /* Connection status - make more compact */
    #connectionStatus {
        font-size: 0.7rem !important;
        margin-left: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
    }
    
    .connection-dot {
        width: 6px !important;
        height: 6px !important;
    }
    
    /* Navigation links - hide on small mobile, show only icons */
    .chat-nav-links {
        display: none !important;
        /* Links will be accessible via bottom nav or sidebar */
    }
    
    /* Header action buttons - ensure minimum touch targets */
    .chat-actions {
        display: flex !important;
        gap: var(--mobile-spacing-xs) !important;
        flex-wrap: nowrap !important;
        margin-left: auto !important;
        padding-left: var(--mobile-spacing-md) !important;
        padding-right: var(--mobile-spacing-md) !important;
    }
    
    .chat-actions .icon-button {
        min-width: var(--min-touch-target) !important;
        min-height: var(--min-touch-target) !important;
        padding: var(--mobile-spacing-sm) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        transition: all 0.2s ease !important;
    }
    
    .chat-actions .icon-button:active {
        transform: scale(0.95) !important;
        background: rgba(255, 255, 255, 0.25) !important;
    }
    
    .chat-actions .icon-button i {
        font-size: 1rem !important;
        color: white !important;
    }
}

/* ===== MOBILE HAMBURGER MENU STYLES ===== */

/* Hamburger toggle button - only show on mobile */
.mobile-menu-toggle {
    display: none !important;
}

@media (max-width: 767.98px) {
    .mobile-menu-toggle {
        display: flex !important;
        min-width: var(--min-touch-target) !important;
        min-height: var(--min-touch-target) !important;
        padding: var(--mobile-spacing-sm) !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 50% !important;
        color: white !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(255, 255, 255, 0.25) !important;
    }
    
    .mobile-menu-toggle:active {
        transform: scale(0.95) !important;
    }
    
    .mobile-menu-toggle i {
        font-size: 1.1rem !important;
    }
}

/* Mobile navigation menu container */
.mobile-nav-menu {
    width: 100% !important;
    background: var(--primary-gradient, linear-gradient(135deg, #1a2b63 0%, #2d4a9e 100%)) !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    padding: var(--mobile-spacing-md) 0 !important;
    margin-top: var(--mobile-spacing-sm) !important;
}

/* Ensure the mobile menu overlays transient UI (tooltips, arrows) when opened */
@media (max-width: 767.98px) {
    .mobile-nav-menu.show {
        position: relative !important; /* create stacking context */
        z-index: 11000 !important; /* sit above tooltips (guest-tooltip z-index:10000 inline) */
    }

    /* When mobile menu is open we hide guest tooltips to avoid visual glitches
       (some tooltips are appended inline and use very large z-index values) */
    body.mobile-menu-open .guest-tooltip {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

.mobile-nav-container {
    padding: 0 var(--mobile-spacing-md) !important;
}

/* Mobile Profile Header (shown at top of mobile menu) */
.mobile-profile-header {
    padding: var(--mobile-spacing-lg) var(--mobile-spacing-lg) !important;
    margin-bottom: var(--mobile-spacing-md) !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.mobile-profile-info {
    display: flex !important;
    align-items: center !important;
    gap: var(--mobile-spacing-md) !important;
}

.mobile-profile-info > i {
    font-size: 2.5rem !important;
    color: #F7D046 !important;
}

.mobile-profile-details {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    color: white !important;
}

.mobile-profile-details strong {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    color: white !important;
}

.mobile-profile-status {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 0.85rem !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

.mobile-credit-balance {
    margin-top: var(--mobile-spacing-md) !important;
    padding-top: var(--mobile-spacing-md) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #F7D046 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
}

.mobile-credit-balance i {
    font-size: 1.2rem !important;
}

.mobile-nav-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: var(--mobile-spacing-xs) !important;
}

.mobile-nav-item {
    width: 100% !important;
}

.mobile-nav-link {
    display: flex !important;
    align-items: center !important;
    gap: var(--mobile-spacing-md) !important;
    padding: var(--mobile-spacing-md) var(--mobile-spacing-lg) !important;
    min-height: var(--min-touch-target) !important;
    color: white !important;
    text-decoration: none !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    border: 1px solid transparent !important;
}

.mobile-nav-link:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: #F7D046 !important;
    transform: translateX(4px) !important;
}

.mobile-nav-link:active {
    transform: translateX(2px) scale(0.98) !important;
    background: rgba(255, 255, 255, 0.25) !important;
}

.mobile-nav-link i {
    font-size: 1.2rem !important;
    min-width: 24px !important;
    text-align: center !important;
}

.mobile-nav-link span {
    flex: 1 !important;
    font-weight: 500 !important;
}

/* Mobile Navigation Section Headers and Subitems */
.mobile-nav-header {
    margin-top: var(--mobile-spacing-sm) !important;
}

.mobile-nav-section-title {
    display: flex !important;
    align-items: center !important;
    gap: var(--mobile-spacing-md) !important;
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-lg) !important;
    color: #F7D046 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    opacity: 0.9 !important;
}

.mobile-nav-section-title i {
    font-size: 1rem !important;
    min-width: 24px !important;
    text-align: center !important;
}

.mobile-nav-subitem .mobile-nav-link {
    padding-left: 2.5rem !important;
    font-size: 0.95rem !important;
    background: rgba(255, 255, 255, 0.05) !important;
}

.mobile-nav-subitem .mobile-nav-link:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* Hide mobile menu on larger screens */
@media (min-width: 768px) {
    .mobile-nav-menu {
        display: none !important;
    }
}

/* ===== 3. BOTTOM NAVIGATION FIXES ===== */
@media (max-width: 767.98px) {
    .bottom-nav {
        /* Edge-to-edge width with safe area support - OPTIMIZED */
        padding-top: 4px !important; /* Reduced from xs */
        padding-bottom: calc(4px + var(--safe-area-bottom)) !important;
        padding-left: calc(var(--mobile-spacing-xs) + var(--safe-area-left)) !important; /* Reduced */
        padding-right: calc(var(--mobile-spacing-xs) + var(--safe-area-right)) !important;
        
        /* Reduced minimum height for more chat space */
        min-height: calc(60px + var(--safe-area-bottom)) !important; /* Reduced from 88px */
        
        /* Improve visual hierarchy */
        box-shadow: 0 -2px 8px rgba(26, 43, 99, 0.15) !important; /* Lighter shadow */
        
        /* Ensure content doesn't get hidden */
        z-index: 1050 !important;
        
        /* Match top header width */
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        
        /* Center the icons like top nav */
        justify-content: center !important;
        gap: 12px !important; /* Reduced from 16px */
    }
    
    /* Bottom nav items - compact touch targets */
    .bottom-nav-item {
        min-width: 56px !important; /* Reduced from 64px */
        max-width: 72px !important; /* Reduced from 90px */
        padding: 2px 0 !important; /* Reduced from 4px */
        gap: 0 !important; /* Removed gap */
        flex: 0 0 auto !important;  /* Don't spread out */
    }
    
    /* Nav ball buttons - compact touch target */
    .nav-ball-btn {
        min-width: 40px !important; /* Reduced from 48px */
        min-height: 40px !important;
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important; /* Removed padding */
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Nav lottery ball SVG - smaller */
    .nav-lottery-ball {
        width: 32px !important; /* Reduced from 36px */
        height: 32px !important;
    }
    
    /* Nav labels - improve readability */
    .nav-label {
        font-size: 0.68rem !important;
        line-height: 1.2 !important;
        font-weight: 600 !important;
        margin-top: 2px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
}

/* ===== 4. FLOATING CHAT INPUT FIXES ===== */
@media (max-width: 767.98px) {
    #floating-chat-input {
        /* Position above bottom nav - OPTIMIZED with reduced spacing */
        bottom: calc(60px + 8px + var(--safe-area-bottom)) !important; /* Reduced nav height and gap */
        
        /* Optimize width and spacing */
        width: calc(100% - 12px) !important; /* Wider: reduced margin from 16px to 6px each side */
        left: 6px !important;
        right: 6px !important;
        transform: none !important;
        
        /* COMPACT padding for mobile */
        padding: 6px !important; /* Reduced from sm (12px) to 6px */
        
        /* Ensure it doesn't cover content */
        max-width: none !important;
        
        /* Lighter shadow for mobile */
        box-shadow: 0 2px 12px rgba(99, 102, 241, 0.12) !important;
        
        /* Tighter border radius */
        border-radius: 16px !important; /* Reduced from default */
    }
    
    /* Chat suggestions - COMPACT mobile layout */
    .chat-suggestions {
        gap: 4px !important; /* Reduced from xs (8px) */
        padding: 0 0 4px 0 !important; /* Reduced padding */
        margin-bottom: 4px !important; /* Reduced margin */
    }
    
    .suggestion-btn {
        /* COMPACT touch target height */
        min-height: 32px !important; /* Reduced from 40px */
        padding: 4px 10px !important; /* Reduced padding */
        font-size: 0.75rem !important; /* Reduced from 0.875rem */
        border-radius: 16px !important; /* Slightly smaller radius */
        white-space: nowrap !important;
    }
    
    /* Chat form - optimize for mobile */
    .chat-form {
        display: flex !important;
        gap: var(--mobile-spacing-xs) !important;
        align-items: flex-end !important;
    }
    
    /* Input wrapper - ensure proper sizing */
    .input-wrapper {
        flex: 1 !important;
        min-width: 0 !important;
        position: relative !important;
    }
    
    /* Textarea - prevent iOS zoom, COMPACT height */
    .chat-form textarea,
    #chat-message {
        /* Prevent iOS zoom with 16px minimum */
        font-size: 16px !important;
        line-height: 1.4 !important; /* Tighter line height */
        
        /* COMPACT height for more chat visibility */
        min-height: 38px !important; /* Reduced from 44px */
        max-height: 80px !important; /* Reduced from 120px */
        
        /* Optimized padding */
        padding: 8px 12px !important; /* Reduced from spacing-sm */
        padding-bottom: 18px !important; /* Reduced space for character counter */
        
        /* Improve border and radius */
        border: 1.5px solid #e0e0e0 !important; /* Thinner border */
        border-radius: 10px !important; /* Slightly smaller radius */
        
        /* Ensure proper resize behavior */
        resize: none !important;
        overflow-y: auto !important;
    }
    
    /* Character counter - HIDDEN on small/xs screens for cleaner mobile UI */
    .char-counter,
    #char-counter {
        display: none !important;
    }
    
    /* Send button - COMPACT touch target */
    .send-button,
    .chat-form button[type="submit"] {
        min-width: 40px !important; /* Reduced from 48px */
        min-height: 40px !important;
        width: 40px !important;
        height: 40px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        background: linear-gradient(135deg, #6366F1, #8B5CF6) !important;
        border: none !important;
        box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25) !important; /* Lighter shadow */
        transition: all 0.2s ease !important;
    }
    
    .send-button:active,
    .chat-form button[type="submit"]:active {
        transform: scale(0.95) !important;
    }
    
    .send-button i,
    .chat-form button[type="submit"] i {
        font-size: 1.1rem !important;
        color: white !important;
    }
}

/* ===== 5. CATEGORY OPTION BUTTONS FIXES ===== */
@media (max-width: 767.98px) {
    .category-options-container {
        padding: var(--mobile-spacing-md) !important;
        margin: var(--mobile-spacing-sm) auto !important;
        border-radius: 16px !important;
        width: calc(100% - var(--mobile-spacing-md) * 2) !important;
    }
    
    .category-options-intro {
        font-size: 0.9rem !important;
        margin-bottom: var(--mobile-spacing-md) !important;
        line-height: 1.5 !important;
    }
    
    .category-buttons {
        gap: var(--mobile-spacing-sm) !important;
    }
    
    .category-option-btn {
        /* Ensure minimum touch target */
        min-height: var(--min-touch-target) !important;
        padding: var(--mobile-spacing-md) var(--mobile-spacing-lg) !important;
        font-size: 0.95rem !important;
        border-radius: 12px !important;
        gap: var(--mobile-spacing-xs) !important;
        
        /* Improve tap feedback */
        transition: all 0.2s ease !important;
    }
    
    .category-option-btn:active {
        transform: translateY(0) scale(0.97) !important;
    }
    
    /* Hide tooltips on mobile (they don't work well with touch) */
    .category-option-btn::after,
    .category-option-btn::before {
        display: none !important;
    }
}

/* ===== 6. CHAT MESSAGES AREA FIXES ===== */
@media (max-width: 767.98px) {
    .chat-messages {
        /* OPTIMIZED spacing - reduced padding for more chat visibility */
        padding-top: var(--mobile-spacing-sm) !important; /* Reduced from md */
        padding-bottom: calc(120px + var(--safe-area-bottom)) !important; /* Reduced from 140px */
        padding-left: var(--mobile-spacing-xs) !important; /* Reduced from sm */
        padding-right: var(--mobile-spacing-xs) !important;
        
        /* Ensure smooth scrolling */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        
        /* Additional Bootstrap-style optimizations */
        scroll-padding-bottom: 120px !important; /* Ensure smooth scroll behavior */
    }
    
    /* Message bubbles - COMPACT mobile layout */
    .message-bubble,
    .chat-message {
        max-width: 92% !important; /* Slightly wider messages */
        margin-bottom: var(--mobile-spacing-sm) !important; /* Reduced gap between messages */
        font-size: 0.95rem !important; /* Slightly smaller for more content */
        line-height: 1.45 !important; /* Tighter line height */
        padding: var(--mobile-spacing-sm) !important; /* Reduced from md */
        border-radius: 14px !important; /* Slightly smaller radius */
    }
    
    /* User messages */
    .user-message {
        margin-left: auto !important;
    }
    
    /* Bot messages */
    .bot-message {
        margin-right: auto !important;
    }
}

/* ===== 7. SIDEBAR MOBILE FIXES ===== */
@media (max-width: 767.98px) {
    .chatgpt-sidebar {
        /* Full height with safe area consideration */
        padding-top: var(--safe-area-top) !important;
        padding-bottom: var(--safe-area-bottom) !important;
        
        /* Improve touch scrolling */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Sidebar buttons - ensure minimum touch targets */
    .chatgpt-sidebar button,
    .chatgpt-sidebar .sidebar-link {
        min-height: var(--min-touch-target) !important;
        padding: var(--mobile-spacing-md) !important;
        font-size: 1rem !important;
    }
    
    /* New chat button */
    .new-chat-button {
        min-height: var(--min-touch-target) !important;
        padding: var(--mobile-spacing-md) var(--mobile-spacing-lg) !important;
    }
}

/* ===== 8. MODAL FIXES FOR MOBILE ===== */
@media (max-width: 767.98px) {
    .modal-dialog,
    .chat-modal-content {
        margin: var(--mobile-spacing-md) !important;
        max-width: calc(100% - var(--mobile-spacing-md) * 2) !important;
    }
    
    .modal-content {
        border-radius: 16px !important;
    }
    
    /* Modal buttons - ensure touch targets */
    .modal button,
    .modal .btn {
        min-height: var(--min-touch-target) !important;
        padding: var(--mobile-spacing-md) var(--mobile-spacing-lg) !important;
        font-size: 1rem !important;
    }
}

/* ===== 9. ACCESSIBILITY IMPROVEMENTS ===== */
@media (max-width: 767.98px) {
    /* Improve focus visibility for keyboard users */
    *:focus-visible {
        outline: 3px solid rgba(99, 102, 241, 0.5) !important;
        outline-offset: 2px !important;
        border-radius: 4px !important;
    }
    
    /* Remove focus outline for mouse/touch users */
    *:focus:not(:focus-visible) {
        outline: none !important;
    }
    
    /* Improve tap highlight color */
    * {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1) !important;
    }
    
    /* Ensure text is selectable but not in buttons */
    button,
    .btn,
    [role="button"] {
        -webkit-user-select: none !important;
        user-select: none !important;
    }
}

/* ===== 10. TYPOGRAPHY OPTIMIZATION FOR MOBILE ===== */
@media (max-width: 767.98px) {
    /* Base text sizing - ensure minimum 16px for iOS */
    body,
    .chat-container {
        font-size: 16px !important;
        line-height: 1.5 !important;
    }
    
    /* Heading sizes optimized for mobile */
    h1, .h1 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: var(--mobile-spacing-md) !important;
    }
    
    h2, .h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        margin-bottom: var(--mobile-spacing-sm) !important;
    }
    
    h3, .h3 {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
        margin-bottom: var(--mobile-spacing-sm) !important;
    }
    
    /* Ensure readable paragraph text */
    p {
        font-size: 1rem !important;
        line-height: 1.6 !important;
        margin-bottom: var(--mobile-spacing-md) !important;
    }
    
    /* Small text should still be readable */
    small, .small {
        font-size: 0.875rem !important;
        line-height: 1.4 !important;
    }
}

/* ===== 11. PERFORMANCE OPTIMIZATIONS ===== */
@media (max-width: 767.98px) {
    /* Reduce animations for better performance */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }
    
    /* Use GPU acceleration for fixed elements */
    .bottom-nav,
    #floating-chat-input,
    .chat-header {
        will-change: transform !important;
        transform: translateZ(0) !important;
        backface-visibility: hidden !important;
    }
}

/* ===== 12. LANDSCAPE MODE OPTIMIZATIONS ===== */
@media (max-width: 767.98px) and (orientation: landscape) {
    /* MINIMAL header height in landscape */
    .chat-header {
        padding-top: 4px !important;
        padding-bottom: 4px !important;
    }
    
    /* Hide subtitle in landscape for more space */
    .chat-subtitle {
        display: none !important;
    }
    
    /* Even smaller ball in landscape */
    .chat-header-info .lottery-ball {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* Make chat messages area larger */
    .chat-messages {
        padding-top: 4px !important;
        padding-bottom: calc(100px + var(--safe-area-bottom)) !important;
    }
    
    /* COMPACT bottom nav for landscape */
    .bottom-nav {
        min-height: calc(48px + var(--safe-area-bottom)) !important;
    }
    
    .nav-ball-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
    }
    
    .nav-lottery-ball {
        width: 28px !important;
        height: 28px !important;
    }
    
    .nav-label {
        font-size: 9px !important;
        display: none !important; /* Hide labels in landscape for more space */
    }
    
    /* Compact floating input in landscape */
    #floating-chat-input {
        bottom: calc(48px + 6px + var(--safe-area-bottom)) !important;
        padding: 4px !important;
    }
    
    .suggestion-btn {
        min-height: 28px !important;
        padding: 3px 8px !important;
        font-size: 0.7rem !important;
    }
}

/* ===== 13. EXTRA SMALL DEVICES (< 375px width) ===== */
@media (max-width: 374.98px) {
    /* Further optimize for very small screens */
    .chat-header-content {
        width: 100% !important; /* Ensure full width on small screens */
    }
    
    .chat-header-content h3,
    #lottomuse-title {
        font-size: 1.1rem !important;
        width: 100% !important;
    }
    
    .chat-subtitle {
        font-size: 0.7rem !important;
        width: 100% !important;
    }
    
    .chat-actions .icon-button {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px !important;
    }
    
    .bottom-nav-item {
        min-width: 56px !important;
    }
    
    .nav-label {
        font-size: 10px !important;
    }
}
