/* 
 * Voxel Game - Main Stylesheet
 * Optimized for performance and mobile devices
 * Version: 0.0.1
 */

/* CSS Variables for easy theming and performance */
:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --bg-dark: rgba(0, 0, 0, 0.7);
    --bg-light: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --hud-size: 60px;
    --mobile-padding: env(safe-area-inset-bottom, 20px);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #000;
    touch-action: none;
    -webkit-touch-callout: none;
}

/* Game Canvas - GPU accelerated */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    will-change: transform;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Version Display - Center of screen */
.version-display {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 1000;
    letter-spacing: 1px;
    opacity: 0.8;
}

/* Mobile HUD Container */
.mobile-hud {
    position: fixed;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.mobile-hud > * {
    pointer-events: auto;
}

/* Joystick Container - Bottom left */
.joystick-container {
    position: absolute;
    bottom: calc(20px + var(--mobile-padding));
    left: 20px;
    width: 120px;
    height: 120px;
    display: none;
}

.joystick-base {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    border: 2px solid var(--bg-light);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.joystick-knob {
    position: absolute;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
    will-change: transform;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Action Buttons - Bottom right */
.action-buttons {
    position: absolute;
    bottom: calc(20px + var(--mobile-padding));
    right: 20px;
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.action-btn {
    width: var(--hud-size);
    height: var(--hud-size);
    background: var(--bg-dark);
    border: 2px solid var(--bg-light);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.1s, background-color 0.1s;
    will-change: transform;
}

.action-btn:active {
    transform: scale(0.9);
    background: var(--primary-color);
}

/* Inventory Bar - Bottom center */
.inventory-bar {
    position: absolute;
    bottom: calc(10px + var(--mobile-padding));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    gap: 2px;
    padding: 5px;
    background: var(--bg-dark);
    border-radius: 5px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.inventory-bar::-webkit-scrollbar {
    display: none;
}

.inventory-slot {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.inventory-slot.active {
    border-color: var(--primary-color);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.inventory-slot:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Performance Stats Display */
.stats-display {
    position: fixed;
    top: 40px;
    left: 10px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'Courier New', monospace;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 999;
    background: var(--bg-dark);
    padding: 10px;
    border-radius: 5px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0.8;
}

.stats-display > div {
    margin-bottom: 4px;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: var(--text-primary);
}

.loading-content h1 {
    font-size: 48px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.loading-bar {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 20px;
}

.loading-progress {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Mobile-specific styles */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    .joystick-container,
    .action-buttons {
        display: grid;
    }
    
    .inventory-slot {
        flex-basis: 40px;
        width: 35px;
        height: 35px;
    }
    
    .stats-display {
        font-size: 10px;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .inventory-bar {
        left: 12px;
        right: 12px;
        transform: none;
        max-width: none;
        width: auto;
        justify-content: flex-start;
        padding: 6px;
    }

    .inventory-slot {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
    }

    .inventory-slot.active {
        transform: none;
        outline: 2px solid var(--primary-color);
        outline-offset: 1px;
    }
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    .version-display {
        top: 5px;
        font-size: 12px;
    }
    
    .joystick-container {
        bottom: 10px;
        left: 10px;
        width: 100px;
        height: 100px;
    }
    
    .action-buttons {
        bottom: 10px;
        right: 10px;
    }
    
    .action-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .inventory-bar {
        bottom: 5px;
        left: 12px;
        right: 12px;
        transform: none;
        max-width: none;
        overflow-x: auto;
    }
    
    .inventory-slot {
        flex: 0 0 36px;
        width: 30px;
        height: 30px;
    }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* GPU acceleration hints */
.mobile-hud,
.joystick-knob,
.action-btn,
.inventory-slot {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-dark: rgba(0, 0, 0, 0.8);
        --bg-light: rgba(255, 255, 255, 0.15);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .action-btn,
    .inventory-slot {
        border-width: 3px;
    }
    
    .stats-display {
        background: #000;
        color: #fff;
    }
}
