/* ══════════════════════════════════════════════════
   跑山獸 Beast Runners — 官方共用樣式表
   Shared stylesheet for index.html & rank.html
   ══════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    --bg: #ffffff;
    --surface: #f8f9fa;
    --border: #e0e0e0;
    --br-red: #a31d22;
    /* A deeper red matching the screenshot */
    --text-primary: #111111;
    --text-white: #ffffff;
    --muted: #666666;
    --success: #28a745;
    --error: #dc3545;
    --rank-up: #28a745;
    --rank-down: #dc3545;
    --radius: 4px;
}

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

/* ── Body ── */
body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: 'Noto Sans TC', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0 60px;
}

/* ════════════════════════════════════════
   SHARED: Header
   ════════════════════════════════════════ */
header {
    width: 100%;
    padding: 0;
    background: #000000;
    border-bottom: 4px solid var(--br-red);
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
}

.header-container {
    width: 100%;
    max-width: 892px;
    margin: 0 auto;
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.wow-logo-box {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wow-logo-box img {
    height: 100%;
    object-fit: contain;
}

.br-title-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.race-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.race-title-name {
    font-size: clamp(20px, 3.5vw, 36px);
    font-weight: 700;
    letter-spacing: 1px;
    color: #ffffff;
    line-height: 1.1;
    text-align: left;
}

.race-title-year {
    display: inline-block;
    background: var(--br-red);
    color: #fff;
    font-size: clamp(11px, 2vw, 15px);
    font-weight: 900;
    letter-spacing: 2px;
    padding: 2px 10px;
}

.tech-support-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.tech-label {
    font-size: 10px;
    color: #aaaaaa;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.br-logo-box-mini {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.br-logo-box-mini img {
    height: 100%;
    object-fit: contain;
}

/* ── Gender Coloring ── */
.gender-m {
    color: #1a73e8;
    font-weight: 700;
}

.gender-f {
    color: #d91414;
    font-weight: 700;
}

/* ── Global Container Padding ── */
.nav-bar,
.search-block,
#status,
.result-block,
.video-block,
.dist-selector-container,
.stats-bar,
.rank-table-container {
    padding-left: 16px;
    padding-right: 16px;
    width: 100%;
    max-width: 892px;
}

/* ════════════════════════════════════════
   SHARED: Navigation
   ════════════════════════════════════════ */
.nav-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    padding: 8px 20px;
    border: 1px solid var(--border);
    background: #fff;
    transition: all 0.2s;
    border-radius: var(--radius);
}

.nav-link:hover {
    background: #f0f0f0;
    border-color: #999;
}

.nav-link.active {
    color: #fff;
    background: var(--br-red);
    border-color: var(--br-red);
}

.event-selector-wrapper {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.event-select-dropdown {
    color: var(--text-primary);
    padding: 6px 30px 6px 12px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 10px center;
    background-size: 12px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.event-select-dropdown:hover {
    border-color: #999;
    background-color: #f8f9fa;
}

@media (max-width: 600px) {
    .nav-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    .event-selector-wrapper {
        margin-left: 0 !important;
        width: 100%;
        justify-content: space-between;
    }
    .event-select-dropdown {
        flex: 1;
        max-width: 200px;
    }
}

/* ════════════════════════════════════════
   index.html — 搜尋區塊
   ════════════════════════════════════════ */
.search-block {
    margin-bottom: 32px;
}

.search-label {
    font-size: 14px;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 10px;
    display: block;
    font-weight: 700;
    text-transform: uppercase;
}

.search-row {
    display: flex;
}

.bib-input {
    flex: 1;
    padding: 14px 20px;
    font-size: 20px;
    font-weight: 700;
    background: #fff;
    border: 2px solid var(--border);
    border-right: none;
    color: var(--text-primary);
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
    outline: none;
}

.bib-input:focus {
    border-color: var(--br-red);
}

.search-btn {
    padding: 0 32px;
    font-size: 16px;
    font-weight: 700;
    background: var(--br-red);
    color: #fff;
    border: 2px solid var(--br-red);
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.15s;
}

.search-btn:hover {
    background: #8e1a1e;
}

#status {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 24px;
    min-height: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* ════════════════════════════════════════
   index.html — Result Card
   ════════════════════════════════════════ */
.result-block {
    display: none;
    margin-bottom: 32px;
}

.result-block.visible {
    display: block;
}

.sky-hunter-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.sh-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.sh-avatar {
    width: 64px;
    height: 64px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sh-avatar span {
    font-size: 16px;
    font-weight: 700;
}

.sh-name-info {
    flex: 1;
}

.sh-name {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.runner-flag {
    height: 18px;
}

.sh-meta {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

.sh-status-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.sh-time {
    font-size: 48px;
    font-weight: 700;
    color: var(--br-red);
}

.sh-finish-tod {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.status-badge.finish {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.dnf {
    background: #ffebee;
    color: #c62828;
}

.sh-ranks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.sh-rank-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.sh-rank-label {
    font-size: 11px;
    color: #888;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.sh-rank-value {
    font-size: 28px;
    font-weight: 700;
}

.sh-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.sh-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: #333;
    border: 1px solid #333;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

.sh-btn:hover {
    background: #000;
}

.sh-btn.outline {
    background: transparent;
    color: #333;
}

/* ════════════════════════════════════════
   index.html — Splits Table
   ════════════════════════════════════════ */
.splits-section {
    margin-top: 24px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.splits-title {
    padding: 16px 20px;
    background: #f8f9fa;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

/* Splits Section Header & Switcher */
.splits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.splits-title {
    margin-bottom: 0 !important;
}

.view-toggle-container {
    display: inline-flex;
    background: #f1f3f5;
    padding: 3px;
    border-radius: 20px;
    border: 1px solid #e9ecef;
}

.view-toggle-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.view-toggle-btn.active {
    background: #ffffff;
    color: #1a1a1a;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.view-toggle-btn:hover:not(.active) {
    color: #212529;
}

/* Splits Timeline Layouts */
.splits-timeline-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.splits-timeline-wrapper.list-view {
    overflow-x: hidden;
}

.splits-timeline {
    min-width: 800px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #ffffff;
}

.splits-timeline-wrapper.list-view .splits-timeline {
    min-width: 0 !important;
    width: 100%;
}

.timeline-header {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1.1fr 1.1fr 1.3fr 1.3fr 1.3fr 24px;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 2px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: #666;
}

.timeline-checkpoint-wrapper {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.timeline-checkpoint-wrapper:last-child {
    border-bottom: none;
}

.timeline-checkpoint-wrapper:nth-child(even) {
    background-color: #fcfcfc;
}

.timeline-checkpoint-wrapper:nth-child(odd) {
    background-color: #ffffff;
}

.timeline-checkpoint {
    display: grid;
    grid-template-columns: 1fr 1.3fr 1.1fr 1.1fr 1.3fr 1.3fr 1.3fr 24px;
    align-items: center;
    padding: 14px 16px;
    font-size: 14px;
    color: #333;
    background: transparent;
    transition: background-color 0.15s ease;
}

.timeline-checkpoint-wrapper.expanded .timeline-checkpoint {
    border-bottom: 1px solid #eee;
}

.timeline-checkpoint:last-child {
    border-bottom: none;
}

.timeline-checkpoint.reached {
    background-color: transparent;
}

.timeline-checkpoint.last-split {
    background-color: #fff8f8 !important;
    border-left: 4px solid var(--br-red);
}

/* Hide chevron column in table-view */
.splits-timeline-wrapper.table-view .col-chevron,
.splits-timeline-wrapper.table-view .cell-chevron {
    display: none !important;
}

/* Redefine grid for table-view (hiding chevron column makes it 7 columns) */
.splits-timeline-wrapper.table-view .timeline-header,
.splits-timeline-wrapper.table-view .timeline-checkpoint {
    grid-template-columns: 1fr 1.3fr 1.1fr 1.1fr 1.3fr 1.3fr 1.3fr;
}

/* Redefine grid for list-view (only show CP, Rank, TIME, Chevron) */
.splits-timeline-wrapper.list-view .timeline-header,
.splits-timeline-wrapper.list-view .timeline-checkpoint {
    grid-template-columns: 1.2fr 1.3fr 1fr 24px;
    cursor: pointer;
}

.splits-timeline-wrapper.list-view .col-passage,
.splits-timeline-wrapper.list-view .cell-passage,
.splits-timeline-wrapper.list-view .col-dist,
.splits-timeline-wrapper.list-view .cell-dist,
.splits-timeline-wrapper.list-view .col-gain,
.splits-timeline-wrapper.list-view .cell-gain,
.splits-timeline-wrapper.list-view .col-loss,
.splits-timeline-wrapper.list-view .cell-loss {
    display: none !important;
}

/* Chevron Styling */
.chevron-icon {
    transition: transform 0.2s ease;
    display: block;
    margin: 0 auto;
    color: #999;
}

.timeline-checkpoint-wrapper.expanded .chevron-icon {
    transform: rotate(180deg);
}

/* Accordion Details Drawer */
.checkpoint-details-drawer {
    display: none;
    background: transparent;
    padding: 12px 20px;
}

.splits-timeline-wrapper.list-view .timeline-checkpoint-wrapper.expanded .checkpoint-details-drawer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
}

.splits-timeline-wrapper.list-view .timeline-checkpoint-wrapper.expanded {
    background-color: #f7f9fc !important;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    font-weight: 600;
}

.detail-value {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

@media (max-width: 480px) {
    .splits-timeline-wrapper.list-view .timeline-checkpoint-wrapper.expanded .checkpoint-details-drawer {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.header-col,
.timeline-checkpoint>div {
    padding: 4px 8px;
    text-align: center;
    white-space: nowrap;
}

.col-cp,
.cell-cp {
    text-align: left !important;
    font-weight: 700;
}

.cell-gain {
    color: var(--success);
    font-weight: 600;
}

.cell-loss {
    color: var(--error);
    font-weight: 600;
}

.rank-delta-cell {
    font-size: 12px;
    font-weight: 700;
    margin-left: 4px;
}

.rank-delta-cell.up {
    color: var(--success);
}

.rank-delta-cell.down {
    color: var(--error);
}

.rank-delta-cell.same {
    color: #999;
}

/* ════════════════════════════════════════
   index.html — Video & Modal
   ════════════════════════════════════════ */
.video-block {
    display: none;
    margin-bottom: 40px;
}

.video-block.visible {
    display: block;
}

video {
    width: 100%;
    background: #000;
    border-radius: var(--radius);
}

.video-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.video-meta-bib {
    font-size: 14px;
    font-weight: 900;
    color: var(--br-red);
    text-transform: uppercase;
}

.video-meta-info {
    font-size: 11px;
    color: var(--muted);
}

.expire-bar {
    margin-top: 8px;
    height: 2px;
    background: #222;
}

.expire-bar-fill {
    height: 100%;
    background: var(--br-red);
    transform-origin: left;
    transition: transform 1s linear;
}

/* ── Modal Button ── */
.modal-btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 900;
    color: #fff;
    background: var(--br-red);
    border: none;
    cursor: pointer;
    letter-spacing: 1px;
    transition: background 0.15s;
    text-align: center;
}

.modal-btn:hover {
    background: #b80f0f;
}

.modal-btn.secondary {
    background: #333;
}

.modal-btn.secondary:hover {
    background: #444;
}

.modal-btn.success {
    background: #28a745;
}

.modal-btn.success:hover {
    background: #218838;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
    overflow: hidden;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #ffffff;
    border: 2px solid var(--border);
    max-width: 90vw;
    max-height: 95vh;
    width: 700px;
    padding: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
}

#modalResult,
#modalLoading,
#modalError {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    font-size: 28px;
    color: var(--muted);
    transition: color 0.15s;
    background: none;
    border: none;
    outline: none;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--br-red);
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-align: center;
}

.modal-instructions {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
    text-align: center;
}

.certificate-img-container {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    max-height: 60vh;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: #f8f9fa;
    position: relative;
    text-align: center;
}

.certificate-preview-img {
    width: 100%;
    max-width: 100%;
    max-height: 60vh;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

.btn-group {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

.spinner-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(217, 20, 20, 0.1);
    border-top-color: var(--br-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ════════════════════════════════════════
   rank.html — Dropdown & Stats
   ════════════════════════════════════════ */
.dist-selector-container {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dist-selector-container label {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

#distanceSelect {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: #f8f9fa;
    color: var(--text-primary);
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 16px;
    font-size: 14px;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 16px;
}

.stats-bar .count {
    color: var(--br-red);
    font-weight: 700;
}

.gender-filters {
    display: flex;
    gap: 4px;
}

.gender-btn {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.gender-btn.active {
    background: var(--br-red);
    color: #fff;
    border-color: var(--br-red);
}

/* ════════════════════════════════════════
   rank.html — Rankings Table
   ════════════════════════════════════════ */
.rank-table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    margin-bottom: 24px;
}

.rank-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px;
}

.rank-table thead th {
    background: #f8f9fa;
    color: #666;
    font-size: 13px;
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
}

.rank-table tbody td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    color: #333;
    font-size: 14px;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
}

.rank-table .name-col {
    text-align: left !important;
}

.rank-table .rank-col {
    width: 80px;
}

.rank-table .rank-col .overall-val {
    color: #111;
    font-size: 18px;
    font-weight: 900;
}

.rank-table .rank-col .gender-val {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.rank-table .bib-col {
    font-weight: 700;
    width: 60px;
}

.rank-table .time-col {
    font-weight: 700;
    width: 100px;
}

.rank-table .status-col {
    width: 80px;
}

.badge {
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 700;
}

.badge.finish {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ════════════════════════════════════════
   Responsive
   ════════════════════════════════════════ */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .header-container {
        padding: 16px 16px;
    }

    .header-left-group {
        gap: 8px;
    }

    .wow-logo-box {
        height: 48px;
    }

    .race-title-name {
        font-size: 18px;
    }

    .rank-table thead th {
        font-size: 11px;
        padding: 10px 6px;
    }

    .rank-table tbody td {
        padding: 10px 6px;
        font-size: 13px;
    }

    .rank-table .rank-col {
        width: 70px;
    }

    .rank-table .bib-col {
        width: 50px;
    }

    .rank-table .time-col {
        width: 85px;
    }

    .sh-time {
        font-size: 36px;
    }

    /* ── Mobile Modal Styles ── */
    .modal-content {
        padding: 16px;
        width: 95vw;
        max-width: 95vw;
        max-height: 92vh;
    }

    .certificate-img-container {
        width: 100%;
        max-width: 100%;
        max-height: 45vh;
        margin-bottom: 12px;
    }

    .certificate-preview-img {
        width: 100%;
        max-width: 100%;
        max-height: 45vh;
    }

    .btn-group {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .modal-btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 13px;
    }

    .modal-close {
        top: 8px;
        right: 12px;
        font-size: 24px;
    }

    .modal-title {
        font-size: 16px;
        margin-top: 8px;
    }

    .modal-instructions {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .spinner-wrapper {
        padding: 24px;
    }

    /* ── Mobile rankings cards toggle ── */
    .rank-table-container {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .rank-table {
        display: none !important;
    }

    .rank-cards-container {
        display: flex !important;
    }
}

/* ── Status badges on rank.html ── */
.badge.dnf {
    background: #ffebee;
    color: #c62828;
}

.badge.dns {
    background: #f5f5f5;
    color: #757575;
}

.badge.dsq {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge.ooc {
    background: #fff8e1;
    color: #f57f17;
}

.badge.racing {
    background: #e3f2fd;
    color: #1565c0;
}

/* ── Loading, Empty States & Row styling on rank.html ── */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    width: 100%;
}

.loading-container p {
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 15px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fff;
    margin-bottom: 24px;
    width: 100%;
}

.podium-1 {
    background-color: rgba(255, 215, 0, 0.08);
}

.podium-2 {
    background-color: rgba(192, 192, 192, 0.06);
}

.podium-3 {
    background-color: rgba(205, 127, 50, 0.05);
}

.rank-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.rank-table tbody tr:hover {
    background-color: #f1f3f5;
}

.rank-table tbody tr.podium-1:hover {
    background-color: rgba(255, 215, 0, 0.15);
}

.rank-table tbody tr.podium-2:hover {
    background-color: rgba(192, 192, 192, 0.12);
}

.rank-table tbody tr.podium-3:hover {
    background-color: rgba(205, 127, 50, 0.1);
}

/* ── Additional Status feedback styles ── */
#status.error {
    border-color: var(--error);
    color: var(--error);
    background-color: #fff5f5;
}

#status.error .dot {
    background-color: var(--error);
}

#status.loading {
    border-color: var(--br-red);
    color: var(--muted);
}

#status.loading .dot {
    background-color: var(--br-red);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.3;
    }
}

/* ── Mobile Runner Cards for rank.html ── */
.rank-cards-container {
    display: none;
    /* Hidden on desktop by default */
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.runner-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.runner-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    border-color: #bbb;
}

/* Gender-specific Card Borders */
.runner-card.gender-m {
    border-color: #0e86d4;
}

.runner-card.gender-m:hover {
    border-color: #0e86d4;
    box-shadow: 0 8px 20px rgba(14, 134, 212, 0.15);
}

.runner-card.gender-f {
    border-color: #CD5C5C;
}

.runner-card.gender-f:hover {
    border-color: #CD5C5C;
    box-shadow: 0 8px 20px rgba(205, 92, 92, 0.15);
}

/* Podium Border Highlights (Background only) */
.runner-card.podium-1 {
    background-color: rgba(255, 215, 0, 0.03);
}

.runner-card.podium-2 {
    background-color: rgba(192, 192, 192, 0.02);
}

.runner-card.podium-3 {
    background-color: rgba(205, 127, 50, 0.02);
}


/* Card Header */
.runner-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.runner-card .card-runner-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.runner-card .card-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.runner-card .card-name-en {
    font-size: 20px;
    color: var(--muted);
    font-weight: 400;
    margin-left: 4px;
}

.runner-card .runner-flag {
    height: 24px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Club styling */
.runner-card .card-club {
    font-size: 18px;
    color: #444;
    display: flex;
    align-items: center;
    gap: 6px;
}

.runner-card .club-icon {
    font-size: 14px;
    color: var(--muted);
}

/* Meta tags */
.runner-card .card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.runner-card .card-tag {
    font-size: 14px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.runner-card .bib-tag {
    background: #f1f3f5;
    color: #495057;
    border: 1px solid #dee2e6;
}

.runner-card .gender-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.runner-card .gender-tag.gender-m {
    background: #e8f0fe;
    color: #1a73e8;
}

.runner-card .gender-tag.gender-f {
    background: #fde8e8;
    color: #d91414;
}

/* Stats grid */
.runner-card .card-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 12px;
    margin-top: 4px;
    padding: 12px 0;
    border-top: 1px solid #f1f3f5;
    border-bottom: 1px solid #f1f3f5;
}

.runner-card .stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.runner-card .stat-label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.runner-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.runner-card .stat-value.font-impact {
    font-family: 'Impact', 'Noto Sans TC', sans-serif;
    font-size: 22px;
    letter-spacing: 0.5px;
}

.runner-card .gender-max {
    font-size: 16px;
    color: var(--muted);
    font-weight: 400;
}

.runner-card .time-item {
    border-left: 1px solid #f1f3f5;
    padding-left: 12px;
}

.runner-card .time-val {
    color: var(--success);
}

/* Card Action */
.runner-card .card-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    transition: color 0.2s ease;
    margin-top: 4px;
}

.runner-card:hover .card-action {
    color: var(--br-red);
}

.runner-card .arrow-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.runner-card:hover .arrow-icon {
    transform: translateX(4px);
}

/* ════════════════════════════════════════
   Interactive Elevation & Pace Profile
   ════════════════════════════════════════ */
.profile-section {
    margin-top: 24px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.profile-title {
    font-size: 16px;
    font-weight: 900;
    color: var(--br-red);
    letter-spacing: 1px;
    text-transform: uppercase;
    border-left: 4px solid var(--br-red);
    padding-left: 10px;
    margin-bottom: 0;
}

.profile-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 11px;
    color: var(--muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.steep { background-color: #FF2D55; }
.legend-dot.climb { background-color: #FF9500; }
.legend-dot.mild  { background-color: #FFCC00; }
.legend-dot.flat  { background-color: #4CD964; }
.legend-dot.down  { background-color: #007AFF; }
.legend-dot.mild-down { background-color: #5AC8FA; }
.legend-dot.steep-down { background-color: #855CF8; }

.canvas-container {
    position: relative;
    width: 100%;
    height: 250px;
    margin-bottom: 10px;
    background: #ffffff;
    border-radius: var(--radius);
    overflow: visible;
    border: 1px solid var(--border);
}

#elevationCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

/* Glassmorphism Tooltip for Elevation Profile */
.profile-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 100;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(252, 76, 2, 0.4);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(252, 76, 2, 0.15);
    border-radius: 6px;
    padding: 12px;
    color: #fff;
    font-size: 12px;
    min-width: 180px;
    transform: translateY(-115%);
    transition: opacity 0.15s ease, transform 0.1s ease;
    line-height: 1.5;
}

.profile-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}

.profile-tooltip .tooltip-row:last-child {
    margin-bottom: 0;
}

.profile-tooltip .tooltip-label {
    color: #888;
    font-weight: 500;
}

.profile-tooltip .tooltip-value {
    font-weight: 700;
    color: #fff;
}

.profile-tooltip .tooltip-value.highlight {
    color: #FC4C02;
    text-shadow: 0 0 4px rgba(252, 76, 2, 0.5);
}

.profile-tooltip .tooltip-value.rank {
    color: #ffd700;
}

.profile-tooltip .tooltip-header {
    font-size: 13px;
    font-weight: 900;
    color: #FC4C02;
    border-bottom: 1px solid #333;
    padding-bottom: 4px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 賽道高度圖統計資訊列樣式 */
.profile-stats-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #fdfdfd;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 12px;
    gap: 16px;
}

.profile-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
}

.profile-stat-box .stat-lbl {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.profile-stat-box .stat-val {
    font-size: 20px;
    font-weight: 700;
    color: #222222;
    font-family: 'Impact', 'Noto Sans TC', sans-serif;
}


@media (max-width: 600px) {
    .profile-stats-bar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 12px;
    }

    .profile-stat-box {
        min-width: 45%;
    }
}