* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    transition: background-color 0.5s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 35% 65%;
    grid-template-areas: 
        "header header"
        "team-header team-header"
        "table charts";
    column-gap: 80px;
    row-gap: 0;
    align-items: start;
}

.header {
    grid-area: header;
    text-align: center;
    transition: color 0.5s;
}

.team-header {
    grid-area: team-header;
    text-align: center;
    font-size: 2em;
    font-weight: bold;
    margin: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: color 0.5s;
}

#teamLogos {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    max-width: 100%;
}

.team-logo {
    height: 50px;
    border: 3px solid;
    border-radius: 5px;
}

.table-area {
    grid-area: table;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: start;
}

.selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

label {
    font-size: 1.2em;
    margin-right: 10px;
}

select {
    padding: 5px;
    font-size: 1em;
    width: 100%;
    max-width: 200px;
}

.table-container {
    margin: 0;
    padding: 0;
    overflow-x: auto; /* Enable horizontal scrolling */
    overflow-y: auto;
    max-width: 450px;
    width: 100%;
    align-self: start;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
    scrollbar-width: auto; /* Ensure scrollbar visibility (Firefox) */
}

table {
    width: 100%;
    max-width: 450px;
    min-width: 650px; /* Ensure all columns are visible */
    border-collapse: collapse;
    transition: color 0.5s;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    white-space: nowrap;
}

th {
    background-color: #f2f2f2;
    cursor: pointer;
}

th.sortable:hover {
    background-color: #e0e0e0;
}

th.sorted {
    background-color: #d0d0d0;
}

.sort-arrow {
    display: inline-block;
    width: 10px;
    text-align: center;
}

.logo-img {
    height: 50px;
    vertical-align: middle;
}

td:first-child {
    background-color: #FFFFFF;
}

.charts-container {
    grid-area: charts;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    width: 100%;
    align-self: start;
}

.chart {
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    width: 100%;
    transition: background-color 0.5s;
}

.chart canvas {
    height: 400px !important;
    width: 100% !important;
}

@media (max-width: 800px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "header"
            "team-header"
            "table"
            "charts";
        row-gap: 0;
    }
    .table-area {
        width: 100%;
    }
    .table-container { 
        width: 100%; 
        max-width: 100%;
        overflow-x: auto; /* Ensure horizontal scrolling on mobile */
        margin: 0;
        padding: 0;
        -webkit-overflow-scrolling: touch;
    }
    .selector-container {
        padding-bottom: 10px;
    }
    table { 
        max-width: 100%;
        min-width: 650px; /* Keep min-width for all columns */
    }
    .charts-container { 
        grid-template-columns: 1fr; 
        width: 100%; 
    }
    .chart { width: 100%; }
    #teamLogos {
        justify-content: center;
    }
}

/* Ensure scrollbar visibility in WebKit browsers */
.table-container::-webkit-scrollbar {
    height: 8px;
}
.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.table-container::-webkit-scrollbar-thumb {
    background: #888;
}
.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}