body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Inter', -apple-system, sans-serif;
    overflow: hidden;
    color: white;
}

#game-container {
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    width: 100%;
    aspect-ratio: 10 / 6;
    max-width: min(1000px, 100vw, calc(100vh * 10 / 6));
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

#ui-layer {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    gap: 10px;
}

.btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.btn-record::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

.instructions {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    pointer-events: none;
}

/* Touch UI Styles */
#touch-ui {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 20;
    pointer-events: none; /* Let container ignore touches */
}

.touch-joystick, .touch-actions {
    display: flex;
    gap: 15px;
    pointer-events: auto; /* Let buttons receive touches */
}

.touch-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    outline: none;
    transition: background 0.1s, transform 0.1s;
    cursor: pointer;
}

.touch-btn:active, .touch-btn.active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

@media (max-width: 1024px) {
    .instructions {
        display: none !important;
    }
}

/* Portrait Mode Adjustments */
@media (orientation: portrait) {
    #game-container {
        /* Taller aspect ratio for portrait to enlarge the visual area */
        aspect-ratio: 4 / 5;
        max-width: min(1000px, 100vw, calc(100vh * 4 / 5));
    }
    
    canvas {
        /* Crop the sides to fill the taller container */
        object-fit: cover;
    }

    #touch-ui {
        bottom: 8vh; /* Position buttons nicely in the bottom black bar */
    }
}
