@font-face {
    font-family: 'PT Sans';
    src: url('/fonts/pt-sans-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'PT Sans';
    src: url('/fonts/pt-sans-italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'PT Sans';
    src: url('/fonts/pt-sans-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --accent: #7AB81C;
    --bg-elevated: #2a2a2a;
    --color-bg: #222;
    --color-cell: #333;
    --color-fg: #fff;
    --color-row-pinned: #3a3a3a;
    --content-width: 70rem;
    --flash-improved: #d29922;
    --flash-new: var(--accent);
    --muted: #777;
    --rank-col-width: 6rem;
}

html { font-size: 62.5%; height: 100%; }

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

body {
    background-color: var(--color-bg);
    color: var(--color-fg);
    display: flex;
    flex-direction: column;
    font-family: 'PT Sans', sans-serif;
    font-size: 1.9rem;
    min-height: 100%;
    overflow-y: scroll;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* bare layout — used by the challenge page and no-challenge page (no nav/footer). */
main.bare {
    flex: 1;
    margin: 4rem auto 6rem;
    width: var(--content-width);
    max-width: calc(100% - 4rem);
}
main.bare h1 { text-align: center; }
main.bare h2 { margin-top: 1rem; margin-bottom: 1rem; }
main.bare p { line-height: 1.5em; margin-bottom: 1rem; }

.challenge-game { color: var(--accent); }
.challenge-goal { color: var(--muted); font-weight: 400; text-align: center; }
.challenge-description { color: var(--muted); margin: 1rem 0; padding: 1rem 0 0; text-align: center; }
.challenge-description a { color: var(--accent); }
.no-challenge { color: var(--muted); font-style: italic; text-align: center; }

/* embed body — OBS browser source: flush the table to the top, no page chrome. */
body.embed { overflow: hidden; font-size: 1.6rem; }
body.embed #leaderboard { margin: 0; padding: 0; }
body.embed .tablecontainer { padding-bottom: 0; }
body.embed .leaderboard-table { margin: 0; }
body.embed .leaderboard-table th { background-color: var(--bg-elevated); }
body.embed .row-pinned td:not(.col-rank) { background-color: var(--color-row-pinned); }
body.embed .row-pinned td.col-rank { box-shadow: inset 3px 0 0 var(--accent); }

.tablecontainer {
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    padding-bottom: 1rem;
}
.leaderboard-table {
    border-collapse: collapse;
    margin: 1rem auto 0;
    table-layout: fixed;
    text-align: left;
    width: 100%;
}
.leaderboard-table th,
.leaderboard-table td { border: 2px solid var(--color-bg); padding: 0.25em 0.625em; }
.leaderboard-table th {
    color: var(--muted);
    font-size: 0.7em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.leaderboard-table td:not(.col-rank) { background-color: var(--color-cell); }
.col-rank { background-color: var(--bg-elevated); color: var(--muted); font-weight: 700; text-align: center; width: var(--rank-col-width); }
.col-user { padding-inline-end: 2em; }
.col-time { text-align: center; white-space: nowrap; }
.leaderboard-table th.col-user { text-align: left; }
.leaderboard-table th.col-time { text-align: center; }
.leaderboard-table th.col-rank { background-color: transparent; color: var(--muted); }
.no-entries td { color: var(--muted); font-style: italic; text-align: center; }
tr.row-placeholder td { background-color: var(--bg-elevated); color: var(--muted); font-style: italic; }

tr.row-climbed td:not(.col-rank),
tr.row-new td:not(.col-rank) { animation: flash 2s ease-out; }
tr.row-climbed td:not(.col-rank) { --flash: var(--flash-improved); }
tr.row-new     td:not(.col-rank) { --flash: var(--flash-new); }

@keyframes flash {
    0%   { background-color: var(--flash); color: #000; }
    100% { background-color: var(--color-cell); color: var(--muted); }
}

/* narrow viewports: drop non-essential styling to avoid horizontal scroll. */
@media (width <= 768px) {
    main.bare h1 { font-size: 1.6em; }
    main.bare .challenge-goal { font-size: 1.2em; }
    .leaderboard-table th { text-align: center; }
    .leaderboard-table th.col-user { text-align: center; }
}
