/* =====================================================
   Swiss Tournament View
   ===================================================== */

.swiss-page {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-bottom: 60px;
    margin-top: 2%;
}

/* ── Tabs ──────────────────────────────────────────── */
.swiss-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px 16px 0;
}

.swiss-tab {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    font-family: Montserrat, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 16px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.swiss-tab:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.swiss-tab-active {
    background: rgba(34,197,94,0.15);
    border-color: rgba(34,197,94,0.4);
    color: #22c55e;
}

.swiss-tab-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Layout ────────────────────────────────────────── */
.swiss-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    width: clamp(20rem, 94%, 1100px);
    align-items: start;
}

@media (max-width: 780px) {
    .swiss-layout {
        grid-template-columns: 1fr;
    }
    .swiss-standings-col {
        position: static;
    }
    .swiss-host-controls {
        flex-wrap: wrap;
    }
    .swiss-host-danger {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .swiss-page {
        gap: 12px;
    }
    .swiss-tabs {
        padding: 8px 10px 0;
        gap: 4px;
        width: 100%;
        box-sizing: border-box;
    }
    .swiss-tab {
        padding: 5px 12px;
        font-size: 0.75rem;
    }
    .swiss-match {
        padding: 12px 14px;
    }
    .swiss-matchup {
        gap: 6px;
    }
    .swiss-team {
        font-size: 0.82rem;
    }
    .swiss-score {
        font-size: 0.95rem;
    }
    .swiss-host-controls {
        padding: 12px 14px;
        gap: 10px;
    }
    .swiss-host-danger {
        justify-content: center;
    }
    .sf-banner-title {
        font-size: 1.3rem;
    }
    .sf-podium {
        gap: 6px;
        padding: 6px 8px 0;
    }
    .sf-podium-name {
        font-size: 0.78rem;
        max-width: 90px;
    }
}

.swiss-col-title {
    font-family: Montserrat, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 10px;
}

/* ── Group header ──────────────────────────────────── */
.swiss-group-header {
    font-family: Montserrat, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: rgb(94, 94, 94);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.swiss-group-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.05);
}

/* ── Match card ────────────────────────────────────── */
.swiss-matches-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.swiss-match {
    background: #15151b;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 14px 18px;
    font-family: Montserrat, sans-serif;
    animation: swissFadeIn 0.25s ease both;
    transition: border-color 120ms ease;
}

.swiss-match:hover {
    border-color: rgba(255,255,255,0.1);
}

@keyframes swissFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.swiss-match-done       { border-left: 3px solid rgba(34,197,94,0.35); }
.swiss-match-pending    { border-left: 3px solid rgba(255,255,255,0.08); }
.swiss-match-inprogress { border-left: 3px solid rgba(250,176,5,0.5); }

.swiss-match-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.swiss-match-label {
    font-size: 0.65rem;
    color: #4e5261;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.swiss-badge {
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.swiss-badge-done       { background: rgba(34,197,94,0.12);   color: #4ade80; }
.swiss-badge-pending    { background: rgba(255,255,255,0.05); color: #4e5261; }
.swiss-badge-inprogress { background: rgba(250,176,5,0.12);   color: #fab005; }

/* ── Matchup row ───────────────────────────────────── */
.swiss-matchup {
    display: flex;
    align-items: center;
    gap: 10px;
}

.swiss-team {
    flex: 1;
    font-size: 0.92rem;
    font-weight: 500;
    color: #c4c9de;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.swiss-team-right {
    text-align: right;
}

.swiss-team-winner { color: #4ade80; font-weight: 600; }
.swiss-team-loser  { color: #5e6378; }

.swiss-score-display {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 70px;
    justify-content: center;
}

.swiss-score {
    font-size: 1.05rem;
    font-weight: 700;
    color: #7a8099;
    min-width: 20px;
    text-align: center;
}

.swiss-score-win { color: #4ade80; }

@keyframes swissScorePop {
    0%   { transform: scale(1);    text-shadow: none; }
    35%  { transform: scale(1.5);  text-shadow: 0 0 8px #4ade80, 0 0 18px #4ade80; }
    100% { transform: scale(1);    text-shadow: none; }
}
.swiss-score-pop {
    animation: swissScorePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    display: inline-block;
}

.swiss-score-sep {
    color: #7e7e7e;
    font-size: 0.9rem;
}

/* ── Score form ────────────────────────────────────── */
.swiss-score-form {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.swiss-score-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.swiss-score-inputs label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.swiss-score-inputs input[type="number"] {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #fff;
    font-family: Montserrat, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 6px 10px;
    width: 70px;
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}

.swiss-score-inputs input[type="number"]:focus {
    border-color: rgba(34,197,94,0.5);
}

.swiss-vs {
    color: rgba(255,255,255,0.25);
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 16px;
}

.swiss-btn-submit {
    align-self: flex-start;
    background: rgba(34,197,94,0.15);
    border: 1px solid rgba(34,197,94,0.35);
    border-radius: 8px;
    color: #22c55e;
    cursor: pointer;
    font-family: Montserrat, sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 7px 18px;
    transition: background 0.15s, border-color 0.15s;
}

.swiss-btn-submit:hover:not(:disabled) {
    background: rgba(34,197,94,0.25);
    border-color: rgba(34,197,94,0.6);
}

.swiss-btn-submit--saving,
.swiss-btn-submit:disabled {
    background: rgba(34,197,94,0.07);
    border-color: rgba(34,197,94,0.15);
    color: rgba(34,197,94,0.45);
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Standings table ───────────────────────────────── */
.swiss-standings-col {
    position: sticky;
    display: flex;
    flex-direction: column;
    gap:10px;
    top: 80px;
}

.swiss-table-wrapper {
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
    overflow-x: auto;
}

.swiss-table {
    width: 100%;
    border-collapse: collapse;
    font-family: Montserrat, sans-serif;
    font-size: 0.82rem;
    background: #15151b;
    border-radius: 16px;
    overflow: hidden;
}

.swiss-table thead {
    background: #222529a8;
}

.swiss-table thead th {
    color: #4e5261;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    padding: 8px 12px;
    text-align: left;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.swiss-table thead th:not(:first-child):not(:nth-child(2)) {
    text-align: center;
}

.swiss-row {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 120ms ease;
}

.swiss-row:last-child { border-bottom: none; }

.swiss-row:hover td { background: rgba(255,255,255,0.03); }

.swiss-row td {
    padding: 11px 12px;
    color: #b0b5cc;
}

.swiss-row-self td { color: #22c55e !important; }
.swiss-row-self:hover td { background: rgba(34,197,94,0.06) !important; }

.swiss-rank {
    color: #5e6378 !important;
    font-size: 0.8rem;
    font-weight: 600;
    width: 28px;
}

.swiss-row-self .swiss-rank { color: rgba(34,197,94,0.7) !important; }

.swiss-team-name {
    font-weight: 500;
    color: #c4c9de !important;
    display:flex;
    justify-content: space-between;
}

.swiss-wins, .swiss-losses, .swiss-buchholz {
    text-align: center;
    font-weight: 600;
}

.swiss-wins     { color: #b0b5cc !important; }
.swiss-losses   { color: #b0b5cc !important; }
.swiss-buchholz { color: #5e6378 !important; }

/* ── Place colours ─────────────────────────────────── */
.swiss-row.place-1 td { color: #fdd064 !important; font-weight: 600; }
.swiss-row.place-2 td { color: #dfdfdf !important; font-weight: 600; }
.swiss-row.place-3 td { color: #e3b188 !important; font-weight: 600; }
.swiss-row.place-1 .swiss-team-name,
.swiss-row.place-2 .swiss-team-name,
.swiss-row.place-3 .swiss-team-name { font-weight: 600; }

/* ── Header tooltip ────────────────────────────────── */
.th-tip {
    cursor: default;
    border-bottom: 1px dashed rgba(255,255,255,0.25);
    padding-bottom: 1px;
}

#th-tooltip {
    position: fixed;
    background: #1e2533;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    color: rgba(255,255,255,0.85);
    font-family: Montserrat, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    padding: 4px 9px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
}

#th-tooltip.th-tooltip--visible { opacity: 1; }

/* ── Host controls ─────────────────────────────────── */
.swiss-host-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 14px 20px;
    width: clamp(20rem, 94%, 1100px);
    box-sizing: border-box;
}

.swiss-host-danger {
    display: flex;
    gap: 10px;
    width: clamp(20rem, 94%, 1100px);
    justify-content: flex-end;
}

.swiss-host-danger .psBtn--finish {
    background: rgba(34,197,94,0.1);
    border-color: rgba(34,197,94,0.3);
    color: #22c55e;
}

.swiss-host-danger .psBtn--cancel {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: #ef4444;
}

.swiss-host-danger .psBtn--reset-trn {
    background: rgba(245,158,11,0.1);
    border-color: rgba(245,158,11,0.3);
    color: #f59e0b;
}

.swiss-btn-next {
    background: rgba(34,197,94,0.15);
    border: 1px solid rgba(34,197,94,0.35);
    border-radius: 8px;
    color: #22c55e;
    cursor: pointer;
    font-family: Montserrat, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 22px;
    transition: background 0.15s, border-color 0.15s;
}

.swiss-btn-next:hover:not(:disabled) {
    background: rgba(34,197,94,0.25);
    border-color: rgba(34,197,94,0.6);
}

.swiss-btn-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.swiss-btn-reset {
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 8px;
    color: #f59e0b;
    cursor: pointer;
    font-family: Montserrat, sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 18px;
    transition: background 0.15s, border-color 0.15s;
}

.swiss-btn-reset:hover:not(:disabled) {
    background: rgba(245,158,11,0.2);
    border-color: rgba(245,158,11,0.55);
}

.swiss-btn-reset:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Edit score ────────────────────────────────────── */

.swiss-edit-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    margin-left: auto;
    transition: background 0.15s;
}

.swiss-edit-btn:hover,
.swiss-edit-btn--active {
    background: rgba(255,255,255,0.08);
}

.swiss-inline-edit {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0 4px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 8px;
}

.swiss-score-input-edit {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #fff;
    font-family: Montserrat, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 6px 10px;
    width: 70px;
    text-align: center;
    outline: none;
    transition: border-color 0.15s;
}

.swiss-score-input-edit:focus {
    border-color: rgba(245,158,11,0.5);
}

.swiss-host-hint {
    font-family: Montserrat, sans-serif;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.35);
}

/* ── Modal dual-score layout ───────────────────────── */
.swiss-dual-score-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 8px 0 4px;
    flex-wrap: wrap;
}

.swiss-score-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.swiss-score-label {
    font-family: Montserrat, sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255,255,255,0.45);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.swiss-versus-sep {
    opacity: 0.25;
    padding: 0 4px;
    margin-top: 20px;
}

.swiss-versus-sep img {
    width: 22px;
    height: 22px;
}

/* ── Score stepper ─────────────────────────────────── */
.edit-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.edit-stepper-minus,
.edit-stepper-plus {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-family: Montserrat, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1;
    padding: 0;
}

.edit-stepper-minus:hover:not(:disabled),
.edit-stepper-plus:hover:not(:disabled) {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.25);
}

.edit-stepper-minus:disabled,
.edit-stepper-plus:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.edit-stepper-val {
    font-family: Montserrat, sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    min-width: 28px;
    text-align: center;
}

/* ── States ────────────────────────────────────────── */
.swiss-loading, .swiss-empty, .swiss-error {
    font-family: Montserrat, sans-serif;
    font-size: 0.88rem;
    color: rgba(255,255,255,0.3);
    padding: 20px 0;
    text-align: center;
}

.swiss-error { color: rgba(239,68,68,0.7); }

/* ── Roster expand ─────────────────────────────────── */
.sr-expand-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    transition: background 0.12s;
}

.sr-expand-btn:hover { background: rgba(255,255,255,0.07); }

.sr-expand-btn img { transition: transform 0.2s; }

.sr-roster-row td {
    padding: 4px 12px 10px !important;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sr-roster {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sr-member {
    font-family: Montserrat, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 20px;
    padding: 3px 10px;
}

.sr-captain {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fab005;
    margin-left: 4px;
}

/* ── Finished panel ────────────────────────────────── */
.sf-banner {
    text-align: center;
    padding: 28px 20px 16px;
}

.sf-banner-label {
    font-family: Montserrat, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.3);
}

.sf-banner-title {
    font-family: Montserrat, sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    margin: 6px 0 0;
    letter-spacing: 0.02em;
}

/* Podium */
.sf-podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    padding: 10px 20px 0;
}

.sf-podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 220px;
}

.sf-podium-medal {
    font-size: 2rem;
    margin-bottom: 8px;
}

.sf-podium-name {
    font-family: Montserrat, sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin-bottom: 4px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sf-podium-record {
    font-family: Montserrat, sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255,255,255,0.35);
    margin-bottom: 10px;
}

.sf-podium-block {
    width: 100%;
    border-radius: 8px 8px 0 0;
}

.sf-block-1 { height: 80px; background: rgba(253,208,100,0.15); border: 1px solid rgba(253,208,100,0.3); border-bottom: none; }
.sf-block-2 { height: 54px; background: rgba(223,223,223,0.08); border: 1px solid rgba(223,223,223,0.2);  border-bottom: none; }
.sf-block-3 { height: 36px; background: rgba(227,177,136,0.08); border: 1px solid rgba(227,177,136,0.2);  border-bottom: none; }

.sf-place-1 .sf-podium-name { color: #fdd064; }
.sf-place-2 .sf-podium-name { color: #dfdfdf; }
.sf-place-3 .sf-podium-name { color: #e3b188; }

/* Full standings table */
.sf-table-wrap {
    border-radius: 0 0 16px 16px;
    border: 1px solid rgba(255,255,255,0.06);
    border-top: none;
    overflow-x: auto;
    margin-top: 0;
}
