/* ============ RESET & BASE ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colores */
    --bg: #0a192f;
    --bg-card: #112240;
    --bg-hover: #1d3557;
    --border: #233554;
    --text: #a8b2d1;
    --text-bright: #e6f1ff;
    --text-dim: #8892b0;
    --accent: #64ffda;
    --accent-dark: #00612d;
    --success: #2AD572;
    --warning: #f39c12;
    --danger: #ff6b6b;

    /* Espaciado */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 12px;
    --gap-lg: 20px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Tipografía */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-md: 13px;
    --fs-lg: 16px;
    --fs-xl: 22px;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    padding: 10px;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.container {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    padding: 0 8px;
    box-sizing: border-box;
}

img {
    max-width: 100%;
    display: inline-block;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

/* Utilidades */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-sm { margin-top: var(--gap-sm); }
.mt-md { margin-top: var(--gap-md); }
.mt-lg { margin-top: var(--gap-lg); }

/* ========== LAYOUT: acordeón + contenido ========== */
#accordian {
    flex: 0 0 200px;
    width: 200px;
    min-height: 400px;
    float: none;
    background: #0d3d28;
    color: #fff;
    font-size: 14px;
    text-shadow: 1px 1px 1px #000;
    border-radius: 6px;
    overflow: hidden;
}

#principal,
#partidos,
#partidoss,
#liga-container,
#ficha-container,
#today-matches,
#matches-container {
    flex: 1 1 auto;
    min-width: 0;
    float: none;
    margin: 0;
    width: auto;
    max-width: 100%;
}

/* ========== ACORDEÓN: logos, links y toggle ========== */
#accordian .liga-mini-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}

#accordian .items-menu li a {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#accordian .items-menu li a:hover {
    background: #152a08;
    border-left: 3px solid #a8d84a;
}

#accordian .material-icons.md-18 {
    font-size: 16px;
    vertical-align: middle;
    margin-right: 4px;
}

#accordian .acc-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 4px 6px;
    background: #0a2a18;
    color: #a8d84a;
    font-size: 14px;
    margin: 0;
}

#accordian .acc-arrow {
    font-size: 11px;
    opacity: 0.8;
    margin-left: 4px;
}

#accordian .acc-section > h3 {
    padding: 4px 6px;
    background: #0a2a18;
    color: #a8d84a;
    font-size: 14px;
    margin: 0;
}

/* ========== TABLA DE POSICIONES: forma reciente ========== */
#posiciones .form-cell { white-space: nowrap; }
#posiciones .form-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: bold;
    text-align: center;
    margin-right: 2px;
    color: #fff;
}
#posiciones .form-dot.w { background: #2AD572; }
#posiciones .form-dot.d { background: #FFD908; color: #000; }
#posiciones .form-dot.l { background: #ff6b6b; }

/* Leyenda de clasificación */
.leyenda-tabla {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 6px 4px;
    font-size: 12px;
    background: #0a2a18;
    color: #ddd;
}
.leyenda-tabla .leyenda-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.leyenda-tabla .leyenda-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .container { flex-direction: column; }
    #accordian { display: none; }
}

/* ========== ESCUDOS EN TABLAS Y LISTAS: chicos y alineados ========== */
#posiciones img,
#promedios img,
#promedios2 img,
#cuadroest img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
}

/* Los escudos en las filas de partido (index/partidos) */
.match-row img,
.team img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
}

/* Escudos en H2H / opponents list (ficha) */
.opponent-row img,
.shield {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 4px;
}

/* Escudo grande en cabecera de ficha */
.match-detail-header .team-info img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* Escudo grande en header de liga (si lo agregás después) */
.liga-header .liga-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* Que la tabla no se desborde con muchas columnas */
#posiciones {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}
#posiciones th,
#posiciones td {
    padding: 3px 4px;
    font-size: 12px;
    text-align: center;
}
#posiciones td:nth-child(2) {
    text-align: left;
}
#posiciones td:nth-child(2) a {
    color: #005a1a;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Contenedor de la tabla con scroll horizontal en mobile */
#liga-container {
    overflow-x: auto;
}

/* ============================================================
   ==========  PESTAÑAS (Clasificación / Estadísticas)  =======
   ============================================================ */
.liga-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: var(--gap-md);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.liga-tab {
    background: transparent;
    border: none;
    padding: 8px 14px;
    color: var(--text-dim);
    font-size: var(--fs-md);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.liga-tab:hover {
    color: var(--text-bright);
    background: var(--bg-hover);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.liga-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ============================================================
   ==========  SECCIÓN DE ESTADÍSTICAS  =======================
   ============================================================ */
.stats-subtitulo {
    font-size: var(--fs-lg);
    font-weight: 700;
    margin: var(--gap-lg) 0 var(--gap-md);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-left: 4px solid var(--accent);
    padding-left: 8px;
}

.stats-categoria {
    margin-bottom: var(--gap-lg);
}

.stats-categoria-titulo {
    font-size: var(--fs-md);
    font-weight: 600;
    margin: 0 0 var(--gap-sm);
    color: var(--text-bright);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding-left: 8px;
    border-left: 3px solid var(--accent-dark);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--gap-md);
}

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    transition: border-color .15s;
}

.stats-card:hover {
    border-color: var(--accent-dark);
}

.stats-card-header {
    font-size: var(--fs-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-bright);
    margin-bottom: var(--gap-sm);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.stats-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.stats-item {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    padding: 5px 0;
    border-bottom: 1px solid rgba(35, 53, 84, .5);
}

.stats-item:last-child {
    border-bottom: none;
}

.stats-rank {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text);
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Podio: oro, plata, bronce */
.stats-item:first-child .stats-rank {
    background: #facc15;
    color: #000;
}
.stats-item:nth-child(2) .stats-rank {
    background: #cbd5e1;
    color: #000;
}
.stats-item:nth-child(3) .stats-rank {
    background: #b45309;
    color: #fff;
}

.stats-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stats-player {
    font-size: var(--fs-md);
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.stats-team {
    font-size: var(--fs-xs);
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.stats-value {
    font-size: var(--fs-md);
    color: var(--accent);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Responsive: en mobile las cards ocupan todo el ancho */
@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stats-subtitulo {
        font-size: var(--fs-md);
    }
}