/* Mobile-specific styles to override desktop UI */

/* Force landscape orientation message */
@media screen and (orientation: portrait) {
    #orientation-message {
        display: flex !important;
    }
}

/* Hide desktop UI elements on mobile */
/* Only apply mobile styles on actual mobile devices, not touchscreen desktops */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    /* Hide desktop UI panel */
    #game-ui-panel {
        display: none !important;
    }
    
    /* Hide inventory panel */
    #inventory-panel {
        display: none !important;
    }
    
    /* Hide party UI for now */
    #party-panel {
        display: none !important;
    }
    
    /* Hide desktop chat */
    #chat-container {
        display: none !important;
    }
    
    /* Hide minimap */
    #minimap-container {
        display: none !important;
    }
    
    /* Hide help button */
    #help-button {
        display: none !important;
    }
    
    /* Ensure mobile controls are visible */
    #touch-controls {
        display: block !important;
    }
    
    #mobile-ui {
        display: flex !important;
    }
    
    /* Ensure game canvas uses full viewport */
    #game canvas {
        width: 100vw !important;
        height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
    }
    
    /* Polish for mobile UI elements */
    #mobile-ui > div {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    /* Enhanced button styles */
    #mobile-ui div[id*="-btn"] {
        background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    #mobile-ui div[id*="-btn"]:active {
        filter: brightness(1.3);
    }
}

/* Mobile Login Screen Styles */
@media (max-width: 768px), (pointer: coarse) {
    /* Prevent zoom on input focus for iOS */
    input[type="text"], input[type="password"] {
        font-size: 16px !important;
        -webkit-appearance: none !important;
        -webkit-border-radius: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Better touch targets */
    button, input {
        min-height: 44px !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    }
    
    /* Ensure proper viewport behavior */
    html {
        -webkit-text-size-adjust: 100% !important;
    }
    
    /* Prevent double-tap zoom */
    * {
        touch-action: manipulation !important;
    }
    
    /* Better scrolling on mobile */
    body {
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Fix for mobile safari viewport issues */
    .game-container {
        min-height: 100vh !important;
        min-height: 100dvh !important; /* Dynamic viewport height */
    }
    
    /* Improve form input experience */
    form input:focus {
        outline: none !important;
        border: 2px solid #ffe066 !important;
        box-shadow: 0 0 20px rgba(255, 224, 102, 0.3) !important;
    }
    
    /* Better button press feedback */
    form button:active {
        transform: scale(0.98) !important;
        transition: transform 0.1s !important;
    }
    
    /* Improve icon touch targets */
    form div[style*="cursor: pointer"] {
        min-width: 30px !important;
        min-height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Better error message display */
    form div[style*="color: #ff6666"] {
        word-wrap: break-word !important;
        text-align: center !important;
        margin: 10px 0 !important;
    }
    
    /* Smooth transitions for form elements */
    form * {
        transition: all 0.2s ease !important;
    }
    
    /* Fix for landscape mode */
    @media (orientation: landscape) and (max-height: 500px) {
        form[style*="position: absolute"] {
            padding: 20px 25px !important;
            gap: 10px !important;
        }
        
        form h2 {
            font-size: 20px !important;
            margin-bottom: 8px !important;
        }
        
        form p {
            font-size: 12px !important;
        }
        
        form input {
            padding: 12px 14px 12px 40px !important;
            min-height: 40px !important;
        }
        
        form button {
            padding: 14px 25px !important;
            min-height: 45px !important;
        }
    }
}

/* Mobile Home/Server Selection Screen */
@media (max-width: 768px) and (orientation: portrait) {
    /* Home screen adjustments for portrait */
    .container {
        padding: 10px !important;
        width: 100% !important;
    }
    
    .server-card {
        width: 100% !important;
        max-width: none !important;
        margin-bottom: 10px !important;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    /* Home screen adjustments for landscape */
    .server-selection {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .server-card {
        min-width: 280px !important;
        flex-shrink: 0 !important;
    }
}

/* Mobile inventory overlay - Modern design */
.mobile-inventory {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    height: 80%;
    max-height: 500px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.9));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid #ffd700;
    border-radius: 20px;
    padding: 20px;
    z-index: 2000;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5),
                0 0 60px rgba(255, 215, 0, 0.2);
}

.mobile-inventory-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ff6666, #ff4444);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.mobile-inventory-close:active {
    transform: scale(0.9);
}

/* Mobile chat overlay - Modern design */
.mobile-chat-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.85));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    border-top: 2px solid #4CAF50;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
}

.mobile-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    color: white;
    font-size: 14px;
}

.mobile-chat-input-container {
    display: flex;
    padding: 10px;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
}

.mobile-chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #4CAF50;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
}

.mobile-chat-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    transition: transform 0.2s;
}

.mobile-chat-send:active {
    transform: scale(0.95);
}

/* Mobile build UI - Already handled in JS */

/* Mobile death screen - Modern design */
.mobile-death-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.95));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    color: white;
}

.mobile-death-title {
    font-size: 48px;
    font-weight: bold;
    color: #ff4444;
    margin-bottom: 20px;
    text-shadow: 0 4px 20px rgba(255, 68, 68, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.05); opacity: 1; }
}

.mobile-death-info {
    font-size: 20px;
    margin-bottom: 10px;
    opacity: 0.8;
}

.mobile-respawn-timer {
    font-size: 36px;
    color: #ffd700;
    margin-top: 20px;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.5);
}

/* Enhanced visual effects */
#mobile-ui .joystick-base,
#mobile-ui .aim-base {
    animation: subtle-pulse 4s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.95; }
}

/* Build mode interface animations */
#mobile-ui .build-interface {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Delete mode indicator animation */
.delete-mode-indicator {
    animation: delete-pulse 1s ease-in-out infinite;
}

@keyframes delete-pulse {
    0%, 100% { 
        background: rgba(255, 0, 0, 0.9);
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
    }
    50% { 
        background: rgba(255, 50, 50, 0.95);
        box-shadow: 0 0 30px rgba(255, 0, 0, 0.7);
    }
}

/* Quick menu button subtle animation */
#mobile-ui > div[style*="top: 70px"] {
    animation: menu-hint 5s ease-in-out infinite;
}

@keyframes menu-hint {
    0%, 90%, 100% { transform: scale(1); }
    95% { transform: scale(1.1); }
}

/* Landscape mode adjustments */
@media screen and (orientation: landscape) and (max-height: 500px) {
    #mobile-ui {
        font-size: 12px;
    }
    
    .mobile-chat-overlay {
        height: 200px;
    }
    
    .mobile-build-overlay {
        bottom: 120px;
    }
    
    .mobile-build-block {
        width: 50px;
        height: 50px;
    }
}

/* Remove any jump button specific styles */
#mobile-jump-btn {
    display: none !important;
}