/* Tournament details — tab bar, Approved Players, and responsive polish
   for Overview / Order of Play / Playoffs / Leaderboard.
   Loaded after tournament_details_redesign.css. Zinc + optic-yellow system. */

#tournament-page-root {
    --apr-signal: #d9f114;
    --apr-ink: #0b0b0c;
    --apr-radius: 18px;
}

/* ── Tab bar: scrollable, no wrapping, edge fade on small screens ── */
#tournament-category-pane .th-tabs-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
#tournament-category-pane .th-tabs-nav::-webkit-scrollbar { display: none; }
#tournament-category-pane .th-tab-btn { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 767.98px) {
    #tournament-category-pane .th-tabs-nav {
        margin-inline: -0.75rem;
        padding-inline: 0.75rem;
        -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
        mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
    }
}

/* ── Approved Players ───────────────────────────────────── */
.apr-head { padding: clamp(1.1rem, 2.4vw, 1.75rem); margin-bottom: 1.25rem; }
.apr-head__top {
    display: flex; flex-wrap: wrap; align-items: flex-start;
    justify-content: space-between; gap: 1rem;
}
.apr-eyebrow {
    display: inline-flex; align-items: center; gap: .4rem; margin: 0 0 .35rem;
    padding: .25rem .7rem; border-radius: 999px;
    background: rgba(217, 241, 20, .22); color: var(--pp-text);
    border: 1px solid rgba(217, 241, 20, .55);
    font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.apr-title { margin: 0; font-size: clamp(1.4rem, 3.2vw, 1.9rem); font-weight: 800; letter-spacing: -.01em; }
.apr-sub { margin: .25rem 0 0; color: var(--pp-text-muted); font-size: .92rem; }
.apr-sub strong { color: var(--pp-text); }

.apr-seg {
    display: inline-flex; padding: 3px; border-radius: 999px;
    background: var(--pp-surface-app); border: 1px solid var(--pp-border);
}
.apr-seg__btn {
    border: 0; background: transparent; color: var(--pp-text-muted);
    padding: .5rem 1rem; min-height: 40px; border-radius: 999px;
    font-weight: 700; font-size: .85rem; cursor: pointer; transition: background .2s, color .2s;
}
.apr-seg__btn.is-active { background: var(--apr-ink); color: #fff; }
.apr-seg__btn:focus-visible, .apr-chip:focus-visible { outline: 2px solid var(--pp-text); outline-offset: 2px; }

.apr-stats {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem; margin-top: 1.25rem;
}
.apr-stat {
    display: flex; flex-direction: column; gap: .1rem;
    padding: .85rem 1rem; border-radius: 14px;
    background: var(--pp-surface-app); border: 1px solid var(--pp-border);
}
.apr-stat__n { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 800; line-height: 1.1; }
.apr-stat__l { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--pp-text-muted); }

.apr-chips {
    display: flex; gap: .5rem; margin-top: 1rem; padding-bottom: .25rem;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.apr-chips::-webkit-scrollbar { display: none; }
.apr-chip {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: .45rem;
    min-height: 40px; padding: .45rem .95rem; border-radius: 999px;
    border: 1px solid var(--pp-border); background: var(--pp-surface-card);
    color: var(--pp-text); font-weight: 700; font-size: .85rem; cursor: pointer;
    transition: background .2s, border-color .2s;
}
.apr-chip span {
    min-width: 1.5rem; padding: .05rem .4rem; border-radius: 999px; text-align: center;
    background: var(--pp-surface-app); font-size: .75rem; font-weight: 800;
}
.apr-chip:hover { border-color: var(--pp-text); }
.apr-chip.is-active { background: var(--apr-signal); border-color: var(--apr-signal); color: var(--apr-ink); }
.apr-chip.is-active span { background: rgba(0, 0, 0, .12); color: var(--apr-ink); }

.apr-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
}
.apr-grid.d-none { display: none; }
.apr-card {
    display: flex; flex-direction: column; gap: .75rem; min-width: 0;
    padding: 1.1rem; border-radius: var(--apr-radius);
    background: var(--pp-surface-card); border: 1px solid var(--pp-border);
    box-shadow: 0 1px 2px rgba(9, 9, 11, .04);
    transition: transform .25s cubic-bezier(.16, 1, .3, 1), box-shadow .25s;
}
.apr-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -20px rgba(9, 9, 11, .3); }
.apr-card.d-none { display: none; }
.apr-card__head { display: flex; flex-direction: column; gap: .5rem; }
.apr-card__team { margin: 0; font-size: 1.05rem; font-weight: 800; overflow-wrap: anywhere; }
.apr-card__tags { display: flex; flex-wrap: wrap; gap: .35rem; }
.apr-tag {
    padding: .15rem .6rem; border-radius: 999px; font-size: .7rem; font-weight: 800;
    letter-spacing: .03em; border: 1px solid var(--pp-border); color: var(--pp-text-muted);
    background: var(--pp-surface-app);
}
.apr-tag--flight { background: var(--apr-ink); border-color: var(--apr-ink); color: #fff; }
.apr-players { display: flex; flex-direction: column; gap: .45rem; }
.apr-player {
    display: flex; align-items: center; gap: .75rem; min-width: 0;
    padding: .55rem .7rem; border-radius: 12px; background: var(--pp-surface-app);
}
.apr-avatar {
    flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center;
    border-radius: 10px; background: #18181b; color: #fff; font-weight: 800;
}
.apr-player__name { font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.apr-card__note { margin: 0; font-size: .78rem; color: var(--pp-text-muted); }

[data-theme="dark"] .apr-avatar, [data-bs-theme="dark"] .apr-avatar { background: #27272a; }
[data-theme="dark"] .apr-seg__btn.is-active, [data-bs-theme="dark"] .apr-seg__btn.is-active { background: var(--apr-signal); color: var(--apr-ink); }
[data-theme="dark"] .apr-tag--flight, [data-bs-theme="dark"] .apr-tag--flight { background: var(--apr-signal); border-color: var(--apr-signal); color: var(--apr-ink); }

@media (max-width: 575.98px) {
    .apr-head__top { flex-direction: column; }
    .apr-seg { width: 100%; }
    .apr-seg__btn { flex: 1; }
    .apr-stat { padding: .7rem .75rem; }
    .apr-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .apr-card, .apr-chip, .apr-seg__btn { transition: none; }
    .apr-card:hover { transform: none; }
}

/* ── Overview ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
    #tab-overview .tdt-overview { grid-template-columns: 1fr; }
}
#tab-overview .tdt-prose { overflow-wrap: anywhere; }

/* ── Order of Play: tighter, scrollable table with sticky flight column ── */
#tab-bracket .table-responsive { -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
    #tab-bracket .th-op-table { font-size: .8rem; min-width: 640px; }
    #tab-bracket .th-op-table th, #tab-bracket .th-op-table td { padding: .55rem .6rem; white-space: nowrap; }
    #tab-bracket .th-op-table td:first-child, #tab-bracket .th-op-table th:first-child {
        position: sticky; left: 0; z-index: 1; background: var(--pp-surface-card);
    }
}

/* ── Playoffs: bracket scrolls inside its card instead of the page ── */
#tab-matches .th-elim-bracket-wrap, #tab-matches .th-elim-bracket { max-width: 100%; }
#tab-matches .th-elim-bracket-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
@media (max-width: 767.98px) {
    #tab-matches .th-bento-card { padding: 1rem; }
}

/* ── Leaderboard ────────────────────────────────────────── */
#tab-leaderboard { min-width: 0; }
@media (max-width: 575.98px) {
    #tab-leaderboard .lb-podium { border-radius: 16px; }
    #tab-leaderboard .th-bento-card { padding: 1rem; }
}

/* ── Standings (Participant Lists by Flight, public) ─────── */
#tab-standings { min-width: 0; }
.ps-head { margin-bottom: 1.15rem; }
.ps-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.4rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: rgba(217, 241, 20, 0.22);
    border: 1px solid rgba(217, 241, 20, 0.55);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pp-text);
}
.ps-title {
    margin: 0;
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.01em;
}
.ps-sub {
    margin: 0.35rem 0 0;
    color: var(--pp-text-muted);
    font-size: 0.92rem;
    line-height: 1.45;
    max-width: 42rem;
}

.ps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 1.15rem;
    align-items: start;
}

.ps-flight {
    background: var(--pp-surface-card, #fff);
    border: 1px solid var(--pp-border, #e4e4e7);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03), 0 6px 16px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ps-flight.is-complete {
    border-color: rgba(15, 159, 110, 0.45);
    box-shadow: 0 0 0 1px rgba(15, 159, 110, 0.16), 0 6px 16px rgba(15, 23, 42, 0.05);
}

.ps-flight__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    background: #09090b;
    color: #fafafa;
}
.ps-flight__head-main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}
.ps-flight__letter {
    font-family: "Bebas Neue", sans-serif;
    font-size: 1.55rem;
    line-height: 1;
    color: #d9f114;
    flex: 0 0 auto;
}
.ps-flight__name {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
    color: #fff;
    overflow-wrap: anywhere;
}
.ps-flight__court {
    margin: 0.15rem 0 0;
    font-size: 0.72rem;
    font-weight: 650;
    color: rgba(255, 255, 255, 0.72);
}
.ps-flight__count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.ps-flight__banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ps-flight__banner-meta {
    margin-left: auto;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    opacity: 0.92;
    white-space: nowrap;
}
.ps-flight__banner--done {
    background: linear-gradient(135deg, #0f9f6e 0%, #059669 100%);
    color: #fff;
}
.ps-flight__banner--live {
    background: #fff7ed;
    color: #b45309;
    border-bottom: 1px solid #fed7aa;
}
.ps-flight__banner--wait {
    background: var(--pp-surface-app, #f4f4f5);
    color: var(--pp-text-muted, #71717a);
    border-bottom: 1px solid var(--pp-border, #e4e4e7);
}
.ps-flight__progress {
    height: 4px;
    background: var(--pp-surface-app, #f4f4f5);
}
.ps-flight__progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}
.ps-flight__empty {
    margin: 0;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--pp-text-muted);
    font-size: 0.88rem;
    font-style: italic;
}

.ps-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    color: var(--pp-text, #09090b);
}
.ps-table th,
.ps-table td {
    padding: 0.65rem 0.7rem;
    border-bottom: 1px solid var(--pp-border, #e4e4e7);
    vertical-align: middle;
}
.ps-table thead th {
    background: var(--pp-surface-app, #f4f4f5);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pp-text-muted, #71717a);
    white-space: nowrap;
}
.ps-table th.num,
.ps-table td.num {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    white-space: nowrap;
}
.ps-table tbody tr:last-child td { border-bottom: 0; }
.ps-table tbody tr:hover td { background: rgba(9, 9, 11, 0.025); }
.ps-table tr.is-gold td {
    background: rgba(217, 241, 20, 0.22);
    font-weight: 800;
}
.ps-table tr.is-silver td { background: rgba(9, 9, 11, 0.04); font-weight: 800; }
.ps-table tr.is-bronze td { background: rgba(245, 158, 11, 0.12); font-weight: 750; }
.ps-table tr.is-advance td { background: rgba(15, 159, 110, 0.08); font-weight: 750; }

.ps-table__standing {
    white-space: nowrap;
    font-weight: 800;
    min-width: 4.5rem;
}
.ps-medal {
    margin-right: 0.25rem;
    font-size: 0.9rem;
    vertical-align: -0.05em;
}
.ps-medal--gold { color: #ca8a04; }
.ps-medal--silver { color: #71717a; }
.ps-medal--bronze { color: #b45309; }
.ps-medal--advance { color: #0f9f6e; }
.ps-seed {
    margin-left: 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--pp-text-muted);
}
.ps-table__team { min-width: 0; }
.ps-player {
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.ps-player + .ps-player { margin-top: 0.15rem; color: var(--pp-text); }

.ps-ties {
    margin: 0;
    padding: 0.65rem 1rem 0.85rem;
    border-top: 1px dashed var(--pp-border);
    font-size: 0.8rem;
    color: var(--pp-text-muted);
}
.ps-ties summary {
    cursor: pointer;
    font-weight: 800;
    color: var(--pp-text);
}
.ps-ties__group { margin-top: 0.55rem; }
.ps-ties__group strong { color: var(--pp-text); }
.ps-ties__group div { margin-top: 0.2rem; line-height: 1.4; }

.ps-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0 0;
    font-size: 0.82rem;
    font-weight: 650;
    color: var(--pp-text-muted);
}
.ps-legend__chip {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 4px;
    background: rgba(217, 241, 20, 0.55);
    border: 1px solid rgba(217, 241, 20, 0.9);
    flex: 0 0 auto;
}

[data-theme="dark"] .ps-flight__banner--live,
[data-bs-theme="dark"] .ps-flight__banner--live {
    background: rgba(251, 146, 60, 0.14);
    color: #fdba74;
    border-bottom-color: rgba(251, 146, 60, 0.28);
}
[data-theme="dark"] .ps-table tr.is-gold td,
[data-bs-theme="dark"] .ps-table tr.is-gold td {
    color: #fde68a;
}
[data-theme="dark"] .ps-flight__banner--wait,
[data-bs-theme="dark"] .ps-flight__banner--wait {
    background: #18181b;
}

@media (max-width: 575.98px) {
    .ps-grid { grid-template-columns: 1fr; gap: 0.85rem; }
    .ps-flight__banner { flex-wrap: wrap; }
    .ps-flight__banner-meta { margin-left: 0; width: 100%; white-space: normal; }
    .ps-table { font-size: 0.82rem; }
    .ps-table th,
    .ps-table td { padding: 0.5rem 0.55rem; }
}

/* ── Approved Players: one card per flight, teams listed inside ── */
.apr-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.apr-group { gap: 1rem; }
.apr-group__head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
    padding-bottom: .85rem; border-bottom: 1px solid var(--pp-border);
}
.apr-group__title { margin: 0; font-size: 1.25rem; font-weight: 800; }
.apr-teams { display: flex; flex-direction: column; gap: 1rem; }
.apr-team { display: flex; flex-direction: column; gap: .4rem; }
.apr-team.d-none { display: none; }
.apr-team__name { font-size: .78rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--pp-text-muted); overflow-wrap: anywhere; }
.apr-team__note { margin-left: .4rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
.apr-team .apr-players { flex-direction: row; flex-wrap: wrap; }
.apr-team .apr-player { flex: 1 1 140px; }
.apr-group:hover { transform: none; }

/* Full names + profile pictures */
.apr-team .apr-player { flex: 1 1 100%; }
@media (min-width: 1200px) { .apr-team .apr-player { flex-basis: calc(50% - .25rem); } }
.apr-avatar { position: relative; overflow: hidden; }
.apr-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.apr-avatar b { font-weight: 800; }
.apr-avatar.has-photo b { opacity: 0; }
.apr-player__name { line-height: 1.25; }
