/* =========================================================
   REFACTOR — CONSOLIDATED PLAY STATE / SESSION HISTORY
========================================================= */

.play-state-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: -6px 0 14px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.play-state-banner-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #6f6f78;
}

.play-state-banner.active .play-state-banner-dot { background: #62d889; }
.play-state-banner.tournament .play-state-banner-dot { background: var(--accent); }

.session-history-button {
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    background: rgba(255,255,255,.06);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.session-history-button:hover { background: rgba(255,255,255,.10); }

.session-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.session-history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: #fff;
    text-align: left;
    cursor: pointer;
}

.session-history-item span { color: var(--muted); font-size: .75rem; }
.session-history-item strong { font-size: .9rem; }

.session-history-table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
    font-size: .82rem;
}

.session-history-table th,
.session-history-table td {
    padding: 8px 6px;
    border-top: 1px solid var(--border);
    text-align: left;
}

.undo-round-context {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 650;
}

@media (max-width: 700px) {
    .play-state-banner { margin-top: -2px; font-size: .72rem; }
    .session-history-button { min-height: 32px; }
}


/* =========================================================
   FOLLOW-UP: MOBILE HISTORY + DOUBLE-ELIMINATION BRACKETS
========================================================= */
.mobile-session-history-button {
    margin-top: 12px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 750;
    cursor: pointer;
}

.tournament-bracket-section {
    margin-top: 20px;
}
.tournament-bracket-section:first-child { margin-top: 0; }
.tournament-bracket-section-title {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.tournament-bracket-section-rounds {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.tournament-bracket-loser,
.tournament-bracket-grand {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
@media (max-width: 700px) {
    .mobile-session-history-button { width: 100%; }
    .tournament-bracket-section-rounds { gap: 12px; }
}


/* =========================================================
   SESSION HISTORY STACKING — MOBILE SAFE
========================================================= */
.session-history-overlay {
    z-index: 13050;
}

@media (max-width: 700px) {
    .session-history-overlay {
        z-index: 13050;
        align-items: flex-start;
        overflow-y: auto;
        padding-top: max(14px, env(safe-area-inset-top));
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }
}


/* v5: full historical-session player names + clickable profiles */
.session-history-table .session-history-player-cell,
.session-history-table td:first-child {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
}

.history-player-name {
    display: inline;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.history-player-name:hover { text-decoration: underline; }

@media (max-width: 700px) {
    .mobile-summary-table.session-history-table { table-layout: auto; }
    .mobile-summary-table.session-history-table th:first-child,
    .mobile-summary-table.session-history-table td:first-child {
        width: 40%;
        min-width: 110px;
        text-align: left;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
    .mobile-summary-table.session-history-table th:not(:first-child),
    .mobile-summary-table.session-history-table td:not(:first-child) {
        white-space: nowrap;
    }
}


