:root {
    --border-color: #B4B4B4;
    --orange: #f47c20;
    --page-background: #ffffff;
    --section-background: #ffffff;

    /* Texto y estructura */
    --text: #404040;
    --text-muted: #555555;
    --text-soft: #666666;
    --text-faint: #777777;
    --text-lighter: #9a9a9a;
    --heading-bg: #f1f1f1;
    --panel-bg: #f7f7f7;
    --hover-bg: #eeeeee;
    --table-bg: #ffffff;
    --pole-row-bg: #f4f4f4;
    --input-bg: #ffffff;
    --bar-track-bg: #e6e6e6;
    --detail-nav-bg: rgba(255, 255, 255, 0.96);
    --chart-empty-color: #bdbdbd;
    --scrollbar-thumb: #b7b7b7;
    --scrollbar-track: #eeeeee;

    /* Texto fijo de las celdas "chip" de la REJILLA de resultados por
       ronda (P1/P2/P3/top-10/etc. en las columnas QAT/AME/...): siempre
       pastel + texto oscuro, en ambos temas. */
    --sticker-text: #404040;
    /* Texto de las celdas "chip" de la tabla de ESTADÍSTICAS y del podio
       P1/P2/P3 del campeonato, que sí cambian con el tema. */
    --stat-sticker-text: #404040;
    --standing-sticker-text: #404040;

    /* Colores de la REJILLA de resultados por ronda: no cambian entre
       temas. */
    --result-p1: #FFFFB9;
    --result-p2: #E6E6E6;
    --result-p3: #FFDC97;
    --result-top-10: #DFFFDF;
    --result-points-zone: #CFEAFF;
    --result-other: #CFCFFF;
    --result-retired: #EBCFFF;

    /* Colores de la tabla de ESTADÍSTICAS (Victorias/Podios/Poles/etc.):
       estos sí cambian en modo oscuro, a los mismos tonos saturados que
       las tarjetas de estadística de los perfiles. */
    --stat-victories: #FFFFB9;
    --stat-podiums: #FFDC97;
    --stat-poles: #FFB9B9;
    --stat-top-tens: #DFFFDF;
    --stat-fastest-laps: #CFCFFF;
    --stat-leads: #CFEAFF;
    --stat-dnfs: #EBCFFF;
    --stat-grand-prix: #F0F0F0;
    --stat-activity: #E6E6E6;

    /* Colores del podio P1/P2/P3 del campeonato (pilotos y equipos):
       cambian en modo oscuro, igual que la tabla de estadísticas. */
    --standing-p1: #FFFFB9;
    --standing-p2: #E6E6E6;
    --standing-p3: #FFDC97;
}

/* Tema oscuro: se activa con data-theme="dark" en <body> (ver toggle en la
   plantilla). Los colores de la tabla de RESULTADOS se quedan igual que en
   claro (pastel + texto oscuro); solo la tabla de ESTADÍSTICAS pasa a los
   tonos saturados de las tarjetas de perfil (oro para victorias, bronce
   para podios, etc.) con texto blanco. */
body[data-theme="dark"] {
    --border-color: #3a3d42;
    --page-background: #16181c;
    --section-background: #1c1e22;
    --text: #e4e6eb;
    --text-muted: #b8bcc4;
    --text-soft: #9aa0aa;
    --text-faint: #82868f;
    --text-lighter: #6b6f78;
    --heading-bg: #24262b;
    --panel-bg: #1f2125;
    --hover-bg: #2a2d32;
    --table-bg: #1c1e22;
    --pole-row-bg: #23252a;
    --input-bg: #1c1e22;
    --bar-track-bg: #2a2d32;
    --detail-nav-bg: rgba(28, 30, 34, 0.96);
    --chart-empty-color: #6b6f78;
    --scrollbar-thumb: #4a4d53;
    --scrollbar-track: #1c1e22;

    --stat-sticker-text: #ffffff;
    --stat-victories: #C99A00;
    --stat-podiums: #C46F22;
    --stat-poles: #D94F55;
    --stat-top-tens: #2D9B57;
    --stat-fastest-laps: #6C63C7;
    --stat-leads: #287DB4;
    --stat-dnfs: #A94E9A;
    --stat-grand-prix: #4C535D;
    --stat-activity: #686D75;

    --standing-sticker-text: #ffffff;
    --standing-p1: #C99A00;
    --standing-p2: #8A8F98;
    --standing-p3: #C46F22;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page-background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.page {
    width: fit-content;
    max-width: calc(100% - 24px);
    margin: 0 auto;
    padding: 16px 0 40px;
}

.season-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    padding: 12px 18px;
    background: var(--category-color, var(--orange));
    color: #ffffff;
}

/* Color de cabecera según la categoría */
.season-header-moto2,
.season-header-sbk {
    background: var(--category-color, var(--orange));
}

.season-header h1 {
    margin: 0;
    font-size: 22px;
}

.season-header p {
    margin: 4px 0 0;
    font-size: 13px;
}

.season-navigation {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 42px;
    padding: 8px 12px;
    background: #252525;
    color: #f2f2f2;
    font-size: 12px;
}

.season-navigation .next-season {
    text-align: right;
}

.season-navigation a {
    color: #f2f2f2;
    text-decoration: none;
}

.season-navigation a:hover {
    text-decoration: underline;
}

.standings-section {
    width: fit-content;
    max-width: 100%;
    margin-top: 16px;
    border: 0;
    background: var(--section-background);
}

.table-heading {
    margin: 0;
    padding: 8px 10px;
    color: var(--text);
    font-size: 15px;
}

.table-container {
    display: block;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    background: transparent;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.results-table {
    width: auto;
    min-width: 0;
    border-collapse: collapse;
    background: var(--table-bg);
    font-size: 12px;
}

.results-table th,
.results-table td {
    height: 24px;
    padding: 1px 3px;
    border: 1px solid var(--border-color);
    line-height: 1;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

/*
   Ajuste óptico: el texto de las filas de datos se desplaza 1 px hacia abajo.
   Se usa más padding arriba y menos abajo porque el centrado geométrico de
   Arial no siempre coincide con su centrado visual.
*/
.results-table tbody td {
    padding-top: 2px;
    padding-bottom: 0;
}

.results-table th {
    background: var(--heading-bg);
    font-weight: 700;
}

.position {
    width: 32px;
    font-weight: 700;
}

.movement-column {
    width: 24px;
    min-width: 24px;
    text-align: center;
    padding: 0 !important;
}

.movement-column svg {
    width: 10px;
    height: 10px;
    fill: #ffffff;
}

.movement-neutral-cell {
    color: var(--text-lighter);
    font-weight: 700;
}

.movement-promoted-cell {
    background: #3B82F6;
}

.movement-relegated-cell {
    background: #EF4444;
}

.standing-relegated-name,
.standing-relegated-name a {
    color: #9A9EA6 !important;
}

.number {
    width: 30px;
    font-weight: 700;
}

.points {
    width: 32px;
    font-weight: 700;
}

.driver-column,
.driver-cell {
    min-width: 160px;
}

.driver-cell {
    text-align: left !important;
}

.driver-content {
    display: flex;
    align-items: center;
    gap: 4px;
}

.driver-content img {
    width: 26px;
    height: 13px;
    flex: 0 0 auto;
    object-fit: contain;
}

.round-column {
    width: 32px;
    min-width: 32px;
    padding: 2px !important;
}

.round-column span {
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    line-height: 1;
}

.round-column img {
    display: block;
    width: 22px;
    height: 15px;
    margin: 0 auto;
    object-fit: contain;
}

.manufacturer-column,
.manufacturer-cell {
    width: 65px;
    min-width: 65px;
}

/* Colores propios de cada equipo */
.team-cell {
    background: var(--team-primary, #f2f2f2) !important;
    color: var(--team-secondary, #111111) !important;
}

/* Colores según la posición */
.result-win {
    background: var(--result-p1);
    color: var(--sticker-text);
}

.result-second {
    background: var(--result-p2);
    color: var(--sticker-text);
}

.result-third {
    background: var(--result-p3);
    color: var(--sticker-text);
}

.result-top-ten {
    background: var(--result-top-10);
    color: var(--sticker-text);
}

.result-points-zone {
    background: var(--result-points-zone);
    color: var(--sticker-text);
}

.result-other {
    background: var(--result-other);
    color: var(--sticker-text);
}

.result-retired {
    background: var(--result-retired);
    color: var(--sticker-text);
}

/* DNS siempre se representa en blanco, nunca como abandono. */
.result-dns {
    background: #ffffff !important;
    color: #404040 !important;
}

.result-dsq {
    background: #262626;
    color: #ffffff;
}

/* La vuelta rápida se distingue en cursiva */
.fastest-lap {
    font-style: italic;
}

.pole-position {
    font-weight: 700;
}

/* Fila inferior de poles */
.pole-row td {
    height: 18px;
    padding-top: 1px;
    padding-bottom: 1px;
    background: var(--pole-row-bg);
    font-weight: 700;
}

.pole-row td:first-child {
    text-align: right;
}

.pole-cell {
    font-size: 11px;
    font-weight: 700;
}

.round-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.round-link:hover {
    opacity: 0.7;
}

@media (max-width: 700px) {
    .page {
        max-width: calc(100% - 8px);
        padding-top: 4px;
    }

    .season-header {
        min-height: 58px;
        padding: 10px;
    }

    .season-header h1 {
        font-size: 18px;
    }

    .season-navigation {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: center;
    }

    .season-navigation .next-season {
        text-align: center;
    }

    .results-table {
        font-size: 12px;
    }
}

/* =========================================================
   TABLAS ESTADÍSTICAS
   ========================================================= */

.statistics-section {
    width: fit-content;
    max-width: 100%;
    margin-top: 16px;
    border: 0;
    background: var(--section-background);
}

/*
   Las columnas comunes reutilizan las clases de la tabla principal:
   .position, .number, .driver-column, .driver-cell,
   .manufacturer-column, .manufacturer-cell y .points.
   Así, cualquier cambio de tamaño hecho arriba también se aplica aquí.
*/

.statistics-team-cell {
    font-weight: 700;
}

.statistics-table .stat-victories {
    min-width: 65px;
    background: var(--stat-victories);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-podiums {
    min-width: 65px;
    background: var(--stat-podiums);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-poles {
    min-width: 65px;
    background: var(--stat-poles);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-top-tens {
    min-width: 65px;
    background: var(--stat-top-tens);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-fastest-laps {
    min-width: 65px;
    background: var(--stat-fastest-laps);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-leads {
    min-width: 65px;
    background: var(--stat-leads);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-dnfs {
    min-width: 65px;
    background: var(--stat-dnfs);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-grand-prix {
    min-width: 65px;
    background: var(--stat-grand-prix);
    color: var(--stat-sticker-text);
}

.statistics-table .stat-activity {
    min-width: 65px;
    background: var(--stat-activity);
    color: var(--stat-sticker-text);
}

/* Nombres de los equipos en negrita */
.team-statistics-table .team-cell {
    font-weight: 700;
}

/* Mayor altura para la cabecera de ambas tablas estadísticas */
.statistics-table thead th {
    height: 38px;
    padding-top: 5px;
    padding-bottom: 5px;
    line-height: 1.15;
}

/* Cabecera de los Grandes Premios especiales */
.results-table th.round-column.special-race {
    background: var(--result-p1);
    color: var(--sticker-text);
}

/* Cabecera de los Grandes Premios disputados en mojado */
.results-table th.round-column.wet-race {
    background: #8FCFDF;
    color: var(--sticker-text);
}

/* GP especial disputado en mojado: se mantiene la celda dorada y solo
   el nombre abreviado del GP se pinta con el azul de lluvia. */
.results-table th.round-column.special-race.wet-race {
    background: var(--result-p1);
    color: var(--sticker-text);
}

.results-table th.round-column.special-race.wet-race .round-link span {
    color: #8FCFDF;
}

/* =========================================================
   RITMOS DE CLASIFICACIÓN Y CARRERA
   ========================================================= */

.pace-section {
    width: fit-content;
    max-width: 100%;
    margin-top: 16px;
    border: 0;
    background: var(--section-background);
}

.pace-grid {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    padding: 0 10px 10px;
}

.pace-panel {
    width: fit-content;
    max-width: 100%;
}

.pace-panel h3 {
    margin: 8px 0 6px;
    color: var(--text);
    font-size: 13px;
}

.pace-value-column,
.pace-value {
    width: 65px;
    min-width: 65px;
}

.pace-value {
    color: var(--text-muted);
    font-weight: 700;
}

.pace-bar-column,
.pace-bar-cell {
    width: 230px;
    min-width: 230px;
}

.pace-bar-cell {
    padding: 4px 6px !important;
}

.pace-bar-track {
    width: 100%;
    height: 12px;
    overflow: hidden;
    background: var(--bar-track-bg);
}

.pace-bar-fill {
    display: block;
    width: var(--pace-width, 0%);
    min-width: 2px;
    height: 100%;
    background: var(--pace-color, #f47c20);
}

.pace-manufacturer-column,
.pace-manufacturer-cell {
    width: 110px;
    min-width: 110px;
}

.pace-manufacturer-cell {
    text-align: left !important;
    font-weight: 700;
}

.pace-team-column,
.pace-team-cell {
    width: 190px;
    min-width: 190px;
}

.pace-team-cell {
    border-left: 4px solid var(--team-pace-color, #f47c20) !important;
    text-align: left !important;
    font-weight: 700;
}

.pace-component-column,
.pace-component-value {
    width: 72px;
    min-width: 72px;
}

.pace-component-value {
    color: var(--text-soft);
    font-weight: 600;
}

.pace-empty {
    height: 35px !important;
    color: var(--text-faint);
    text-align: center;
}

@media (max-width: 900px) {
    .pace-grid {
        flex-direction: column;
    }
}

/* =========================================================
   EVOLUCIÓN DEL CAMPEONATO
   ========================================================= */

.charts-section {
    width: 1280px;
    max-width: 100%;
    margin-top: 16px;
    border: 0;
    background: var(--section-background);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 0 10px 10px;
}

.chart-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
}

.chart-card h3 {
    margin: 0;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--heading-bg);
    color: var(--text);
    font-size: 13px;
}

.chart-canvas-container {
    position: relative;
    width: 100%;
    height: 500px;
    padding: 8px;
}

.chart-empty {
    margin: 0;
    padding: 14px 10px;
    color: var(--chart-empty-color);
    font-size: 13px;
}

@media (max-width: 1050px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-canvas-container {
        height: 470px;
    }
}

@media (max-width: 600px) {
    .charts-grid {
        gap: 8px;
        padding-right: 6px;
        padding-left: 6px;
    }

    .chart-canvas-container {
        height: 430px;
        padding: 5px;
    }
}

/*
   Las celdas con bandera no usan el ajuste vertical general.
   La bandera queda centrada y solo el texto se desplaza 1 px hacia abajo.
*/
.results-table tbody td.driver-cell:has(.driver-content) {
    padding-top: 0;
    padding-bottom: 0;
}

.driver-content img {
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
}

.driver-content span {
    position: relative;
    top: 1px;
}

.season-header-rookies-cup {
    background: #6F747C;
}

.scoring-system-bar {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 8px;
}

.scoring-system-bar form {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
}

.scoring-system-bar label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.scoring-system-bar select,
.scoring-system-bar button {
    min-height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.scoring-system-bar select {
    padding: 0 9px;
}

.scoring-system-bar button {
    padding: 0 12px;
    cursor: pointer;
}

@media (max-width: 720px) {
    .scoring-system-bar,
    .scoring-system-bar form {
        width: 100%;
    }

    .scoring-system-bar form {
        align-items: stretch;
        flex-direction: column;
    }
}


.floating-home-logo {
    width: 38px;
    height: 38px;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    background: rgba(18, 18, 18, 0.88);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(8px);
}

.floating-home-logo img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.theme-toggle-button {
    width: 38px;
    height: 38px;
    position: fixed;
    top: 10px;
    /* Ancla por la izquierda (como el logo de inicio), no por la derecha:
       esta página permite scroll horizontal en móvil por las tablas
       anchas, y "right" se calcula sobre ese ancho expandido, dejando el
       botón fuera de la pantalla visible. */
    left: 56px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    background: rgba(18, 18, 18, 0.88);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(8px);
    color: #ffffff;
    cursor: pointer;
}

.theme-toggle-button svg {
    width: 19px;
    height: 19px;
}

.theme-toggle-icon-dark {
    display: none;
}

body[data-theme="dark"] .theme-toggle-icon-light {
    display: none;
}

body[data-theme="dark"] .theme-toggle-icon-dark {
    display: block;
}

.detail-driver-link {
    color: inherit;
    text-decoration: none;
}

.detail-driver-link:hover {
    text-decoration: underline;
}

.team-profile-link {
    color: inherit;
    text-decoration: none;
}

.team-profile-link:hover {
    text-decoration: underline;
}

/* =========================================================
   H2H ENTRE COMPAÑEROS · TEMPORADA DETALLADA
   ========================================================= */
.season-h2h-section {
    margin-top: 30px;
}

.season-h2h-grid {
    display: flex;
    justify-content: left;
    gap: 16px;
    align-items: flex-start;
}

.season-h2h-panel {
    width: fit-content;
    padding: 12px 0;
    border: 0;
    background: var(--section-background);
}

.season-h2h-panel h3 {
    margin: 0 0 10px;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.season-h2h-table-wrap {
    overflow-x: auto;
}

.season-h2h-table {
    width: auto;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

.season-h2h-table td {
    height: 26px;
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    text-align: center;
    vertical-align: middle;
}

.season-h2h-driver {
    width: 20%;
    min-width: 40px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.season-h2h-score {
    width: 11%;
    min-width: 26px;
    background: var(--heading-bg);
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.season-h2h-score-left {
    border-right-color: var(--border-color) !important;
}

.season-h2h-score-right {
    border-left-color: var(--border-color) !important;
}

.season-h2h-pace {
    width: 20%;
    min-width: 50px;
    background: var(--h2h-pace-color, #2b2b2b);
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

body[data-theme="dark"] .season-h2h-pace {
    background: var(--h2h-pace-color-dark, var(--h2h-pace-color, #2b2b2b));
    color: #ffffff;
}

@media (max-width: 900px) {
    .season-h2h-grid {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   AJUSTES TABLA DETALLADA · RESULTADOS DE EQUIPOS / PODIO
   ========================================================= */

/* P1/P2/P3 del podio del campeonato (pilotos y equipos). */
.results-table td.standing-first {
    background: var(--standing-p1) !important;
    color: var(--standing-sticker-text) !important;
}

.results-table td.standing-second {
    background: var(--standing-p2) !important;
    color: var(--standing-sticker-text) !important;
}

.results-table td.standing-third {
    background: var(--standing-p3) !important;
    color: var(--standing-sticker-text) !important;
}

.team-drivers-column,
.team-drivers-cell {
    width: 52px;
    min-width: 52px;
}

.team-driver-stack,
.team-result-stack {
    display: grid;
    grid-template-rows: repeat(2, minmax(12px, auto));
    align-items: stretch;
}

.team-driver-stack span {
    display: flex;
    min-height: 13px;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.team-round-result-cell {
    width: 32px;
    min-width: 32px;
    padding: 0 !important;
    background: var(--table-bg);
}

.team-result-line {
    display: flex;
    min-height: 13px;
    align-items: center;
    justify-content: center;
    padding: 1px 2px;
    font-size: 10px;
    font-weight: 400;
    line-height: 1;
}

.team-result-line.pole-position {
    font-weight: 700;
}

.team-result-line + .team-result-line {
    border-top: 1px solid var(--border-color);
}

.guest-results-table .position {
    color: var(--text-faint);
}

/* Fondo gris uniforme en toda la tabla detallada. */
body,
.page {
    background-color: var(--page-background);
}

.standings-section,
.statistics-section,
.pace-section,
.charts-section,
.season-h2h-section,
.season-h2h-panel {
    background-color: var(--page-background);
}


/* =========================================================
   NAVEGACIÓN INTERNA · TABLA DETALLADA
   ========================================================= */
.detail-section-nav {
    position: fixed;
    top: 60px;
    left: 10px;
    z-index: 180;
    display: flex;
    width: 118px;
    flex-direction: column;
    gap: 2px;
    padding: 7px;
    border: 1px solid var(--border-color);
    background: var(--detail-nav-bg);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    font-size: 11px;
}

.detail-section-nav a {
    display: block;
    padding: 5px 6px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.detail-section-nav a:hover {
    background: var(--hover-bg);
}

.standings-section,
.statistics-section,
.pace-section,
.charts-section,
.season-h2h-section {
    scroll-margin-top: 12px;
}

/* Selector de temporada/categoría junto al sistema de puntuación. */
.scoring-system-bar .season-category-selector,
.scoring-system-bar .scoring-selector {
    margin: 0;
}

/* El nombre del equipo conserva sus colores y se muestra en negrita. */
.team-name-cell {
    font-weight: 700;
}

/* Los pilotos de la tabla de equipos heredan los colores del equipo. */
.team-results-table .team-drivers-cell.team-cell {
    background: var(--team-primary, #f2f2f2) !important;
    color: var(--team-secondary, #111111) !important;
}

@media (max-width: 1150px) {
    .detail-section-nav {
        position: static;
        width: fit-content;
        max-width: 100%;
        margin: 8px auto 0;
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Móvil: tablas detalladas compactas con referencia fija */
.mobile-label { display: none; }

@media (max-width: 720px) {
    .desktop-label { display: none !important; }
    .mobile-label { display: inline !important; }

    .table-container {
        max-width: 100vw;
        overflow-x: auto;
    }

    .results-table th,
    .results-table td {
        padding-right: 4px;
        padding-left: 4px;
        font-size: 10px;
    }

    .results-table .manufacturer-column,
    .results-table .manufacturer-cell {
        display: none !important;
    }

    .results-table .position {
        width: 27px;
        min-width: 27px;
        position: sticky;
        left: 0;
        z-index: 5;
        background: var(--table-bg);
    }

    .results-table thead .position {
        z-index: 8;
    }

    .results-table .number {
        display: none !important;
    }

    .results-table .driver-column,
    .results-table .driver-cell {
        width: 78px;
        min-width: 78px;
        max-width: 78px;
        position: sticky;
        left: 27px;
        z-index: 4;
        background: var(--table-bg);
        box-shadow: 6px 0 10px rgba(0,0,0,.10);
    }

    .results-table thead .driver-column {
        z-index: 8;
    }

    .results-table .driver-content {
        gap: 4px;
    }

    .results-table .driver-content img {
        width: 18px;
        height: 12px;
    }

    .results-table .team-name-cell {
        width: 78px;
        min-width: 78px;
        max-width: 78px;
        position: sticky;
        left: 27px;
        z-index: 4;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        box-shadow: 6px 0 10px rgba(0,0,0,.10);
    }

    .detail-section-nav {
        font-size: 9px;
    }
}

/* =========================================================
   MÓVIL · identidad completa, dorsal fijo y estadísticas compactas
   ========================================================= */
@media (max-width: 720px) {
    .table-container {
        width: 100%;
        max-width: 100%;
    }

    /* La tabla detallada conserva dorsal + nombre completo. */
    .results-table .number {
        width: 30px;
        min-width: 30px;
        max-width: 30px;
        display: table-cell !important;
        position: sticky;
        left: 27px;
        z-index: 6;
    }

    .results-table thead .number {
        z-index: 9;
        background: var(--heading-bg);
    }

    .results-table .driver-column,
    .results-table .driver-cell {
        width: 132px;
        min-width: 132px;
        max-width: 132px;
        left: 57px;
    }

    .results-table .driver-content {
        gap: 3px;
    }

    .results-table .driver-content img {
        width: 18px;
        height: 12px;
    }

    .results-table .driver-cell a,
    .results-table .driver-cell span {
        font-size: 9.5px;
    }

    /* Las tablas de equipos no tienen dorsal: el equipo se pega a Pos. */
    .team-results-table .driver-column,
    .team-results-table .driver-cell,
    .team-statistics-table .driver-column,
    .team-statistics-table .driver-cell {
        left: 27px;
        width: 138px;
        min-width: 138px;
        max-width: 138px;
    }

    /* Encabezados estadísticos abreviados, como en la macrotabla. */
    .statistics-table .stat-victories,
    .statistics-table .stat-podiums,
    .statistics-table .stat-poles,
    .statistics-table .stat-top-tens,
    .statistics-table .stat-fastest-laps,
    .statistics-table .stat-leads,
    .statistics-table .stat-dnfs,
    .statistics-table .stat-grand-prix,
    .statistics-table .stat-activity {
        width: 31px;
        min-width: 31px;
        max-width: 31px;
        padding-right: 2px;
        padding-left: 2px;
    }

    .statistics-table th {
        font-size: 9px;
    }
}

/* =========================================================
   MÓVIL · la tabla detallada es un bloque completo del documento
   No hay un viewport horizontal interno: el usuario puede alejar
   el zoom del navegador y ver todas las rondas de una sola vez.
   ========================================================= */
@media (max-width: 720px) {
    html,
    body {
        overflow-x: visible;
    }

    .page,
    .standings-section,
    .statistics-section,
    .pace-section,
    .charts-section,
    .season-h2h-section {
        overflow: visible;
    }

    .table-container {
        width: max-content !important;
        max-width: none !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: auto;
    }

    .results-table {
        width: max-content !important;
        max-width: none !important;
    }
}

/* La etiqueta de la fila de poles necesita un colspan distinto en móvil
   porque la columna de fabricante/equipo se oculta. */
.pole-label-mobile {
    display: none;
}

@media (max-width: 720px) {
    .pole-label-desktop {
        display: none !important;
    }

    .pole-label-mobile {
        display: table-cell !important;
        text-align: right;
    }
}

/* Promoción · Championship Detail: destino del ascenso en texto. */
.movement-promotion-label-cell {
    background: transparent;
    text-align: center;
}

.movement-promotion-label {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.02em;
}

.movement-promotion-label-f1 {
    color: #E53935;
}

.movement-promotion-label-f2 {
    color: #2C9BE8;
}
