/* Mobile Enhancements for 2048 Game */

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    .dropdown-item:hover,
    .user-icon:hover,
    .contest-card:hover,
    .game-item:hover,
    .withdrawal-item:hover,
    .stat-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    
    /* Add active states for touch feedback */
    .btn:active,
    .nav-link:active,
    .dropdown-item:active,
    .user-icon:active {
        transform: scale(0.95) !important;
        transition: transform 0.1s ease !important;
    }
    
    /* Improve touch targets */
    .btn,
    .nav-link,
    .dropdown-item,
    .user-icon,
    .filter-btn,
    .submit-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better form inputs on mobile */
    .form-input,
    .filter-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px 16px !important;
    }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Better spacing for mobile */
    .container,
    .profile-container,
    .contest-details-container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Game controls mobile improvements */
    .top-controls {
        margin: 10px 0 !important;
        padding: 15px !important;
    }
    
    .game-mode-module,
    .time-module {
        margin-bottom: 10px !important;
    }
    
    .game-mode-dropdown-header,
    .time-dropdown-header {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    }
    
    .game-mode-dropdown-option,
    .time-dropdown-option {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    }
    
    /* Prevent scrolling during game interaction */
    .game-board-section {
        touch-action: none !important;
        overflow: hidden !important;
        position: relative !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .game-container {
        touch-action: none !important;
        overflow: hidden !important;
        position: relative !important;
        -webkit-overflow-scrolling: touch;
    }
    
    #game-board {
        touch-action: none !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        pointer-events: auto !important;
    }
    
    #tile-container {
        touch-action: none !important;
        pointer-events: none !important;
    }
    
    /* Prevent body and html scroll during game */
    body.game-active,
    html.game-active {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        touch-action: none !important;
        -webkit-overflow-scrolling: touch;
    }
    
    body.game-active {
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Prevent scrolling on container when game is active */
    .container.game-active,
    .game-area.game-active {
        touch-action: none !important;
        overflow: hidden !important;
    }
    
    /* Improved button sizing */
    .btn {
        padding: 12px 20px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
    }
    
    /* Better modal positioning */
    .modal-overlay {
        padding: 20px !important;
    }
    
    .modal-content {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border-radius: 4px !important;
    }
    
    /* Withdrawal Modal Mobile Styles */
    .withdrawal-modal {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        background: #ffffff !important;
    }
    
    .withdrawal-modal .modal-body {
        padding: 20px !important;
        background: #ffffff !important;
    }
    
    .withdrawal-modal .modal-header {
        padding: 16px 20px !important;
        background: #ffffff !important;
    }
    
    .withdrawal-modal .modal-actions {
        padding: 16px 20px !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .withdrawal-modal .btn-primary,
    .withdrawal-modal .btn-secondary {
        width: 100% !important;
    }
    
    /* Improved table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better grid layouts */
    .contests-grid,
    .profile-stats,
    .game-stats {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Improved form layouts */
    .filter-form,
    .contest-actions {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    /* Better text sizing */
    .page-title,
    .section-title {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }
    
    /* Improved spacing */
    .contest-card,
    .game-item,
    .withdrawal-item {
        padding: 20px !important;
        margin-bottom: 15px !important;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    /* Even better spacing */
    .container,
    .profile-container,
    .contest-details-container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    /* Smaller text for very small screens */
    .page-title {
        font-size: 20px !important;
    }
    
    .section-title {
        font-size: 18px !important;
    }
    
    /* Compact cards */
    .contest-card,
    .game-item,
    .withdrawal-item {
        padding: 15px !important;
    }
    
    /* Better button sizing */
    .btn {
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
    
    /* Withdrawal Modal Small Mobile */
    .withdrawal-modal {
        max-height: 90vh !important;
    }
    
    .withdrawal-modal .modal-body {
        padding: 16px !important;
    }
    
    .withdrawal-modal .modal-header {
        padding: 12px 16px !important;
    }
    
    .withdrawal-modal .modal-header .modal-title {
        font-size: 20px !important;
    }
    
    .withdrawal-modal .modal-actions {
        padding: 12px 16px !important;
    }
    
    .withdrawal-modal .form-input {
        padding: 14px 16px !important;
        font-size: 16px !important;
    }
}

/* Landscape orientation improvements */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar {
        height: 60px !important;
    }
    
    .container,
    .profile-container {
        margin-top: 70px !important;
    }
    
    .modal-content {
        max-height: 80vh !important;
        overflow-y: auto !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .btn,
    .nav-link,
    .dropdown-item {
        border-width: 0.5px !important;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
    .modal-content {
        background: #2a3655 !important;
        color: #ffffff !important;
    }
    
    /* Keep withdrawal modal white even in dark mode */
    .withdrawal-modal {
        background: #ffffff !important;
    }
    
    .withdrawal-modal .modal-body,
    .withdrawal-modal .modal-header {
        background: #ffffff !important;
        color: #1f2937 !important;
    }
}

/* Print styles */
@media print {
    .navbar,
    .mobile-menu-btn,
    .btn,
    .modal-overlay {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}
