.standings table,
.brackets table {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    border-collapse: collapse;
    border: 1px solid var(--background-color);
    width: 100%;
}

.standings th,
.brackets th {
    background-color: var(--background-color);
    text-align: center;
    padding: 10px;
    font-weight: bold;
    border: 1px solid var(--background-color);
    color: var(--secondary-color);
}

.standings td,
.brackets td {
    padding: 4px;
    text-align: center;
    border: 1px solid var(--background-color);
}

h3 {
    font-size: 1.5rem !important;
    line-height: 1.5rem !important;
}

@media screen and (max-width: 768px) {

    .standings th,
    .brackets th {
        padding: 6px;
        font-size: 0.7rem;
    }

    .standings td,
    .brackets td {
        padding: 5px;
        text-transform: uppercase;
    }

    .standings .table-container,
    .brackets .table-container {
        overflow-x: auto;
        margin: 0 auto;
        max-width: 90%;
    }

    h1 {
        font-size: 2.5rem !important;
        line-height: 2.5rem !important;
        padding: 1rem;
    }
}

@media screen and (min-width: 1024px) {
    .standings.active {
        display: grid;
        grid-template-areas:
            "header header"
            "col1 col2";
        grid-template-columns: 1fr 1fr;
    }

    #modules {
        display: grid;
        gap: 20px;
        max-width: 90%;
        margin: 0 auto;
        padding-bottom: 2rem;
        margin-bottom: 2rem;
    }

    h3 {
        margin-top: 1rem;
    }

    .brackets {
        margin-bottom: 20px;
    }

    .brackets .table-container {
        max-width: 100%;
    }

    .brackets table {
        width: 100%;
    }
}

body[d-broadcaster_code=fiba] .modules li.active.event-1 button {
    background-color: #ff5252;
}

body[d-broadcaster_code=fiba] .modules li.active.event-1 button a,
body[d-broadcaster_code=fiba] .modules li.active.event-1 button span {
    color: #000;
}

body[d-broadcaster_code=fiba] .modules li.event-1 button a {
    color: #ff5252;
}

body[d-broadcaster_code=fiba] .modules li.active.event-2 button {
    background-color: #8c21f3;
}

body[d-broadcaster_code=fiba] .modules li.event-2 button a {
    color: #8c21f3;
}

body[d-broadcaster_code=fiba] .modules li.active.event-2 button a,
body[d-broadcaster_code=fiba] .modules li.active.event-2 button span {
    color: #FFF;
}

#header_logo.logo,
#header_logo2.logo {
    padding-top: 25px !important;
    padding-bottom: 25px !important;
}

.brackets .bracket-container {
    max-width: 90%;
    margin: 0 auto;
}

.brackets .game .team {
    font-weight: bold;
}

.brackets .game .time {
    font-size: 1rem;
    color: var(--sixth-color);
}

@media screen and (min-width: 1025px) {
    .brackets .bracket-container {
        display: contents;
        /* Allow grid children to be direct grid items */
    }

    .brackets .round {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Explicit column assignments for all possible rounds */
    .round-of-16 {
        grid-column: 1;
    }

    .quarter-finals {
        grid-column: 1;
    }

    .semi-finals {
        grid-column: 2;
    }

    .final {
        grid-column: 3;
    }

    .msf {
        grid-column: 3;
    }

    .msf5 {
        grid-column: 3;
    }
}

#modules .brackets {
    max-width: 90%;
    width: 90%;
    margin: 0 auto;
}

#modules .brackets .round {
    margin: 0 10px;
    text-align: center;
}

#modules .brackets .game {
    background: var(--background-color);
    padding: 10px;
    margin: 5px 0;
    position: relative;
    min-width: 250px;
    display: block;
}

#modules .brackets .game .score {
    margin-top: 5px;
    color: var(--fifth-color)
}

#modules .brackets .connector {
    position: absolute;
    width: 15px;
    height: 2px;
    background: var(--background-color);
    top: 50%;
    right: -15px;
    transform: translateY(-50%);
}

#modules .brackets .connector::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 15px;
    background: var(--background-color);
    left: 100%;
    top: -7px;
}

@media screen and (max-width: 768px) {
    #modules .brackets .game {
        padding: 6px;
    }

    #modules .brackets .connector {
        width: 10px;
        right: -10px;
    }

    #modules .brackets .connector::after {
        height: 10px;
        top: -5px;
    }
}

@media screen and (min-width: 1025px) {
    #modules .brackets .round {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 300px;
    }

    /* Explicit column assignments */
    #modules .brackets .round-of-16 {
        grid-column: 1;
    }

    #modules .brackets .quarter-finals {
        grid-column: 1;
    }

    #modules .brackets .semi-finals {
        grid-column: 2;
    }

    #modules .brackets .final {
        grid-column: 3;
    }

    #modules .brackets .msf {
        grid-column: 3;
    }

    #modules .brackets .msf5 {
        grid-column: 3;
    }
}

/* Override any conflicting main or global styles */
main,
#main {
    overflow: unset !important;
    overflow-x: unset !important;
}

h4 {
    margin: 0;
    text-transform: uppercase;
}

.standings table {
    margin-left: auto;
    margin-right: auto;
}

.standings.hidden {
    display: none !important;
}

.standings.active {
    gap: 10px;
    width: 100%;
    margin: 0 auto;
    transition: opacity 0.5s ease;
}

.standings.transitioning {
    opacity: 0;
}

.standings h2 {
    grid-area: header;
    /* Span both columns */
    text-align: center;
    margin-bottom: 10px;
}

.standings .pools {
    display: contents;
    /* Allow children to participate in grid */
}

.standings .pools li {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.standings .pools h3 {
    text-align: center;
    margin-top: 0;
}

.standings table th,
.standings table td {
    width: 60px;
    /* Default width for all columns */
}

.standings table th:nth-child(2),
.standings table td:nth-child(2) {
    /* Team column */
    width: 150px;
    /* Wider for team names */
}

.standings table th:nth-child(1),
.standings table td:nth-child(1) {
    /* Rank column */
    width: 50px;
}

li:first-child li h3,
li:first-child li th {
    color: var(--primary-color);
}

li:nth-child(2) li h3,
li:nth-child(2) li th {
    color: var(--fourth-color);
}

li li td,
h1 {
    color: var(--secondary-color);
}

#modules .brackets .sf .game {
    margin-bottom: 50px;
    margin-top: 50px;
}

#modules .brackets .f .game {
    margin-top: 140px;
}