.resultados-page {
    --resultados-bg: #f4f6f8;
    --resultados-surface: #ffffff;
    --resultados-surface-soft: #eef2f6;

    --resultados-text: #17212b;
    --resultados-muted: #687583;

    --resultados-primary: #1d4f7a;
    --resultados-primary-dark: #10243e;
    --resultados-primary-light: #dce7f0;

    --resultados-border: #dce3e9;

    --win: #1c7045;
    --loss: #963b3b;

    background: var(--resultados-bg);
    color: var(--resultados-text);
}

.historico-hero {
    background:
        linear-gradient(
            135deg,
            var(--resultados-primary-dark),
            var(--resultados-primary)
        );

    color: white;

    padding:
        58px
        24px
        52px;
}

.historico-hero-inner {
    max-width: 1180px;
    margin: auto;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 40px;
}

.historico-hero h1 {
    margin:
        8px
        0
        10px;

    font-size:
        clamp(
            2rem,
            5vw,
            4rem
        );

    max-width: 780px;
    line-height: 1.03;
}

.historico-hero p {
    margin: 0;

    color: rgba(
        255,
        255,
        255,
        0.75
    );

    font-size: 1.1rem;
}

.historico-eyebrow {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.historico-eyebrow.dark {
    color: var(--resultados-primary);
}

.historico-status {
    padding: 9px 14px;

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            0.25
        );

    border-radius: 999px;

    font-size: 0.8rem;
    white-space: nowrap;
}

.historico-status.ok {
    background:
        rgba(
            255,
            255,
            255,
            0.12
        );
}

.historico-container {
    max-width: 1180px;

    margin: auto;

    padding:
        32px
        24px
        80px;
}

.historico-controls {
    display: flex;
    justify-content: flex-end;

    margin-bottom: 24px;
}

.historico-controls label {
    display: block;

    margin-bottom: 6px;

    font-size: 0.75rem;
    font-weight: 700;
    color: var(--resultados-muted);
}

.resultados-page select {
    min-width: 180px;

    padding:
        10px
        14px;

    border:
        1px solid
        var(--resultados-border);

    border-radius: 8px;

    background: white;
    color: var(--resultados-text);
}

.stats-grid {
    display: grid;

    grid-template-columns:
        repeat(
            6,
            1fr
        );

    gap: 14px;

    margin-bottom: 42px;
}

.stat {
    background: var(--resultados-surface);

    border:
        1px solid
        var(--resultados-border);

    border-radius: 12px;

    padding: 20px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
}

.stat-label {
    margin-top: 4px;

    color: var(--resultados-muted);

    font-size: 0.8rem;
}

.historico-section {
    background: var(--resultados-surface);

    border:
        1px solid
        var(--resultados-border);

    border-radius: 14px;

    overflow: hidden;
}

.historico-section-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;

    padding:
        28px
        28px
        20px;

    border-bottom:
        1px solid
        var(--resultados-border);
}

.historico-section-header h2 {
    margin:
        5px
        0
        0;
}

#match-count {
    color: var(--resultados-muted);
    font-size: 0.85rem;
}

.matches {
    display: flex;
    flex-direction: column;
}

.match {
    display: grid;

    grid-template-columns:
        120px
        minmax(
            0,
            1fr
        )
        150px;

    align-items: center;
    gap: 20px;

    padding:
        20px
        28px;

    border-bottom:
        1px solid
        var(--resultados-border);

    cursor: pointer;

    transition:
        background
        0.15s ease;
}

.match:last-child {
    border-bottom: none;
}

.match:hover {
    background:
        var(--resultados-surface-soft);
}

.match-date {
    font-size: 0.82rem;
    color: var(--resultados-muted);
}

.match-date strong {
    display: block;

    color: var(--resultados-text);

    font-size: 0.95rem;
}

.teams {
    min-width: 0;
}

.team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 2px 0;
}

.team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ferrol {
    font-weight: 800;
    color: var(--resultados-primary);
}

.team-score {
    font-size: 1.2rem;
    font-weight: 800;
}

.match-meta {
    text-align: right;

    color: var(--resultados-muted);

    font-size: 0.78rem;
}

.result {
    display: inline-block;

    margin-bottom: 5px;

    padding:
        4px
        8px;

    border-radius: 5px;

    font-size: 0.7rem;
    font-weight: 800;
}

.result.win {
    color: var(--win);
    background: #e4f2e9;
}

.result.loss {
    color: var(--loss);
    background: #f6e8e8;
}

.result.draw {
    color: #755b14;
    background: #f5eed8;
}

.loading {
    padding: 50px;
    text-align: center;
    color: var(--resultados-muted);
}


/* Modal */

.historico-modal {
    position: fixed;
    inset: 0;

    z-index: 100;
}

.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;

    background:
        rgba(
            5,
            15,
            9,
            0.68
        );
}

.modal-panel {
    position: absolute;

    top: 5vh;
    left: 50%;

    transform:
        translateX(-50%);

    width:
        min(
            1000px,
            calc(
                100% - 32px
            )
        );

    max-height: 90vh;
    overflow-y: auto;

    background: white;

    border-radius: 14px;

    padding: 34px;
}

.modal-close {
    position: absolute;

    right: 18px;
    top: 14px;

    border: 0;
    background: transparent;

    font-size: 2rem;
    cursor: pointer;
}

.detail-score {
    display: grid;

    grid-template-columns:
        1fr
        auto
        1fr;

    gap: 25px;
    align-items: center;

    margin:
        30px
        0;

    text-align: center;
}

.detail-score .score {
    font-size: 3rem;
    font-weight: 900;
}

.detail-team {
    font-size: 1.1rem;
    font-weight: 700;
}

.lineups {
    display: grid;

    grid-template-columns:
        1fr
        1fr;

    gap: 30px;

    margin-top: 30px;
}

.lineup {
    border:
        1px solid
        var(--resultados-border);

    border-radius: 10px;

    overflow: hidden;
}

.lineup h3 {
    margin: 0;

    padding:
        14px
        16px;

    background:
        var(--resultados-surface-soft);
}

.player {
    display: grid;

    grid-template-columns:
        40px
        1fr
        50px;

    gap: 10px;

    padding:
        9px
        14px;

    border-top:
        1px solid
        var(--resultados-border);

    font-size: 0.86rem;
}

.player-points {
    text-align: right;
    font-weight: 700;
}

.events {
    margin-top: 34px;
}

.event {
    display: grid;

    grid-template-columns:
        60px
        1fr
        100px;

    gap: 14px;

    padding:
        12px
        0;

    border-bottom:
        1px solid
        var(--resultados-border);

    font-size: 0.86rem;
}

.event-minute {
    font-weight: 800;
}

.event-score {
    text-align: right;
    font-weight: 800;
}

.event-player {
    color: var(--resultados-muted);

    margin-top: 3px;
}


@media (
    max-width: 800px
) {
    .historico-hero-inner {
        display: block;
    }

    .historico-status {
        display: inline-block;
        margin-top: 25px;
    }

    .stats-grid {
        grid-template-columns:
            repeat(
                2,
                1fr
            );
    }

    .match {
        grid-template-columns:
            1fr;

        gap: 10px;
    }

    .match-meta {
        text-align: left;
    }

    .lineups {
        grid-template-columns:
            1fr;
    }

    .detail-score {
        grid-template-columns:
            1fr;
    }
}


/* Temporada actual */

.current-season {
    margin-bottom: 32px;

    background:
        linear-gradient(
            135deg,
            #102c1e,
            #1b5135
        );

    color: white;

    border-radius: 14px;

    padding: 30px;
}

.current-season h2 {
    margin:
        5px
        0
        8px;

    font-size: 2rem;
}

.current-season p {
    color:
        rgba(
            255,
            255,
            255,
            0.72
        );
}

.pending-season {
    padding:
        20px
        0
        5px;
}

.pending-season strong {
    display: block;

    margin-bottom: 7px;

    font-size: 1.1rem;
}


/* Clasificaciones */

.standings-section {
    margin-bottom: 32px;
}

.standings-container {
    padding: 0 28px 28px;
}

.standing-block {
    margin-top: 25px;
}

.standing-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;

    margin-bottom: 12px;
}

.standing-header h3 {
    margin: 0;
}

.standing-phase {
    color: var(--resultados-muted);
    font-size: 0.82rem;
}

.standing-table {
    width: 100%;

    border-collapse: collapse;

    font-size: 0.85rem;
}

.standing-table th,
.standing-table td {
    padding:
        10px
        9px;

    border-bottom:
        1px solid
        var(--resultados-border);

    text-align: right;
}

.standing-table th {
    color: var(--resultados-muted);

    font-size: 0.7rem;

    text-transform: uppercase;
}

.standing-table th:nth-child(2),
.standing-table td:nth-child(2) {
    text-align: left;
}

.standing-table tr.ferrol-row {
    background:
        var(--resultados-primary-light);

    font-weight: 800;
}

.standing-pos {
    width: 35px;

    font-weight: 800;
}


@media (
    max-width: 800px
) {
    .standings-container {
        overflow-x: auto;
    }

    .standing-table {
        min-width: 720px;
    }
}


/* Navegación por categorías */

.category-navigation {
    background: #ffffff;

    border-bottom:
        1px solid
        var(--resultados-border);
}

.category-buttons {
    max-width: 1180px;

    margin: auto;

    padding:
        16px
        24px;

    display: flex;

    gap: 9px;

    overflow-x: auto;
}

.category-button {
    border:
        1px solid
        var(--resultados-border);

    background: white;

    color: var(--resultados-text);

    padding:
        9px
        17px;

    border-radius: 999px;

    font-size: 0.82rem;

    font-weight: 750;

    cursor: pointer;

    white-space: nowrap;

    transition:
        0.15s ease;
}

.category-button:hover {
    background:
        var(--resultados-surface-soft);
}

.category-button.active {
    background:
        var(--resultados-primary);

    border-color:
        var(--resultados-primary);

    color: white;
}

.category-count {
    margin-left: 5px;

    opacity: 0.55;

    font-size: 0.72rem;
}

.category-loading {
    color: var(--resultados-muted);

    font-size: 0.82rem;
}


/* Aviso de privacidad cantera */

.category-privacy {
    margin-bottom: 24px;

    padding:
        13px
        16px;

    background: #fff8df;

    border:
        1px solid #eadca6;

    border-radius: 9px;

    font-size: 0.82rem;

    color: #5f5225;
}


/* Portada */

.home-actions {
    margin-bottom: 30px;
}

.home-action {
    display: inline-block;

    padding:
        12px
        20px;

    background: var(--resultados-primary);

    color: white;

    border-radius: 8px;

    text-decoration: none;

    font-weight: 700;
}

.news-empty {
    padding: 50px 28px;

    color: var(--resultados-muted);
}

.news-empty strong {
    display: block;

    color: var(--resultados-text);

    margin-bottom: 7px;

    font-size: 1.1rem;
}


/*
 * Historical standings metadata
 */

.standing-source {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    opacity: 0.65;
}

.standing-notice,
.standing-warning {
    margin: 0 1.25rem 1rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 0.86rem;
    line-height: 1.45;
}

.standing-notice {
    background: #f4f6f8;
    border-left: 4px solid #697782;
}

.standing-warning {
    background: #fff7e6;
    border-left: 4px solid #c98b17;
}

@media (max-width: 700px) {
    .standing-notice,
    .standing-warning {
        margin-left: 0;
        margin-right: 0;
    }
}


/*
 * Historical derived phase summaries
 */

.phase-summary-block {
    border-top: 4px solid #697782;
}

.standing-derived-note {
    margin: 0 1.25rem 1rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    opacity: 0.82;
}

@media (max-width: 700px) {
    .standing-derived-note {
        margin-left: 0;
        margin-right: 0;
    }
}


/*
 * Final integration polish
 */

.historico-status {
    opacity: .82;
}

.category-navigation {
    background: var(--resultados-surface);
}

.category-button.active {
    background: var(--resultados-primary-dark);
    border-color: var(--resultados-primary-dark);
}

.ferrol-row {
    background: var(--resultados-primary-light);
}

.historico-section {
    box-shadow: 0 8px 28px rgba(16,36,62,.045);
}

.current-season {
    background:
        linear-gradient(
            135deg,
            var(--resultados-primary-dark),
            var(--resultados-primary)
        );
}


/*
 * Resultados compact layout
 */

.historico-hero {
    padding:
        44px
        24px
        38px;
}

.historico-hero h1 {
    font-size:
        clamp(
            2rem,
            4.2vw,
            3.4rem
        );

    max-width: 700px;
}

.historico-container {
    padding-top: 22px;
}

.historico-controls {
    margin-bottom: 18px;
}

.category-navigation {
    padding-top: 14px;
    padding-bottom: 14px;
}

.stats-grid {
    margin-bottom: 30px;
}


/*
 * Hide normal API status in public view
 */

.historico-status.ok {
    display: none;
}


.historico-hero-inner {
    align-items: center;
}

.historico-hero-inner > div:first-child {
    flex: 1;
}
