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

:root {
    --primary-color: #2563eb;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --dark-bg: #1f2937;
    --light-bg: #f9fafb;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    color: white;
    padding: 40px 20px;
    margin-bottom: 30px;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* Race Selector */
.race-selector {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.race-btn {
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.race-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.race-btn.active {
    background: white;
    color: #764ba2;
    border-color: white;
    box-shadow: 0 5px 20px rgba(255, 255, 255, 0.3);
}

/* Sections */
section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

section h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 10px;
}

section h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--text-secondary);
}

/* Search Section */
.search-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-box:last-child {
    margin-bottom: 0;
}

.search-box input {
    flex: 1;
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    box-shadow: var(--shadow);
}

.search-box button {
    padding: 15px 30px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.search-box button:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.search-box button:active {
    transform: translateY(0);
}

/* Results Section */
.results-section {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.results-section h2 {
    color: white;
    border-color: white;
}

.hidden {
    display: none;
}

.participant-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    color: var(--text-primary);
}

.participant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.participant-header h3 {
    font-size: 2rem;
    margin: 0;
    color: var(--text-primary);
}

.bib-badge {
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1.1rem;
}

.participant-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: var(--light-bg);
    border-radius: 6px;
}

.detail-row .label {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-row .value {
    font-weight: 700;
    color: var(--text-primary);
}

.time-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.time-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
}

.time-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 10px;
}

.time-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.time-note {
    font-size: 0.85rem;
    opacity: 0.8;
}

.rankings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.ranking-card {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.ranking-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.ranking-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.percentile {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    border-radius: 5px;
    transition: width 0.5s ease;
}

/* Multiple matches */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-item {
    padding: 15px;
    background: var(--light-bg);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.match-item:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Filters */
.filter-status {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1rem;
    box-shadow: var(--shadow);
}

.filter-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
    margin-left: 10px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.filter-group select:focus {
    border-color: var(--primary-color);
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 30px;
}

.chart-container {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
}

.chart-container h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.chart-container canvas {
    height: 300px !important;
}

/* Leaderboard */
.leaderboard-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.tab-btn:hover {
    background: var(--border-color);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

thead {
    background: var(--dark-bg);
    color: white;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: var(--light-bg);
}

.podium-row {
    background: #fef3c7;
}

.podium-row:hover {
    background: #fde68a;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    padding: 20px;
    margin-top: 40px;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .race-selector {
        flex-direction: column;
        gap: 10px;
    }

    .race-btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
    }

    section {
        padding: 20px;
    }

    section h2 {
        font-size: 1.5rem;
    }

    .search-box {
        flex-direction: column;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .participant-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .time-value {
        font-size: 2rem;
    }

    .stat-card {
        padding: 20px;
    }

    .stat-icon {
        font-size: 2rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 20px 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    section {
        padding: 15px;
        margin-bottom: 15px;
    }

    .stats-grid,
    .rankings-grid,
    .time-stats {
        grid-template-columns: 1fr;
    }
}
