/* styles.css - Responsive Game Styling - VERSION: 1.1 - MOBILE CONTROLS UPDATE */

/* Enhanced Mobile Menu Overlay - Responsive and Accessible - CHROME UI REMOVED */
#mobileMenuOverlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* CHROME UI FIX: Completely hide mobile menu overlay that was causing Chrome-specific UI issues */
}

#mobileMenuOverlay button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* CHROME UI FIX: Hide all mobile menu overlay buttons */
}

#mobileMenuOverlay button:hover,
#mobileMenuOverlay button:active,
#mobilePlayGameBtn,
#mobilePlayGameBtn:hover,
#mobileHowToPlayBtn,
#mobileAboutBtn {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    /* CHROME UI FIX: Hide all mobile menu overlay elements */
}

@keyframes pulse-glow {
    0%, 100% { 
        /* CHROME UI FIX: Enhanced glow animation for clean appearance */
        box-shadow: 0 8px 24px rgba(220, 20, 60, 0.6);
    }
    50% { 
        box-shadow: 0 12px 32px rgba(220, 20, 60, 0.9);
    }
}

/* CHROME UI FIX: Always hide mobile menu overlay on all devices */
#mobileMenuOverlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* CSS Reset and mobile optimization */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* iOS Safari Fix: Explicit touch-action for better responsiveness */
    touch-action: none;
    -ms-touch-action: none;
    -webkit-touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    -webkit-user-select: none;
    user-select: none;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    /* iOS Safari Fix: Force hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Canvas Menu is now rendered directly on the game canvas - no HTML menu styles needed */

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    /* iOS Safari Fix: Comprehensive touch handling */
    -webkit-overflow-scrolling: touch;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-touch-action: none;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    /* SAFARI BLACK LINE FIX: Ensure no borders or outlines */
    border: none;
    outline: none;
    box-shadow: none;
    /* iOS Safari Fix: Improve input responsiveness */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    background: #000000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    /* SAFARI BLACK LINE FIX: Ensure no borders or shadows */
    border: none;
    outline: none;
    box-shadow: none;
    margin: 0;
    padding: 0;
}

canvas {
    display: block;
    background: #000000;
    width: 100%;
    height: 100%;
    /* Maintain crisp pixel rendering */
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: manipulation;
    /* SAFARI BLACK LINE FIX: Ensure no borders or outlines */
    border: none;
    outline: none;
    box-shadow: none;
    margin: 0;
    padding: 0;
}

/* Desktop styles - Remove white space */
@media (min-width: 1024px) {
    body {
        margin: 0;
        padding: 0;
        background: #000;
    }
    
    #gameContainer {
        border: none;
        border-radius: 0;
        width: 100vw;
        height: 100vh;
        background: #000;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
    
    canvas {
        border-radius: 0;
        margin: 0;
        padding: 0;
    }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 1023px) {
    #gameContainer {
        border: 2px solid #2E8B57;
        border-radius: 8px;
        width: 98vw;
        height: 95vh;
    }
    
    canvas {
        border-radius: 4px;
    }
}

/* Enhanced Mobile Layout - Universal Mobile Browser Consistency Fix (Safari, Chrome, Brave, Firefox) */
@media (max-width: 1024px) {
    html {
        /* Consistent viewport handling for ALL mobile browsers */
        width: 100vw !important;
        height: 100vh !important;
        /* Modern viewport units with fallbacks for consistency */
        width: 100svw !important; 
        height: 100svh !important;
        /* Universal mobile browser fixes */
        -webkit-text-size-adjust: 100% !important;
        -webkit-font-smoothing: antialiased !important;
        text-rendering: optimizeLegibility !important;
        /* Brave browser specific optimizations */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        /* SAFARI BLACK LINE FIX: Mobile-specific black line prevention */
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        -webkit-border-radius: 0 !important;
        border-radius: 0 !important;
    }
    
    body {
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        /* Consistent viewport units across all mobile browsers */
        width: 100svw !important;
        height: 100svh !important;
        background: #000 !important;
        /* Enhanced mobile performance and consistency for all browsers */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        will-change: transform !important;
        /* Universal mobile browser consistency fixes */
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -webkit-font-smoothing: antialiased !important;
        text-rendering: optimizeLegibility !important;
        /* Brave browser specific performance optimizations */
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }
    
    #gameContainer {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        /* Use small viewport units where supported */
        width: 100svw !important;
        height: 100svh !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #000 !important;
        border: none !important;
        border-radius: 0 !important;
        /* Safe area support for notched devices */
        padding-top: env(safe-area-inset-top, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    
    canvas {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        /* SAFARI BLACK LINE FIX: Explicit border and outline removal */
        outline: none !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        background: #000000 !important;
        /* GPU acceleration for smooth rendering across all mobile browsers */
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        will-change: transform !important;
        /* Brave browser specific canvas optimizations */
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        /* CHROME MOBILE LAG FIX: Additional Chrome mobile optimizations */
        -webkit-perspective: 1000px !important;
        perspective: 1000px !important;
        -webkit-transform-style: preserve-3d !important;
        transform-style: preserve-3d !important;
    }
}




/* Modal Styles */

.answer-btn {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 12px;
    background: #404040;
    color: white;
    border: 2px solid #FFD700;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
}

.answer-btn:hover {
    background: #606060;
    transform: translateY(-2px);
}



#winModal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 5vw;
    border-radius: 15px;
    border: 4px solid #FFD700;
    text-align: center;
    z-index: 20;
    display: none;
    max-width: 90vw;
    max-height: 90vh;
    font-size: clamp(14px, 4vw, 24px);
}

#deathModal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(139, 0, 0, 0.95);
    color: white;
    /* MOBILE RESPONSIVE FIX: Better padding scaling for mobile devices */
    padding: clamp(15px, 3vw, 25px);
    border-radius: clamp(8px, 2vw, 15px);
    border: clamp(2px, 0.5vw, 4px) solid #FF4444;
    text-align: center;
    z-index: 1000;
    display: none;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
    /* MOBILE RESPONSIVE FIX: Better width/height constraints for mobile */
    width: clamp(280px, 85vw, 450px);
    max-width: 90vw;
    max-height: 80vh;
    min-width: 280px;
    /* MOBILE RESPONSIVE FIX: Better font sizing for mobile readability */
    font-size: clamp(16px, 3.5vw, 20px);
    /* Ensure modal is always on top and visible */
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    /* Arabic text support */
    direction: rtl;
    font-family: 'Noto Sans Arabic', 'Courier New', monospace;
    /* MOBILE RESPONSIVE FIX: Better content fitting */
    overflow-y: auto;
    box-sizing: border-box;
}

.restart-btn {
    padding: clamp(12px, 3vw, 16px) clamp(20px, 5vw, 32px);
    background: #228B22;
    color: white;
    border: 2px solid #FFD700;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Noto Sans Arabic', 'Courier New', monospace;
    font-size: clamp(14px, 4vw, 18px);
    margin-top: 15px;
    transition: all 0.2s;
    touch-action: manipulation;
    min-height: 48px; /* Increased for better touch target */
    min-width: 140px; /* Increased for better touch target */
    -webkit-tap-highlight-color: rgba(255, 215, 0, 0.3);
    user-select: none;
    -webkit-user-select: none;
    /* Ensure button is always functional */
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 1001;
}

/* Desktop centering for restart buttons */
@media (min-width: 769px) {
    .restart-btn {
        display: block;
        margin-left: auto;
        margin-right: auto;
        margin-top: 20px;
    }
}

.restart-btn:hover {
    background: #32CD32;
    transform: translateY(-2px);
}

.restart-btn:active {
    transform: translateY(0);
}

/* Mobile-specific touch feedback and modal fixes */
@media (max-width: 768px) {
    /* MOBILE RESPONSIVE FIX: Better death modal sizing for mobile */
    #deathModal {
        width: clamp(260px, 90vw, 380px) !important;
        padding: clamp(12px, 4vw, 20px) !important;
        font-size: clamp(14px, 4vw, 18px) !important;
        max-height: 70vh !important;
        border-radius: clamp(6px, 2vw, 12px) !important;
        border-width: clamp(1px, 0.5vw, 3px) !important;
    }
    
    #deathModal h2 {
        font-size: clamp(18px, 5vw, 22px) !important;
        margin: clamp(8px, 2vw, 12px) 0 !important;
    }
    
    #deathModal p {
        font-size: clamp(14px, 4vw, 16px) !important;
        margin: clamp(8px, 2vw, 12px) 0 !important;
        line-height: 1.4 !important;
    }
    
    .restart-btn {
        font-size: clamp(14px, 4vw, 16px) !important; /* Better responsive font size */
        min-height: 48px !important; /* Larger touch target */
        min-width: 140px !important;
        padding: clamp(12px, 3vw, 16px) clamp(18px, 4vw, 24px) !important;
        margin-top: clamp(12px, 3vw, 16px) !important;
    }
    
    .restart-btn:active {
        background: #32CD32;
        transform: scale(0.95);
        transition: all 0.1s;
    }
}

/* Duplicate game over try again button removed - using original HTML modal button instead */

/* Game Completion Play Again Button (shows over end screen) - Already centered */
.game-completion-play-again-btn {
    position: absolute;
    top: 85%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 15px 30px;
    background: #404040;
    color: white;
    border: 3px solid #FFD700;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Noto Sans Arabic', 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    z-index: 30; /* Higher than other elements */
    display: none;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    min-width: 200px;
    text-align: center;
}

/* Enhanced desktop styling for completion button */
@media (min-width: 769px) {
    .game-completion-play-again-btn {
        padding: 18px 35px;
        font-size: 20px;
        min-width: 220px;
    }
}

.game-completion-play-again-btn:hover {
    background: #606060;
    transform: translate(-50%, -50%) translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: #FFD700;
}

.game-completion-play-again-btn:active {
    transform: translate(-50%, -50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Map Selection Button Styles */
.map-select-btn {
    padding: 15px 10px;
    background: #4169E1;
    color: white;
    border: 2px solid #FFD700;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    transition: all 0.2s;
    text-align: center;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.map-select-btn:hover {
    background: #6495ED;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Quiz Modal Styles - Enhanced Mobile Responsive */
#quizModal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: clamp(15px, 4vw, 30px);
    border-radius: clamp(8px, 2vw, 15px);
    border: clamp(2px, 0.5vw, 4px) solid #FFD700;
    text-align: center;
    z-index: 20;
    display: none;
    max-width: min(90vw, 600px);
    width: 90%;
    direction: rtl; /* Right-to-left for Arabic support */
    font-family: 'Noto Sans Arabic', 'Courier New', monospace;
    /* Enhanced mobile support */
    max-height: 90vh;
    overflow-y: auto;
}

#quizModal h2 {
    margin-top: 0;
    font-size: clamp(20px, 5vw, 28px);
    margin-bottom: clamp(15px, 3vw, 20px);
    line-height: 1.2;
}

#questionText {
    font-size: clamp(16px, 4vw, 20px);
    margin-bottom: clamp(20px, 4vw, 25px);
    line-height: 1.5;
    min-height: clamp(40px, 8vw, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2vw, 15px);
    word-wrap: break-word;
    hyphens: auto;
}

#answersContainer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(10px, 2vw, 15px);
    margin-bottom: clamp(15px, 3vw, 20px);
}

#quizFeedback {
    font-size: clamp(16px, 3.5vw, 18px);
    font-weight: bold;
    margin-top: clamp(12px, 2.5vw, 15px);
    min-height: clamp(25px, 5vw, 30px);
    line-height: 1.3;
}

/* Mobile-specific quiz modal adjustments */
@media (max-width: 480px) {
    #quizModal {
        padding: 20px 15px;
        max-width: 95vw;
        max-height: 85vh;
    }
    
    #questionText {
        font-size: 16px;
        line-height: 1.4;
        min-height: 50px;
        padding: 12px 8px;
    }
    
    #answersContainer {
        grid-template-columns: 1fr; /* Single column on very small screens */
        gap: 12px;
    }
    
    #quizFeedback {
        font-size: 15px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    #quizModal {
        max-height: 80vh;
        padding: 15px;
    }
    
    #questionText {
        font-size: 14px;
        min-height: 40px;
        padding: 8px;
    }
    
    #answersContainer {
        gap: 10px;
        margin-bottom: 15px;
    }
}

/* Mute button */
#muteButton {
    position: absolute;
    top: clamp(10px, 2vw, 20px);
    right: clamp(10px, 2vw, 20px);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: clamp(40px, 8vw, 60px);
    height: clamp(40px, 8vw, 60px);
    font-size: clamp(16px, 4vw, 24px);
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    touch-action: manipulation;
    min-height: 44px;
    min-width: 44px;
}

#muteButton:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

#muteButton:active {
    transform: scale(0.95);
}

/* =======================================================================
   ENHANCED MOBILE CONTROLS POSITIONING - CROSS-BROWSER COMPATIBILITY
   ======================================================================= */

/* Safari iOS specific positioning fixes */
@supports (-webkit-overflow-scrolling: touch) {
    .movement-controls {
        left: 15px !important;
        bottom: 15px !important;
        position: absolute !important;
        -webkit-transform: translateZ(0) translate3d(0,0,0) !important;
        transform: translateZ(0) translate3d(0,0,0) !important;
        z-index: 99999 !important;
    }
}

/* Chrome mobile and Android specific positioning fixes */
@media screen and (-webkit-min-device-pixel-ratio: 1) {
    .movement-controls {
        left: 15px !important;
        bottom: 15px !important;
        position: absolute !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        z-index: 99999 !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }
}

/* Samsung devices specific fixes */
@media screen and (max-width: 1024px) and (-webkit-min-device-pixel-ratio: 2) {
    .movement-controls {
        left: 15px !important;
        bottom: 15px !important;
        position: absolute !important;
        z-index: 99999 !important;
    }
}

/* Apple devices specific fixes (iPhone, iPad) */
@supports (-webkit-appearance: none) and (not (-webkit-overflow-scrolling: auto)) {
    .movement-controls {
        left: 15px !important;
        bottom: 15px !important;
        position: absolute !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        z-index: 99999 !important;
    }
}

/* ===== BULLETPROOF MOBILE CONTROLS ===== */
/* CROSS-BROWSER COMPATIBILITY: Enhanced Safari, Chrome, Samsung, and Apple device support */

/* Main mobile controls container - HIDDEN BY DEFAULT, SHOWN ONLY ON MOBILE */
.mobile-controls,
#mobileControls {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    pointer-events: none !important;
    z-index: 999999 !important;
    /* DEFAULT: HIDDEN ON DESKTOP */
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* DESKTOP: Absolutely hide controls on PC/laptop screens */
@media (min-width: 1025px), (hover: hover) and (pointer: fine) {
    .mobile-controls,
    #mobileControls,
    .movement-controls,
    .action-controls,
    .control-btn {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* DESKTOP LANDSCAPE: Extra check for large landscape screens */
@media (min-width: 1025px) and (orientation: landscape) {
    .mobile-controls,
    #mobileControls {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* MOBILE ONLY: Show controls ONLY on touch devices with small screens */
@media (max-width: 1024px) and (pointer: coarse) {
    .mobile-controls,
    #mobileControls {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 999999 !important;
        pointer-events: none !important;
        background: transparent !important;
    }

    .mobile-controls .control-btn {
        pointer-events: auto !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .movement-controls, .action-controls {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Control groups - anchored positioning */
.control-group {
    position: absolute !important;
    pointer-events: auto !important;
}

/* Movement controls - bottom left corner */
.movement-controls {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    gap: 15px !important;
    z-index: 999999999 !important;
    pointer-events: auto !important;
    flex-direction: row !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
}

/* Action controls - bottom right corner */
.action-controls {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    gap: 15px !important;
    flex-direction: column !important;
    z-index: 999999999 !important;
    pointer-events: auto !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
}

/* Button base styles - iOS Safari Optimized */
.control-btn {
    position: relative !important;
    width: 70px !important;
    height: 70px !important;
    min-width: 70px !important;
    min-height: 70px !important;
    border: 3px solid #FFD700 !important;
    border-radius: 50% !important;
    background: rgba(34, 139, 34, 0.95) !important;
    color: white !important;
    font-size: 24px !important;
    font-weight: bold !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: auto !important;
    /* iOS Safari Fix: Better touch handling */
    touch-action: manipulation !important;
    -ms-touch-action: manipulation !important;
    -webkit-touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4) !important;
    z-index: 999999999 !important;
    /* iOS Safari Fix: Hardware acceleration for smoother response */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    will-change: transform !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* Movement buttons */
.movement-btn {
    background: rgba(34, 139, 34, 0.95) !important;
}

/* Action buttons */
.action-btn {
    background: rgba(220, 20, 60, 0.95) !important;
}

/* Button icons and labels */
.btn-icon {
    font-size: 28px !important;
    line-height: 1 !important;
}

.btn-label {
    font-size: 10px !important;
    margin-top: 2px !important;
}

/* Press state - visual feedback */
.control-btn:active,
.control-btn.pressed {
    transform: scale(0.9) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6) !important;
}

.movement-btn:active,
.movement-btn.pressed {
    background: rgba(80, 80, 80, 1) !important;
    border-color: rgba(255, 255, 0, 1) !important;
}

.action-btn:active,
.action-btn.pressed {
    background: rgba(255, 69, 0, 1) !important;
    border-color: rgba(255, 255, 0, 1) !important;
}

/* Enhanced Responsive sizing for different screen sizes */
@media (max-width: 480px) {
    /* SMALL MOBILE RESPONSIVE FIX: Better death modal for very small screens */
    #deathModal {
        width: clamp(240px, 95vw, 320px) !important;
        padding: clamp(10px, 3vw, 16px) !important;
        font-size: clamp(12px, 3.5vw, 16px) !important;
        max-height: 65vh !important;
        min-width: 240px !important;
        border-radius: clamp(4px, 1.5vw, 8px) !important;
    }

    #deathModal h2 {
        font-size: clamp(16px, 4.5vw, 20px) !important;
        margin: clamp(6px, 1.5vw, 10px) 0 !important;
    }

    #deathModal p {
        font-size: clamp(12px, 3vw, 14px) !important;
        margin: clamp(6px, 1.5vw, 10px) 0 !important;
        line-height: 1.3 !important;
    }

    .restart-btn {
        font-size: clamp(12px, 3.5vw, 14px) !important;
        min-height: 44px !important;
        min-width: 120px !important;
        padding: clamp(10px, 2.5vw, 14px) clamp(16px, 3.5vw, 20px) !important;
        margin-top: clamp(10px, 2.5vw, 14px) !important;
    }

    .movement-controls {
        bottom: max(15px, env(safe-area-inset-bottom, 15px)) !important;
        left: max(15px, env(safe-area-inset-left, 15px)) !important;
        gap: 12px !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        position: fixed !important;
        z-index: 999999999 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        flex-direction: row !important;
    }

    .action-controls {
        bottom: max(15px, env(safe-area-inset-bottom, 15px)) !important;
        right: max(15px, env(safe-area-inset-right, 15px)) !important;
        gap: 12px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        z-index: 999999999 !important;
        flex-direction: column !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }

    .control-btn {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        border-width: 3px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 999999999 !important;
    }

    .action-btn {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 999999999 !important;
    }
    
    .btn-icon {
        font-size: clamp(14px, 4vw, 18px) !important;
    }
    
    .btn-label {
        font-size: clamp(6px, 1.5vw, 8px) !important;
    }
    
    /* Adjust menu overlay for very small screens */
    #mobileMenuOverlay {
        min-height: 35%;
        flex-direction: column;
        gap: 10px;
    }
    
    #mobileMenuOverlay button {
        flex: none;
        width: 80%;
        max-width: 280px;
        margin: 5px 0;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .movement-controls {
        bottom: 15px !important;
        left: 15px !important;
        gap: 15px !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        position: fixed !important;
        z-index: 999999999 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        flex-direction: row !important;
    }

    .action-controls {
        bottom: 15px !important;
        right: 15px !important;
        gap: 15px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        z-index: 999999999 !important;
        flex-direction: column !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }
}

/* Enhanced Landscape orientation - adjust for notches and navigation bars */
@media (orientation: landscape) and (max-width: 1024px) {
    .movement-controls {
        bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
        left: max(12px, env(safe-area-inset-left, 12px)) !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        position: fixed !important;
        z-index: 999999999 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        gap: 12px !important;
        flex-direction: row !important;
    }

    .action-controls {
        bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
        right: max(12px, env(safe-area-inset-right, 12px)) !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        z-index: 999999999 !important;
        flex-direction: column !important;
        gap: 12px !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }

    /* Consistent button sizes for landscape */
    .control-btn {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 999999999 !important;
    }

    .action-btn {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 999999999 !important;
    }
    
    /* Adjust menu for landscape */
    #mobileMenuOverlay {
        height: auto;
        min-height: 45%;
        max-height: 60%;
        padding-top: max(15px, env(safe-area-inset-top, 15px));
    }
    
    /* Hide rotate reminder in landscape */
    #rotateReminder {
        display: none !important;
    }
}

/* Landscape orientation adjustments - Remove white spaces on rotation */
@media (orientation: landscape) and (max-width: 768px) {
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #000 !important;
        overflow: hidden !important;
        width: 100vw !important;
        height: 100vh !important;
        width: 100svw !important;
        height: 100svh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
    }

    #gameContainer {
        border: none !important;
        border-radius: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        width: 100svw !important;
        height: 100svh !important;
        background: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        outline: none !important;
    }

    canvas {
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        width: 100svw !important;
        height: 100svh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-box-shadow: none !important;
        background: #000000 !important;
        z-index: 1 !important;
    }

    .mobile-controls, #mobileControls {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 999999 !important;
        background: transparent !important;
    }

    .movement-controls {
        bottom: max(15px, env(safe-area-inset-bottom, 15px)) !important;
        left: max(20px, env(safe-area-inset-left, 20px)) !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
        position: fixed !important;
        z-index: 999999999 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        gap: 15px !important;
        flex-direction: row !important;
    }

    .action-controls {
        bottom: max(15px, env(safe-area-inset-bottom, 15px)) !important;
        right: max(20px, env(safe-area-inset-right, 20px)) !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        z-index: 999999999 !important;
        flex-direction: column !important;
        gap: 15px !important;
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }

    .control-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 999999999 !important;
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
    }

    .action-btn {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 999999999 !important;
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .control-btn {
        background: rgba(0, 0, 0, 0.9);
        border-color: white;
        color: white;
    }
    
    .movement-btn {
        background: rgba(40, 40, 40, 0.9);
    }
    
    .action-btn {
        background: rgba(139, 0, 0, 0.9);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .control-btn {
        transition: none;
    }
    
    .control-btn:hover {
        transform: none;
    }
    
    .control-btn:active {
        transform: scale(0.98);
    }
}

/* Rotate Reminder Styles */
.rotate-reminder {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
}

.rotate-content {
    text-align: center;
    padding: 30px;
    max-width: 300px;
}

.rotate-icon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: rotate-pulse 2s infinite;
}

.rotate-content p {
    font-size: 18px;
    line-height: 1.5;
    margin: 0;
}

@keyframes rotate-pulse {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-15deg) scale(1.1); }
    75% { transform: rotate(15deg) scale(1.1); }
}

/* Show rotate reminder only on mobile portrait mode */
@media (orientation: portrait) and (max-width: 768px) {
    .rotate-reminder {
        display: flex !important;
    }
}

/* Hide rotate reminder on landscape */
@media (orientation: landscape) {
    .rotate-reminder {
        display: none !important;
    }
}

/* ===========================================
   *** SAFARI BLACK BAR FIX - CRITICAL ***
   =========================================== */

/* CSS Variable for dynamic viewport height */
:root {
    --vh: 1vh;
}

/* Safari-specific viewport fixes using CSS variables */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 1024px) and (orientation: landscape) {
        html {
            height: calc(var(--vh, 1vh) * 100) !important;
            height: -webkit-fill-available !important;
        }
        
        body {
            height: calc(var(--vh, 1vh) * 100) !important;
            height: -webkit-fill-available !important;
        }
        
        #gameContainer {
            height: calc(var(--vh, 1vh) * 100) !important;
            height: -webkit-fill-available !important;
        }
        
        canvas {
            height: 100% !important;
        }
        
        /* FORCE CONTROLS TO STAY VISIBLE IN SAFARI LANDSCAPE */
        #mobileControls {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            position: fixed !important;
            z-index: 999999999 !important;
        }

        .movement-controls {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            pointer-events: auto !important;
            position: fixed !important;
            bottom: 20px !important;
            left: 20px !important;
            z-index: 999999999 !important;
            flex-direction: row !important;
            gap: 15px !important;
        }

        .action-controls {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            pointer-events: auto !important;
            position: fixed !important;
            bottom: 20px !important;
            right: 20px !important;
            z-index: 999999999 !important;
            flex-direction: column !important;
            gap: 15px !important;
        }

        .control-btn {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            pointer-events: auto !important;
            z-index: 999999999 !important;
            width: 60px !important;
            height: 60px !important;
            min-width: 60px !important;
            min-height: 60px !important;
        }

        #leftBtn, #rightBtn, #jumpBtn, #punchBtn {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            pointer-events: auto !important;
        }
    }
}

/* ===== ABSOLUTE FINAL DESKTOP OVERRIDE ===== */
/* This rule has the highest specificity and runs last to ensure desktop hiding */
@media (min-width: 1025px), (hover: hover) and (pointer: fine) {
    body #gameContainer #mobileControls,
    body #gameContainer .mobile-controls,
    body .mobile-controls,
    body #mobileControls,
    #mobileControls,
    .mobile-controls {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    body #gameContainer #mobileControls *,
    body #gameContainer .mobile-controls *,
    #mobileControls *,
    .mobile-controls * {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}