body {
    margin: 0;
    overflow: hidden; /* Prevents scrolling on mobile */
    background-color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

canvas {
    background-color: black;
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- Mobile Controls --- */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allows clicks to pass through to the canvas if needed */
    display: none; /* Hidden by default, shown via media query */
}

.control-pad {
    position: absolute;
    bottom: 20px;
    display: grid;
    gap: 10px;
    pointer-events: auto; /* Buttons are interactive */
}

.left-pad {
    left: 20px;
    grid-template-areas:
        ". up ."
        "left down right";
}

.right-pad {
    right: 20px;
    grid-template-areas:
        ". up ."
        "left down right";
}

.control-button {
    width: 60px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: white;
    user-select: none; /* Prevents text selection on touch */
}

.control-button:active {
    background-color: rgba(255, 255, 255, 0.6);
}

/* Assign buttons to grid areas */
#p1-up, #p2-up { grid-area: up; }
#p1-down, #p2-down { grid-area: down; }
#p1-left, #p2-left { grid-area: left; }
#p1-right, #p2-right { grid-area: right; }

/* Show controls only on smaller screens (typical for mobile) */
@media (max-width: 1024px) {
    #mobile-controls {
        display: block;
    }
}