/* ════════════════════════════════════════════════════════════
   Mundial 2026 — Fixture Interactivo
   ════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary-red: #E63946;
    --primary-blue: #457B9D;
    --accent-gold: #FFD60A;
    --accent-green: #06D6A0;
    --pitch: #2d5016;
    --dark-gray: #1a1a2e;
    --light-gray: #f5f5f5;
    --text-dark: #0f0f0f;
    --text-light: #ffffff;
    --border-color: #e0e0e0;
    --card-bg: rgba(255, 255, 255, 0.96);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.18);
    --font-display: 'Archivo', 'Segoe UI', sans-serif;
    --font-body: 'Archivo', 'Segoe UI', Tahoma, sans-serif;
}

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
    font-family: var(--font-body);
    background-color: var(--pitch);
    /* Césped con líneas de campo */
    background-image:
        linear-gradient(90deg, transparent 24%, rgba(255,255,255,.05) 25%, rgba(255,255,255,.05) 26%, transparent 27%, transparent 74%, rgba(255,255,255,.05) 75%, rgba(255,255,255,.05) 76%, transparent 77%, transparent),
        linear-gradient(180deg, transparent 24%, rgba(255,255,255,.05) 25%, rgba(255,255,255,.05) 26%, transparent 27%, transparent 74%, rgba(255,255,255,.05) 75%, rgba(255,255,255,.05) 76%, transparent 77%, transparent);
    background-size: 50px 50px, 50px 50px;
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

button:focus-visible, .tab:focus-visible, .clickable:focus-visible {
    outline: 3px solid var(--accent-gold);
    outline-offset: 2px;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 28px;
    padding: 44px 30px 38px;
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-blue) 100%);
    color: white;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.header-hosts {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.header-hosts img {
    width: 38px; height: 26px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

.header h1 {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 900;
    font-stretch: 110%;
    letter-spacing: -1px;
    text-transform: uppercase;
    line-height: 1.05;
}

.subtitle {
    font-size: 1.05rem;
    font-weight: 300;
    opacity: 0.95;
    letter-spacing: 2px;
    margin-top: 8px;
    text-transform: uppercase;
}

/* ── Barra de fase ──────────────────────────────────────────── */
.phase-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px 22px;
    background: var(--card-bg);
    border-left: 5px solid var(--primary-red);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.phase-badge {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary-red);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.phase-progress { font-size: 13px; color: #777; }

.btn-advance { animation: pulse 2.2s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(230, 57, 70, .45); }
    50% { box-shadow: 0 0 0 10px rgba(230, 57, 70, 0); }
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 28px;
    overflow-x: auto;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(255,255,255,.25);
}

.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-thumb { background: var(--primary-red); border-radius: 4px; }

.tab {
    background: rgba(255,255,255,.12);
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    padding: 11px 18px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
    color: rgba(255,255,255,.85);
    text-transform: uppercase;
    letter-spacing: .5px;
}

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

.tab.active {
    background: var(--card-bg);
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
}

.tab-check { color: var(--accent-green); font-weight: 900; }

.tab-bracket { margin-left: auto; background: var(--accent-gold); color: var(--dark-gray); }
.tab-bracket:hover { background: #ffe34d; color: var(--dark-gray); }
.tab-bracket.active { background: var(--accent-gold); color: var(--dark-gray); border-bottom-color: var(--dark-gray); }

/* ── Banderas ───────────────────────────────────────────────── */
.flag-img {
    width: 24px; height: 16px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.flag-img.flag-lg { width: 36px; height: 24px; }
.flag-img.flag-xl { width: 56px; height: 38px; border-radius: 4px; }

/* ── Grupos ─────────────────────────────────────────────────── */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 22px;
}

.group-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 22px;
    box-shadow: var(--shadow);
    border-top: 5px solid var(--primary-red);
    transition: transform .2s ease, box-shadow .2s ease;
}

.group-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.group-header {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    background: var(--primary-red);
    color: #fff;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 900;
}

.group-table { width: 100%; border-collapse: collapse; }

.group-table thead th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: #888;
    padding: 8px 6px;
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: .5px;
}

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

.group-table tbody tr { border-bottom: 1px solid #f0f0f0; }
.group-table tbody tr:last-child { border-bottom: none; }
.group-table td { padding: 9px 6px; font-size: 14px; }

.row-qualified { background: rgba(6, 214, 160, .08); }
.row-qualified .team-cell span { font-weight: 700; }

.team-cell { display: flex; align-items: center; gap: 9px; }

.stat-cell {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    font-variant-numeric: tabular-nums;
}

.stat-points { color: var(--primary-red); font-weight: 800; }

/* Partidos dentro del grupo */
.group-matches { margin-top: 18px; }

.group-matches-title {
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--border-color);
}

.gm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background .15s ease;
}

.gm-row:last-child { border-bottom: none; }
.gm-row:hover { background: rgba(230, 57, 70, .06); }

.gm-team { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.gm-left { justify-content: flex-end; }
.gm-right { justify-content: flex-start; }

.gm-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gm-left .gm-name { text-align: right; }

.gm-score { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.gm-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border: 2px solid #ccc;
    border-radius: 5px;
    font-weight: 800;
    font-size: 14px;
    color: #999;
    background: #fff;
    font-variant-numeric: tabular-nums;
}

.gm-row.is-played .gm-box { border-color: var(--primary-red); color: var(--primary-red); }

.gm-vs { font-size: 10px; color: #aaa; }
.gm-empty { color: #999; font-size: 13px; }

/* ── Partidos eliminatorias ─────────────────────────────────── */
.matches-list { display: flex; flex-direction: column; gap: 14px; max-width: 860px; margin: 0 auto; }

.match-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px 24px 20px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--primary-red);
    transition: transform .2s ease, box-shadow .2s ease;
}

.match-card.clickable { cursor: pointer; }
.match-card.clickable:hover { box-shadow: var(--shadow-lg); transform: translateX(4px); }
.match-card.played { border-left-color: var(--accent-green); }

.match-number {
    font-size: 10px;
    color: #999;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.match-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.match-team {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    min-width: 0;
}

.match-team.right { flex-direction: row-reverse; text-align: right; }
.match-team.is-winner { font-weight: 900; }
.match-team.is-winner span::after { content: ' ✓'; color: var(--accent-green); }

.match-center { text-align: center; min-width: 110px; }

.match-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.match-score .vs { font-size: 13px; color: #999; font-weight: 400; }
.score-value { min-width: 34px; text-align: center; color: var(--primary-red); }

.match-penalties { font-size: 12px; color: #b8860b; font-weight: 700; margin-top: 2px; }

/* ── Llaves (bracket) ───────────────────────────────────────── */
.bracket-wrap {
    background: rgba(0, 0, 0, .18);
    border-radius: 14px;
    padding: 24px 18px;
    overflow-x: auto;
}

.bracket {
    display: flex;
    gap: 28px;
    min-width: max-content;
    align-items: stretch;
}

.bracket-col {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 10px;
    min-width: 190px;
}

.bracket-col-title {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-gold);
    text-align: center;
    margin-bottom: 4px;
    position: sticky;
    top: 0;
}

.bracket-match {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 8px 10px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-blue);
}

.bracket-match.clickable { cursor: pointer; transition: transform .15s ease; }
.bracket-match.clickable:hover { transform: scale(1.04); box-shadow: var(--shadow-lg); }

.bm-team {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 0;
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.bm-team.is-winner { color: var(--text-dark); font-weight: 900; }
.bm-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-score {
    font-family: var(--font-display);
    font-weight: 900;
    color: var(--primary-red);
    min-width: 18px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bm-pens { font-size: 10px; color: #b8860b; font-weight: 700; text-align: right; }

.bracket-empty {
    color: rgba(255,255,255,.55);
    font-size: 13px;
    text-align: center;
    padding: 16px 8px;
    border: 1px dashed rgba(255,255,255,.3);
    border-radius: 8px;
}

.bracket-champion { justify-content: center; }

.bracket-champ-box {
    background: linear-gradient(135deg, var(--accent-gold), var(--primary-red));
    color: #fff;
    border-radius: 12px;
    padding: 22px 16px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.8;
    box-shadow: var(--shadow-lg);
}

/* ── Campeón ────────────────────────────────────────────────── */
.champion-card {
    background: linear-gradient(135deg, var(--accent-gold) 0%, var(--primary-red) 100%);
    border-radius: 14px;
    padding: 70px 40px;
    text-align: center;
    color: white;
    margin-top: 40px;
    box-shadow: var(--shadow-lg);
}

.trophy { font-size: 120px; margin-bottom: 24px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }

.champion-card h2 {
    font-family: var(--font-display);
    font-size: 1.9rem;
    margin-bottom: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.champion-card h3 {
    font-family: var(--font-display);
    font-size: 3.2rem;
    font-weight: 900;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

/* ── Botones ────────────────────────────────────────────────── */
.btn {
    padding: 11px 24px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: all .2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:disabled { opacity: .6; cursor: wait; }

.btn-primary { background: var(--primary-red); color: white; box-shadow: var(--shadow); }
.btn-primary:hover:not(:disabled) { background: #d62828; box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary { background: var(--light-gray); color: var(--text-dark); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: #e8e8e8; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active { display: flex; animation: modalIn .25s ease; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-24px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 540px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 92vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-blue) 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-close {
    background: rgba(255,255,255,.2);
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: white;
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease;
}

.btn-close:hover { background: rgba(255,255,255,.35); }

.modal-body { padding: 26px; }

.modal-footer {
    padding: 18px 26px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.match-display {
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin-bottom: 24px;
    padding: 18px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.match-display .vs {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--primary-red);
    font-weight: 900;
}

.team-display { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 40%; }
.team-display .team-name { font-weight: 700; font-size: 15px; text-align: center; }

.score-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.score-input { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.score-input label {
    font-size: 11px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: .5px;
    max-width: 110px;
    text-align: center;
}

.score-input input {
    width: 76px; height: 76px;
    border: 2px solid var(--primary-blue);
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 900;
    text-align: center;
    color: var(--primary-red);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.score-input input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, .15);
}

.score-separator {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 900;
    color: var(--primary-red);
}

.penalties-section {
    margin-top: 24px;
    padding-top: 22px;
    border-top: 2px dashed var(--accent-gold);
}

.penalties-section h4 {
    font-size: 12px;
    margin-bottom: 16px;
    color: var(--primary-blue);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
}

.penalties-section .score-input input {
    width: 60px; height: 60px;
    font-size: 24px;
    border-color: var(--accent-gold);
    color: #b8860b;
}

/* ── Estados ────────────────────────────────────────────────── */
.loading { text-align: center; padding: 60px; color: rgba(255,255,255,.8); font-size: 16px; }

.error-box {
    background: #fff;
    border-left: 5px solid var(--primary-red);
    padding: 18px 22px;
    border-radius: 10px;
    color: var(--primary-red);
    font-weight: 700;
}

.empty-box {
    background: var(--card-bg);
    padding: 36px 24px;
    border-radius: 12px;
    text-align: center;
    color: #777;
    font-weight: 600;
}

.empty-box small { font-weight: 400; color: #999; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .header { padding: 28px 18px 26px; }
    .groups-grid { grid-template-columns: 1fr; }
    .phase-info { flex-direction: column; text-align: center; }
    .match-team { font-size: 13px; gap: 8px; }
    .match-score { font-size: 22px; }
    .match-center { min-width: 88px; }
    .score-input input { width: 64px; height: 64px; font-size: 26px; }
    .champion-card { padding: 46px 24px; }
    .champion-card h3 { font-size: 2rem; flex-wrap: wrap; }
    .trophy { font-size: 88px; }
    .tab-bracket { margin-left: 6px; }
    .bracket-col { min-width: 165px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-red); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-blue); }

/* ── Barra de backup (versión standalone) ───────────────────── */
.backup-bar {
    margin-top: 36px;
    padding: 16px 22px;
    background: rgba(0, 0, 0, .25);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.backup-note { color: rgba(255, 255, 255, .75); font-size: 13px; }

.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.backup-actions .btn { padding: 8px 14px; font-size: 11px; }

.btn-danger { color: var(--primary-red); border-color: var(--primary-red); }
.btn-danger:hover { background: #ffeaea; }

@media (max-width: 768px) {
    .backup-bar { flex-direction: column; text-align: center; }
}

/* Fecha y sede en el modal */
.match-meta {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin: -12px 0 18px;
}
