/* IFKDB mobile primary-tab coherence v1.
   Additive final overrides loaded globally after the PWA layer. */

@media (min-width: 23.4375rem) and (max-width: 47.99rem) {
    /* Season: seven primary tabs should fit on one row from 375px upward. */
    html body.subpage .season-modern-page .season-modern-page-card .season-modern-tabs {
        display: flex !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        gap: .05rem !important;
        overflow: hidden !important;
        padding: .28rem !important;
    }

    html body.subpage .season-modern-page .season-modern-page-card .season-modern-tabs button {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 1 1 0 !important;
        min-height: 2.35rem !important;
        justify-content: center !important;
        padding: .42rem .08rem !important;
        font-size: clamp(.56rem, 1.65vw, .66rem) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    html body.subpage .season-modern-page .season-modern-tabs .season-modern-tab-count {
        display: none !important;
    }

    /* Player/personnel profiles: the primary tabs fit rather than becoming a carousel. */
    html body.player-page .player-profile-tabbar .player-modern-tabs,
    html body.player-page .player-modern-tabs,
    html body.subpage .player-modern-tabs {
        display: flex !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        gap: .06rem !important;
        overflow: hidden !important;
        padding: .34rem !important;
    }

    html body.player-page .player-modern-tabs button,
    html body.subpage .player-modern-tabs button {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 1 1 0 !important;
        justify-content: center !important;
        padding: .42rem .12rem !important;
        font-size: clamp(.58rem, 1.9vw, .69rem) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    html body .player-modern-tabs .player-modern-tab-count {
        display: none !important;
    }

    /* Head-to-head: counts are secondary; keep the section choices on one line. */
    html body.h2h-body .h2h-page .h2h-tabs {
        display: flex !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        gap: .06rem !important;
        overflow: hidden !important;
        padding: .28rem !important;
    }

    html body.h2h-body .h2h-page .h2h-tabs button,
    html body.h2h-body .h2h-page .h2h-tabs .h2h-tabs__link {
        min-width: 0 !important;
        max-width: none !important;
        flex: 1 1 0 !important;
        justify-content: center !important;
        padding: .42rem .08rem !important;
        font-size: clamp(.57rem, 1.8vw, .68rem) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    html body.h2h-body .h2h-page .h2h-tabs button span,
    html body.h2h-body .h2h-page .h2h-tabs .h2h-tabs__link span {
        display: none !important;
    }

    /* Match content tabs already use short mobile labels; lock them to one row. */
    html body.subpage .match-modern-page .match-modern-tabs {
        display: flex !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        gap: .08rem !important;
        overflow: hidden !important;
    }

    html body.subpage .match-modern-page .match-modern-tabs button {
        width: auto !important;
        min-width: 0 !important;
        flex: 1 1 0 !important;
        justify-content: center !important;
        padding-inline: .16rem !important;
        overflow: hidden !important;
    }

    html body.subpage .match-modern-page .match-modern-tabs .match-modern-tab-icon,
    html body.subpage .match-modern-page .match-modern-tabs .match-modern-tab-count {
        display: none !important;
    }

    /* Venue/table/context pages: two or three choices never need a carousel. */
    html body .ifk-context-page-card .ifk-context-tabs--attached {
        display: flex !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
        gap: .14rem !important;
        overflow: hidden !important;
    }

    html body .ifk-context-page-card .ifk-context-tabs--attached a {
        min-width: 0 !important;
        flex: 1 1 0 !important;
        justify-content: center !important;
        padding-inline: .3rem !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 23.436rem) {
    /* Below 375px, prefer a compact two-row grid to horizontal scrolling. */
    html body.subpage .season-modern-page .season-modern-page-card .season-modern-tabs {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: .08rem !important;
        overflow: hidden !important;
        padding: .26rem !important;
    }

    html body.subpage .season-modern-page .season-modern-page-card .season-modern-tabs button,
    html body.player-page .player-modern-tabs button,
    html body.subpage .player-modern-tabs button {
        min-width: 0 !important;
        padding: .4rem .08rem !important;
        font-size: .58rem !important;
    }

    html body.player-page .player-modern-tabs,
    html body.subpage .player-modern-tabs,
    html body.h2h-body .h2h-page .h2h-tabs {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: .08rem !important;
        overflow: hidden !important;
    }

    html body .player-modern-tab-count,
    html body.h2h-body .h2h-page .h2h-tabs span {
        display: none !important;
    }
}
