html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #3d3d3d;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    padding: 0;
    margin: auto;
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

/* Hide mobile controls by default */
.mobile-only {
    display: none;
}

/* Mobile controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 12px;
}

.control-row:last-child {
    margin-bottom: 0;
}

/* Center single button rows (up button and enter button) */
.control-row:has(#up-btn),
.control-row:has(#enter-btn) {
    justify-content: center;
}

/* Middle row with 3 buttons */
.control-row:has(#down-btn) {
    gap: 15px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #fff;
    border-radius: 15px;
    color: #333;
    font-size: 18px;
    font-weight: bold;
    padding: 15px 25px;
    min-width: 80px;
    min-height: 60px;
    touch-action: manipulation;
    user-select: none;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.direction-btn {
    font-size: 24px;
    width: 100px;
    height: 80px;
    border-radius: 50px;
}

.enter-btn {
    width: 150px;
    height: 60px;
    font-size: 16px;
    background: rgba(0, 200, 0, 0.9);
    border-color: #00ff00;
    color: white;
}

.control-btn:active,
.control-btn.active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.enter-btn:active,
.enter-btn.active {
    background: rgba(0, 150, 0, 0.7);
}

/* Show mobile controls only on touch devices */
@media (pointer: coarse) and (hover: none) {
    .mobile-only {
        display: block;
    }
    
    /* Adjust canvas positioning for mobile controls */
    canvas {
        bottom: 230px; /* Make room for controls */
    }
}

/* Portrait orientation specific styles */
@media (orientation: portrait) and (pointer: coarse) {
    #mobile-controls {
        padding: 15px;
    }
    
    .control-btn {
        padding: 12px 20px;
        min-width: 70px;
        min-height: 50px;
        font-size: 16px;
    }
    
    .direction-btn {
        font-size: 20px;
        width: 80px;
        height: 65px;
    }
    
    .enter-btn {
        width: 120px;
        height: 50px;
        font-size: 14px;
    }
    
    canvas {
        bottom: 200px; /* More space for 3-row layout */
    }
}