/* RetroMaze Mobile - Touch-First Styles */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

body {
    margin: 0;
    padding: 0;
    background: #000;
    color: #0ff;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

#gameContainer {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle, #111 0%, #000 100%);
}

#gameCanvas {
    border: 2px solid #0ff;
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
    background: #000;
    touch-action: none;
}

/* Mobile-Optimized HUD */
#mobileHUD {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#statusBar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border: 2px solid #0ff;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

#statusBar > div {
    color: #0ff;
    min-width: 60px;
    text-align: center;
}

#timer.warning {
    animation: pulse 1s infinite;
    color: #ff0000 !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.compass-widget {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 50px;
    height: 50px;
    border: 2px solid #0ff;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

/* Touch Controls */
#touchControls {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

/* Virtual Joystick */
.joystick-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 120px;
    height: 120px;
    border: 3px solid #0ff;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    pointer-events: all;
    touch-action: none;
}

.joystick-container.active {
    border-color: #ff0;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.5);
}

.joystick-knob {
    position: absolute;
    width: 40px;
    height: 40px;
    background: #0ff;
    border-radius: 50%;
    top: 40px;
    left: 40px;
    transition: background-color 0.1s;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.joystick-container.active .joystick-knob {
    background: #ff0;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.7);
}

/* Action Buttons */
.action-buttons {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    pointer-events: all;
}

.action-btn {
    width: 80px;
    height: 80px;
    border: 3px solid #0ff;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    color: #0ff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: all 0.1s;
    backdrop-filter: blur(10px);
}

.action-btn:active,
.action-btn.active {
    background: rgba(0, 255, 255, 0.3);
    border-color: #ff0;
    color: #ff0;
    transform: scale(0.9);
    box-shadow: inset 0 0 10px rgba(255, 255, 0, 0.3);
}

.fire-btn { border-color: #ff4444; color: #ff4444; }
.interact-btn { border-color: #44ff44; color: #44ff44; }
.sprint-btn { border-color: #ffff44; color: #ffff44; }
.menu-btn { border-color: #ff44ff; color: #ff44ff; }

.fire-btn:active { border-color: #ff8888; color: #ff8888; }
.interact-btn:active { border-color: #88ff88; color: #88ff88; }
.sprint-btn:active { border-color: #ffff88; color: #ffff88; }
.menu-btn:active { border-color: #ff88ff; color: #ff88ff; }

/* Minimap */
.minimap-container {
    position: absolute;
    top: 80px;
    right: 15px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #0ff;
    border-radius: 8px;
    padding: 5px;
    backdrop-filter: blur(10px);
    pointer-events: all;
    transition: all 0.3s ease;
}

.minimap-container.expanded {
    transform: scale(1.5);
    z-index: 50;
}

#minimapCanvas {
    display: block;
    width: 120px;
    height: 120px;
    border-radius: 4px;
}

.minimap-toggle {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    border: 2px solid #0ff;
    border-radius: 50%;
    background: #000;
    color: #0ff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

/* Settings Panel */
.settings-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid #0ff;
    border-radius: 10px;
    padding: 20px;
    min-width: 300px;
    max-width: 90vw;
    z-index: 100;
    backdrop-filter: blur(15px);
    pointer-events: all;
}

.settings-panel.hidden {
    display: none;
}

.settings-panel h3 {
    color: #ff0;
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 20px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    color: #0ff;
    margin-bottom: 5px;
    font-size: 14px;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 30px;
    background: rgba(0, 255, 255, 0.2);
    border-radius: 15px;
    -webkit-appearance: none;
    appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 25px;
    height: 25px;
    background: #0ff;
    border-radius: 50%;
    cursor: pointer;
}

.setting-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #0ff;
}

.close-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(45deg, #0ff, #00f);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    margin-top: 15px;
    touch-action: manipulation;
}

/* Waypoint Container */
.waypoint-container {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

/* Start Screen */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    text-align: center;
    padding: 20px;
}

.start-screen h1 {
    color: #ff0;
    font-size: clamp(24px, 8vw, 48px);
    margin: 0 0 10px 0;
    text-shadow: 0 0 20px #ff0;
}

.start-screen p {
    color: #0ff;
    font-size: clamp(14px, 4vw, 18px);
    margin: 10px 0;
    max-width: 600px;
    line-height: 1.4;
}

.start-btn {
    background: linear-gradient(45deg, #0ff, #00f);
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: clamp(16px, 4vw, 20px);
    font-weight: bold;
    font-family: 'Courier New', monospace;
    border-radius: 8px;
    margin-top: 20px;
    touch-action: manipulation;
    transition: all 0.3s ease;
    min-width: 200px;
    min-height: 50px;
}

.start-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
}

/* One-Handed Mode */
.one-handed .action-buttons {
    right: 30px;
    bottom: 160px;
    grid-template-columns: 1fr;
}

.one-handed .joystick-container {
    left: 30px;
    bottom: 160px;
}

/* High Contrast Mode */
.high-contrast #gameCanvas {
    filter: contrast(200%) brightness(150%);
}

.high-contrast .action-btn {
    border-width: 4px;
    font-weight: bold;
}

.high-contrast #statusBar {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border-color: #000;
}

/* Mobile Responsive Adjustments */
@media (max-width: 480px) {
    #statusBar {
        gap: 10px;
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .joystick-container {
        width: 100px;
        height: 100px;
        bottom: 20px;
        left: 20px;
    }
    
    .joystick-knob {
        width: 35px;
        height: 35px;
        top: 32px;
        left: 32px;
    }
    
    .action-btn {
        width: 70px;
        height: 70px;
        font-size: 20px;
    }
    
    .action-buttons {
        bottom: 20px;
        right: 20px;
        gap: 10px;
    }
    
    .compass-widget {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    #statusBar {
        top: 5px;
        padding: 4px 10px;
        font-size: 12px;
    }
    
    .joystick-container {
        width: 80px;
        height: 80px;
        bottom: 15px;
        left: 15px;
    }
    
    .joystick-knob {
        width: 25px;
        height: 25px;
        top: 27px;
        left: 27px;
    }
    
    .action-btn {
        width: 60px;
        height: 60px;
        font-size: 18px;
    }
    
    .action-buttons {
        bottom: 15px;
        right: 15px;
    }
    
    .compass-widget {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    .minimap-container {
        top: 50px;
        right: 10px;
    }
    
    #minimapCanvas {
        width: 80px;
        height: 80px;
    }
}

/* Performance optimizations for older devices */
@media (max-resolution: 150dpi) {
    * {
        image-rendering: pixelated;
    }
    
    #gameCanvas {
        image-rendering: crisp-edges;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .action-btn,
    .joystick-knob,
    .start-btn {
        transition: none;
    }
    
    @keyframes pulse {
        0%, 100% { opacity: 1; }
    }
}

@media (prefers-high-contrast: high) {
    body {
        background: #000;
        color: #fff;
    }
    
    #gameCanvas,
    .action-btn,
    .joystick-container,
    #statusBar {
        border-color: #fff;
        color: #fff;
    }
}

/* Dark mode considerations */
@media (prefers-color-scheme: dark) {
    .settings-panel {
        background: rgba(0, 0, 0, 0.98);
    }
}

/* Safe area handling for devices with notches */
@supports (padding: max(0px)) {
    #statusBar {
        top: max(10px, env(safe-area-inset-top));
    }
    
    .joystick-container {
        bottom: max(30px, env(safe-area-inset-bottom) + 10px);
        left: max(30px, env(safe-area-inset-left) + 10px);
    }
    
    .action-buttons {
        bottom: max(30px, env(safe-area-inset-bottom) + 10px);
        right: max(30px, env(safe-area-inset-right) + 10px);
    }
}