﻿.finish-page {
    --navy: #071d49;
    --blue: #0067db;
    color-scheme: light;
    min-height: 100vh;
    min-height: 100dvh;
    background: #f1f4f8;
    color: var(--navy);
    font-family: "Segoe UI", Arial, sans-serif;
}

    .finish-page * {
        box-sizing: border-box;
    }

.finish-header {
    background: var(--navy);
    color: white;
    border-top: 5px solid #1685f8;
}

.header-inner, .tabs-inner, .finish-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 28px 24px;
}

.eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #b9d2f7;
}

.finish-header h1 {
    margin: 8px 0 0;
    color: white;
    font-size: clamp(28px, 5vw, 48px);
    font-weight: 900;
    letter-spacing: -1.5px;
    line-height: 1;
}

    .finish-header h1 span {
        color: #39a1ff;
    }

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4658;
}

.finish-tabs {
    background: white;
    border-bottom: 1px solid #dce3ed;
}

.tabs-inner {
    display: flex;
    align-items: stretch;
    padding: 0 24px;
}

.finish-tab {
    padding: 19px 28px;
    border: 0;
    border-bottom: 4px solid transparent;
    background: transparent;
    color: #65748d;
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

    .finish-tab.selected {
        color: var(--blue);
        border-bottom-color: var(--blue);
    }

    .finish-tab:hover {
        background: #f1f6fe;
    }

.finish-page button:focus-visible {
    outline: 3px solid #1685f8;
    outline-offset: 2px;
}

.participant-count {
    margin-left: auto;
    align-self: center;
    color: #64728a;
    font-size: 12px;
}

.finish-content {
    padding: 20px 24px 48px;
}

.time-legend {
    display: flex;
    justify-content: flex-end;
    gap: 18px;
    margin-bottom: 22px;
    color: #52617a;
    font-size: 11px;
    font-weight: 600;
}

    .time-legend span {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .time-legend i {
        width: 10px;
        height: 10px;
        border-radius: 2px;
    }

.legend-red {
    background: #d51f36;
}

.legend-yellow {
    background: #ffe04c;
}

.results-section {
    margin-bottom: 30px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-left: 12px;
    border-left: 4px solid var(--blue);
}

    .section-heading h2 {
        margin: 0;
        font-size: clamp(18px, 3vw, 25px);
        font-weight: 900;
        letter-spacing: -.5px;
    }

    .section-heading > span {
        color: #63728b;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 1px;
    }

.results-list {
    overflow: hidden;
    border: 1px solid #dce3ed;
    border-radius: 8px;
    background: white;
}

.result-columns, .result-row {
    display: grid;
    grid-template-columns: 64px 64px minmax(0, 1fr) 150px 64px;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
}

.result-columns {
    background: var(--navy);
    color: #d4e1f6;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .7px;
}

.result-entry {
    border-bottom: 1px solid #e3e9f1;
}

    .result-entry:last-child {
        border-bottom: 0;
    }

    .result-entry:nth-child(odd) > .result-row {
        background: #f4f7fb;
    }

.result-row {
    min-height: 88px;
}

.result-rank {
    font-size: 23px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.result-flag img {
    display: block;
    width: 38px;
    height: 26px;
    object-fit: contain;
}

.flag-fallback {
    font-size: 10px;
    font-weight: 800;
    color: #63728b;
}

.result-athlete {
    min-width: 0;
}

.athlete-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 36px;
    padding: 3px 0;
    border: 0;
    background: transparent;
    color: var(--navy);
    text-align: left;
    font: inherit;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.25;
    cursor: pointer;
}

    .athlete-toggle > span:first-child {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .athlete-toggle:hover {
        color: var(--blue);
    }

.expand-symbol {
    flex-shrink: 0;
    color: var(--blue);
    font-size: 19px;
}

.athlete-category {
    margin-top: 2px;
    color: #61718a;
    font-size: 12px;
    font-weight: 600;
}

.athlete-country {
    margin-top: 3px;
    color: #64728a;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.result-time, .result-order, .align-right {
    text-align: right;
}

.time-chip {
    display: inline-block;
    min-width: 124px;
    padding: 11px 12px;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: center;
}

    .time-chip.finished {
        background: #d51f36;
        color: white;
    }

    .time-chip.racing {
        background: #ffe04c;
        color: #17233b;
    }

.result-order {
    color: #758198;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.podium-list {
    border-top: 3px solid #cfaa45;
}

.podium-section .section-heading {
    border-left-color: #cfaa45;
}

.message-box {
    padding: 36px 18px;
    border: 1px solid #dce3ed;
    border-radius: 8px;
    background: white;
    color: #63728b;
    text-align: center;
}

.retry-button {
    padding: 10px 18px;
    border: 0;
    border-radius: 4px;
    background: var(--blue);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

/* Desplegable del atleta */
.athlete-detail {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: start;
    gap: 24px;
    padding: 24px;
    background: #eaf0f8;
    border-top: 1px solid #d6e1ee;
}

.athlete-photo-column, .athlete-detail-content {
    min-width: 0;
}

.athlete-photo {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: center top;
    border-radius: 8px;
    background: white;
}

.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    background: #d6e1f0;
    color: #566b8d;
    text-align: center;
}

    .photo-placeholder > span {
        font-size: 40px;
        font-weight: 900;
    }

    .photo-placeholder small {
        padding: 0 5px;
        font-size: 11px;
    }

.athlete-detail h3 {
    margin: 0 0 12px;
    color: var(--navy);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .6px;
}

.ranking-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ranking-card {
    flex: 1 1 120px;
    min-width: 0;
    padding: 12px;
    border-radius: 6px;
    background: white;
    border-top: 3px solid var(--blue);
}

    .ranking-card strong {
        display: block;
        color: var(--blue);
        font-size: 25px;
        font-variant-numeric: tabular-nums;
    }

    .ranking-card span {
        display: block;
        margin-top: 4px;
        color: #566780;
        font-size: 11px;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

.athlete-detail .history-heading {
    margin-top: 22px;
}

.history-list {
    overflow: hidden;
    border: 1px solid #d6e1ee;
    border-radius: 6px;
    background: white;
}

.history-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 85px;
    align-items: center;
    gap: 12px;
    padding: 13px;
    border-bottom: 1px solid #e3e9f1;
}

    .history-row:last-child {
        border-bottom: 0;
    }

.history-position {
    display: flex;
    flex-direction: column;
    text-align: center;
    overflow-wrap: anywhere;
}

    .history-position small {
        color: #6b7b91;
        font-size: 9px;
    }

    .history-position strong {
        font-size: 19px;
    }

.history-event {
    min-width: 0;
    overflow-wrap: anywhere;
}

    .history-event strong {
        display: block;
        font-size: 12px;
        line-height: 1.4;
    }

    .history-event span, .history-event time {
        display: block;
        margin-top: 4px;
        color: #66758a;
        font-size: 10px;
    }

.history-time {
    text-align: right;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.detail-empty {
    color: #63728b;
    font-size: 12px;
}

@media (max-width: 600px) {
    .header-inner {
        padding: 22px 14px;
    }

    .eyebrow {
        font-size: 9px;
        letter-spacing: 1px;
    }

    .live-badge {
        font-size: 9px;
        letter-spacing: 0;
        gap: 5px;
    }

    .tabs-inner {
        padding: 0 10px;
    }

    .finish-tab {
        padding: 16px 19px;
        font-size: 13px;
    }

    .participant-count {
        font-size: 10px;
    }

    .finish-content {
        padding: 16px 10px 30px;
    }

    .time-legend {
        margin-bottom: 20px;
        font-size: 10px;
    }

    .result-columns, .result-row {
        grid-template-columns: 33px 29px minmax(0, 1fr) 88px 32px;
        gap: 6px;
        padding: 12px 8px;
    }

    .result-columns {
        font-size: 8px;
        letter-spacing: 0;
    }

    .result-rank {
        font-size: 18px;
    }

    .result-flag img {
        width: 27px;
        height: 19px;
    }

    .athlete-toggle {
        min-height: 44px;
        font-size: 13px;
        gap: 4px;
    }

    .athlete-category, .athlete-country {
        font-size: 10px;
    }

    .time-chip {
        width: 100%;
        min-width: 0;
        padding: 10px 3px;
        font-size: 13px;
    }

    .result-order {
        font-size: 10px;
    }

    .section-heading {
        padding-left: 9px;
    }

    .athlete-detail {
        grid-template-columns: 72px minmax(0, 1fr);
        gap: 10px;
        padding: 12px 8px;
    }

    .photo-placeholder > span {
        font-size: 25px;
    }

    .photo-placeholder small {
        font-size: 9px;
    }

    .athlete-detail h3 {
        font-size: 11px;
    }

    .ranking-card {
        flex-basis: 80px;
        padding: 8px;
    }

        .ranking-card strong {
            font-size: 21px;
        }

        .ranking-card span {
            font-size: 10px;
        }

    .history-row {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 6px;
        padding: 9px 6px;
    }

    .history-time {
        grid-column: 2;
        text-align: left;
    }

    .history-position strong {
        font-size: 15px;
    }

    .history-event strong {
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .result-columns, .result-row {
        grid-template-columns: 28px 24px minmax(0, 1fr) 78px 28px;
        gap: 4px;
        padding-left: 6px;
        padding-right: 6px;
    }

    .result-flag img {
        width: 23px;
    }

    .time-chip {
        font-size: 12px;
    }

    .athlete-detail {
        grid-template-columns: 60px minmax(0, 1fr);
    }
}

/* Cabecera compacta con pestañas integradas */
.finish-header {
    border-top: 3px solid #1685f8;
}

    .finish-header .header-inner {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 12px;
        padding: 10px 24px;
        min-height: 62px;
    }

    .finish-header h1 {
        margin: 0;
        font-size: 25px;
        line-height: 1;
        letter-spacing: -1px;
    }

.header-tabs {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: auto;
    margin-left: 20px;
}

    .header-tabs .finish-tab {
        min-height: 42px;
        padding: 10px 22px;
        border: 1px solid transparent;
        border-radius: 5px;
        background: transparent;
        color: #c6d7f0;
        font-size: 13px;
        font-weight: 900;
    }

        .header-tabs .finish-tab:hover {
            background: #173464;
            color: white;
        }

        .header-tabs .finish-tab.selected {
            background: #0878ec;
            border-color: #2892ff;
            color: white;
        }

.live-badge {
    font-size: 10px;
    letter-spacing: .3px;
}

.finish-content {
    padding-top: 18px;
    padding-bottom: 12px;
}

.results-section {
    margin-bottom: 22px;
}

.section-heading h2 {
    font-size: 22px;
}

/* Filas más compactas */
.result-row {
    min-height: 78px;
    padding-top: 11px;
    padding-bottom: 11px;
}

.athlete-toggle {
    min-height: 36px;
}

/* Categoría y país juntos, más grandes y en negrita */
.athlete-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    column-gap: 7px;
    row-gap: 2px;
    margin-top: 3px;
    color: #435570;
    font-size: 14px;
    font-weight: 750;
    line-height: 1.35;
}

.meta-separator {
    color: #7b8aa0;
}

/* Color del tiempo según estado */
.time-chip.finished {
    background: #168348;
    color: white;
}

.time-chip.racing {
    background: #ffe04c;
    color: #17233b;
}

/* Medallas: colorear toda la fila.
   Estos selectores prevalecen sobre las filas alternas. */
.results-list .result-entry > .result-row.medal-gold {
    background: linear-gradient(90deg, #f6dfa0 0%, #fff4d6 100%);
    box-shadow: inset 5px 0 0 #c99b22;
}

.results-list .result-entry > .result-row.medal-silver {
    background: linear-gradient(90deg, #dce3eb 0%, #f0f3f7 100%);
    box-shadow: inset 5px 0 0 #92a0b2;
}

.results-list .result-entry > .result-row.medal-bronze {
    background: linear-gradient(90deg, #e9c7ae 0%, #faeade 100%);
    box-shadow: inset 5px 0 0 #b57849;
}

.medal-gold .result-rank {
    color: #785500;
}

.medal-silver .result-rank {
    color: #45556c;
}

.medal-bronze .result-rank {
    color: #79401f;
}

/* Leyenda al pie */
.results-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px 22px;
    border-top: 1px solid #dce3ed;
}

.footer-count {
    color: #52617a;
    font-size: 12px;
    font-weight: 700;
}

.results-footer .time-legend {
    margin: 0;
    gap: 16px;
    font-size: 12px;
    font-weight: 700;
}

.legend-green {
    background: #168348;
}

.legend-yellow {
    background: #ffe04c;
}

/* Móvil */
@media (max-width: 600px) {
    .finish-header .header-inner {
        gap: 8px;
        min-height: 54px;
        padding: 7px 10px;
    }

    .finish-header h1 {
        font-size: 18px;
        letter-spacing: -.6px;
    }

    .header-tabs {
        gap: 3px;
        margin-left: auto;
        margin-right: 0;
    }

        .header-tabs .finish-tab {
            min-height: 40px;
            padding: 9px 13px;
            font-size: 11px;
        }

    .finish-header .live-badge {
        display: none;
    }

    .finish-content {
        padding-top: 14px;
        padding-bottom: 8px;
    }

    .section-heading h2 {
        font-size: 18px;
    }

    .result-row {
        min-height: 76px;
        padding-top: 9px;
        padding-bottom: 9px;
    }

    .athlete-toggle {
        min-height: 44px;
    }

    .athlete-meta {
        column-gap: 4px;
        font-size: 11px;
        font-weight: 800;
        margin-top: 1px;
    }

    .results-footer {
        padding: 12px 10px 18px;
    }

        .footer-count,
        .results-footer .time-legend {
            font-size: 10px;
        }

        .results-footer .time-legend {
            gap: 10px;
        }
}

/* Ajuste compacto: nombre, categoría, país y columnas de resultados. */
.finish-page .result-columns,
.finish-page .result-row {
    grid-template-columns: 48px 40px minmax(0, 1fr) 136px 36px;
    column-gap: 5px;
    padding-left: 10px;
    padding-right: 10px;
}

.finish-page .result-rank {
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow-wrap: normal;
    font-size: 23px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.finish-page .result-columns > span:first-child {
    text-align: center;
}

.finish-page .result-flag {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Conserva la columna y sus números; oculta únicamente su título. */
.finish-page .result-columns > span:last-child {
    visibility: hidden;
}

.finish-page .athlete-toggle {
    min-height: 0;
    margin: 0;
    padding: 0;
    line-height: 1.15;
    gap: 5px;
}

.finish-page .athlete-meta {
    margin: 2px 0 0;
    padding: 0;
    line-height: 1.2;
    column-gap: 5px;
    row-gap: 1px;
    font-size: 14px;
    font-weight: 800;
}

@media (max-width: 600px) {
    html, body {
        margin: 0;
        padding: 0;
    }

    .finish-page .finish-content {
        padding: 10px 4px 4px;
    }

    .finish-page .results-section {
        margin: 0 0 14px;
    }

    .finish-page .section-heading {
        margin: 0 2px 8px;
        padding-left: 7px;
    }

    .finish-page .results-list {
        margin: 0;
        border-radius: 5px;
    }

    .finish-page .result-columns,
    .finish-page .result-row {
        grid-template-columns: 34px 27px minmax(0, 1fr) 84px 23px;
        column-gap: 3px;
        padding: 8px 4px;
    }

    .finish-page .result-row {
        min-height: 60px;
    }

    .finish-page .result-columns {
        font-size: 8px;
        line-height: 1.25;
        letter-spacing: 0;
    }

    .finish-page .result-rank {
        font-size: 18px;
    }

    .finish-page .result-flag img {
        width: 26px;
        height: 19px;
    }

    .finish-page .athlete-toggle {
        font-size: 13px;
        min-height: 0;
        padding: 0;
    }

    .finish-page .expand-symbol {
        font-size: 16px;
        line-height: 1;
    }

    .finish-page .athlete-meta {
        font-size: 11px;
        margin-top: 2px;
        column-gap: 3px;
    }

    .finish-page .time-chip {
        width: 100%;
        min-width: 0;
        padding: 8px 2px;
        font-size: 13px;
    }

    .finish-page .result-order {
        font-size: 10px;
    }

    .finish-page .athlete-detail {
        padding: 9px 5px;
        gap: 8px;
    }

    .finish-page .results-footer {
        padding: 10px 6px 14px;
    }
}

@media (max-width: 360px) {
    .finish-page .result-columns,
    .finish-page .result-row {
        grid-template-columns: 32px 24px minmax(0, 1fr) 76px 21px;
        column-gap: 2px;
        padding-left: 3px;
        padding-right: 3px;
    }

    .finish-page .result-rank {
        font-size: 17px;
    }

    .finish-page .result-flag img {
        width: 23px;
        height: 17px;
    }

    .finish-page .time-chip {
        font-size: 12px;
    }
}
@media (max-width: 600px) {
    .finish-page .athlete-detail {
        display: grid;
        grid-template-columns: 76px minmax(0, 1fr);
        grid-template-rows: auto auto auto auto;
        gap: 8px 10px;
        padding: 12px 8px;
        align-items: start;
    }

    /* Los elementos interiores participan en el grid principal */
    .finish-page .athlete-detail-content {
        display: contents;
    }

    /* Foto a la izquierda del título y los rankings */
    .finish-page .athlete-photo-column {
        grid-column: 1;
        grid-row: 1 / 3;
    }

    .finish-page .athlete-photo,
    .finish-page .photo-placeholder {
        width: 100%;
        border-radius: 7px;
    }

    /* Título de rankings */
    .finish-page .athlete-detail-content > h3:first-child {
        grid-column: 2;
        grid-row: 1;
        margin: 0;
        font-size: 12px;
    }

    /* Rankings compactos a la derecha */
    .finish-page .ranking-cards {
        grid-column: 2;
        grid-row: 2;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .finish-page .ranking-card {
        min-width: 0;
        padding: 8px;
        border-radius: 5px;
    }

        .finish-page .ranking-card strong {
            font-size: 22px;
            line-height: 1.1;
        }

        .finish-page .ranking-card span {
            margin-top: 4px;
            font-size: 10px;
            line-height: 1.2;
        }

    /* Título de resultados a todo el ancho */
    .finish-page .athlete-detail .history-heading {
        grid-column: 1 / -1;
        grid-row: 3;
        margin: 10px 0 2px;
        font-size: 12px;
    }

    /* Historial debajo de la foto y los rankings */
    .finish-page .history-list {
        grid-column: 1 / -1;
        grid-row: 4;
        width: 100%;
        min-width: 0;
    }

    .finish-page .history-row {
        grid-template-columns: 32px minmax(0, 1fr) 70px;
        gap: 8px;
        padding: 10px 8px;
    }

    .finish-page .history-time {
        grid-column: 3;
        text-align: right;
        white-space: nowrap;
        font-size: 11px;
    }

    /* Mensajes cuando faltan datos */
    .finish-page .athlete-detail-content > .detail-empty {
        grid-column: 2;
        grid-row: 2;
        margin: 0;
    }

    .finish-page .athlete-detail-content >
    .history-heading + .detail-empty {
        grid-column: 1 / -1;
        grid-row: 4;
    }
}