/* --- Global Game Wrapper --- */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: calc(100vh - 100px); /* Account for navbar/footer */
    max-height: 900px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: #0d1117;
    color: #c9d1d9;
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: manipulation;
}

/* --- Game Area Layout --- */
#canvas-parent {
    position: relative;
    width: 100%;
    flex: 1; /* Grow to fill available space */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
    border: 4px solid #30363d;
    max-width: 600px; /* Limit width to keep portrait aspect */
}

canvas {
    display: block;
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensure 600x800 aspect ratio is maintained */
}

.pixel-text {
    text-shadow: 2px 2px #000;
}

/* --- Overlay Styling --- */
.overlay, #game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(13, 17, 23, 0.9);
    color: #c9d1d9;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 50;
}

#game-overlay {
    display: flex; /* Script controls hidden class */
}

/* --- Touch Controls (Non-overlapping) --- */
#touch-controls {
    width: 100%;
    max-width: 600px;
    background: #161b22;
    border-top: 2px solid #30363d;
    display: none; /* Hidden on desktop */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Show touch controls only on touch devices */
@media (hover: none) and (pointer: coarse) {
    #touch-controls {
        display: flex;
        flex-direction: column;
    }
    
    #game-container {
        height: calc(100vh - 60px); /* Tighter fit for mobile */
    }
}

.touch-btn-group {
    display: flex;
    width: 100%;
    height: 70px;
}

.touch-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    background: rgba(255, 255, 255, 0.05);
    border-right: 1px solid #30363d;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.touch-btn:last-child { border-right: 0; }
.touch-btn:active { background: rgba(255, 255, 255, 0.15); }

#touch-shoot { background-color: rgba(239, 68, 68, 0.15); }
#touch-deploy-turret { background-color: rgba(34, 197, 94, 0.15); }
#touch-deploy-shield { background-color: rgba(59, 130, 246, 0.15); }

/* --- Buttons --- */
.btn {
    background-color: #161b22;
    border: 2px solid #30363d;
    color: #c9d1d9;
    padding: 12px 24px;
    font-family: inherit;
    cursor: pointer;
    margin: 5px;
    transition: all 0.2s;
}

.btn:hover:not(:disabled) {
    background-color: #30363d;
    border-color: #58a6ff;
}

.hidden { display: none !important; }