/*
 * Tournament page (nhl/tournaments/tournament.html) + its modals (matchup, register, edit roster).
 * Loaded after dashboard/css/dashboard.css, whose tokens (--d-*), buttons (.dbtn), pills and cards it reuses.
 *
 * Bracket layout: two sides that meet at the final. Every round is a column whose games area has the same height;
 * games are grouped in pairs that feed one game in the next round. Because each group takes an equal share of the
 * column (flex: 1), a next-round game always sits exactly level with the middle of its two feeders, so the
 * connector lines are pure CSS (no JS measuring).
 */

/* The page wrapper is a size container, so the bracket can size itself to the visible width
   (cqw excludes the scrollbar; 100vw would not). */
.tpage-wrap {
    container-type: inline-size;
}

.tpage {
    --bk-gap: 34px;                 /* space between round columns; connectors live in it */
    --bk-line: hsla(0, 0%, 100%, 0.16);
    --bk-line-won: var(--d-accent-line);
}

/* ---------- Header ---------- */

.t-crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 13.5px;
    color: var(--d-faint);
}

.dash .t-crumbs a {
    color: var(--d-muted);
}

.dash .t-crumbs a:hover {
    color: #fff;
}

.t-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px 28px;
    margin-bottom: 18px;
}

.t-head__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.tpage h1.t-head__title {
    font-size: clamp(1.6rem, 1.1rem + 1.8vw, 2.4rem);
    letter-spacing: -0.01em;
}

.t-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin-top: 10px;
    font-size: 14.5px;
    color: var(--d-muted);
}

.t-meta-row > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.t-meta-row i {
    color: var(--d-faint);
}

.t-meta-row strong {
    font-weight: 500;
    color: #fff;
}

.t-meta-row .t-prize {
    color: var(--d-accent);
    font-weight: 700;
}

/* "Presented by [logo]" under the title (sponsored tournaments) */
.t-sponsor {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 12px;
}

.t-sponsor__label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--d-faint);
}

.t-sponsor__brand {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: #fff;
}

.t-sponsor .sponsor-logo {
    --logo-h: 30px;
    --logo-max-w: 180px;
}

.dash a.t-sponsor__brand {
    transition: opacity .15s ease;
}

.dash a.t-sponsor__brand:hover {
    color: #fff;
    opacity: .8;
}

/* sponsor box beside the registered teams, before the start */
.t-sponsor-card__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 18px 18px;
}

.t-sponsor-card .sponsor-logo {
    --logo-h: 40px;
    --logo-max-w: 220px;
    margin-bottom: 6px;
}

.t-sponsor-card__name {
    font-weight: 600;
    color: #fff;
}

.t-sponsor-card__body p {
    font-size: 14px;
    color: var(--d-muted);
}

.t-sponsor-card__body .dbtn {
    margin-top: 4px;
}

.t-head__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.t-head__actions form {
    margin: 0;
}

/* champion banner */
.t-champion {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px 20px;
    border: 1px solid hsla(45, 90%, 60%, 0.35);
    border-radius: var(--d-radius);
    background: radial-gradient(120% 180% at 0% 0%, hsla(45, 90%, 55%, 0.16), transparent 60%), var(--d-bg-card);
}

.t-champion__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: hsla(45, 90%, 55%, 0.16);
    color: hsla(45, 95%, 62%, 1);
    font-size: 20px;
}

.t-champion img {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    object-fit: cover;
}

.t-champion__actions {
    margin-left: auto;
}

.t-champion__actions form {
    margin: 0;
}

.t-champion__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: hsla(45, 95%, 62%, 1);
}

.t-champion__name {
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

/* results-reporting info */
.t-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 22px;
    padding: 14px 18px;
    border: 1px solid var(--d-border);
    border-radius: var(--d-radius);
    background: var(--d-bg-card);
    font-size: 14px;
    color: var(--d-muted);
}

.t-info > i {
    color: var(--d-info);
    font-size: 16px;
}

.t-info__text {
    flex: 1 1 420px;
}

.t-info__text strong {
    color: #fff;
    font-weight: 500;
}

.t-info__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- Before it starts: teams + waitlist ---------- */

.t-pre {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

@media (max-width: 860px) {
    .t-pre { grid-template-columns: 1fr; }
}

.t-capacity {
    padding: 14px 18px 16px;
    border-bottom: 1px solid var(--d-border);
}

.t-capacity__row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13.5px;
    color: var(--d-muted);
}

.t-capacity__row strong {
    color: #fff;
}

.t-teams {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.t-team {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    border-bottom: 1px solid hsla(0, 0%, 100%, 0.05);
}

.t-team img {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: cover;
    border: 1px solid var(--d-border);
}

.t-team__name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-team.is-mine .t-team__name {
    color: var(--d-accent);
}

.t-seed {
    display: inline-grid;
    place-items: center;
    flex: none;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    background: hsla(0, 0%, 100%, 0.07);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--d-muted);
    font-variant-numeric: tabular-nums;
}

.t-starts {
    padding: 18px;
    text-align: center;
}

.t-starts__icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin: 0 auto 10px;
    border-radius: 13px;
    background: var(--d-info-soft);
    color: var(--d-info);
    font-size: 18px;
}

.t-starts__when {
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.t-starts p {
    margin-top: 6px;
    font-size: 13.5px;
    color: var(--d-muted);
}

/* ---------- Bracket ---------- */

.bk-card {
    /* Break out of the 1200px page column so a 16/32-team bracket fits on wide screens (scrolls when it can't). */
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    width: min(1720px, calc(100cqw - 48px));
    max-width: none;
    border: 1px solid var(--d-border);
    border-radius: var(--d-radius);
    background: var(--d-bg-card);
}

.bk-scroll {
    overflow-x: auto;
    padding: 18px 20px 26px;
}

.bk {
    /* --cols (round columns incl. the final) is set inline from the view. Card width shares the bracket card's
       width between the columns, within 148-220px; narrower screens scroll. Declared here, where --cols is set,
       because custom properties resolve where they're declared. */
    --cols: 7;
    --bk-col: clamp(148px, calc((min(1720px, 100cqw - 48px) - 62px - (var(--cols) - 1) * var(--bk-gap)) / var(--cols)), 220px);
    display: flex;
    align-items: stretch;
    gap: var(--bk-gap);
    width: max-content;
    min-width: 100%;
    justify-content: center;
}

.bk-side {
    display: flex;
    gap: var(--bk-gap);
}

.bk-round {
    display: flex;
    flex-direction: column;
    width: var(--bk-col);
}

.bk-round__label {
    height: 30px;
    margin-bottom: 6px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
    color: var(--d-faint);
    white-space: nowrap;
}

.bk-round__games {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bk-group {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bk-cell {
    display: flex;
    align-items: center;
    flex: 1;
    min-height: 100px;
    padding: 6px 0 18px;
}

/* connectors, left side: a "]" joining the pair, then a stub into the next round */
.bk-side--left .bk-group::after,
.bk-side--right .bk-group::after {
    content: "";
    position: absolute;
    top: calc(25% - 6px);
    bottom: calc(25% + 6px);
    width: calc(var(--bk-gap) / 2);
    border: 2px solid var(--bk-line);
}

.bk-side--left .bk-group::after {
    right: calc(var(--bk-gap) / -2);
    border-left: 0;
    border-radius: 0 8px 8px 0;
}

.bk-side--right .bk-group::after {
    left: calc(var(--bk-gap) / -2);
    border-right: 0;
    border-radius: 8px 0 0 8px;
}

.bk-side--left .bk-group::before,
.bk-side--right .bk-group::before {
    content: "";
    position: absolute;
    top: calc(50% - 7px);
    width: calc(var(--bk-gap) / 2);
    border-top: 2px solid var(--bk-line);
}

.bk-side--left .bk-group::before { right: calc(var(--bk-gap) * -1); }
.bk-side--right .bk-group::before { left: calc(var(--bk-gap) * -1); }

/* a single game (the last round on each side) runs straight into the final */
.bk-group--single::after {
    display: none;
}

.bk-side--left .bk-group--single::before,
.bk-side--right .bk-group--single::before {
    width: var(--bk-gap);
}

/* the final, in the middle */
.bk-center {
    display: flex;
    flex-direction: column;
    width: calc(var(--bk-col) + 20px);
}

.bk-center .bk-round__label {
    color: hsla(45, 95%, 62%, 1);
}

.bk-center__body {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    min-height: 250px;              /* room for the trophy above and the champion below, even in a 4-team bracket */
    padding-bottom: 12px;
}

.bk-center__trophy {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(50% + 50px);
    display: flex;
    justify-content: center;
}

.bk-center__champ {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(50% + 58px);          /* below the final card AND its "Matchup" link */
    text-align: center;
}

.bk-center__trophy > i {
    font-size: 34px;
    color: hsla(45, 95%, 60%, 1);
    filter: drop-shadow(0 6px 18px hsla(45, 95%, 50%, 0.35));
}

.bk-center__trophy.is-empty > i {
    color: hsla(0, 0%, 100%, 0.18);
    filter: none;
}

.bk-center__champ {
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.bk-center__champ small {
    display: block;
    font-family: 'Roboto', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: hsla(45, 95%, 62%, 1);
}

.bk-center .bk-game {
    border-color: hsla(45, 90%, 60%, 0.35);
}

/* game card */
.bk-game {
    position: relative;
    width: 100%;
    border: 1px solid var(--d-border-strong);
    border-radius: 10px;
    background: var(--d-bg-raised);
    box-shadow: 0 8px 20px -14px hsla(0, 0%, 0%, 0.9);
}

.bk-game.is-mine {
    border-color: var(--d-accent-line);
    box-shadow: 0 0 0 3px var(--d-accent-soft);
}

.bk-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 10px 0 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--d-text);
}

.bk-slot + .bk-slot {
    border-top: 1px solid var(--d-border);
}

.bk-slot img {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    object-fit: cover;
}

.bk-slot .t-seed {
    min-width: 21px;
    height: 19px;
    padding: 0 4px;
    font-size: 10.5px;
}

.bk-slot__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bk-slot__mark {
    flex: none;
    font-size: 12px;
    color: var(--d-accent);
}

.bk-slot.is-winner {
    color: #fff;
    font-weight: 700;
    background: linear-gradient(90deg, hsla(125, 100%, 68%, 0.10), transparent 70%);
    box-shadow: inset 3px 0 0 var(--d-accent);
}

.bk-slot.is-winner:first-child { border-top-left-radius: 9px; border-top-right-radius: 9px; }
.bk-slot.is-winner:nth-child(2) { border-bottom-left-radius: 9px; border-bottom-right-radius: 9px; }

.bk-slot.is-loser {
    color: var(--d-faint);
}

.bk-slot.is-loser img {
    opacity: .45;
    filter: grayscale(0.6);
}

.bk-slot.is-mine .bk-slot__name {
    color: var(--d-accent);
}

.bk-slot.is-empty {
    color: var(--d-faint);
    font-style: italic;
    font-weight: 400;
}

.bk-slot.is-empty .t-seed {
    visibility: hidden;
}

.bk-game__link {
    position: absolute;
    left: 50%;
    bottom: -19px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--d-bg-card);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--d-accent);
}

.dash a.bk-game__link {
    color: var(--d-accent);
}

.dash a.bk-game__link:hover {
    text-decoration: underline;
}

.bk-game.is-mine .bk-game__link {
    background: var(--d-accent);
}

.dash .bk-game.is-mine a.bk-game__link {
    color: #06080a;
}

.bk-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 12.5px;
    color: var(--d-muted);
}

.bk-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.bk-legend i {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* staff bracket editor (update_bracket.css adds the hover outline) */
.bk-slot.selectable:hover {
    background: hsla(125, 100%, 68%, 0.08);
}

/* ---------- Matchup modal ---------- */

.mu-teams {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
}

.mu-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    border: 1px solid hsla(0, 0%, 100%, 0.09);
    border-radius: 12px;
    background: hsla(0, 0%, 100%, 0.025);
    text-align: center;
}

.mu-team.winner {
    border-color: hsla(125, 100%, 68%, 0.4);
    background: hsla(125, 100%, 68%, 0.07);
}

.mu-team.loser {
    opacity: .6;
}

.mu-team img {
    width: 52px;
    height: 52px;
    border-radius: 13px;
    object-fit: cover;
}

.mu-team__name {
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    overflow-wrap: anywhere;
}

.mu-team__seed {
    font-size: 12px;
    color: hsla(0, 0%, 100%, 0.5);
}

.mu-roster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-top: 2px;
}

.mu-roster span {
    padding: 2px 8px;
    border-radius: 999px;
    background: hsla(0, 0%, 100%, 0.07);
    font-size: 12px;
    color: hsla(0, 0%, 100%, 0.8);
}

.mu-roster span.active {
    background: hsla(125, 100%, 68%, 0.14);
    color: var(--primary, #5AFF67);
}

.mu-vs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 30px;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 15px;
    font-weight: 800;
    color: hsla(0, 0%, 100%, 0.35);
}

.mu-vs small {
    font-family: 'Roboto', sans-serif;
    font-size: 11.5px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    color: hsla(0, 0%, 100%, 0.6);
}

.mu-code {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px dashed hsla(125, 100%, 68%, 0.45);
    border-radius: 12px;
    background: hsla(125, 100%, 68%, 0.06);
}

.mu-code__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: hsla(0, 0%, 100%, 0.6);
}

.mu-code__value {
    font-family: 'Montserrat', 'Roboto', monospace;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: var(--primary, #5AFF67);
}

.mu-panel {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid hsla(0, 0%, 100%, 0.09);
}

.mu-reports {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.mu-reports div {
    padding: 9px 12px;
    border-radius: 10px;
    background: hsla(0, 0%, 100%, 0.04);
    font-size: 12.5px;
    color: hsla(0, 0%, 100%, 0.55);
}

.mu-reports strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.mu-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
}

.mu-actions .dbtn {
    padding: 11px 14px;
}

.mu-status {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid hsla(0, 0%, 100%, 0.1);
    background: hsla(0, 0%, 100%, 0.03);
    font-size: 13.5px;
    line-height: 1.5;
    color: hsla(0, 0%, 100%, 0.75);
}

.mu-status[hidden] {
    display: none;
}

.mu-status > i {
    margin-top: 3px;
}

.mu-status a {
    color: var(--primary, #5AFF67);
    font-weight: 600;
    text-decoration: underline;
}

.mu-status--ok { border-color: hsla(125, 100%, 68%, 0.35); background: hsla(125, 100%, 68%, 0.07); }
.mu-status--ok > i { color: var(--primary, #5AFF67); }
.mu-status--warn { border-color: hsla(40, 95%, 60%, 0.4); background: hsla(40, 95%, 60%, 0.09); }
.mu-status--warn > i { color: hsla(40, 95%, 60%, 1); }
.mu-status--info > i { color: hsla(210, 95%, 68%, 1); }

.mu-noshow {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed hsla(0, 0%, 100%, 0.1);
}

.mu-noshow form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.mu-noshow .dbtn:disabled {
    opacity: .45;
    cursor: not-allowed;
    filter: none;
}

.no-show-help {
    font-size: 12.5px;
    color: hsla(0, 0%, 100%, 0.55);
}

/* ---------- Register / edit roster modals ---------- */

.reg-note {
    margin-top: 6px;
    font-size: 12.5px;
    color: hsla(0, 0%, 100%, 0.5);
}

#roster-title {
    display: none;
    margin-top: 18px;
}

#roster-title.is-static {
    display: block;
}

#roster-title h3 {
    margin: 0;
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-size: 15px;
    color: #fff;
}

#members-container {
    margin-top: 8px;
}

/* Choices.js (roster picker), dark theme */
.dash-modal .choices {
    margin: 0;
}

.dash-modal .choices__inner {
    min-height: 44px;
    padding: 6px 8px;
    border: 1px solid hsla(0, 0%, 100%, 0.18);
    border-radius: 9px;
    background: hsla(0, 0%, 100%, 0.04);
    color: #fff;
    font-size: 14px;
}

.dash-modal .is-focused .choices__inner,
.dash-modal .is-open .choices__inner {
    border-color: var(--primary, #5AFF67);
}

.dash-modal .choices__list--multiple .choices__item {
    border: 0;
    border-radius: 999px;
    background: hsla(125, 100%, 68%, 0.16);
    color: var(--primary, #5AFF67);
    font-weight: 600;
}

.dash-modal .choices[data-type*="select-multiple"] .choices__button {
    border-left-color: hsla(125, 100%, 68%, 0.35);
    filter: invert(1) hue-rotate(180deg);
}

.dash-modal .choices__input {
    background: transparent;
    color: #fff;
}

.dash-modal .choices__list--dropdown,
.dash-modal .choices__list[aria-expanded] {
    border: 1px solid hsla(0, 0%, 100%, 0.18);
    border-radius: 9px;
    background: #11161b;
    color: #fff;
}

.dash-modal .choices__list--dropdown .choices__item--selectable.is-highlighted,
.dash-modal .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
    background: hsla(0, 0%, 100%, 0.07);
}

/* Laptop widths: slightly tighter columns so a 16-team bracket still fits without scrolling. */
@media (max-width: 1440px) {
    .tpage { --bk-gap: 28px; }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .tpage { --bk-gap: 28px; }
    .bk { --bk-col: 170px; }
    .t-head__actions { width: 100%; }
    .t-head__actions .dbtn, .t-head__actions form { flex: 1 1 auto; }
    .t-head__actions form .dbtn { width: 100%; }
    .mu-teams { grid-template-columns: 1fr; }
    .mu-vs { flex-direction: row; justify-content: center; padding: 0; }
    .mu-reports, .mu-actions { grid-template-columns: 1fr; }
}
