html {
    height: 100%;
    overflow: hidden; /* Often good to prevent double scrollbars if body scrolls */
}

body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* overflow-y: auto; /* Removed, #app will manage its own scroll */
    background-color: #111; /* Moved from #app for consistency */
    display: flex; /* Center #app on desktop */
    justify-content: center; /* Center #app on desktop */
    /* align-items: center; /* Vertically center #app if its height is less than 100vh (not the case here) */
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Fixed height for the app viewport */
    width: 100vw; /* Full width on mobile */
    max-width: 800px; /* Max width for the entire game/controls interface on desktop */
    overflow: hidden; /* Prevent #app itself from scrolling; #controls-container will scroll */
    box-shadow: 0 0 20px rgba(0,0,0,0.3); /* Optional: visual cue for app boundary */
}

#game-container {
    position: -webkit-sticky; 
    position: sticky;
    top: 0;
    z-index: 20; 
    flex-shrink: 0; 
    background-color: #1c1c1c; 
    overflow: hidden; 
    display: flex; 
    justify-content: center; 
    align-items: flex-start; /* Ensure container wraps content height */
    /* padding-top: 10px; */
}

#controls-container {
    flex-grow: 1; 
    flex-shrink: 1; 
    flex-basis: 0;  
    min-height: 0;  
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    padding: 10px;
    /* background-color: #ff00ff; BRIGHT MAGENTA for #controls-container debugging */
    border: 3px solid #2d3a3a; /* BRIGHT CYAN BORDER for #controls-container debugging */
    color: white;
}

#game-container canvas {
    max-width: 100%;
    /* max-height: 100%; */
}

.control-panel {
    background-color: #2a2a2a; 
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px; /* Space between bet controls and leaderboard */
    display: grid;
    grid-template-areas:
        "bet-type amount-controls main-bet-btn"
        "presets presets main-bet-btn";
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}

.bet-type-selector {
    grid-area: bet-type;
    display: flex;
    background-color: #1e1e1e;
    border-radius: 8px;
    padding: 3px;
}

.bet-type-btn {
    background-color: transparent;
    border: none;
    color: #aaa;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.bet-type-btn.active {
    background-color: #333;
    color: white;
}

.amount-controls {
    grid-area: amount-controls;
    display: flex;
    align-items: center;
    justify-content: center; /* Center the amount and +/- buttons */
    background-color: #1e1e1e;
    border-radius: 8px;
    padding: 5px;
}

.amount-adjust-btn {
    background-color: #444;
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
}

.amount-display {
    color: white;
    font-size: 16px;
    font-weight: bold;
    margin: 0 10px;
    min-width: 50px; /* Ensure space for amount */
    text-align: center;
}

.preset-amounts {
    grid-area: presets;
    display: flex;
    justify-content: space-around; /* Distribute preset buttons */
}

.preset-btn {
    background-color: #3a3a3a;
    border: none;
    color: #ccc;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    flex-grow: 1; /* Allow buttons to take up space */
    margin: 0 3px; /* Small gap between buttons */
}

.main-bet-btn {
    grid-area: main-bet-btn;
    background-color: #00c853; /* Green color */
    color: white;
    border: none;
    border-radius: 8px;
    padding: 15px 20px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1.2;
    text-align: center;
    min-height: 70px; /* Make it taller */
}

.leaderboard-panel {
    background-color: #2c2c3d; /* BRIGHT BLUE for .leaderboard-panel debugging */
    border-radius: 10px;
    padding: 10px;
    color: #ccc;
    border: 2px solid #5f5f2d; /* BRIGHT YELLOW BORDER for .leaderboard-panel debugging */
    min-height: 200px; /* TEMPORARY: Explicit min-height for debugging */
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    background-color: #1e1e1e;
    border-radius: 8px;
    padding: 5px;
}

.leaderboard-tab-btn {
    background-color: transparent;
    border: none;
    color: #aaa;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin: 0 5px;
}

.leaderboard-tab-btn.active {
    background-color: #333;
    color: white;
}

.leaderboard-header, .leaderboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr; /* Player, Bet, X, Win */
    gap: 10px;
    padding: 8px 5px;
    align-items: center;
    font-size: 13px;
}

.leaderboard-header {
    font-weight: bold;
    color: #aaa;
    border-bottom: 1px solid #333;
}

.leaderboard-row {
    border-bottom: 1px solid #1e1e1e;
}

.leaderboard-row:last-child {
    border-bottom: none;
}

.player-info {
    display: flex;
    align-items: center;
}

.player-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 8px;
    background-color: #444; /* Placeholder bg for avatar */
}

/* Minor adjustments for desktop if needed, current setup is fairly responsive */
@media (min-width: 768px) { 
    /* #app already has max-width, body centers it. */
    
    #game-container {
        /* align-items: flex-start; is already set above */
        /* max-height: 40vh; */ /* REMOVED */
    }
    .leaderboard-header, .leaderboard-row {
        font-size: 14px;
    }
}
