body {
    background-color: #1a1a1a;
    color: #ffffff;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 50px;
    padding: 0 15px; /* Adds a small gap on the left and right */
    box-sizing: border-box;
}

#game-container {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4 / 3; /* Automatically calculates the height */
    background-color: #000000;
    border: 2px solid #444444;
    box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.5);
    box-sizing: border-box; /* Ensures the border doesn't push it off screen */
}

ruffle-player {
    width: 100%;
    height: 100%;
}

/* Touch Controls Container */
#touch-controls {
    position: absolute;
    bottom: 20px;
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 10;
    /* Keeps it on top of the game */
    /* We will hide this later when a controller connects */
}

/* Keep action buttons in a row */
.action-buttons {
    display: flex;
    gap: 10px;
}

/* Transform the D-Pad into a 3-column grid */
.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 10px;
}

/* Map each button to its specific grid coordinate */
#btn-up {
    grid-column: 2; /* Middle column */
    grid-row: 1;    /* Top row */
}

#btn-left {
    grid-column: 1; /* Left column */
    grid-row: 2;    /* Bottom row */
}

#btn-down {
    grid-column: 2; /* Middle column */
    grid-row: 2;    /* Bottom row */
}

#btn-right {
    grid-column: 3; /* Right column */
    grid-row: 2;    /* Bottom row */
}

.touch-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: white;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    /* Prevents text highlighting */
    touch-action: none;
    /* Prevents browser handling of touches */
}

.touch-btn:active {
    background: rgba(255, 255, 255, 0.5);
}

/* --- Lobby UI --- */
#lobby-view {
    width: 100%;
    max-width: 800px;
    text-align: center;
}

/* --- Game Arena Wrapper --- */
#game-view {
    width: 100%;
    max-width: 800px;
}

.game-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.game-card {
    background-color: #2a2a2a;
    border: 2px solid #444;
    border-radius: 10px;
    padding: 10px;
    width: 200px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.game-card:hover {
    transform: scale(1.05);
    border-color: #4CAF50;
}

.game-cover {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    background-color: #000; /* Placeholder if no image is found */
}

/* --- Arena Header --- */
.arena-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-bottom: 10px;
}

#btn-back {
    background-color: #444;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

#btn-back:hover {
    background-color: #666;
}

/* Landscape Mode Overrides */
@media (orientation: landscape) {
    #game-container {
        width: auto;       /* Stop forcing the width to 100% */
        height: 80vh;      /* Scale based on the viewport height (vh) instead */
        max-height: 600px; /* Keep our original maximum size */
    }
    
    body {
        margin-top: 10px;  /* Shrink the top margin so the game sits higher on the screen */
    }
}