:root {
    --page-background: #f3f6fa;
    --card-background: #ffffff;
    --primary-text: #172033;
    --secondary-text: #5b6577;
    --border-color: #d8dee8;
    --primary-blue: #173f73;
    --primary-blue-hover: #102f59;
    --light-blue: #e7f0fb;
    --batting-header: #dcecff;
    --pitching-header: #fff0da;
    --pitching-accent: #9a5b0b;
    --row-stripe: #f7f9fc;
    --subtotal-background: #e9edf4;
    --focus-color: #3d73b9;
    --record-summary-background: #eef3f9;
    --shadow:
        0 8px 24px rgba(23, 32, 51, 0.08);
}

html {
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page-background);
    color: var(--primary-text);
    font-family:
        Arial,
        Helvetica,
        sans-serif;
    line-height: 1.45;
}

button,
input,
select {
    font: inherit;
}

.page-container {
    width: min(1380px, calc(100% - 28px));
    margin: 0 auto;
    padding: 34px 0 60px;
}

.page-heading {
    margin-bottom: 21px;
}

.eyebrow,
.section-number {
    margin: 0 0 4px;
    color: var(--primary-blue);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.9rem);
    line-height: 1.1;
}

.page-introduction {
    max-width: 760px;
    margin: 9px 0 0;
    color: var(--secondary-text);
    font-size: 0.98rem;
}

.filter-card,
.active-filter-card,
.summary-panel {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 13px;
    box-shadow: var(--shadow);
}

.filter-card {
    padding: 20px;
}

.filter-grid {
    display: grid;
    grid-template-columns:
        repeat(6, minmax(145px, 1fr));
    gap: 13px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-field label {
    font-size: 0.82rem;
    font-weight: 800;
}

.filter-field select,
.filter-field input {
    width: 100%;
    min-height: 40px;
    border: 1px solid #bfc7d4;
    border-radius: 7px;
    background: #ffffff;
    color: var(--primary-text);
    padding: 7px 9px;
}

.filter-field select:focus,
.filter-field input:focus {
    border-color: var(--focus-color);
    outline: 3px solid rgba(61, 115, 185, 0.14);
}

.filter-error {
    margin: 10px 0 0;
    border: 1px solid #d7a4a4;
    border-radius: 7px;
    background: #fff2f2;
    color: #8d2020;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 8px 10px;
}

.filter-buttons {
    display: flex;
    gap: 9px;
    margin-top: 15px;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    min-height: 39px;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    font-size: 0.86rem;
    font-weight: 800;
    text-decoration: none;
    padding: 7px 15px;
}

.primary-button {
    border: 1px solid var(--primary-blue);
    background: var(--primary-blue);
    color: #ffffff;
    cursor: pointer;
}

.primary-button:hover {
    border-color: var(--primary-blue-hover);
    background: var(--primary-blue-hover);
}

.secondary-button {
    border: 1px solid #bac3d1;
    background: #ffffff;
    color: var(--primary-text);
}

.secondary-button:hover {
    background: #f2f5f9;
}

.active-filter-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 14px;
    padding: 13px 17px;
}

.active-filter-label {
    display: block;
    color: var(--secondary-text);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.active-filter-details {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.active-filter-details span {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #f8fafc;
    color: #39445a;
    font-size: 0.75rem;
    padding: 4px 8px;
}

.summary-panel {
    margin-top: 21px;
    padding: 20px;
}

.summary-panel-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 25px;
    margin-bottom: 15px;
}

.summary-panel-heading h2 {
    margin: 0;
    font-size: clamp(1.3rem, 2.2vw, 1.7rem);
    line-height: 1.18;
}

.summary-panel-description {
    max-width: 510px;
    margin: 0;
    color: var(--secondary-text);
    font-size: 0.84rem;
    text-align: right;
}

.paired-table-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.table-column,
.record-table-column {
    min-width: 0;
}

.table-wrapper {
    min-width: 0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 9px;
}

.summary-table {
    width: 100%;
    min-width: 490px;
    border-collapse: collapse;
    background: #ffffff;
    font-size: 0.77rem;
    font-variant-numeric: tabular-nums;
    table-layout: fixed;
}

.summary-table col.column-label {
    width: 14%;
}

.summary-table col.column-n {
    width: 10%;
}

.summary-table col.column-run {
    width: 11%;
}

.summary-table col.column-average {
    width: 21%;
}

.lead-trail-table .summary-table col.column-label {
    width: 22%;
}

.lead-trail-table .summary-table col.column-n {
    width: 9%;
}

.lead-trail-table .summary-table col.column-run {
    width: 10%;
}

.lead-trail-table .summary-table col.column-average {
    width: 19%;
}

.summary-table caption {
    border-bottom: 1px solid var(--border-color);
    background: #edf2f8;
    color: var(--primary-text);
    font-size: 0.88rem;
    font-weight: 800;
    text-align: left;
    padding: 9px 10px;
}

.batting-table .summary-table caption {
    background: var(--batting-header);
    color: var(--primary-blue);
}

.pitching-table .summary-table caption {
    background: var(--pitching-header);
    color: var(--pitching-accent);
}

.summary-table th,
.summary-table td {
    border-bottom: 1px solid #e3e7ee;
    padding: 5px 2px;
    text-align: center;
    white-space: nowrap;
}

.summary-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #243852;
    color: #ffffff;
    font-size: 0.72rem;
    text-align: center;
}

.summary-table tbody th {
    font-weight: 800;
    text-align: center;
}

.summary-table tbody tr:nth-child(even) {
    background: var(--row-stripe);
}

.summary-table tbody tr:hover {
    background: #eaf2fc;
}

.summary-table .average-column {
    font-weight: 700;
}

.summary-table .subtotal-row {
    background: var(--subtotal-background) !important;
}

.summary-table .subtotal-row th,
.summary-table .subtotal-row td {
    border-top: 2px solid #adb7c6;
    font-weight: 800;
}

/* Table 4 */

.record-table-wrapper {
    width: 100%;
}

.record-summary-table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    background: #ffffff;
    font-size: 0.73rem;
    font-variant-numeric: tabular-nums;
    table-layout: fixed;
}

.record-summary-table th,
.record-summary-table td {
    border-right: 1px solid #e1e6ee;
    border-bottom: 1px solid #e1e6ee;
    text-align: center;
    vertical-align: middle;
    padding: 2px 3px;
}

.record-summary-table thead th {
    background: #243852;
    color: #ffffff;
    font-weight: 800;
    line-height: 1.08;
}

.record-summary-table thead tr:first-child th {
    padding-top: 5px;
    padding-bottom: 5px;
}

.record-summary-table tbody th {
    width: 54px;
    background: #f1f4f8;
    font-weight: 800;
}

.record-summary-table tbody tr:nth-child(even) td {
    background: var(--row-stripe);
}

.record-summary-table tbody tr:hover td {
    background: #eaf2fc;
}

.record-inning-heading {
    width: 54px;
}

.record-group-heading {
    letter-spacing: 0.02em;
}

.record-summary-heading {
    border-left: 3px solid #91a1b6 !important;
    background: #324d6e !important;
}

.record-cell {
    min-width: 76px;
    height: 38px;
}

.record-summary-cell {
    background: var(--record-summary-background) !important;
}

.record-summary-start {
    border-left: 3px solid #91a1b6 !important;
}

.record-summary-table td.record-summary-cell:first-of-type {
    border-left: 3px solid #91a1b6;
}

.record-line {
    display: block;
    color: var(--primary-text);
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1.02;
}

.winning-percentage-line {
    display: block;
    margin-top: 1px;
    color: var(--secondary-text);
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
}

.record-no-data {
    color: #929bad;
    font-size: 0.8rem;
}

.back-to-top-row {
    text-align: right;
    padding: 5px 3px 0;
}

.back-to-top-row a {
    color: var(--primary-blue);
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
}

.back-to-top-row a:hover {
    text-decoration: underline;
}

.table-note {
    margin: 11px 0 0;
    color: var(--secondary-text);
    font-size: 0.73rem;
}

@media (max-width: 1250px) {
    .filter-grid {
        grid-template-columns:
            repeat(3, minmax(170px, 1fr));
    }
}

@media (max-width: 1050px) {
    .paired-table-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .page-container {
        width: min(100% - 18px, 1380px);
        padding-top: 22px;
    }

    .filter-grid {
        grid-template-columns:
            repeat(2, minmax(140px, 1fr));
    }

    .active-filter-card,
    .summary-panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .active-filter-details {
        justify-content: flex-start;
    }

    .summary-panel-description {
        text-align: left;
    }
}

@media (max-width: 540px) {
    .filter-card,
    .summary-panel {
        padding: 15px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-buttons {
        flex-direction: column;
    }

    .primary-button,
    .secondary-button {
        width: 100%;
    }

    .summary-table {
        min-width: 470px;
    }

    .lead-trail-table .summary-table {
        min-width: 540px;
    }

    .record-summary-table {
        min-width: 1040px;
    }
}

@media print {
    body {
        background: #ffffff;
    }

    .page-container {
        width: 100%;
        padding: 0;
    }

    .filter-card,
    .back-to-top-row {
        display: none;
    }

    .summary-panel,
    .active-filter-card {
        box-shadow: none;
        break-inside: avoid;
    }

    .paired-table-grid {
        grid-template-columns: 1fr 1fr;
    }

    .record-summary-table {
        min-width: 0;
        font-size: 0.6rem;
    }

    .record-summary-table th,
    .record-summary-table td {
        padding: 2px 1px;
    }
}