/* ═══════════════════════════════════════════════════════════
 * bracket.css — visual tournament bracket
 *
 * Shared by the public arena (light) and the acpanel (dark). The
 * structure + light palette live on .wr-bracket; body.acpanel swaps
 * the palette for the dark admin panel. Rounds are columns; each pair
 * of matches is joined by connector lines into the next round, giving
 * the familiar bracket tree. Loaded after the theme so it wins.
 * ═══════════════════════════════════════════════════════════ */

.wr-bracket
{
    /* light palette (public arena) */
    --bkt-card-bg: #ffffff;
    --bkt-card-border: #e7e4f0;
    --bkt-text: #221f38;
    --bkt-muted: #6f6b85;
    --bkt-line: #d8d1ec;
    --bkt-win: #1c9c63;
    --bkt-win-bg: rgba(28, 156, 99, .10);
    --bkt-accent: #7b61ff;
    --bkt-amber: #b9791a;
    --bkt-h-gap: 26px;
    --bkt-card-w: 244px;

    display: flex;
    align-items: stretch;
    overflow-x: auto;
    padding: 4px 2px 12px;
}

/* dark palette (admin panel) */
body.acpanel .wr-bracket
{
    --bkt-card-bg: #17171b;
    --bkt-card-border: #2f2f37;
    --bkt-text: #f1f1f3;
    --bkt-muted: #a7a7b3;
    --bkt-line: #3b3b44;
    --bkt-win: #00b37e;
    --bkt-win-bg: rgba(0, 179, 126, .14);
    --bkt-accent: #a98bff;
    --bkt-amber: #f0a43c;
}

/* ── Rounds (columns) ── */
.wr-bkt-round
{
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    min-width: calc(var(--bkt-card-w) + var(--bkt-h-gap) * 2);
}

.wr-bkt-round.is-final
{
    min-width: var(--bkt-card-w);
}

.wr-bkt-round-title
{
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--bkt-muted);
    padding-left: 2px;
    margin-bottom: 12px;
}

.wr-bkt-round.is-final .wr-bkt-round-title
{
    color: var(--bkt-accent);
}

.wr-bkt-body
{
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1 1 auto;
    gap: 16px;
}

/* ── Pairs + connector lines ── */
.wr-bkt-pair
{
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    flex: 1 1 auto;
    gap: 16px;
    position: relative;
    margin-right: calc(var(--bkt-h-gap) * 2);
}

.wr-bkt-round.is-final .wr-bkt-pair
{
    margin-right: 0;
}

/* horizontal stub out of each match toward the spine */
.wr-bkt-round:not(.is-final) .wr-bkt-match::after
{
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    width: var(--bkt-h-gap);
    height: 2px;
    background: var(--bkt-line);
}

/* vertical spine joining the two matches of a pair */
.wr-bkt-round:not(.is-final) .wr-bkt-pair::before
{
    content: "";
    position: absolute;
    left: calc(100% + var(--bkt-h-gap));
    top: 25%;
    bottom: 25%;
    width: 2px;
    background: var(--bkt-line);
}

/* a lone match (bye) has no sibling to join */
.wr-bkt-round:not(.is-final) .wr-bkt-pair.is-solo::before
{
    display: none;
}

/* feed from the spine midpoint into the next round */
.wr-bkt-round:not(.is-final) .wr-bkt-pair::after
{
    content: "";
    position: absolute;
    left: calc(100% + var(--bkt-h-gap));
    top: 50%;
    width: var(--bkt-h-gap);
    height: 2px;
    background: var(--bkt-line);
}

/* ── Match card ── */
.wr-bkt-match
{
    position: relative;
    background: var(--bkt-card-bg);
    border: 1px solid var(--bkt-card-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(20, 16, 40, .05);
}

.wr-bkt-match.is-live
{
    border-color: var(--bkt-accent);
    box-shadow: 0 0 0 1px var(--bkt-accent), 0 2px 10px rgba(123, 97, 255, .18);
}

.wr-bkt-side
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    color: var(--bkt-text);
    font-size: .9rem;
}

.wr-bkt-side+.wr-bkt-side
{
    border-top: 1px solid var(--bkt-card-border);
}

.wr-bkt-side.is-winner
{
    /* background: var(--bkt-win-bg); */
    background: rgba(28, 156, 99, 0.1);
    color: var(--bkt-win);
    font-weight: 700;
}

.wr-bkt-side.is-tbd
{
    color: var(--bkt-muted);
}

.wr-bkt-name
{
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.wr-bkt-ava
{
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--bkt-accent), #5a44c9);
}

.wr-bkt-side.is-tbd .wr-bkt-ava
{
    background: var(--bkt-line);
    color: var(--bkt-muted);
}

.wr-bkt-pname
{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 128px;
}

/* Bold the logged-in player everywhere they appear, so their path through the
   bracket stands out at a glance. */
.wr-bkt-side.is-you
{
    /* background-color: #dbecad; */
    background-color: #aedfea;
    color: #000;
}

.wr-bkt-side.is-you .wr-bkt-pname
{
    font-weight: 800;
}

.wr-bkt-you
{
    font-style: normal;
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .05em;
    /* color: var(--bkt-accent); */
    color: red;
    text-transform: uppercase;
    margin-left: 1px;
}

/* "bot" chip — marks an automated player so humans know who's not real */
.wr-bkt-bot
{
    font-style: normal;
    font-size: .56rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bkt-muted);
    background: var(--bkt-line);
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 2px;
}

.wr-bkt-score
{
    font-family: ui-monospace, SFMono-Regular, Menlo, "JetBrains Mono", monospace;
    font-weight: 700;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ── Footer (status + timing) ── */
.wr-bkt-foot
{
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: .66rem;
    color: var(--bkt-muted);
    border-top: 1px dashed var(--bkt-card-border);
}

.wr-bkt-status
{
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.wr-bkt-match.is-live .wr-bkt-status
{
    color: var(--bkt-accent);
}

.wr-bkt-match.is-done .wr-bkt-status
{
    color: var(--bkt-win);
}

.wr-bkt-match.is-pending .wr-bkt-status
{
    color: var(--bkt-amber);
}

.wr-bkt-due
{
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px)
{
    .wr-bracket
    {
        --bkt-card-w: 200px;
        --bkt-h-gap: 18px;
    }

    .wr-bkt-pname
    {
        max-width: 100px;
    }
}