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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

header {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 40px 20px;
    text-align: center;
}

header h1 {
    margin: 0 0 8px;
    font-size: 2rem;
    font-weight: 700;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.85;
    margin: 0;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 16px 24px;
    text-align: center;
    min-width: 140px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-detail {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 4px;
}

.results-section {
    margin-top: 24px;
}

.results-section h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #1a1a2e;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-select {
    background: #fff;
    border: 2px solid #1a1a2e;
    color: #1a1a2e;
    padding: 7px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    appearance: auto;
}

.filter-select:focus {
    outline: none;
    border-color: #4a6fa5;
}

.filter-btn {
    background: #fff;
    border: 2px solid #d4a017;
    color: #d4a017;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #fef9e7;
}

.filter-btn.active {
    background: #d4a017;
    color: #fff;
}

.table-wrapper {
    overflow-x: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: #1a1a2e;
    color: #fff;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #f0f4ff;
}

tbody tr:last-child td {
    border-bottom: none;
}

.col-num {
    width: 50px;
    text-align: center;
    color: #888;
}

.col-date {
    white-space: nowrap;
}

.col-time {
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-weight: 600;
}

.col-rank {
    text-align: right;
}

.best-time {
    color: #16a34a;
    font-weight: 700;
}

.sub3-time {
    color: #d4a017;
    font-weight: 700;
}

.star {
    color: #d4a017;
    margin-right: 4px;
}

footer {
    text-align: center;
    padding: 24px;
    color: #888;
    font-size: 0.8rem;
}

footer a {
    color: #555;
}

/* PB row glow */
@keyframes pb-shimmer {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(22, 163, 74, 0.08); }
}

tbody tr.pb-row {
    animation: pb-shimmer 3s ease-in-out infinite;
}

tbody tr.pb-row td:first-child {
    box-shadow: inset 3px 0 0 #16a34a;
}

tbody tr.pb-row:hover {
    background: rgba(22, 163, 74, 0.12);
}

/* DNF row */
tbody tr.dnf-row {
    opacity: 0.55;
}

/* Country flags */
.country-flag {
    margin-right: 6px;
}

/* Achievements */
.achievements {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 0;
}

.achievements-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border-radius: 10px;
    padding: 14px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1;
    min-width: 220px;
}

.badge-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.badge-icon.gold { background: linear-gradient(135deg, #d4a017, #f0c75e); color: #fff; }
.badge-icon.blue { background: linear-gradient(135deg, #1a1a2e, #2d4a7a); color: #fff; }
.badge-icon.green { background: linear-gradient(135deg, #16a34a, #4ade80); color: #fff; }
.badge-icon.purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); color: #fff; }

.badge-content {
    display: flex;
    flex-direction: column;
}

.badge-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1a1a2e;
}

.badge-detail {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

/* Photo Gallery */
.gallery {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 0;
}

.gallery-header {
    margin-bottom: 20px;
}

.gallery-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #1a1a2e;
}

.gallery-subtitle {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: #888;
}

.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gallery-hero {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    height: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.gallery-hero img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.gallery-hero:hover img {
    transform: scale(1.03);
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 32px 20px 14px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-hero:hover .gallery-caption,
.gallery-thumb:hover .gallery-caption {
    opacity: 1;
}

.gallery-thumbs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: 200px;
    gap: 12px;
}

.gallery-thumb {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.gallery-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.gallery-thumb:hover img {
    transform: scale(1.05);
}

.gallery-thumb .gallery-caption {
    font-size: 0.75rem;
    padding: 24px 12px 10px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-caption {
    color: #ccc;
    font-size: 0.9rem;
    margin-top: 12px;
    text-align: center;
    letter-spacing: 0.3px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    line-height: 1;
    z-index: 1001;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 2.5rem;
    padding: 12px 18px;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1;
    z-index: 1001;
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

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

    .stats {
        gap: 16px;
    }

    .stat-card {
        min-width: 120px;
        padding: 12px 16px;
    }

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

    th, td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .achievements-grid {
        gap: 10px;
    }

    .badge {
        min-width: 100%;
        padding: 10px 14px;
    }

    .gallery-hero {
        height: 180px;
    }

    .gallery-thumbs {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: 120px;
    }

    .gallery-thumb {
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 1.8rem;
        padding: 8px 14px;
    }

    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
}
