*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #f97316;
    --accent-glow: rgba(249, 115, 22, 0.25);
    --bar-bg: #334155;
    --border: #475569;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 640px;
}

/* ---- Header ---- */

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.season-label {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

/* ---- Leaderboard ---- */

.riders {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rider-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s;
}

.rider-card.leader {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.rider-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-hover);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 1.2rem;
}

.rider-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.rider-name {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rider-stats {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.rider-km {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

/* ---- Progress bar ---- */

.progress-bar {
    height: 8px;
    background: var(--bar-bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* ---- Distance chart ---- */

.distance-chart {
    margin-top: 2.5rem;
}

.distance-chart h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.chart-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    height: 300px;
}

/* ---- Recent rides ---- */

.recent-rides {
    margin-top: 2.5rem;
}

.recent-rides h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.recent-rides ul {
    list-style: none;
}

.recent-rides li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.recent-rides li:last-child {
    border-bottom: none;
}

.ride-athlete {
    font-weight: 600;
    flex-shrink: 0;
}

.ride-name {
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ride-distance {
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
}

.ride-date {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ---- Footer ---- */

footer {
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ---- Misc ---- */

.loading,
.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4rem;
    }

    .rider-km {
        font-size: 1.25rem;
    }

    .avatar {
        width: 40px;
        height: 40px;
    }
}
