.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;
}

/* Resultados: jerarquía principal + opciones secundarias */

.resultados-more {
    margin-top: 2rem;
}

.resultados-more-title {
    margin-bottom: 1rem;
}

.resultados-option {
    margin-bottom: .75rem;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.resultados-option > summary {
    padding: 1rem 1.25rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.resultados-option > summary::-webkit-details-marker {
    display: none;
}

.resultados-option > summary::after {
    content: "+";
    float: right;
    font-size: 1.25rem;
    line-height: 1;
}

.resultados-option[open] > summary::after {
    content: "−";
}

.resultados-option > :not(summary) {
    margin-left: 1rem;
    margin-right: 1rem;
}

.resultados-option > :last-child {
    margin-bottom: 1rem;
}

@media (max-width: 700px) {
    .resultados-option > summary {
        padding: .9rem 1rem;
    }

    .standing-block {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

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


/* RESULTADOS COMPACTOS FINAL */

.historico-more {
    margin-top: 2rem;
}

.historico-option {
    margin-top: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.historico-option > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}

.historico-option > summary::-webkit-details-marker {
    display: none;
}

.historico-option > summary::after {
    content: "+";
    font-size: 1.5rem;
    line-height: 1;
}

.historico-option[open] > summary::after {
    content: "−";
}

.historico-option > .stats-grid,
.historico-option > .standings-section,
.historico-option > .historico-history-inner {
    padding: 0 1rem 1rem;
}

.current-season {
    display: grid;
    gap: 0.75rem;
}

.current-calendar-match {
    padding: 0.9rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: #fff;
}

.current-calendar-meta {
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    opacity: 0.72;
}

.current-calendar-teams {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        auto
        minmax(0, 1fr);
    align-items: center;
    gap: 0.8rem;
}

.current-calendar-teams span:last-child {
    text-align: right;
}

.current-calendar-teams strong {
    white-space: nowrap;
}

@media (max-width: 700px) {

    .standings-container {
        overflow-x: visible;
    }

    .standing-block {
        overflow: hidden;
    }

    .standing-table {
        width: 100%;
        min-width: 0 !important;
        table-layout: fixed;
    }

    .standing-table th,
    .standing-table td {
        padding: 0.45rem 0.18rem;
        font-size: 0.70rem;
    }

    .standing-table th:nth-child(7),
    .standing-table td:nth-child(7),
    .standing-table th:nth-child(8),
    .standing-table td:nth-child(8) {
        display: none;
    }

    .standing-table th:nth-child(1),
    .standing-table td:nth-child(1) {
        width: 8%;
    }

    .standing-table th:nth-child(2),
    .standing-table td:nth-child(2) {
        width: 38%;
        overflow-wrap: anywhere;
    }

    .current-calendar-match {
        padding: 0.8rem;
    }

    .current-calendar-teams {
        gap: 0.45rem;
        font-size: 0.82rem;
    }
}


/* ==========================================================
   RESULTADOS — DISEÑO FINAL
   ========================================================== */

.current-season {
    margin-bottom: 32px;
    padding: 0;
    background: transparent !important;
    color: var(--resultados-text) !important;
    border-radius: 0;
    display: grid;
    gap: 10px;
}

.current-season h2 {
    color: var(--resultados-text);
    margin: 0 0 12px;
}

.current-season p {
    color: var(--resultados-muted);
}

.current-calendar-match {
    padding: 14px 16px;
    border: 1px solid var(--resultados-border);
    border-radius: 10px;
    background: #fff;
    color: var(--resultados-text);
}

.current-calendar-meta {
    margin-bottom: 7px;
    color: var(--resultados-muted);
    opacity: 1;
}

.current-calendar-teams {
    color: var(--resultados-text);
}

.standing-source,
.standing-notice,
.standing-warning,
.standing-derived-note {
    display: none !important;
}

.phase-summary-block {
    border-top: 0;
}

.resultados-more {
    margin-top: 34px;
}

.resultados-more-title {
    margin: 0 0 14px;
}

.resultados-option {
    margin-bottom: 10px;
    border: 1px solid var(--resultados-border);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.resultados-option > summary {
    padding: 15px 18px;
    font-weight: 800;
}

#current-standings .standing-block,
#standings .standing-block:first-child {
    margin-top: 10px;
}

@media (max-width: 700px) {

    .historico-container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .standings-container {
        padding: 0 10px 18px;
        overflow: visible !important;
    }

    .standing-block {
        overflow: visible !important;
    }

    .standing-header {
        display: block;
        margin-bottom: 10px;
    }

    .standing-phase {
        margin-top: 4px;
    }

    .standing-table {
        width: 100%;
        min-width: 0 !important;
        table-layout: fixed;
    }

    .standing-table th,
    .standing-table td {
        padding: 8px 2px;
        font-size: .68rem;
        white-space: nowrap;
        text-align: center;
    }

    .standing-table th:nth-child(1),
    .standing-table td:nth-child(1) {
        width: 8%;
    }

    .standing-table th:nth-child(2),
    .standing-table td:nth-child(2) {
        width: 42%;
        text-align: left;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .standing-table th:nth-child(7),
    .standing-table td:nth-child(7),
    .standing-table th:nth-child(8),
    .standing-table td:nth-child(8) {
        display: none;
    }

    .standing-table th:nth-child(3),
    .standing-table td:nth-child(3),
    .standing-table th:nth-child(4),
    .standing-table td:nth-child(4),
    .standing-table th:nth-child(5),
    .standing-table td:nth-child(5),
    .standing-table th:nth-child(6),
    .standing-table td:nth-child(6),
    .standing-table th:nth-child(9),
    .standing-table td:nth-child(9) {
        width: 10%;
    }

    .current-season {
        margin-bottom: 26px;
    }

    .current-calendar-match {
        padding: 11px 10px;
    }

    .current-calendar-teams {
        gap: 6px;
        font-size: .78rem;
    }

    .current-calendar-teams span {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .resultados-more {
        margin-top: 24px;
    }

    .resultados-option > :not(summary) {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Calendario actual por jornada */
.journey-control {
    margin-bottom: 1rem;
}

.journey-control label {
    display: block;
    margin-bottom: .4rem;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.journey-control select {
    width: 100%;
    max-width: 240px;
    padding: .7rem .85rem;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-weight: 700;
}

#journey-matches {
    display: grid;
    gap: .75rem;
}

@media (max-width: 700px) {
    .journey-control select {
        max-width: none;
    }
}

/* Historico: separacion por fases */

.historical-phase {
    margin-top: 24px;
    border: 1px solid var(--resultados-border);
    border-radius: 12px;
    overflow: hidden;
}

.historical-phase:first-child {
    margin-top: 0;
}

.historical-phase-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 14px 28px;
    background: var(--resultados-surface-soft);
    border-bottom: 1px solid var(--resultados-border);
}

.historical-phase-header span {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--resultados-muted);
}

.historical-phase-header strong {
    font-size: 1rem;
    color: var(--resultados-text);
}

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

@media (max-width: 800px) {
    .historical-phase-header {
        padding: 12px 18px;
    }
}
