/* Team page header — mobile-only overrides (desktop uses original Bootstrap layout) */

.team-header-record-col {
    width: 110px;
}

@media (max-width: 767.98px) {
    #teamHeaderCard {
        padding: 0.75rem 0.55rem 0.9rem;
    }

    #teamHeaderCard > .row.align-items-center {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.85rem;
    }

    #teamHeaderCard .col-auto,
    #teamHeaderCard .col.d-flex {
        width: 100%;
        max-width: 100%;
    }

    #teamHeaderCard .col.d-flex {
        justify-content: center !important;
    }

    #teamHeader {
        width: fit-content;
        max-width: 100%;
        margin-inline: auto;
        padding: 0.35rem 0.15rem !important;
    }

    #teamLogo {
        width: 84px !important;
        height: 84px !important;
    }

    #teamName {
        font-size: 1.4rem;
        line-height: 1.15;
        white-space: normal !important;
    }

    #teamHeaderCard .col.d-flex > .d-flex.align-items-center {
        flex-direction: column;
        width: 100%;
        align-items: stretch;
    }

    #teamHeaderCard .text-center.px-4 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding-inline: 0.1rem !important;
        gap: 0.5rem 1rem;
    }

    #teamRank {
        font-size: 1.5rem !important;
    }

    #teamRank .badge {
        font-size: 1.15rem;
    }

    #confStanding {
        font-size: 1.15rem !important;
    }

    #teamHeaderCard .team-header-records {
        margin-left: 0 !important;
        width: 100%;
    }

    #teamHeaderCard .team-header-records > .d-flex {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.35rem;
        margin-bottom: 0.3rem !important;
    }

    #teamHeaderCard .team-header-record-col {
        width: auto;
        min-width: 0;
        flex: 1 1 calc(33.33% - 0.35rem);
        max-width: calc(33.33% - 0.35rem);
        margin-left: 0 !important;
    }

    #teamHeaderCard .team-header-records .h4 {
        font-size: 1.05rem;
    }

    #teamHeaderCard .team-header-records .h5 {
        font-size: 0.95rem;
    }

    #teamHeaderCard small.text-muted {
        font-size: 0.68rem;
    }
}

/* Team schedule card layout (team page) */

.team-sched-v2 {
    --sched-panel: #ffffff;
    --sched-row: #ffffff;
    --sched-row-alt: #f6f7f9;
    --sched-win-row: rgba(18, 94, 58, 0.11);
    --sched-loss-row: rgba(158, 32, 26, 0.12);
    --sched-tie-row: rgba(120, 90, 10, 0.09);
    --sched-text: #1c1f26;
    --sched-muted: #5f6775;
    --sched-rank: #9a7209;
    --sched-loc: #3d4654;
    --sched-loc-bg: #e6dfd4;
    --sched-win-bg: rgba(18, 94, 58, 0.16);
    --sched-win-text: #0f5132;
    --sched-loss-bg: rgba(158, 32, 26, 0.16);
    --sched-loss-text: #842029;
    --sched-team-primary: #1a3a6b;
    /* Slightly larger schedule scale */
    --sched-font-row: 0.9375rem;
    --sched-font-body: 0.8125rem;
    --sched-font-small: 0.75rem;
    --sched-font-label: 0.75rem;
    --sched-col-week: 38px;
    --sched-col-date: max-content;
    --sched-col-gr: 26px;
    --sched-col-loc: 32px;
    --sched-col-rank: 62px;
    --sched-col-logo: 28px;
    --sched-col-result: 78px;
}

.team-sched-v2-tabs-card {
    width: fit-content;
    max-width: 100%;
}

.team-sched-v2-tabs-card:has(#roster.active) {
    width: min(100%, 960px);
}

.team-sched-v2-tabs-card > .card-header {
    background: #fff;
    border-bottom: 1px solid #e6dfd4;
    padding-top: 0.65rem;
    padding-bottom: 0;
}

.team-sched-v2-card {
    width: fit-content;
    max-width: 100%;
}

.team-sched-v2-schedule-col {
    max-width: 100%;
}

.team-sched-v2-body {
    background: var(--sched-panel);
    padding: 0.65rem 0.85rem 0.9rem;
    width: fit-content;
    max-width: 100%;
}

/* One column definition — all rows share tracks via subgrid */
.team-sched-v2-grid {
    display: grid;
    grid-template-columns:
        var(--sched-col-week)
        var(--sched-col-date)
        var(--sched-col-gr)
        var(--sched-col-loc)
        var(--sched-col-rank)
        var(--sched-col-logo)
        auto
        var(--sched-col-result)
        auto;
    column-gap: 0.45rem;
    row-gap: 4px;
    width: fit-content;
    max-width: 100%;
}

.team-sched-v2-section {
    display: contents;
}

.team-sched-v2-list {
    display: contents;
}

.team-sched-v2-colheads {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    padding: 0.2rem 0.55rem 0.4rem;
    font-size: var(--sched-font-label);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sched-muted);
}

.team-sched-v2-colheads span:nth-child(3),
.team-sched-v2-colheads span:nth-child(8) {
    text-align: center;
}

.team-sched-v2-colheads .gr-col-head {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

.team-sched-v2-postseason-label {
    grid-column: 1 / -1;
    font-size: var(--sched-font-label);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sched-muted);
    padding: 0.55rem 0.55rem 0.2rem;
}

.team-sched-v2-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    min-height: 0;
}

.team-sched-v2-desktop {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    align-items: center;
    padding: 0.28rem 0.55rem;
    border-radius: 8px;
    background: var(--sched-row);
    min-height: 40px;
    font-size: var(--sched-font-row);
    line-height: 1.2;
    transition: box-shadow 0.12s ease;
}

.team-sched-v2-mobile {
    display: none;
}

.team-sched-v2-row:nth-of-type(even) .team-sched-v2-desktop {
    background: var(--sched-row-alt);
}

.team-sched-v2-row.is-win .team-sched-v2-desktop,
.team-sched-v2-row.is-win .team-sched-v2-mobile {
    background: var(--sched-win-row);
}

.team-sched-v2-row.is-loss .team-sched-v2-desktop,
.team-sched-v2-row.is-loss .team-sched-v2-mobile {
    background: var(--sched-loss-row);
}

.team-sched-v2-row.is-tie .team-sched-v2-desktop,
.team-sched-v2-row.is-tie .team-sched-v2-mobile {
    background: var(--sched-tie-row);
}

.team-sched-v2-row.is-clickable {
    cursor: pointer;
}

.team-sched-v2-row.is-clickable:hover .team-sched-v2-desktop,
.team-sched-v2-row.is-clickable:hover .team-sched-v2-mobile {
    box-shadow: 0 1px 6px rgba(28, 31, 38, 0.12);
}

.team-sched-v2-row.is-bye .team-sched-v2-desktop {
    min-height: 34px;
}

.team-sched-v2-row.is-bye .team-sched-v2-desktop .team-sched-v2-bye-label {
    grid-column: 2 / -1;
    text-align: center;
    justify-self: stretch;
}

.team-sched-v2-week {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 0.18rem 0.35rem;
    border-radius: 5px;
    background: var(--sched-team-primary);
    color: #fff;
    font-weight: 700;
    font-size: var(--sched-font-body);
    line-height: 1;
    justify-self: start;
    margin-right: 0;
}

.team-sched-v2-gr {
    text-align: center;
    font-weight: 700;
    font-size: var(--sched-font-body);
    color: var(--sched-muted);
}

.team-sched-v2-date {
    color: var(--sched-text);
    font-size: var(--sched-font-small);
    white-space: nowrap;
}

.team-sched-v2-loc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.14rem 0.32rem;
    border-radius: 5px;
    background: var(--sched-loc-bg);
    color: var(--sched-loc);
    font-weight: 700;
    font-size: var(--sched-font-label);
    text-transform: lowercase;
    justify-self: start;
}

.team-sched-v2-rank {
    font-size: var(--sched-font-body);
    color: var(--sched-rank);
    text-align: center;
    white-space: nowrap;
}

.team-sched-v2-rank strong {
    font-weight: 800;
}

.team-sched-v2-rank .rank-prior {
    color: var(--sched-muted);
    font-weight: 500;
}

.team-sched-v2-opp-logo-wrap {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.team-sched-v2-opp-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.team-sched-v2-main {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
    white-space: nowrap;
}

.team-sched-v2-opp-name {
    font-weight: 700;
    color: var(--sched-text);
}

.team-sched-v2-opp-meta {
    font-size: var(--sched-font-body);
    color: var(--sched-muted);
}

.team-sched-v2-line {
    font-size: var(--sched-font-body);
    color: var(--sched-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.team-sched-v2-line.is-empty {
    text-align: center;
}

.team-sched-v2-result {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.16rem 0.45rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: var(--sched-font-body);
    white-space: nowrap;
    justify-self: start;
}

.team-sched-v2-result.is-win {
    background: var(--sched-win-bg);
    color: var(--sched-win-text);
}

.team-sched-v2-result.is-loss {
    background: var(--sched-loss-bg);
    color: var(--sched-loss-text);
}

.team-sched-v2-result.is-tie {
    background: var(--sched-loc-bg);
    color: var(--sched-text);
}

.team-sched-v2-result.is-upcoming {
    background: transparent;
    color: var(--sched-muted);
    font-weight: 600;
    padding: 0;
    justify-self: center;
}

.team-sched-v2-bye-label {
    font-style: italic;
    color: var(--sched-muted);
    font-size: var(--sched-font-small);
}

.team-sched-v2-loading {
    grid-column: 1 / -1;
}

/* Fallback when subgrid is unavailable — shared fixed columns */
@supports not (grid-template-columns: subgrid) {
    .team-sched-v2-grid {
        --sched-cols: var(--sched-col-week) var(--sched-col-date) var(--sched-col-gr) var(--sched-col-loc) var(--sched-col-rank) var(--sched-col-logo) 200px var(--sched-col-result) 100px;
        grid-template-columns: var(--sched-cols);
    }

    .team-sched-v2-colheads,
    .team-sched-v2-desktop {
        grid-template-columns: var(--sched-cols);
    }
}

/* Mobile schedule cards */
@media (max-width: 768px) {
    .team-sched-v2-schedule-col {
        width: 100%;
    }

    .team-sched-v2-card,
    .team-sched-v2-tabs-card {
        width: 100%;
    }

    .team-sched-v2-body {
        width: 100%;
        padding: 0.55rem 0.65rem 0.75rem;
    }

    .team-sched-v2-grid {
        display: block;
        width: 100%;
    }

    .team-sched-v2-section,
    .team-sched-v2-list {
        display: block;
    }

    .team-sched-v2-colheads {
        display: none;
    }

    .team-sched-v2-row {
        display: block;
        margin-bottom: 0.5rem;
    }

    .team-sched-v2-row:last-child {
        margin-bottom: 0;
    }

    .team-sched-v2-desktop {
        display: none;
    }

    .team-sched-v2-mobile {
        display: block;
        border: 1px solid #e6dfd4;
        border-radius: 8px;
        padding: 0.55rem 0.65rem;
        background: var(--sched-row);
    }

    .team-sched-v2-postseason-label {
        display: block;
        margin: 0.75rem 0 0.45rem;
        padding: 0.45rem 0.55rem;
    }

    .team-sched-v2-mobile-main {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 0.3rem;
        row-gap: 0.25rem;
    }

    .team-sched-v2-mobile-when {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
        min-width: 0;
        padding-right: 0.1rem;
    }

    .team-sched-v2-mobile-date {
        font-size: var(--sched-font-small);
        color: var(--sched-text);
        font-weight: 600;
        line-height: 1.25;
        white-space: nowrap;
    }

    .team-sched-v2-mobile-time {
        font-size: var(--sched-font-label);
        color: var(--sched-muted);
        line-height: 1.25;
        white-space: nowrap;
    }

    .team-sched-v2-mobile-loc {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 1.75rem;
        padding: 0.14rem 0.3rem;
        border-radius: 5px;
        background: var(--sched-loc-bg);
        color: var(--sched-loc);
        font-weight: 700;
        font-size: var(--sched-font-label);
        align-self: center;
    }

    .team-sched-v2-row:nth-of-type(even) .team-sched-v2-mobile {
        background: var(--sched-row-alt);
    }

    .team-sched-v2-mobile-opp {
        min-width: 0;
    }

    .team-sched-v2-mobile-opp-row {
        display: flex;
        align-items: flex-start;
        gap: 0.4rem;
        min-width: 0;
    }

    .team-sched-v2-mobile-opp-text {
        min-width: 0;
        flex: 1;
    }

    .team-sched-v2-mobile-opp-name {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--sched-text);
        line-height: 1.25;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .team-sched-v2-mobile-opp-name strong {
        color: var(--sched-rank);
        font-weight: 800;
    }

    .team-sched-v2-mobile-opp-name .rank-prior {
        color: var(--sched-muted);
        font-weight: 500;
        font-size: 0.78rem;
    }

    .team-sched-v2-mobile-opp-meta {
        font-size: 0.75rem;
        color: var(--sched-muted);
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-top: 0.08rem;
    }

    .team-sched-v2-mobile .team-sched-v2-opp-logo-wrap {
        display: flex;
        width: 28px;
        height: 28px;
        flex-shrink: 0;
    }

    .team-sched-v2-mobile .team-sched-v2-opp-logo {
        width: 26px;
        height: 26px;
    }

    .team-sched-v2-mobile-result {
        align-self: center;
        justify-self: end;
    }

    .team-sched-v2-mobile-result .team-sched-v2-result {
        justify-self: end;
    }

    .team-sched-v2-mobile-lines {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.35rem 0.85rem;
        margin-top: 0.4rem;
        padding-top: 0.35rem;
        border-top: 1px solid #e6dfd4;
        font-size: 0.7rem;
        color: var(--sched-muted);
        line-height: 1.35;
    }

    .team-sched-v2-mobile-line-spread,
    .team-sched-v2-mobile-line-ou {
        font-variant-numeric: tabular-nums;
    }

    .team-sched-v2-mobile-line-spread {
        font-weight: 600;
        color: var(--sched-text);
    }

    .team-sched-v2-mobile--bye .team-sched-v2-mobile-main {
        grid-template-columns: auto 1fr;
    }

    .team-sched-v2-mobile--bye .team-sched-v2-bye-label {
        text-align: center;
        font-style: italic;
        color: var(--sched-muted);
        font-size: var(--sched-font-small);
    }

    .team-sched-v2-loading {
        display: block;
        padding: 0.75rem 0;
    }
}
