:root {
    --mario-blue: #5c94fc;
    --font-retro: 'Press Start 2P', cursive;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    font-family: var(--font-retro);
    overflow: hidden;
    touch-action: none; /* Prevent scroll on mobile */
    user-select: none;
}

#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ensure canvas scales correctly */
#game-container canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated; /* Crisp pixels */
}

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

/* HUD */
#hud {
    display: flex;
    justify-content: space-between;
    padding: 20px 40px;
    color: white;
    font-size: 16px;
    text-shadow: 2px 2px 0 #000;
    text-align: center;
    line-height: 1.5;
}

/* Controls */
#controls-layer {
    display: none; /* Hidden on desktop by default */
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
    justify-content: space-between;
    pointer-events: auto;
}

.dpad {
    display: flex;
    gap: 15px;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.6);
}

#btn-jump {
    width: 70px;
    height: 70px;
    font-weight: bold;
    font-family: var(--font-retro);
    font-size: 18px;
}

/* Utility buttons */
#back-button, #mute-button {
    position: absolute;
    z-index: 20;
    font-family: var(--font-retro);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid white;
    padding: 10px;
    cursor: pointer;
    text-transform: uppercase;
}

#back-button {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
}

#mute-button {
    top: 20px;
    right: 20px;
    font-size: 16px;
    border-radius: 5px;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#back-button:hover, #mute-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    #hud {
        padding: 10px;
        font-size: 12px;
    }
    #controls-layer {
        display: flex; /* Show touch controls on small screens */
    }
    #back-button {
        top: 20px;
        left: 20px;
        bottom: auto;
        transform: none;
    }
}
