:root {
    --bg-dark: #0f1115;
    --panel-bg: rgba(20, 24, 30, 0.9);
    --panel-border: #ff4500;
    --primary: #ff4500;
    --primary-hover: #ff6347;
    --secondary: #3b4252;
    --secondary-hover: #4c566a;
    --danger: #d00000;
    --danger-hover: #ff0000;
    --text-main: #f8f9fa;
    --text-muted: #adb5bd;
    --health-color: #2ecc71;
    --water-color: #3498db;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #000;
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #1a1a1a 0%, #000000 100%);
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Keep pixel art crisp if needed */
    image-rendering: pixelated; 
    z-index: 1;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through except on active UI */
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
    pointer-events: auto;
    z-index: 20;
}

.hidden {
    opacity: 0;
    pointer-events: none !important;
    display: none !important;
}

.active {
    opacity: 1;
    display: flex !important;
}

/* Typography */
h1, h2 {
    font-family: var(--font-heading);
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.5);
    margin-bottom: 20px;
    text-align: center;
}

h1 {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 5px;
    letter-spacing: 2px;
}

h2 {
    font-size: 2rem;
    color: var(--primary);
}

.logo-container {
    text-align: center;
    margin-bottom: 40px;
    animation: pulseLogo 2s infinite alternate;
}

.menu-icon {
    width: 120px;
    height: 120px;
    margin-bottom: 15px;
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.6);
}

@keyframes pulseLogo {
    from { transform: scale(1); filter: drop-shadow(0 0 10px rgba(255,69,0,0.4)); }
    to { transform: scale(1.05); filter: drop-shadow(0 0 20px rgba(255,69,0,0.8)); }
}

/* Panels */
.panel {
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 15px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), inset 0 0 20px rgba(255,69,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.btn {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(rgba(255,255,255,0.2), transparent, transparent);
    transform: rotate(45deg);
    pointer-events: none;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), #cc3700);
    color: #fff;
    border-bottom: 4px solid #992900;
}

.btn.primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
}

.btn.secondary {
    background: linear-gradient(135deg, var(--secondary), #2e3440);
    color: #fff;
    border-bottom: 4px solid #1c2028;
}

.btn.secondary:hover {
    background: linear-gradient(135deg, var(--secondary-hover), var(--secondary));
}

.btn.danger {
    background: linear-gradient(135deg, var(--danger), #800000);
    color: #fff;
    border-bottom: 4px solid #4d0000;
}

.btn.danger:hover {
    background: linear-gradient(135deg, var(--danger-hover), var(--danger));
}

/* Tutorial */
.tutorial-content {
    margin: 20px 0;
    width: 100%;
}

.tut-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
}

.tut-icon {
    font-size: 2rem;
    margin-right: 15px;
    min-width: 40px;
    text-align: center;
}

.tut-item p {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    pointer-events: auto;
}

.hud-item {
    background: rgba(20, 24, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.hud-item .label {
    font-family: var(--font-heading);
    font-weight: bold;
    font-size: 0.9rem;
    margin-right: 10px;
    width: 30px;
}

.bar-container {
    width: 100px;
    height: 12px;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #333;
}

.bar {
    height: 100%;
    width: 100%;
    transition: width 0.2s ease;
}

.fill-green { background: var(--health-color); box-shadow: 0 0 5px var(--health-color); }
.fill-blue { background: var(--water-color); box-shadow: 0 0 5px var(--water-color); }

.info-box {
    flex-direction: column;
    align-items: center;
    font-family: var(--font-heading);
}

.mission-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.timer-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
}

.objective-tracker {
    position: absolute;
    top: 80px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.obj-item {
    background: rgba(20, 24, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: bold;
    backdrop-filter: blur(4px);
}

.btn-icon {
    background: rgba(20, 24, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 1.5rem;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    height: 150px;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
}

#joystick-zone {
    width: 150px;
    height: 150px;
    position: relative;
    pointer-events: auto;
    touch-action: none;
}

#joystick-base {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

#joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(255, 69, 0, 0.7);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.5);
    position: absolute;
    transform: translate(0px, 0px);
}

.action-buttons {
    display: flex;
    gap: 20px;
    pointer-events: auto;
}

.btn-action {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-size: 2rem;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(52, 152, 219, 0.3);
    backdrop-filter: blur(2px);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
    touch-action: none;
    transition: transform 0.1s;
}

.btn-action:active {
    transform: scale(0.9);
    background: rgba(52, 152, 219, 0.6);
}

/* Stats */
.stats {
    margin: 20px 0;
    text-align: left;
    width: 100%;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
}

.stats p {
    font-size: 1.1rem;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.score-display {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 20px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 69, 0, 0.5);
}

/* Flash Effects */
.overlay-flash {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

#damage-flash {
    background: radial-gradient(circle, transparent 50%, rgba(255,0,0,0.4) 100%);
}

.flash-active {
    opacity: 1 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    h1 { font-size: 1.8rem; }
    .logo-container { margin-bottom: 20px; }
    .menu-icon { width: 70px; height: 70px; }
    
    .top-bar { 
        padding: 8px; 
        gap: 5px;
    }
    
    .hud-item { 
        padding: 4px 6px; 
        font-size: 0.7rem;
    }
    
    .hud-item .label {
        font-size: 0.7rem;
        margin-right: 4px;
        width: 25px;
    }

    .bar-container { 
        width: 50px; 
        height: 10px;
    }
    
    .timer-text {
        font-size: 0.9rem;
    }

    .mission-text {
        font-size: 0.6rem;
    }

    .objective-tracker {
        top: 60px;
        right: 8px;
        gap: 5px;
    }

    .obj-item {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .btn-icon {
        padding: 5px 8px;
        font-size: 1.1rem;
    }

    #mobile-controls { 
        bottom: 10px; 
        padding: 0 15px; 
    }
    #joystick-base { width: 90px; height: 90px; }
    #joystick-stick { width: 35px; height: 35px; }
    .btn-action { width: 60px; height: 60px; font-size: 1.3rem; }
}

@media (min-width: 1024px) {
    #mobile-controls {
        display: none; /* Hide on desktop by default, rely on keyboard */
    }
}
