/* ============================================================
   tournament.css — Torneo de coasters (tournament.php)
   Bordes rectos, verdes de la web y protagonismo de las fotos.
   ============================================================ */

/* ── PORTADA ────────────────────────────────────────────────── */
.tournament-hero {
    position: relative;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

/* Foto de portada (la sube el admin) con degradado oscuro encima */
.tournament-hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0a1628 0%, #0f2027 40%, #0b3d2e 70%, #0a1628 100%);
    background-size: cover;
    background-position: center;
    z-index: 0;
}

.tournament-hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10, 22, 40, 0.96) 0%, rgba(10, 22, 40, 0.6) 50%, rgba(10, 22, 40, 0.2) 100%);
}

.tournament-hero-content {
    position: relative;
    z-index: 2;
    padding: 2.5rem 2rem 1.25rem;
    width: 100%;
}

.tournament-hero-eyebrow {
    font-family: var(--rcw-font-title);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--rcw-green-neon);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tournament-title {
    display: flex;
    flex-direction: column;
    line-height: 1;
    margin: 0 0 0.75rem;
}

.tournament-title-main,
.tournament-title-accent {
    font-family: var(--rcw-font-title);
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.02em;
    line-height: 0.95;
}

.tournament-title-accent {
    color: var(--rcw-green-neon);
}

.tournament-title-year {
    font-family: var(--rcw-font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--rcw-text-muted);
    letter-spacing: 0.2em;
    margin-top: 0.5rem;
}

/* Estado: en directo / empieza en… (bloque verde relleno) */
.tn-status {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: stretch;
    background: rgba(10, 22, 40, 0.85);
    font-family: var(--rcw-font-title);
    font-size: 0.9rem;
    color: #fff;
}

.tn-status > * {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
}

.tn-live {
    background: #198754;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    gap: 0.5rem;
}

.tn-live .fa-circle {
    font-size: 0.55rem;
    animation: tnPulse 1.4s ease-in-out infinite;
}

.tn-live.is-soon {
    background: #146c43;
}

.tn-status-time {
    color: #6ee7b7;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.tn-status-time b {
    margin-left: 0.35rem;
    color: #fff;
}

@keyframes tnPulse {
    50% { opacity: 0.25; }
}

.tournament-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}

.tournament-subtitle {
    font-size: 1.1rem;
    color: var(--rcw-text-secondary);
    margin: 0;
    font-weight: 300;
    line-height: 1.5;
}

/* ── PESTAÑAS ───────────────────────────────────────────────── */
.tournament-nav {
    display: flex;
    background: var(--rcw-bg-card);
    border-bottom: 1px solid var(--rcw-border);
    margin-bottom: 2rem;
}

.tournament-nav-btn {
    flex: 0 0 auto;
    padding: 1rem 1.5rem;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--rcw-text-muted);
    font-family: var(--rcw-font-body);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--rcw-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tournament-nav-btn:hover {
    color: var(--rcw-text-primary);
    background: var(--rcw-bg-hover);
}

.tournament-nav-btn.active {
    color: #fff;
    background: #198754;
    border-bottom-color: #6ee7b7;
}

.tournament-nav-admin {
    margin-left: auto;
}

.tournament-tab {
    display: none;
    padding-bottom: 4rem;
}

.tournament-tab.active {
    display: block;
}

.tournament-section-title {
    font-family: var(--rcw-font-title);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rcw-text-secondary);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--rcw-border);
}

.text-neon {
    color: var(--rcw-green-neon);
}

.tournament-loading {
    text-align: center;
    padding: 4rem;
    color: var(--rcw-text-muted);
    grid-column: 1 / -1;
}

.tournament-empty {
    grid-column: 1 / -1;
}

.tournament-empty i {
    display: block;
    font-size: 2rem;
    opacity: 0.3;
    margin-bottom: 0.75rem;
}

/* ── PRÓXIMOS DUELOS / CAMPEONA ─────────────────────────────── */
.tn-next {
    display: flex;
    align-items: stretch;
    background: #0f5132;
    margin-bottom: 2rem;
}

.tn-next-photo {
    width: 280px;
    max-width: 40%;
    object-fit: cover;
    flex-shrink: 0;
}

.tn-next-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.5rem;
}

.tn-next-kicker {
    font-family: var(--rcw-font-title);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6ee7b7;
}

.tn-next-title {
    font-family: var(--rcw-font-title);
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.15;
}

.tn-next-sub {
    color: rgba(255, 255, 255, 0.75);
}

.tn-next-count {
    font-family: var(--rcw-font-title);
    font-size: 2.6rem;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.tn-next-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: #0a3622;
}

.tn-next-actions .btn-outline-secondary {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

.tn-champion {
    background: #198754;
}

/* ── TARJETA DE DUELO ───────────────────────────────────────── */
.tournament-matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 1.5rem;
}

.tournament-match-card {
    background: var(--rcw-bg-card);
    border: 1px solid var(--rcw-border);
    position: relative;
}

.tournament-match-card.match-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--rcw-green-neon);
    z-index: 3;
}

.tournament-match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--rcw-bg-card-alt);
    border-bottom: 1px solid var(--rcw-border);
}

.tournament-match-phase {
    font-family: var(--rcw-font-title);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--rcw-green-neon);
}

.tournament-match-timer {
    font-family: var(--rcw-font-title);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--rcw-text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-variant-numeric: tabular-nums;
}

.tournament-match-timer.timer-active {
    color: var(--rcw-green-bright);
}

.tournament-match-body {
    display: grid;
    grid-template-columns: 1fr 48px 1fr;
    min-height: 200px;
}

.tournament-match-coaster {
    position: relative;
    overflow: hidden;
}

.tournament-match-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.75);
    transition: transform 0.4s ease, filter 0.4s ease;
}

.tournament-match-coaster:hover .tournament-match-photo {
    transform: scale(1.04);
    filter: brightness(0.9);
}

.tournament-match-info {
    position: relative;
    z-index: 1;
    height: 100%;
    min-height: 200px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 60%);
}

.tournament-match-coaster.is-right .tournament-match-info {
    align-items: flex-end;
    text-align: right;
}

.tournament-match-flag {
    font-size: 1.1rem;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.tournament-match-name {
    font-family: var(--rcw-font-title);
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    line-height: 1.2;
}

.tournament-match-park {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.7);
}

.tournament-match-coaster.voted .tournament-match-photo,
.tournament-match-coaster.winner .tournament-match-photo {
    filter: brightness(0.95);
}

.tournament-match-coaster.loser .tournament-match-photo {
    filter: brightness(0.4) saturate(0.3);
}

/* Etiquetas sobre la foto: GANA / EMPATE / TU VOTO */
.tn-tag {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 2;
    padding: 0.2rem 0.5rem;
    font-family: var(--rcw-font-title);
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
}

.tn-tag-win {
    top: 0;
    background: #198754;
    color: #fff;
}

.tn-tag-draw {
    top: 0;
    background: #30363d;
    color: #fff;
}

.tn-tag-vote {
    bottom: 0;
    background: rgba(10, 54, 34, 0.92);
    color: #6ee7b7;
}

.tournament-match-coaster.voted .tournament-match-info {
    padding-bottom: 1.75rem;
}

.tournament-match-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rcw-bg-card-alt);
    border-left: 1px solid var(--rcw-border);
    border-right: 1px solid var(--rcw-border);
}

.tournament-vs-badge {
    font-family: var(--rcw-font-title);
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--rcw-text-muted);
    writing-mode: vertical-rl;
    letter-spacing: 0.15em;
}

/* Botones de voto */
.tournament-match-votes {
    display: grid;
    grid-template-columns: 1fr 48px 1fr;
    border-top: 1px solid var(--rcw-border);
}

.tournament-match-votes.is-guest {
    grid-template-columns: 1fr;
}

.tournament-vote-btn {
    padding: 0.75rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--rcw-text-secondary);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tournament-vote-btn:hover:not(:disabled) {
    background: #198754;
    color: #fff;
}

.tournament-vote-btn.voted,
.tournament-vote-btn.voted:disabled {
    background: #198754;
    color: #fff;
}

.tournament-vote-btn:disabled:not(.voted) {
    opacity: 0.45;
    cursor: not-allowed;
}

.tournament-vote-vs-spacer {
    background: var(--rcw-bg-card-alt);
    border-left: 1px solid var(--rcw-border);
    border-right: 1px solid var(--rcw-border);
}

/* Resultado */
.tournament-vote-bar-container {
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--rcw-border);
    background: var(--rcw-bg-card-alt);
}

.tournament-vote-bar {
    display: flex;
    gap: 3px;
    height: 2rem;
}

/* Cada lado ocupa su % (con un mínimo para que quepa la cifra) */
.tn-bar-side {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50%;
    min-width: 3rem;
    background: #0a3622;
    color: #6ee7b7;
    font-family: var(--rcw-font-title);
    font-size: 0.95rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition: width 0.6s ease;
}

.tn-bar-side.lead {
    background: #198754;
    color: #fff;
}

.tn-bar-side.tie {
    background: #146c43;
    color: #fff;
}

.tournament-vote-percentages {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--rcw-text-secondary);
    font-variant-numeric: tabular-nums;
}

.tournament-vote-bar-guest {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--rcw-text-muted);
}

.tn-overtime-note {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: #6ee7b7;
    text-align: center;
}

/* Etiquetas de estado */
.tn-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    font-family: var(--rcw-font-title);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #30363d;
    color: var(--rcw-text-secondary);
    white-space: nowrap;
}

.tn-badge.is-live,
.tn-badge.is-overtime {
    background: #198754;
    color: #fff;
}

.tn-badge.is-done {
    background: #144f27;
    color: #6ee7b7;
}

/* ── CALENDARIO ─────────────────────────────────────────────── */
.tournament-calendario-filters {
    display: flex;
    margin-bottom: 1.5rem;
    background: var(--rcw-bg-input);
    border: 1px solid var(--rcw-border);
}

.tournament-filter-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-right: 1px solid var(--rcw-border);
    color: var(--rcw-text-muted);
    padding: 0.75rem 0.5rem;
    font-family: var(--rcw-font-title);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    white-space: nowrap;
}

.tournament-filter-btn:last-child {
    border-right: none;
}

.tournament-filter-btn:hover {
    background: var(--rcw-bg-hover);
    color: var(--rcw-text-primary);
}

.tournament-filter-btn.active {
    background: #198754;
    color: #fff;
    font-weight: 800;
}

/* Fechas de cada fase */
.tn-phases {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--rcw-border);
    border: 1px solid var(--rcw-border);
    margin-bottom: 1.5rem;
}

.tn-phase {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.8rem;
    background: var(--rcw-bg-card);
}

.tn-phase span {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rcw-text-muted);
}

.tn-phase b {
    font-family: var(--rcw-font-title);
    font-size: 0.9rem;
    color: var(--rcw-green-neon);
}

.tournament-calendario-group-divider {
    font-family: var(--rcw-font-title);
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    background: #157347;
    padding: 0.6rem 0.9rem;
    margin: 1.5rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tn-phases + .tournament-calendario-group-divider,
#jornadas-container > .tournament-calendario-group-divider:first-child {
    margin-top: 0;
}

.tournament-calendario-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.tournament-calendario-card {
    background: var(--rcw-bg-card);
    border: 1px solid var(--rcw-border);
    min-width: 0;
}

.tournament-calendario-header {
    background: var(--rcw-bg-card-alt);
    padding: 0.5rem 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--rcw-border);
}

.tournament-calendario-title {
    font-family: var(--rcw-font-title);
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rcw-green-neon);
}

.tournament-calendario-body {
    display: flex;
    align-items: stretch;
    min-height: 64px;
}

.tournament-calendario-side {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.tournament-calendario-side.right {
    flex-direction: row-reverse;
    text-align: right;
}

.tournament-calendario-photo {
    width: 40px;
    height: 40px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--rcw-border);
}

.tournament-calendario-flag {
    flex-shrink: 0;
    font-size: 0.9rem;
    line-height: 1;
}

.tournament-calendario-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: #fff;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Duelo cerrado: la ganadora en blanco con un trofeo y la perdedora apagada (sin cambiar el fondo) */
.tournament-calendario-side.winner .tournament-calendario-name {
    color: #fff;
    font-weight: 800;
}

.tournament-calendario-side.loser .tournament-calendario-name {
    color: #64748b;
    font-weight: 500;
}

.tournament-calendario-side.loser .tournament-calendario-photo {
    filter: grayscale(1) brightness(0.6);
}

.tournament-calendario-side.loser .tournament-calendario-flag {
    opacity: 0.5;
}

.tn-cal-win {
    flex-shrink: 0;
    color: #34d399;
    font-size: 0.85rem;
}

.tournament-calendario-vs {
    background: var(--rcw-bg-card-alt);
    border-left: 1px solid var(--rcw-border);
    border-right: 1px solid var(--rcw-border);
    min-width: 44px;
    padding: 0 0.4rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--rcw-font-title);
    font-weight: 900;
    font-size: 0.75rem;
    color: var(--rcw-text-muted);
    white-space: nowrap;
}

.tournament-calendario-vs.has-score {
    color: #fff;
    background: #144f27;
}

/* ── GRUPOS ─────────────────────────────────────────────────── */
.tournament-groups-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

/* Las 4 fotos del grupo, en fila */
.tn-group-photos {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 90px;
    overflow: hidden;
}

.tn-group-photos img {
    display: block;
    width: 100%;
    height: 90px;
    min-width: 0;
    object-fit: cover;
    filter: brightness(0.85);
}

.tournament-group-card {
    background: var(--rcw-bg-card);
    border: 1px solid var(--rcw-border);
    overflow: hidden;
    min-width: 0;
}

.tournament-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.9rem;
    background: #198754;
}

.tournament-group-name {
    font-family: var(--rcw-font-title);
    font-weight: 800;
    font-size: 0.9rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.tournament-group-badge {
    width: 28px;
    height: 28px;
    background: #0a3622;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--rcw-font-title);
    font-weight: 900;
    color: #6ee7b7;
}

/* Grupo con un duelo en juego: la tabla ya lo cuenta (en directo) */
.tn-group-head-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tn-group-live {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 28px;
    padding: 0 0.6rem;
    background: #0a3622;
    color: #6ee7b7;
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tn-group-live .fa-circle,
.tn-row-live {
    font-size: 0.45rem;
    animation: tnPulse 1.4s ease-in-out infinite;
}

.tn-row-live {
    margin-right: 0.35rem;
    color: #34d399;
    vertical-align: middle;
}

.tournament-group-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.tournament-group-table th:first-child,
.tournament-group-table td:first-child {
    width: 46%;
}

.tournament-group-table.no-dv th:first-child,
.tournament-group-table.no-dv td:first-child {
    width: 50%;
}

.tournament-group-table thead th {
    padding: 0.4rem 0.2rem;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rcw-text-muted);
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--rcw-border);
    background: var(--rcw-bg-input);
    cursor: default;
}

.tournament-group-table thead th:first-child {
    text-align: left;
    padding-left: 0.6rem;
}

.tournament-group-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tournament-group-table tbody tr:last-child {
    border-bottom: none;
}

.tournament-group-table tbody tr.qualified {
    background: rgba(16, 185, 129, 0.08);
}

.tournament-group-table tbody td {
    padding: 0.5rem 0.2rem;
    font-size: 0.74rem;
    text-align: center;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

.tournament-group-table tbody td:first-child {
    text-align: left;
    padding-left: 0.6rem;
}

.tournament-group-coaster-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.tournament-group-pos {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 800;
    flex-shrink: 0;
    font-family: var(--rcw-font-title);
    background: var(--rcw-bg-card-alt);
    color: var(--rcw-text-muted);
}

.tournament-group-pos.pos-1,
.tournament-group-pos.pos-2 {
    background: #198754;
    color: #fff;
}

.tournament-group-img {
    width: 34px;
    height: 24px;
    object-fit: cover;
    flex-shrink: 0;
}

.tournament-group-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tournament-group-cname {
    font-weight: 700;
    font-size: 0.74rem;
    color: var(--rcw-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tournament-group-pname {
    font-size: 0.62rem;
    color: var(--rcw-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tournament-group-pts {
    font-weight: 800;
    font-size: 0.82rem;
    color: var(--rcw-green-neon);
    font-family: var(--rcw-font-title);
}

/* Las 32 antes del sorteo */
.tn-participants {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.tn-participants-note {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--rcw-text-secondary);
}

.tn-participant {
    position: relative;
    display: block;
    height: 170px;
    overflow: hidden;
    background: var(--rcw-bg-card);
    text-decoration: none;
}

.tn-participant-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.8);
    transition: transform 0.4s ease, filter 0.4s ease;
}

.tn-participant:hover .tn-participant-photo {
    transform: scale(1.05);
    filter: brightness(0.95);
}

.tn-participant-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 2rem 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88), transparent);
}

.tn-participant-name {
    font-family: var(--rcw-font-title);
    font-weight: 800;
    color: #fff;
    line-height: 1.15;
}

.tn-participant-park {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── CUADRO ─────────────────────────────────────────────────── */
.tournament-bracket {
    overflow-x: auto;
    padding-bottom: 1rem;
}

/* Las 4 rondas a la vez (octavos, cuartos, semis y final con el 3.er puesto debajo). Cada columna reparte su
   alto entre sus cruces, así cada uno queda a la altura de los dos de los que sale; en el hueco entre columnas,
   las líneas que los unen. En el móvil, el cuadro se mueve de lado dentro de su caja. */
.tournament-bracket-wrapper {
    --tb-half: 1rem;
    display: flex;
    align-items: stretch;
    gap: calc(var(--tb-half) * 2);
    min-width: 920px;
    padding: 0.75rem;
    border: 1px solid var(--rcw-border);
}

.tournament-bracket-round {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
}

.tournament-bracket-round-title {
    font-family: var(--rcw-font-title);
    font-weight: 700;
    font-size: 0.75rem;
    text-align: center;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0.6rem;
    background: #198754;
    white-space: nowrap;
}

.tournament-bracket-round-days {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    opacity: 0.85;
}

.tournament-bracket-matches {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 0.4rem;
}

.tournament-bracket-pair,
.tournament-bracket-slot {
    position: relative;
    display: flex;
    flex: 1;
}

.tournament-bracket-pair {
    flex-direction: column;
}

.tournament-bracket-slot {
    align-items: center;
    padding: 0.35rem 0;
}

.tournament-bracket-slot > .tournament-bracket-match,
.tournament-bracket-final {
    width: 100%;
}

/* Líneas: de cada cruce sale una raya a la derecha, las dos de una pareja se juntan y entran en el siguiente */
.tournament-bracket-round:not(.is-last) .tournament-bracket-slot::after,
.tournament-bracket-round:not(:first-child) .tournament-bracket-slot::before {
    content: "";
    position: absolute;
    top: 50%;
    width: var(--tb-half);
    margin-top: -1px;
    border-top: 2px solid #198754;
}

.tournament-bracket-round:not(.is-last) .tournament-bracket-slot::after {
    left: 100%;
}

.tournament-bracket-round:not(:first-child) .tournament-bracket-slot::before {
    right: 100%;
}

.tournament-bracket-pair::after {
    content: "";
    position: absolute;
    left: calc(100% + var(--tb-half) - 1px);
    top: calc(25% - 1px);
    bottom: calc(25% - 1px);
    border-left: 2px solid #198754;
}

/* Final en el centro de su columna y el 3.er puesto debajo, sin mover la final */
.tournament-bracket-final {
    position: relative;
}

.tournament-bracket-third {
    position: absolute;
    top: calc(100% + 1.5rem);
    left: 0;
    right: 0;
}

.tournament-bracket-third .tournament-bracket-round-title {
    background: #146c43;
    margin-bottom: 0.5rem;
}

.tournament-bracket-match {
    background: var(--rcw-bg-card);
    border: 1px solid var(--rcw-border);
    position: relative;
}

.tournament-bracket-match.match-active {
    border-color: #198754;
}

.tournament-bracket-team {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.5rem;
    gap: 0.45rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tournament-bracket-team-img {
    width: 34px;
    height: 24px;
    object-fit: cover;
    flex-shrink: 0;
}

.tournament-bracket-team-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 0.76rem;
    color: var(--rcw-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tournament-bracket-team-score {
    font-weight: 800;
    font-size: 0.8rem;
    color: var(--rcw-text-muted);
    font-family: var(--rcw-font-title);
}

.tournament-bracket-team.winner {
    background: rgba(16, 185, 129, 0.12);
}

/* Hueco aún sin decidir: quién puede llegar */
.tournament-bracket-team-tbd {
    width: 34px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rcw-bg-card-alt);
    color: var(--rcw-text-muted);
    font-size: 0.7rem;
}

.tournament-bracket-team.is-tbd .tournament-bracket-team-name {
    color: var(--rcw-text-muted);
    font-weight: 500;
}

.tournament-bracket-team.winner .tournament-bracket-team-name,
.tournament-bracket-team.winner .tournament-bracket-team-score {
    color: var(--rcw-green-neon);
}

.tournament-bracket-date {
    padding: 0.25rem 0.5rem;
    font-size: 0.66rem;
    color: var(--rcw-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tournament-bracket-date:empty {
    display: none;
}

/* ── NORMAS ─────────────────────────────────────────────────── */
.tournament-rules-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--rcw-border);
}

.tournament-rule {
    padding: 1.5rem;
    background: var(--rcw-bg-card);
}

.tournament-rule-icon {
    font-size: 1.5rem;
    color: var(--rcw-green-neon);
    margin-bottom: 0.75rem;
}

.tournament-rule h3 {
    font-family: var(--rcw-font-title);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
    color: var(--rcw-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tournament-rule p {
    font-size: 0.85rem;
    color: var(--rcw-text-secondary);
    line-height: 1.55;
    margin: 0;
}

.tournament-rule strong {
    color: #fff;
}

/* ── ADMIN ──────────────────────────────────────────────────── */
.tn-schedule {
    display: grid;
    grid-template-columns: 1.4fr 1fr 0.8fr 0.8fr auto;
    gap: 0.75rem;
    align-items: end;
}

.tn-schedule .form-control,
.tn-schedule .form-select {
    background: #0d1117;
    border: 2px solid #198754;
    color: #fff;
}

.tn-count {
    background: #0a3622;
    color: #6ee7b7;
}

.tournament-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.tournament-admin-results,
.tournament-admin-participants,
.tournament-admin-pending,
.tournament-admin-photo-grid {
    display: grid;
    gap: 1px;
    background: var(--rcw-border);
    border: 1px solid var(--rcw-border);
    overflow-y: auto;
}

.tournament-admin-results:empty,
.tournament-admin-participants:empty,
.tournament-admin-photo-grid:empty {
    display: none;
}

.tournament-admin-results {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    max-height: 400px;
}

.tournament-admin-participants {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    max-height: 500px;
}

.tournament-admin-pending {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    max-height: 600px;
}

.tournament-admin-photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    max-height: 700px;
}

.tournament-admin-result-card,
.tournament-admin-participant,
.tournament-admin-pending-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    background: var(--rcw-bg-card);
    min-width: 0;
}

.tournament-admin-result-card.already-added {
    opacity: 0.45;
}

.tournament-admin-result-img,
.tournament-admin-participant-img {
    width: 52px;
    height: 34px;
    object-fit: cover;
    flex-shrink: 0;
}

.tournament-admin-result-info,
.tournament-admin-pending-info {
    flex: 1;
    min-width: 0;
}

.tournament-admin-result-name,
.tournament-admin-pending-names,
.tournament-admin-participant-name {
    font-weight: 700;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tournament-admin-participant-name {
    flex: 1;
    min-width: 0;
}

.tournament-admin-participant-name b {
    color: var(--rcw-green-neon);
}

.tournament-admin-result-park,
.tournament-admin-pending-phase {
    font-size: 0.7rem;
    color: var(--rcw-text-muted);
}

.tournament-admin-remove-btn {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
}

.tournament-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1.5rem;
    border: 2px dashed var(--rcw-border);
    cursor: pointer;
    text-align: center;
}

.tournament-upload-zone:hover,
.tournament-upload-zone.drag-over {
    border-color: #198754;
    background: rgba(16, 185, 129, 0.05);
}

.tournament-upload-icon {
    font-size: 1.75rem;
    color: var(--rcw-green-neon);
}

.tournament-upload-text {
    font-weight: 600;
    color: var(--rcw-text-secondary);
}

.tournament-upload-hint {
    font-size: 0.75rem;
    color: var(--rcw-text-muted);
}

.tournament-admin-photo-card {
    background: var(--rcw-bg-card);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tournament-admin-photo-img-wrap {
    position: relative;
    height: 120px;
    overflow: hidden;
    background: var(--rcw-bg-card-alt);
}

.tournament-admin-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tournament-admin-photo-edit-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    width: 30px;
    height: 30px;
    margin: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tournament-admin-photo-edit-btn:hover {
    background: #198754;
}

.tournament-admin-photo-custom-badge {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 1;
    font-size: 0.62rem;
    font-weight: 700;
    background: #198754;
    color: #fff;
    padding: 0.1rem 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tournament-admin-photo-info {
    padding: 0.5rem 0.6rem;
    min-width: 0;
}

.tournament-admin-photo-name {
    font-weight: 700;
    font-size: 0.76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tournament-admin-photo-park {
    font-size: 0.68rem;
    color: var(--rcw-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tournament-page .btn,
.tournament-page .dropdown-menu,
.tournament-page .badge {
    border-radius: 0;
}

/* Programación (admin) */
.tn-checks {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 1rem;
}

.tn-check {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.6rem 0.8rem;
    background: var(--rcw-bg-card-alt);
}

.tn-check.is-ok {
    background: #0f5132;
}

.tn-check-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rcw-text-muted);
}

.tn-check.is-ok .tn-check-label {
    color: #6ee7b7;
}

.tn-check b {
    font-family: var(--rcw-font-title);
    font-size: 1rem;
    color: #fff;
}

.tn-agenda {
    display: grid;
    gap: 8px;
}

.tn-agenda-day {
    background: var(--rcw-bg-input);
}

.tn-agenda-day.is-today {
    box-shadow: inset 4px 0 0 #10b981;
}

.tn-agenda-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.9rem;
    padding: 0.55rem 0.8rem;
    background: var(--rcw-bg-card);
}

.tn-agenda-date {
    font-family: var(--rcw-font-title);
    font-weight: 800;
    color: #fff;
    min-width: 13rem;
}

.tn-agenda-label {
    font-weight: 600;
    color: var(--rcw-green-neon);
    flex: 1;
    min-width: 10rem;
}

.tn-agenda-time {
    font-size: 0.8rem;
    color: var(--rcw-text-muted);
    font-variant-numeric: tabular-nums;
}

.tn-badge.is-planned {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--rcw-border-strong);
}

.tn-agenda-matches {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--rcw-border);
}

.tn-agenda-match {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--rcw-bg-input);
    font-size: 0.82rem;
    min-width: 0;
}

.tn-agenda-g {
    flex: 0 0 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #198754;
    font-family: var(--rcw-font-title);
    font-weight: 800;
    font-size: 0.75rem;
}

.tn-agenda-n {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tn-agenda-match .tn-agenda-n:last-child {
    text-align: right;
}

.tn-agenda-vs {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--rcw-text-muted);
    text-transform: uppercase;
}

.tn-agenda-note {
    margin: 0;
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
    color: var(--rcw-text-muted);
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (min-width: 1600px) {
    .tournament-groups-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1199px) {
    .tournament-groups-grid,
    .tn-participants {
        grid-template-columns: repeat(2, 1fr);
    }

    .tournament-rules-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 991px) {
    .tn-schedule {
        grid-template-columns: 1fr 1fr;
    }

    .tn-schedule .btn {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767px) {
    /* Calendario en el móvil: más sitio para el nombre */
    .tournament-calendario-side {
        gap: 0.35rem;
        padding: 0.5rem;
    }

    .tournament-calendario-photo {
        width: 32px;
        height: 32px;
    }

    .tournament-calendario-flag {
        display: none;
    }

    .tn-checks,
    .tn-agenda-matches {
        grid-template-columns: 1fr 1fr;
    }

    .tn-agenda-matches {
        grid-template-columns: 1fr;
    }

    .tn-agenda-date {
        min-width: 0;
    }

    .tournament-hero {
        min-height: 340px;
    }

    .tournament-hero-content {
        padding: 2rem 1rem 1rem;
    }

    .tournament-hero-eyebrow {
        font-size: 0.65rem;
        letter-spacing: 0.18em;
    }

    .tournament-title-main,
    .tournament-title-accent {
        font-size: 2.2rem;
    }

    .tn-status {
        font-size: 0.8rem;
    }

    .tournament-info-bar .tn-share {
        width: 100%;
    }

    /* Pestañas: rejilla de 3 en el móvil, sin scroll lateral */
    .tournament-nav {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .tournament-nav-btn {
        padding: 0.75rem 0.25rem;
        font-size: 0.72rem;
        gap: 0.35rem;
    }

    .tournament-nav-admin {
        margin-left: 0;
    }

    .tournament-matches-grid {
        grid-template-columns: 1fr;
    }

    .tournament-match-body {
        grid-template-columns: 1fr 34px 1fr;
        min-height: 170px;
    }

    .tournament-match-votes {
        grid-template-columns: 1fr 34px 1fr;
    }

    .tournament-match-info {
        min-height: 170px;
        padding: 0.6rem;
    }

    .tournament-match-name {
        font-size: 0.9rem;
    }

    .tournament-vote-btn {
        font-size: 0.75rem;
        padding: 0.7rem 0.25rem;
    }

    .tn-next {
        flex-direction: column;
    }

    .tn-next-photo {
        width: 100%;
        max-width: none;
        height: 180px;
    }

    .tn-next-title {
        font-size: 1.25rem;
    }

    .tn-next-count {
        font-size: 2rem;
    }

    .tn-next-actions {
        padding: 1rem 1.5rem 1.5rem;
    }

    .tournament-calendario-filters {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .tournament-filter-btn {
        border-bottom: 1px solid var(--rcw-border);
        padding: 0.65rem 0.25rem;
        font-size: 0.68rem;
    }

    .tournament-calendario-grid {
        grid-template-columns: 1fr;
    }

    .tournament-groups-grid,
    .tournament-rules-grid {
        grid-template-columns: 1fr;
    }

    .tn-participants {
        gap: 0.5rem;
    }

    .tn-participant {
        height: 130px;
    }

    .tn-participant-name {
        font-size: 0.85rem;
    }

    .tn-schedule {
        grid-template-columns: 1fr;
    }
}
