:root {
    /* Color Variables */
    --color-body-bg: #f6f7f8;
    --color-text: #333333;
    --color-white: #ffffff;
    --color-primary: #ba0c2f;
    --color-header-text: var(--color-white);
    --color-table-header-bg: #eff1f2;
    --color-table-row-even-bg: #f6f7f8;
    --color-table-row-hover-bg: #ffe9ed;
    --color-border: #dddddd;
    --color-secondary-text: #868e92;
    --color-game-card-bg: #f9f9f9;
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-shadow-deep: rgba(0, 0, 0, 0.2);
    --color-modal-bg: rgba(0, 0, 0, 0.5);
    --color-modal-content-bg: var(--color-white);
    --color-close: #333333;
    --color-close-hover: red;
    --color-link: var(--color-primary);
    --color-link-hover: var(--color-primary);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--color-body-bg);
    color: var(--color-text);
    line-height: 1.6;
}

h1, h2 {
    text-align: center;
    margin: 20px 0;
}
.container {
    width: 90%;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Bottom Section Layout */
.bottom-section {
    display: flex;
    gap: 20px;
    align-items: flex-start; /* **Added this line** */
}

.leaderboard {
    flex: 6;
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: 0 4px 8px var(--color-shadow);
    overflow: hidden;
}

.leaderboard-header {
    background-color: var(--color-primary);
    color: var(--color-header-text);
    font-weight: 600;
    padding: 15px 0;
    text-align: center;
    font-size: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px;
    text-align: center;
}
th {
    background-color: var(--color-table-header-bg);
    font-weight: 500;
}
.leaderboard tr:nth-child(even) {
    background-color: var(--color-table-row-even-bg);
}
a {
    text-decoration: none;
    color: var(--color-link);
    font-weight: 600;
}
a:hover {
    text-decoration: underline;
    color: var(--color-link-hover);
}

/* Games Sections */
.games-section {
    flex: 4;
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: 0 4px 8px var(--color-shadow);
    overflow: hidden;
}
.games-section-header {
    background-color: var(--color-primary);
    color: var(--color-header-text);
    font-weight: 600;
    padding: 15px 0;
    text-align: center;
    font-size: 18px;
    margin-bottom: 10px;
}
#active-games-section, #upcoming-games-section {
    width: 100%;
}
#active-games-container, #upcoming-games-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 10px;
}
.game-card {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-left: 10px;
    margin-right: 10px;
    align-items: center;
    padding: 15px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-game-card-bg);
    box-shadow: 0 2px 4px var(--color-shadow);
}
.team-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.team-name {
    font-weight: bold;
    font-size: 16px;
}
.team-link {
    text-decoration: none;
    align-items: center;
    color: var(--color-text);
}
.team-logo-and-score {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
}
.team-score {
    font-size: 22px;
    font-weight: bold;
    margin-top: 0px;
}
.win-probability {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}
.game-details {
    text-align: center;
    font-size: 16px;
    color: var(--color-secondary-text);
}
.game-link {
    text-decoration: none;
    color: var(--color-secondary-text);
    font-weight: 500;
}

/* Responsive Enhancements */
@media (max-width: 1024px) {
    .bottom-section {
        flex-direction: column;
    }
    .leaderboard, .games-section {
        flex: none;
        width: 100%;
    }
}
@media (max-width: 768px) {
    th, td {
        padding: 8px;
    }
    .game-details {
        font-size: 12px;
    }
    .team-name {
        font-size: 12px;
    }
    .game-card {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Modal */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--color-modal-bg);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background-color: var(--color-modal-content-bg);
    padding: 20px 30px; /* Reduced padding to accommodate scrollable area */
    border-radius: 10px;
    max-width: 80%;
    width: 90%;
    max-height: 80vh; /* Set maximum height relative to viewport */
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 10px var(--color-shadow-deep);
    animation: slide-down 0.3s ease-out;
    position: relative;
}
@keyframes slide-down {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.close {
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    color: var(--color-close);
    position: absolute;
    right: 20px;
    top: 10px;
}
.close:hover {
    color: var(--color-close-hover);
}

/* Scrollable Picks Container */
.picks-container {
    overflow-y: auto;
    margin-top: 20px;
    /* Set flex-grow to allow it to take up remaining space */
    flex-grow: 1;
}

.picks-container table {
    width: 100%;
    border-collapse: collapse;
}
.picks-container th, .picks-container td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}
.picks-container th {
    background-color: var(--color-table-header-bg);
    font-weight: 600;
}
.correct {
    background-color: #d4edda; /* Light green */
    color: #155724; /* Dark green */
}

.incorrect {
    background-color: #f8d7da; /* Light red */
    color: #721c24; /* Dark red */
}



/* Modal Responsive Enhancements */
@media (max-width: 480px) {
    .modal-content {
        padding: 15px 20px;
    }
    .modal-content table, .modal-content th, .modal-content td {
        font-size: 14px;
    }
}

/* Prevent background scrolling when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(246, 247, 248, 0.9); /* Semi-transparent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999; /* Ensure it sits above other elements */
}

/* Loading Bubbles Container */
.loading-bubbles {
    display: flex;
    gap: 15px;
}

/* Individual Bubble */
.loading-bubble .bubble {
    width: 20px;
    height: 20px;
    background-color: var(--color-primary);
    border-radius: 50%;
    opacity: 0.6;
    animation: bubble 1.4s infinite ease-in-out both;
}

.bubble {
    width: 20px;
    height: 20px;
    background-color: var(--color-primary);
    border-radius: 50%;
    opacity: 0.6;
    animation: bubble 1.4s infinite ease-in-out both;
}

/* Animation for Bubbles */
@keyframes bubble {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

@keyframes bubbleDelay1 {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes bubbleDelay2 {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.bubble:nth-child(1) {
    animation: bubble 1.4s infinite ease-in-out both;
    animation-delay: -0.32s;
}

.bubble:nth-child(2) {
    animation: bubble 1.4s infinite ease-in-out both;
    animation-delay: -0.16s;
}

.bubble:nth-child(3) {
    animation: bubble 1.4s infinite ease-in-out both;
    animation-delay: 0s;
}

/* Hide the loading overlay when not active */
#loading-overlay.hidden {
    display: none;
}