/* Mobile-first CSS Reset and Base Styles */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #6CA6CD;
    color: #fff;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-overflow-scrolling: touch;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #4682B4, #6CA6CD);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease-out;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-screen p {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom, #87CEEB, #4682B4);
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    pointer-events: auto;
}

#inventory {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 12px;
    min-width: 140px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#inventory h3 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

#inventory-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
}

#inventory-list li {
    padding: 2px 0;
    text-align: center;
}

#status {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

#magnet-status, #speed-indicator {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.touch-button {
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(145deg, #FF6B47, #FF4500);
    border: none;
    border-radius: 50px;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 75, 0, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 160px;
    justify-content: center;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.touch-button:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 10px rgba(255, 75, 0, 0.4);
}

.touch-button:disabled {
    opacity: 0.6;
    transform: none !important;
    box-shadow: 0 2px 10px rgba(255, 75, 0, 0.2);
}

.button-icon {
    font-size: 1.2em;
}

.button-text {
    font-weight: 600;
}

#instructions {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Haptic feedback effect */
.haptic-feedback {
    animation: haptic 0.1s ease-out;
}

@keyframes haptic {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive adjustments for larger screens */
@media (min-width: 768px) {
    #ui-container {
        padding: 40px;
    }
    
    #inventory {
        min-width: 200px;
        padding: 16px 20px;
    }
    
    #inventory h3 {
        font-size: 1rem;
    }
    
    #inventory-list {
        font-size: 0.9rem;
    }
    
    .touch-button {
        padding: 18px 32px;
        font-size: 1.1rem;
        min-width: 180px;
    }
    
    #instructions {
        font-size: 0.9rem;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) {
    #hud {
        align-items: flex-start;
    }
    
    #controls {
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    
    #instructions {
        margin-left: 20px;
    }
}
