* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on iOS */
}

html, body {
    width: 100%;
    height: 100%;
    position: fixed; /* Prevents iOS Safari from bouncing */
    overflow: hidden;
}

body {
    background-color: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none; /* Prevents browser handling of touch gestures */
    -webkit-touch-callout: none; /* Prevents callout on long-press */
    -webkit-user-select: none; /* Prevents text selection */
    user-select: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vh; /* Ensures the container doesn't get too wide on desktop */
    background-color: #000;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    touch-action: none;
    overflow: hidden; /* Prevent scrolling within the container */
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: pointer; /* Shows pointer cursor on desktop */
    object-fit: contain; /* Prevent stretching */
    position: absolute; /* Position absolutely to avoid layout issues */
    top: 0;
    left: 0;
    image-rendering: pixelated; /* For Chrome/Edge */
    image-rendering: crisp-edges; /* For Firefox */
    -ms-interpolation-mode: nearest-neighbor; /* For IE (legacy) */
}

/* Button styles */
#button-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    /* Default position for desktop - sidebar */
    position: relative;
}

button {
    padding: 8px 12px;
    background-color: #444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

button:hover {
    background-color: #555;
}

/* Adjust game container when console is expanded */
body.console-expanded #game-container {
    height: calc(100% - 200px);
    margin-bottom: 200px;
}

/* Mobile-specific styles */
@media (max-width: 800px) {
    #game-container {
        max-width: 100%; /* Allow full width on mobile */
        height: calc(100% - 80px); /* Reduced to account for browser controls */
        margin-bottom: 80px; /* Add margin at the bottom */
        position: relative; /* Ensure position is relative */
        overflow: hidden; /* Prevent scrolling */
    }
    
    #game-canvas {
        position: absolute; /* Position absolutely within container */
        top: 0;
        left: 0;
        width: 100%; /* Full width */
        height: 100%; /* Full height */
        object-fit: contain; /* Maintain aspect ratio */
    }
    
    /* Mobile button styles - position at top center */
    #button-container {
        position: fixed;
        top: 5px;
        left: 0;
        right: 0;
        flex-direction: row;
        justify-content: center;
        gap: 10px;
        margin-top: 0;
        z-index: 100;
        padding: 5px;
        background-color: rgba(0, 0, 0, 0.5);
    }
    
    button {
        padding: 6px 8px;
        font-size: 12px;
        background-color: rgba(68, 68, 68, 0.9);
        border: 1px solid #666;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        min-width: 100px;
    }
    
    button:active {
        background-color: #555;
        transform: translateY(1px);
    }
    
    /* Adjust game container when console is expanded on mobile */
    body.console-expanded #game-container {
        height: calc(100% - 200px);
        margin-bottom: 200px;
    }
    
    /* Ensure debug controls don't interfere with game buttons */
    #toggle-console-button, .log-controls {
        z-index: 99; /* Lower than game buttons */
    }
    
    /* Add padding at the bottom to avoid controls overlapping with game elements */
    #game-container {
        padding-bottom: 80px;
    }
} 