* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-image: url('img/Img-F.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100vh;
}

:root {
    --color-background-primary: rgba(255,255,255,0.72);
    --color-background-secondary: rgba(255,255,255,0.5);
    --color-text-primary: #111111;
    --color-text-secondary: #4B4B4B;
    --color-border-tertiary: rgba(0,0,0,.08);
    --color-gold: #C9A227;
    --color-gold-light: #E5C158;
    --color-black: #111111;
    --border-radius-md: 12px;
    --glass-blur: blur(14px);
    --shadow-soft: 0 4px 20px rgba(0,0,0,.08);
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI',
        sans-serif;
}

.trophy-logo {
    width: 90px;
    height: auto;
    display: block;
    margin: 0 auto 10px;

    object-fit: contain;

    filter:
        drop-shadow(0 4px 12px rgba(0,0,0,.15));

    transition:
        transform .2s ease;
}

.trophy-logo:hover {
    transform: scale(1.03);
}

/* ── APP LAYOUT ───────────────────────────────────────────────── */
.app {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* ── HEADER ───────────────────────────────────────────────────── */
.header {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: rgba(255,255,255,.38);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,.08);
}

.header h1 {
    font-size: 22px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}
.header p {
    font-size: 13px;
    color: var(--color-text-secondary);
}
.trophy {
    font-size: 28px;
    display: block;
    margin-bottom: 8px;
}

/* ── STATS BAR ────────────────────────────────────────────────── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--color-background-secondary);
    border-radius: var(--border-radius-md);
    padding: 10px 14px;
    text-align: center;
}
.stat-val {
    font-size: 22px;
    font-weight: 500;
    color: var(--color-text-primary);
}
.stat-lbl {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

/* ── TABS ─────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 0 2px;
}
.tab {
    background: rgba(255,255,255,.45);
    padding: 6px 14px;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(255,255,255,.35);
    backdrop-filter: blur(10px);
    color: #333;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tab.active {
    background: linear-gradient(135deg,#C9A227,#E5C158);
    color: #111;
    border: none;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(201,162,39,.35);
}

.tab:hover:not(.active) { 
    background: var(--color-background-secondary); 
}

/* ── SEARCH ───────────────────────────────────────────────────── */
.search-wrap { margin-bottom: 1rem; }
input[type="search"] {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(255,255,255,.35);
    background: rgba(255,255,255,.5);
    backdrop-filter: blur(10px);
    color: #111;
    font-size: 14px;
}

/* ── GRUPOS / TABLA ───────────────────────────────────────────── */
.group-section { margin-bottom: 2rem; }
.group-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #C9A227;
    display: flex;
    align-items: center;
    gap: 8px;
}
.group-title span {
    background: #C9A227;
    color: #111;
    border-radius: 50%;
    width: 22px; height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
}
.table-wrap { overflow-x: auto; }

table {
    background: rgba(255,255,255,.35);
    width: 100%;
    backdrop-filter: blur(12px);
    border-collapse: collapse;
    border-radius: 16px;
    overflow: hidden;
    font-size: 13px;
    min-width: 400px;
}

thead tr { background: var(--color-background-secondary); }
th {
    padding: 7px 10px;
    text-align: left;
    font-weight: 500;
    color: var(--color-text-secondary);
    font-size: 12px;
    border-bottom: 0.5px solid var(--color-border-tertiary);
}
td {
    padding: 7px 10px;
    color: var(--color-text-primary);
    border-bottom: 0.5px solid var(--color-border-tertiary);
}
tr:last-child td { 
    border-bottom: none;
}

tr:hover td { 
    background: var(--color-background-secondary); 
}

.flag { 
    font-size: 16px; margin-right: 6px; 
}

.team-name { 
    display: flex; align-items: center; 
}

.pts {
    color: #C9A227;
    font-weight: 700;
}

/* Botones de puntos */
.btn-pts {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-primary);
    color: var(--color-text-primary);
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.1s;
}
.btn-pts:hover { background: var(--color-background-secondary); }
.btn-add { background: #1B5E20 !important; color: #fff !important; border-color: #1B5E20 !important; }
.btn-add:hover { background: #2E7D32 !important; }
.controls { display: flex; align-items: center; gap: 6px; }

/* Badges de posición */
.badge-pos {
    width: 20px; height: 20px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pos1 { background: #FDD835; color: #5D4037; }
.pos2 { background: #90A4AE; color: #263238; }
.pos3, .pos4 { background: var(--color-background-secondary); color: var(--color-text-secondary); }

/* Reset btn */
.reset-btn {
    padding: 5px 12px;
    border-radius: var(--border-radius-md);
    border: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-primary);
    color: var(--color-text-secondary);
    font-size: 12px;
    cursor: pointer;
    margin-left: auto;
}
.reset-btn:hover { background: #FFEBEE; color: #C62828; border-color: #C62828; }

/* ── BOTONES HEADER ───────────────────────────────────────────── */
.logout-btn, .matches-btn {
    padding: 6px 12px;
    margin: 0 4px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border-tertiary);
    background: var(--color-background-primary);
    font-size: 12px;
    cursor: pointer;
}
.logout-btn { background: #FFEBEE; color: #C62828; }
.logout-btn:hover { background: #FFCDD2; }
.matches-btn { background: #E8F5E8; color: #1B5E20; }
.matches-btn:hover { background: #C8E6C9; }

/* ── SECCIÓN PARTIDOS ─────────────────────────────────────────── */
.matches-section {
    margin: 0 1rem 1.5rem;
}
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text-primary);
    padding: .5rem 0 .75rem;
    border-bottom: 2px solid #1B5E20;
    margin-bottom: .75rem;
}

/* Separador de fecha */
.fecha-separator {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-secondary);
    padding: .75rem .25rem .35rem;
    margin-top: .5rem;
}

/* Tarjeta de partido */
.match-card {
    background: rgba(255,255,255,.4);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    padding: .9rem 1rem;
    margin-bottom: .85rem;
    transition: transform .15s, box-shadow .15s;
}

.match-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.match-card.live      { border-left-color: #ef4444; }
.match-card.finished  { border-left-color: #6b7280; opacity: .85; }
.match-card.scheduled { border-left-color: #3b82f6; }

@keyframes pulse {
    0%  { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
    50% { box-shadow: 0 4px 12px rgba(211,47,47,.3); }
}
.match-card.live { animation: pulse 2s infinite; }

.match-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
    font-size: 11px;
}
.match-venue {
    font-size: 10px;
    color: var(--color-text-secondary);
    margin-bottom: .4rem;
}

/* Badges */
.group-badge { background: #1B5E20; color: white; padding: 2px 7px; border-radius: 20px; font-size: 10px; font-weight: 700; }
.badge-live  { background: #fee2e2; color: #ef4444; padding: 2px 7px; border-radius: 20px; font-weight: 700; font-size: 11px; }
.badge-ft    { background: #f3f4f6; color: #6b7280; padding: 2px 7px; border-radius: 20px; font-weight: 600; font-size: 11px; }
.badge-sched { background: #dbeafe; color: #2563eb; padding: 2px 7px; border-radius: 20px; font-weight: 600; font-size: 11px; }
.countdown   { font-size: 10px; color: #f59e0b; font-weight: 600; margin-left: auto; }

/* Equipos */
.match-teams {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .4rem 0;
    gap: .5rem;
}
.team-col { display: flex; align-items: center; gap: .35rem; flex: 1; }
.team-col:last-child { justify-content: flex-end; flex-direction: row-reverse; }
.team-flag { font-size: 1.4rem; line-height: 1; }
.team-name-match { font-size: .8rem; font-weight: 600; color: var(--color-text-primary); }
.score-big { font-size: 1.5rem; font-weight: 800; color: #1B5E20; min-width: 24px; text-align: center; }
.vs-col  { text-align: center; }
.vs-text { color: var(--color-text-secondary); font-size: .8rem; font-weight: 700; }
.vs-sep  { color: #1B5E20; font-size: 1.2rem; font-weight: 800; }

/* Zona predicción */
.pred-zone {
    margin-top: .65rem;
    padding-top: .55rem;
    border-top: 1px solid rgba(0,0,0,.06);
}
.pred-zone.open { display: flex; justify-content: flex-end; }
.pred-zone.done { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: 12px; }

.btn-predecir {
    background: #1B5E20;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
}
.btn-predecir:hover  { opacity: .87; transform: scale(1.02); }
.btn-predecir:active { transform: scale(.97); }

.pred-label { font-size: 11px; color: var(--color-text-secondary); }
.pred-score { font-weight: 700; color: var(--color-text-primary); font-size: 12px; }
.pred-real  { font-size: 11px; color: var(--color-text-secondary); }

.pred-pts   { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pts-gold   { background: #fef9c3; color: #a16207; }
.pts-silver { background: #f1f5f9; color: #475569; }
.pts-bronze { background: #fef3c7; color: #92400e; }

.predict-btn {
    background: #1B5E20;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s;
}
.predict-btn:hover { opacity: .85; }

.prediction-badge {
    font-size: 11px;
    font-weight: 600;
    color: #059669;
    background: #d1fae5;
    padding: 3px 10px;
    border-radius: 20px;
}

/* Loading partidos */
.loading-matches {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 2rem;
    color: var(--color-text-secondary);
    font-size: .9rem;
}
.loading-spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(0,0,0,.1);
    border-top-color: #1B5E20;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* API warning */
.api-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    font-size: 13px;
    line-height: 1.7;
    color: #92400e;
    margin: .5rem 0 1rem;
}
.api-warning a    { color: #b45309; font-weight: 600; }
.api-warning code { background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

/* ── LEADERBOARD ──────────────────────────────────────────────── */
.leaderboard-wrap {
    background: rgba(255,255,255,.45);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,.4);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    margin-bottom: 1rem;
}
.leaderboard-title {
    background: linear-gradient(135deg,#111111,#2B2B2B);
    color: white;
    font-weight: 700;
    font-size: .9rem;
    padding: .75rem 1rem;
}
.leaderboard-row {
    display: flex;
    align-items: center;
    padding: .6rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-size: .85rem;
    gap: .5rem;
    transition: background .15s;
}
.leaderboard-row:last-of-type { border-bottom: none; }
.leaderboard-row.me { background: rgba(59,130,246,.07); font-weight: 700; }
.lb-pos  { min-width: 28px; font-size: .95rem; }
.lb-user { flex: 1; color: var(--color-text-primary); }
.lb-pts  { color: #1B5E20; font-weight: 800; font-size: .9rem; min-width: 50px; text-align: right; }
.lb-note { font-size: 11px; color: var(--color-text-secondary); text-align: center; padding: .5rem 1rem .75rem; }
.leaderboard-footer {
    font-size: 10px;
    color: var(--color-text-secondary);
    padding: .5rem 1rem .75rem;
    text-align: center;
    border-top: 1px solid rgba(0,0,0,.06);
}

.leaderboard-codigo {
    background: #f8fafc;
    border-bottom: 1px solid rgba(0,0,0,.06);
    padding: .6rem 1rem;
    font-size: 12px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.leaderboard-codigo strong {
    color: #1B5E20;
    font-size: 15px;
    letter-spacing: .1em;
    font-family: monospace;
}
.btn-copy {
    background: #1B5E20;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
}
.btn-codigo {
    background: transparent;
    border: 1.5px solid #1B5E20;
    color: #1B5E20;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.btn-codigo:hover { background: #1B5E20; color: white; }

/* ── HEADER ───────────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: rgba(255,255,255,.38);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,.08);
}

.header-main {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.header-main h1 {
    font-size: 22px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.header-main p {
    font-size: 13px;
    color: var(--color-text-secondary);
}

#userInfo {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 10px;
}

.header-btns {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.matches-btn--gold {
    background: #FFF8E1;
    color: #C9A227;
}
.matches-btn--gold:hover {
    background: #FFF3CD;
}

/* Divisor entre header-main y reglas */
.header-reglas {
    width: 1px;
    background: rgba(0,0,0,.08);
    flex-shrink: 0;
    align-self: stretch;
    margin: 0;
}

.header-reglas {
    width: auto;
    background: transparent;
    border-left: 1px solid rgba(0,0,0,.08);
    padding-left: 1rem;
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.reglas-titulo {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: .3px;
    margin-bottom: 4px;
}

.reglas-lista {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.reglas-lista li {
    font-size: 10.5px;
    color: var(--color-text-secondary);
    line-height: 1.55;
    padding-left: 10px;
    position: relative;
}

.reglas-lista li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: #C9A227;
    font-weight: 700;
}

.reglas-lista strong {
    color: var(--color-text-primary);
    font-weight: 600;
}

/* En móvil las reglas bajan debajo del header-main */
@media (max-width: 600px) {
    .header {
        flex-direction: column;
    }
    .header-reglas {
        flex: none;
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(0,0,0,.08);
        padding-left: 0;
        padding-top: 1rem;
    }
}

/* ================================================================
   RESPONSIVO
   ================================================================ */

/* Tablet (max 768px) */
@media (max-width: 768px) {
    .app {
        padding: 0.75rem;
    }
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    .tabs {
        gap: 4px;
    }
    .tab {
        padding: 5px 10px;
        font-size: 12px;
    }
    .leaderboard-row {
        font-size: .8rem;
    }
    .match-teams {
        gap: .3rem;
    }
    .team-name-match {
        font-size: .75rem;
    }
    .score-big {
        font-size: 1.2rem;
    }
}

/* Móvil (max 480px) */
@media (max-width: 480px) {
    body {
        background: none;
    }
    .bg-fondo {
        display: block;
        position: fixed;
        top: 0; left: 0;
        width: 100%; height: 100%;
        z-index: 0;
        background-image: url('img/ImgF-Moviles.png');
        background-size: cover;
        background-position: center top;
        background-repeat: no-repeat;
    }
    .app {
        position: relative;
        z-index: 2;
        padding: 0.75rem;
    }
    .header {
        padding: 1rem;
    }
    .header h1 {
        font-size: 20px;
    }
    .trophy {
        font-size: 26px;
    }
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .stat-val {
        font-size: 20px;
    }
    .stat-lbl {
        font-size: 12px;
    }
    .tabs {
        gap: 4px;
    }
    .tab {
        padding: 6px 10px;
        font-size: 12px;
    }
    table {
        font-size: 13px;
        min-width: 320px;
    }
    th, td {
        padding: 7px 8px;
    }
    .match-card {
        padding: .8rem .9rem;
    }
    .team-flag {
        font-size: 1.2rem;
    }
    .team-name-match {
        font-size: .78rem;
    }
    .score-big {
        font-size: 1.2rem;
        min-width: 20px;
    }
    .leaderboard-row {
        padding: .55rem .85rem;
        font-size: .82rem;
    }
    .leaderboard-title {
        font-size: .85rem;
        padding: .65rem .85rem;
    }
    .btn-predecir {
        padding: 6px 14px;
        font-size: 12px;
    }
    .logout-btn, .matches-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}