* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: linear-gradient(180deg, #f4f6f9 0%, #eef2f7 100%);
    color: #111827;
    padding-top: 0;
    overflow-x: hidden;
}

/* HEADER - SAME STYLE AS RUNNER TRACKING PAGE */
.header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #000e48;
    padding: 16px;
    text-align: center;
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
    border-bottom: 1px solid #001a66;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.container {
    width: calc(100% - 40px);
    max-width: 1600px;
    margin: 0 auto;
}

/* ================= FILTER + BIG CENTER SEARCH ================= */

.filter-search-bar {
    position: sticky;
    top: 53px;
    z-index: 9;
    width: calc(100% - 40px);
    max-width: 1600px;
    margin: 0 auto 24px;
    padding: 16px 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: center;
    background: #f4f6f9;
    box-shadow: 0 8px 18px rgba(0,0,0,0.04);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    min-width: 0;
}

.filters button {
    border: none;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    background: #e5e7eb;
    font-weight: 600;
    transition: all .2s ease;
}

.filters button:hover {
    background: #d1d5db;
}

.filters button.active {
    background: #111827;
    color: white;
}

.runner-search-box {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.runner-search-box input {
    flex: 1;
    min-width: 0;
    width: auto;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 18px 24px;
    font-size: 20px;
    outline: none;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.runner-search-box input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.14), 0 8px 24px rgba(0,0,0,0.08);
}

.runner-search-box button {
    flex: 0 0 auto;
    border: none;
    border-radius: 999px;
    padding: 0 24px;
    height: 58px;
    cursor: pointer;
    font-weight: 800;
    font-size: 13px;
    background: #111827;
    color: white;
    white-space: nowrap;
}

.runner-search-box button:hover {
    background: #374151;
}

/* ================= LEADERBOARD CARDS ================= */

#raceTable {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.card {
    background: white;
    padding: 18px;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    cursor: pointer;
    min-width: 0;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.10);
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.bib {
    font-size: 20px;
    font-weight: 900;
    padding: 8px 14px;
    border-radius: 12px;
    color: white;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.rank {
    background: linear-gradient(135deg, #111827, #374151);
    color: white;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.meta {
    font-size: 13px;
    margin-top: 6px;
    line-height: 1.4;
    word-break: break-word;
}

.rank-meta {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    background: #f3f4f6;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.rank-meta span {
    white-space: nowrap;
}

.row {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    gap: 10px;
    word-break: break-word;
    font-size: 14px;
}

.progress-wrap {
    margin-top: 10px;
}

.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar div {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #22c55e);
    transition: width 0.6s ease;
}

.progress-text {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    text-align: right;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: rgba(255,255,255,0.4);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -40%; }
    100% { left: 120%; }
}

.splits {
    font-size: 12px;
    margin-top: 10px;
    background: #f9fafb;
    padding: 8px;
    border-radius: 8px;
}

.split-time-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.split-time-row div:last-child {
    text-align: right;
}

.gender-icon {
    font-weight: 900;
    font-size: 15px;
    margin-right: 4px;
    display: inline-block;
}

.gender-male {
    color: #2563eb;
}

.gender-female {
    color: #ec4899;
}

.gender-non-binary {
    color: #a855f7;
}

.status {
    margin-top: 10px;
    font-weight: 800;
    padding: 8px 12px;
    border-radius: 10px;
    display: inline-block;
    font-size: 13px;
    letter-spacing: 0.3px;
}

.status-finished {
    background: #ecfdf5;
    color: #16a34a;
    border: 1px solid #86efac;
    box-shadow: 0 0 0 2px rgba(22,163,74,0.15);
}

.status-ongoing {
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fdba74;
    box-shadow: 0 0 0 2px rgba(234,88,12,0.15);
}

.status-dns,
.status-dnf {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.status-stopped,
.status-not-started {
    background: #111827;
    color: #ffffff;
    border: 1px solid #374151;
}

/* ================= FOOTER ================= */

.site-footer {
    margin-top: 40px;
    padding: 18px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 1024px) {
    #raceTable {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-search-bar {
        grid-template-columns: 1fr;
    }

    .runner-search-box {
        max-width: 680px;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 0;
        background: #f4f6f9;
        font-size: 15px;
        overflow-x: hidden;
    }

    .header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: #000e48;
        padding: 16px;
        text-align: center;
        font-size: 16px;
        font-weight: 800;
        color: #ffffff;
        border-bottom: 1px solid #001a66;
        letter-spacing: 0.5px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        line-height: 1.3;
    }

    .container,
    .filter-search-bar {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .container {
        padding: 0 12px 20px;
    }

    .filter-search-bar {
        position: sticky;
        top: 53px;
        z-index: 9;
        padding: 10px 12px 14px;
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        background: #f4f6f9;
        box-shadow: 0 8px 18px rgba(0,0,0,0.06);
        overflow: hidden;
    }

    .filters {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 2px;
        background: transparent;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filters::-webkit-scrollbar {
        display: none;
    }

    .filters button {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 11px 15px;
        font-size: 13px;
        border-radius: 999px;
    }

    .runner-search-box {
        width: 100%;
        max-width: 100%;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        overflow: hidden;
    }

    .runner-search-box input {
        flex: 1;
        min-width: 0;
        width: auto;
        font-size: 15px;
        padding: 14px 16px;
        border-radius: 999px;
        box-shadow: none;
    }

    .runner-search-box button {
        flex: 0 0 auto;
        min-width: 68px;
        height: 48px;
        padding: 0 14px;
        border-radius: 999px;
        font-size: 11px;
        white-space: nowrap;
    }

    #raceTable {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        width: 100%;
        padding: 16px;
        border-radius: 14px;
    }

    .card:hover {
        transform: none;
    }

    .top-row {
        align-items: center;
        gap: 10px;
    }

    .bib {
        font-size: 20px;
        padding: 8px 13px;
    }

    .rank {
        width: 34px;
        height: 34px;
        font-size: 12px;
    }

    .meta {
        font-size: 14px;
        line-height: 1.5;
    }

    .rank-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 7px;
        font-size: 13px;
    }

    .rank-meta span {
        margin-left: 0 !important;
        white-space: normal;
    }

    .row {
        flex-direction: column;
        align-items: flex-start;
        gap: 7px;
        font-size: 14px;
        line-height: 1.45;
    }

    .progress-text {
        text-align: left;
        font-size: 12px;
    }

    .splits {
        font-size: 13px;
        line-height: 1.45;
    }

    .split-time-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 7px;
    }

    .split-time-row div:last-child {
        text-align: left;
    }

    .status {
        font-size: 13px;
        padding: 8px 11px;
    }
}

@media (max-width: 420px) {
    .container {
        padding: 0 10px 18px;
    }

    .filter-search-bar {
        top: 53px;
        padding: 8px 10px 12px;
    }

    .filters button {
        font-size: 13px;
        padding: 10px 13px;
    }

    .runner-search-box {
        gap: 6px;
    }

    .runner-search-box input {
        font-size: 14px;
        padding: 13px 14px;
    }

    .runner-search-box button {
        min-width: 62px;
        height: 46px;
        font-size: 10px;
        padding: 0 11px;
    }

    .bib {
        font-size: 18px;
    }

    .card {
        padding: 14px;
    }

    .meta,
    .row,
    .splits,
    .rank-meta,
    .status {
        font-size: 13px;
    }
}

/* ================= DNF / DNS CARD - GRAY + CENTER SLEEPING ================= */

.inactive-card {
    background: #e5e7eb;
    color: #6b7280;
    opacity: 0.75;
    position: relative;
    filter: grayscale(1);
    cursor: not-allowed;
    overflow: hidden;
}

.inactive-card * {
    pointer-events: none;
}

.inactive-card:hover {
    transform: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.inactive-card::after {
    position: absolute;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    font-size: 56px;
    line-height: 1;
    animation: sleepCenter 1.8s ease-in-out infinite;
    pointer-events: none;
    z-index: 10;
    opacity: 0.9;
}

.inactive-card[data-status="DNF"]::after {
    content: "😵";
}

.inactive-card[data-status="DNS"]::after {
    content: "😴";
}

@keyframes sleepCenter {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.45;
    }

    50% {
        transform: translate(-50%, -62%) scale(1.18);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.45;
    }
}

.inactive-card .bib,
.inactive-card .rank {
    background: #6b7280 !important;
    box-shadow: none;
}

.inactive-card .rank-meta,
.inactive-card .splits {
    background: #d1d5db;
}

.inactive-card .progress-bar div {
    background: #9ca3af;
}

.inactive-card .progress-bar::after {
    display: none;
}

@media (max-width: 420px) {
    .inactive-card::after {
        font-size: 46px;
    }
}