:root {
    --background: #ffffff;
    --foreground: #111111;
    --muted: #6b7280;
    --line: #e5e7eb;
    --accent: #fc4c02;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #0a0a0a;
        --foreground: #f5f5f5;
        --muted: #a1a1aa;
        --line: #27272a;
        --accent: #fc5b16;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--background);
    color: var(--foreground);
    font-family: Inter, "Helvetica Neue", Arial, sans-serif;
}

body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.container {
    width: min(680px, 100%);
    margin: 0 auto;
}

.page-nav {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-bottom: 24px;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link-current {
    color: var(--foreground);
}

.hero {
    margin-bottom: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo {
    display: block;
    width: 300px;
    max-width: 100%;
    height: auto;
    margin: 0 0 22px;
    object-fit: contain;
}

.logo-small {
    width: 180px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2.4rem, 6vw, 4rem);
    line-height: 1;
}

.intro {
    max-width: 36rem;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

.actions {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.action-link {
    color: var(--foreground);
    text-decoration: none;
    font-style: italic;
}

.action-link:hover {
    color: var(--accent);
}

.strava-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-style: normal;
    font-weight: 600;
    line-height: 1;
}

.strava-button:hover {
    background: #e54600;
    color: #ffffff;
}

.strava-button-disabled,
.strava-button-disabled:hover {
    background: var(--line);
    color: var(--muted);
    cursor: not-allowed;
}

.button-danger,
.button-danger:hover {
    background: #b42318;
    color: #ffffff;
}

.board {
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.flash {
    margin: 0 0 24px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--foreground);
    background: color-mix(in srgb, var(--accent) 10%, var(--background));
}

.about-section {
    border-top: 1px solid var(--line);
    padding-top: 24px;
    margin-top: 24px;
}

.about-section h2 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.about-section p {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.65;
}

.about-section p:last-child {
    margin-bottom: 0;
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 18px;
}

.board-header h2,
.board-header p {
    margin: 0;
}

.board-header h2 {
    font-size: 1.25rem;
}

.board-header p,
.meta,
.empty {
    color: var(--muted);
    font-size: 0.95rem;
}

.leaderboard {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.leaderboard li {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.rank {
    font-size: 0.95rem;
    color: var(--muted);
}

.runner {
    min-width: 0;
}

.runner strong,
.runner span {
    display: block;
}

.runner span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.score {
    text-align: right;
}

.score strong,
.score span {
    display: block;
}

.score span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.stack-form label {
    display: grid;
    gap: 8px;
}

.stack-form span,
.data-table th {
    font-size: 0.9rem;
    color: var(--muted);
}

.stack-form input,
.stack-form select {
    min-height: 46px;
    width: 100%;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--background);
    color: var(--foreground);
    font: inherit;
}

.stack-form button {
    margin-top: 4px;
    width: fit-content;
    border: 0;
    cursor: pointer;
}

.inline-form {
    margin: 0;
}

.inline-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-form button {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    font: inherit;
}

.compact-input {
    min-height: 34px;
    width: 72px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--background);
    color: var(--foreground);
    font: inherit;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 0;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.data-table td {
    font-size: 0.95rem;
}

@media (max-width: 640px) {
    body {
        padding: 18px 14px;
        place-items: center;
    }

    .container {
        width: 100%;
    }

    .hero {
        margin-bottom: 28px;
    }

    .page-nav {
        justify-content: flex-start;
        margin-bottom: 18px;
    }

    .logo {
        width: min(300px, 72vw);
        margin-bottom: 18px;
    }

    h1 {
        font-size: 2.2rem;
    }

    .intro {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .strava-button {
        width: 100%;
    }

    .stack-form button {
        width: 100%;
    }

    .leaderboard li {
        grid-template-columns: 36px minmax(0, 1fr) auto;
        gap: 10px;
        padding: 12px 0;
    }

    .score {
        grid-column: auto;
        text-align: right;
        margin-top: 0;
    }

    .board-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .rank,
    .runner span,
    .score span,
    .board-header p,
    .meta,
    .empty {
        font-size: 0.88rem;
    }

    .runner strong,
    .score strong {
        font-size: 0.98rem;
    }

    .runner strong,
    .runner span,
    .score strong,
    .score span {
        white-space: nowrap;
    }
}
