body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f3f4f6;
    color: #111827;
}

.race-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding: 8px 12px 9px;
    background: #111827;
    color: #fff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.14);
}

.event-name {
    font-size: 11px;
    line-height: 1.2;
    color: #d1d5db;
    font-weight: 600;
}

h1 {
    margin: 1px 0 0;
    font-size: 17px;
    line-height: 1.1;
    letter-spacing: 0;
    font-weight: 700;
    color: #f9fafb;
}

.race-status {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
    flex: 0 0 auto;
}

.race-clock {
    padding: 3px 7px;
    border-radius: 6px;
    background: #374151;
    color: #fff;
    font-size: 11px;
    line-height: 1.15;
    font-weight: 800;
    text-transform: uppercase;
}

.race-clock.live,
.race-clock.official {
    background: #047857;
}

.race-clock.unofficial {
    background: #111827;
    border: 1px solid #fff;
}

.laps-to-go {
    font-size: 12px;
    line-height: 1.1;
    font-weight: 700;
    color: #e5e7eb;
    white-space: nowrap;
}

.live-shell {
    max-width: none;
    margin: 0;
    padding: 8px;
}

.updated {
    margin: 0 0 6px;
    color: #6b7280;
    font-size: 12px;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.results-table {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.results-table colgroup {
    display: none;
}

.results-table thead,
.results-table tbody {
    display: block;
    width: 100%;
}

.results-table > thead > tr,
.results-table > tbody > tr {
    display: grid;
    grid-template-columns: 34px 26px 44px minmax(150px, 1fr) 0 48px 62px 48px 0;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid #e5e7eb;
    box-sizing: border-box;
}

.results-table > thead > tr {
    background: #f9fafb;
}

.results-table > tbody > tr:last-child {
    border-bottom: 0;
}

.results-table > thead > tr > th,
.results-table > tbody > tr > td {
    display: block;
    min-width: 0;
    padding: 2px 5px;
    border: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    line-height: 1.15;
    box-sizing: border-box;
}

.results-table > thead > tr > th {
    color: #374151;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.results-table > tbody > tr > td {
    font-size: 13px;
}

.results-table [data-col="pos"] { grid-column: 1; }
.results-table [data-col="trend"] { grid-column: 2; }
.results-table [data-col="bib"] { grid-column: 3; }
.results-table [data-col="name"] { grid-column: 4; font-weight: 800; }
.results-table [data-col="team"] { grid-column: 5; display: none; }
.results-table [data-col="country"] { grid-column: 6; }
.results-table [data-col="time"] { grid-column: 7; }
.results-table [data-col="gap"] { grid-column: 8; }
.results-table .expand-head,
.results-table .expand-cell { grid-column: 9; }

.hidden-column {
    display: none !important;
}

.expand-head,
.expand-cell {
    display: none;
    padding-left: 0;
    padding-right: 4px;
    text-align: center;
}

.country-cell {
    text-align: center;
}

.country-flag {
    display: inline-block;
    max-width: 24px;
    max-height: 16px;
    vertical-align: middle;
}

.position {
    font-weight: 900;
}

.trend-up {
    color: #047857;
}

.trend-down {
    color: #b91c1c;
}

.trend-same {
    color: #6b7280;
}

.trend-icon {
    display: inline-block;
    width: 0;
    height: 0;
    vertical-align: middle;
}

.trend-icon.trend-up {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 8px solid #047857;
}

.trend-icon.trend-down {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 8px solid #b91c1c;
}

.trend-icon.trend-same {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
}

.photo-cell {
    text-align: center;
}

.time-cell {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    overflow: visible;
    text-overflow: clip;
}

tr.flash > td {
    animation: rowFlash 1.4s ease-out;
}

@keyframes rowFlash {
    0% { background: #bbf7d0; }
    100% { background: transparent; }
}

.gap-row,
.lap-row {
    border-bottom: 0 !important;
}

.results-table > tbody > tr.gap-row > td,
.results-table > tbody > tr.rider-detail > td {
    grid-column: 1 / -1;
}

.results-table > tbody > tr.gap-row > td {
    padding: 3px 10px;
    background: #dbeafe;
    color: #4b5563;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    border: 0;
}

.results-table > tbody > tr.lap-row > td {
    background: #e5e7eb;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0;
}

.expand-toggle {
    display: none;
}

.results-table > tbody > tr.rider-detail {
    display: none;
    border-bottom: 1px solid #e5e7eb;
}

.results-table > tbody > tr.rider-detail.open {
    display: grid;
}

.results-table > tbody > tr.rider-detail > td {
    background: #f9fafb;
    padding: 2px 10px 3px;
    border: 0;
    white-space: normal;
    overflow: visible;
}

.detail-meta {
    padding: 2px 0 3px;
    color: #374151;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.2;
}

.passage-table {
    display: block;
    width: 100%;
    margin-top: 0;
}

.passage-table tbody {
    display: block;
}

.passage-table tr {
    display: grid;
    grid-template-columns: 42px 42px 24px 72px 70px;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.passage-table th,
.passage-table td {
    display: block;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: #374151;
    font-size: 11px;
    line-height: 1.15;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    box-sizing: border-box;
}

.passage-table th {
    font-weight: 800;
    color: #111827;
}

.passage-table th:nth-child(3),
.passage-table td:nth-child(3) {
    text-align: center;
}

.dimmed {
    opacity: 0.42;
}

.unofficial-row {
    opacity: 0.54;
}

.result-row {
    color: #6b7280;
    background: #fafafa;
}

.result-cell {
    font-weight: 800;
}

.photo-marker {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: #111827;
    vertical-align: middle;
}

.photo-marker.lynx {
    background: #16a34a;
}

/* Vanaf tablet/breed genoeg: team direct tonen, geen + knop. */
@media (min-width: 721px) {
    .results-table [data-col="team"] {
        display: block;
    }

    .results-table > thead > tr,
    .results-table > tbody > tr {
        grid-template-columns: 34px 26px 44px minmax(135px, 1.2fr) minmax(100px, 0.75fr) 48px 62px 48px 0;
    }
}

@media (min-width: 920px) {
    .results-table > thead > tr,
    .results-table > tbody > tr {
        grid-template-columns: 34px 26px 44px minmax(210px, 1.2fr) minmax(170px, 1fr) 48px 62px 48px 0;
    }
}

@media (min-width: 1120px) {
    .results-table > thead > tr,
    .results-table > tbody > tr {
        grid-template-columns: 34px 26px 44px minmax(250px, 1.2fr) minmax(220px, 1fr) 48px 66px 52px 0;
    }
}

@media (max-width: 720px) {
    .race-header {
        padding: 8px 10px;
        gap: 8px;
    }

    .event-name {
        font-size: 11px;
    }

    h1 {
        font-size: 16px;
    }

    .race-clock,
    .laps-to-go {
        font-size: 11px;
    }

    .live-shell {
        padding: 6px 4px;
    }

    .results-table > thead > tr,
    .results-table > tbody > tr {
        grid-template-columns: 28px 22px 36px minmax(105px, 1fr) 0 38px 58px 42px 28px;
    }

    .results-table > thead > tr > th,
    .results-table > tbody > tr > td {
        padding: 2px 3px;
        font-size: 12px;
    }

    .results-table > thead > tr > th {
        font-size: 10px;
    }

    .expand-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        margin: 0;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        background: #fff;
        color: #111827;
        font-weight: 900;
        line-height: 1;
    }

    .expand-head,
    .expand-cell {
        display: block;
    }
}
