/* Südtirol CrossPathRace */
/* Layout: the map is the whole screen. A slim HUD floats on top (players, race), an action dock at the bottom (thumb zone),
   a reveal card in the middle after each round, and drawers for details, log, settings and help. */
:root {
    --paper: #e9eee9;
    --panel: #f7f9f6;
    --ink: #1b282b;
    --muted: #5b696b;
    --line: #cbd4cd;
    --blue: #1d5fd8;
    --orange: #dc5b23;
    --path: #2f6f45;
    --track: #8d6127;
    --road: #7b8587;
    --bike: #8a3fb8;
    --gold: #b98512;
    --good: #2f7a3e;
    --bad: #b8402a;
    --closed: #1b282b;
    --t-low: #c9d9c0;
    --t-high: #f2efe8;
    --shade: #4a5a50;
    --contour: #a08f6c;
    --casing: rgb(255 255 255 / .7);
    --glass: color-mix(in srgb, var(--panel) 90%, transparent);
    --font-display: "Archivo", "Arial Narrow", sans-serif;
    --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
    --font-data: "IBM Plex Mono", ui-monospace, monospace;
    --gut: 12px;
}

@media (prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) {
        --paper: #101719;
        --panel: #162125;
        --ink: #e2eae5;
        --muted: #93a29f;
        --line: #2b3a3d;
        --blue: #6c9dff;
        --orange: #ff8a4c;
        --path: #6fbf86;
        --track: #d2a45e;
        --road: #97a2a4;
        --bike: #c69af0;
        --gold: #ecc45a;
        --good: #7fd08f;
        --bad: #ff8f78;
        --closed: #e2eae5;
        --t-low: #1d2b26;
        --t-high: #3a4440;
        --shade: #000000;
        --contour: #b39466;
        --casing: rgb(0 0 0 / .45);
        color-scheme: dark
    }
}

:root[data-theme="dark"] {
    --paper: #101719;
    --panel: #162125;
    --ink: #e2eae5;
    --muted: #93a29f;
    --line: #2b3a3d;
    --blue: #6c9dff;
    --orange: #ff8a4c;
    --path: #6fbf86;
    --track: #d2a45e;
    --road: #97a2a4;
    --bike: #c69af0;
    --gold: #ecc45a;
    --good: #7fd08f;
    --bad: #ff8f78;
    --closed: #e2eae5;
    --t-low: #1d2b26;
    --t-high: #3a4440;
    --shade: #000000;
    --contour: #b39466;
    --casing: rgb(0 0 0 / .45);
    color-scheme: dark
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none
}

[hidden] {
    display: none !important
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.35;
    -webkit-tap-highlight-color: transparent
}

.c0 {
    color: var(--blue)
}

.c1 {
    color: var(--orange)
}

button {
    font: 600 14px var(--font-body);
    color: var(--ink);
    background: var(--panel);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    touch-action: manipulation
}

button:hover:not(:disabled) {
    border-color: var(--muted)
}

button:disabled {
    opacity: .45;
    cursor: not-allowed
}

button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px
}

button.primary {
    background: var(--pc, var(--ink));
    border-color: var(--pc, var(--ink));
    color: var(--panel);
    padding: 11px 18px;
    font-size: 16px;
    font-weight: 700
}

/* the board */
.game {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: var(--paper)
}

.game>svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none
}

.game>svg.panning {
    cursor: grabbing
}

.game::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse at 50% 50%, transparent 60%, rgb(40 50 40 / .18) 100%)
}

/* top HUD */
.hud {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--gut) 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    z-index: 5
}

.hud>* {
    pointer-events: auto
}

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

.iconbtn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--glass);
    backdrop-filter: blur(6px);
    font-size: 18px;
    line-height: 1;
    flex: none
}

.race {
    flex: 1;
    min-width: 0;
    max-width: 640px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 5px 8px;
    backdrop-filter: blur(6px)
}

.pl {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0
}

.pl.p1 {
    flex-direction: row-reverse
}

.av {
    position: relative;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 18px;
    background: color-mix(in srgb, var(--pc) 16%, var(--panel));
    border: 2.5px solid var(--pc)
}

.p0 .av {
    --pc: var(--blue)
}

.p1 .av {
    --pc: var(--orange)
}

.av small {
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    font: 800 8.5px var(--font-display);
    letter-spacing: .06em;
    color: #fff;
    background: var(--pc);
    border-radius: 5px;
    padding: 0 3px;
    line-height: 12px
}

.pv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0
}

.p1 .pv {
    align-items: flex-end
}

.pl .min {
    font: 700 20px var(--font-data);
    font-variant-numeric: tabular-nums;
    line-height: 1
}

.pl .min.lead {
    text-decoration: underline 3px;
    text-underline-offset: 4px
}

.rk {
    display: inline-flex;
    gap: 2px
}

.rk i {
    width: 9px;
    height: 8px;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 100%, 0 100%)
}

/* the records sit on a thin second row of the race bar, under each player */
.race {
    row-gap: 2px
}

.prec {
    grid-row: 2;
    grid-column: 1;
    margin-top: 7px;
    /* clear the YOU / BOT badge under the face */
    font: 700 12px var(--font-body);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    white-space: nowrap;
    line-height: 1.2
}

.prec .emo {
    width: 12px;
    height: 12px;
    margin: 0 1px 0 0
}

.prec.p1 {
    grid-column: 3;
    text-align: right
}

.prec:empty {
    display: none
}

.rk i.off {
    opacity: .2
}

.mid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0
}

.mid .rd {
    font: 700 10px var(--font-data);
    color: var(--muted);
    letter-spacing: .02em;
    white-space: nowrap
}

.rail {
    position: relative;
    width: min(30vw, 240px);
    height: 14px
}

.rail::before {
    content: "";
    position: absolute;
    left: 0;
    right: 12px;
    top: 50%;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 2px;
    background: var(--line)
}

.rail::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    border-radius: 2px;
    background: var(--ink);
    clip-path: polygon(50% 0, 100% 45%, 100% 100%, 0 100%, 0 45%)
}

.rail .dot {
    position: absolute;
    top: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--panel);
    transform: translateX(-50%);
    transition: left .7s cubic-bezier(.3, .8, .3, 1)
}

.rail .dot.d0 {
    background: var(--blue)
}

.rail .dot.d1 {
    background: var(--orange)
}

.fxs {
    display: flex;
    gap: 2px
}

.fxs:empty {
    display: none
}

.fx {
    font-size: 15px;
    line-height: 20px;
    min-width: 22px;
    height: 22px;
    text-align: center;
    border-radius: 999px;
    background: var(--panel);
    border: 1.5px solid currentColor;
    font-family: var(--font-data);
    font-weight: 700
}

.fx small {
    font-size: 10px;
    margin-left: 1px
}

.fx.good {
    color: var(--good)
}

.fx.bad {
    color: var(--bad)
}

@media (max-width:520px) {
    .rail {
        width: 16vw
    }

    .fxs {
        position: absolute;
        top: calc(100% + 6px)
    }

    .pl {
        position: relative
    }

    .p1 .fxs {
        right: 0
    }
}

@media (prefers-reduced-motion:reduce) {
    .rail .dot {
        transition: none
    }
}

/* map controls */
.zoom {
    position: absolute;
    right: var(--gut);
    top: 50%;
    transform: translateY(-60%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 4
}

.zoom button {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 19px;
    line-height: 1;
    background: var(--glass);
    backdrop-filter: blur(6px)
}

.zoom #follow {
    font-size: 11px;
    font-weight: 700
}

.zoom #mute {
    font-size: 16px
}

img.emo {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -.22em;
    display: inline-block
}

.av img.emo {
    width: 20px;
    height: 20px;
    vertical-align: 0
}

.fx img.emo {
    width: 15px;
    height: 15px;
    vertical-align: -2px
}

.toast {
    position: absolute;
    left: 50%;
    top: calc(var(--hudH, 110px) + 8px);
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 14px rgb(0 0 0 / .18);
    max-width: calc(100% - 32px);
    text-align: center;
    z-index: 6
}

/* bottom action dock: one slim bar */
.dock {
    position: absolute;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    transform: translateX(-50%);
    width: min(620px, calc(100% - 2*var(--gut)));
    box-sizing: border-box;
    padding: 8px 8px 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 6px 24px rgb(0 0 0 / .16);
    z-index: 5
}

.dock-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.25
}

.dock-text b {
    font: 800 16px var(--font-display);
    color: var(--pc, var(--ink))
}

.dock-text .ready {
    font-size: 12px
}

.dock-text .ready b {
    font: inherit;
    font-weight: 700;
    color: var(--ink)
}

.dock-text .target b {
    font: inherit;
    font-weight: 700;
    color: var(--ink)
}

.dock-text #turnHint b {
    font: 700 14px var(--font-data);
    color: var(--ink)
}

.dock-text #turnHint b.up {
    color: var(--good)
}

.dock-text #turnHint b.down {
    color: var(--bad)
}

.dock-text .hitme {
    color: var(--good);
    font-weight: 700
}

.rockbtn {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px
}

.rockbtn small {
    font: 600 12px var(--font-data);
    color: var(--muted)
}

.rockbtn .rk-ic {
    display: inline-flex;
    line-height: 1
}

.rockbtn[aria-pressed="true"] {
    border-color: var(--pc);
    color: var(--pc);
    background: color-mix(in srgb, var(--pc) 12%, var(--panel))
}

.go {
    flex: none;
    min-width: 92px;
    padding: 10px 14px;
    border-radius: 12px
}

.skip {
    flex: none;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700
}

.caption {
    position: absolute;
    left: 50%;
    top: calc(var(--hudH, 110px) + 10px);
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    box-sizing: border-box;
    padding: 9px 16px;
    border-radius: 14px;
    background: var(--panel);
    border: 2px solid var(--cc, var(--line));
    box-shadow: 0 8px 24px rgb(0 0 0 / .2);
    font: 700 15px var(--font-body);
    text-align: center;
    z-index: 7;
    animation: capIn .25s ease-out
}

.caption b {
    font-family: var(--font-display);
    color: var(--cc, var(--ink))
}

.caption .cm {
    color: var(--muted);
    font-weight: 600;
    font-size: 14px
}

.caption .big {
    font-size: 22px;
    vertical-align: -3px
}

@keyframes capIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -8px)
    }

    100% {
        opacity: 1;
        transform: translate(-50%, 0)
    }
}

@media (prefers-reduced-motion:reduce) {
    .caption {
        animation: none
    }
}

.go:disabled {
    opacity: .35
}

.infobar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--dockH, 180px) + 8px);
    width: min(720px, calc(100% - 24px));
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    font-family: var(--font-data);
    font-size: 12px;
    color: var(--muted);
    background: var(--glass);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 10px;
    z-index: 4;
    pointer-events: none
}

.infobar:empty {
    display: none
}

.infobar b {
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 13.5px
}

@media (max-width:520px) {
    .dock-text b {
        font-size: 15px
    }

    .rockbtn {
        padding: 10px
    }
}

/* reveal card */
.revealwrap {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--hudH, 110px) + 6px);
    display: flex;
    justify-content: center;
    padding: 0 var(--gut);
    z-index: 7;
    pointer-events: none
}

.reveal {
    pointer-events: auto;
    width: min(520px, 100%);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 14px 40px rgb(0 0 0 / .28);
    animation: cardIn .35s cubic-bezier(.2, .9, .3, 1.2)
}

.reveal h3 {
    margin: 0;
    font: 700 12px var(--font-data);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted)
}

.reveal p {
    margin: 0;
    font-size: 14px;
    line-height: 1.35
}

.reveal p b {
    font-family: var(--font-display)
}

.reveal .hit {
    color: var(--bad);
    font-weight: 700
}

.reveal .miss {
    color: var(--muted)
}

.reveal .find {
    font-weight: 700
}

.reveal .find.good {
    color: var(--good)
}

.reveal .find.bad {
    color: var(--bad)
}

.reveal .tap {
    font-size: 12px;
    color: var(--muted);
    text-align: right
}

@keyframes cardIn {
    0% {
        opacity: 0;
        transform: translateY(-14px) scale(.96)
    }

    100% {
        opacity: 1;
        transform: none
    }
}

@media (prefers-reduced-motion:reduce) {
    .reveal {
        animation: none
    }
}

/* title + end screen: an alpine scene with a trail signpost */
.title {
    position: fixed;
    inset: 0;
    z-index: 18;
    display: grid;
    place-items: center;
    overflow: auto;
    padding: max(16px, env(safe-area-inset-top)) 16px 24px;
    --sky: #cfe2e6;
    --sun: #fbe7b0;
    --far: #8aa3ad;
    --snow: #f4f7f6;
    --mid: #58796f;
    --pine: #2c5444;
    --meadow: #a9c97f;
    --trail: #fff8e8;
    --roof: #b8402a;
    --hutwall: #efe3cc;
    --wood: #7a4e2c;
    --board: #f5ecd7;
    --boardink: #2a211a;
    --blaze: #d2302c
}

@media (prefers-color-scheme:dark) {
    .title {
        --sky: #1c2a37;
        --sun: #e8d9a8;
        --far: #3e5562;
        --snow: #c9d6da;
        --mid: #2b4540;
        --pine: #17302a;
        --meadow: #3f5a35;
        --trail: #d8cfb8;
        --hutwall: #d9ccb3;
        --board: #efe4cb
    }
}

/* loading screen: covers everything until the map, scripts, fonts and art are ready */
.loading {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 18px;
    background: #cfe2e6;
    color: #2a211a;
    font: 700 16px var(--font-body);
    transition: opacity .4s ease
}

.loading.done {
    opacity: 0;
    pointer-events: none
}

.loading .spin {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 6px solid rgb(42 33 26 / .15);
    border-top-color: #d2302c;
    animation: spin .9s linear infinite
}

.loading b {
    font: 800 26px var(--font-display);
    letter-spacing: -.01em
}

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

@media (prefers-color-scheme:dark) {
    .loading {
        background: #1c2a37;
        color: #efe4cb
    }

    .loading .spin {
        border-color: rgb(239 228 203 / .18);
        border-top-color: #d2302c
    }
}

@media (prefers-reduced-motion:reduce) {
    .loading .spin {
        animation-duration: 2.4s
    }
}

.title .scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%
}

.post {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(440px, 100%);
    padding: 6px 0 18px
}

.pole {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: -40vh;
    width: 18px;
    margin-left: -9px;
    background: var(--wood);
    border-radius: 3px;
    z-index: 0
}

.pole i {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(40vh - 110px);
    height: 54px;
    background: linear-gradient(var(--blaze) 0 33%, #fff 33% 67%, var(--blaze) 67%)
}

.board {
    position: relative;
    z-index: 1;
    border: 0;
    background: var(--board);
    color: var(--boardink);
    box-shadow: 0 3px 0 rgb(0 0 0 / .25), inset 0 0 0 2px rgb(122 78 44 / .35);
    font-family: var(--font-display);
    cursor: pointer
}

.board.name {
    margin: 0 0 6px;
    padding: 14px 26px 12px;
    border-radius: 6px;
    font-size: clamp(30px, 8.6vw, 50px);
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1;
    text-align: center;
    cursor: default
}

.board.name small {
    display: block;
    margin-top: 6px;
    font: 600 15px var(--font-body);
    letter-spacing: 0;
    color: #6b5a48
}

.row-label {
    position: relative;
    z-index: 1;
    margin: 6px 0 -4px;
    font: 700 13px var(--font-body);
    color: var(--boardink);
    background: var(--board);
    padding: 1px 10px;
    border-radius: 999px
}

.row {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center
}

.board.arrow {
    flex: 1;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    padding: 10px 18px;
    font-size: 20px;
    font-weight: 800;
    text-align: left;
    min-height: 64px
}

.board.arrow.left {
    clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 50%);
    padding-left: 26px
}

.board.arrow.right {
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
    padding-right: 26px;
    grid-template-columns: 1fr auto;
    text-align: right
}

.board.arrow .ic {
    grid-row: span 2;
    font-size: 28px
}

.board.arrow small {
    font: 500 13px var(--font-body);
    color: #6b5a48
}

.board.arrow.left small {
    grid-column: 2
}

.board.arrow.right small {
    grid-column: 1
}

.board[aria-pressed="true"].left {
    background: #2f5fd0;
    color: #fff
}

.board[aria-pressed="true"].right {
    background: #d8622b;
    color: #fff
}

.board[aria-pressed="true"] small {
    color: rgb(255 255 255 / .85)
}

.board.small {
    flex: 1;
    padding: 10px 12px;
    border-radius: 6px;
    font: 700 15px var(--font-body)
}

.board.small[aria-pressed="true"] {
    background: var(--boardink);
    color: var(--board)
}

.row.off {
    opacity: .45;
    pointer-events: none
}

.board.go-board {
    margin-top: 10px;
    padding: 16px 34px;
    border-radius: 8px;
    font-size: 22px;
    font-weight: 800;
    background: var(--blaze);
    color: #fff;
    box-shadow: 0 4px 0 #7d1a17
}

.board.go-board:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #7d1a17
}

.board:focus-visible,
.howto:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px
}

.howto {
    position: relative;
    z-index: 1;
    border: 0;
    background: transparent;
    color: var(--boardink);
    font: 600 14px var(--font-body);
    text-decoration: underline;
    padding: 6px;
    cursor: pointer;
    background: rgb(255 255 255 / .55);
    border-radius: 6px
}

.board.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 18px;
    padding: 14px 20px;
    border-radius: 6px;
    cursor: default;
    font: 600 15px var(--font-body);
    min-width: min(320px, 100%)
}

.board.stats b {
    display: block;
    font: 800 24px var(--font-display)
}

.board.stats b.inline {
    display: inline;
    font: 800 15px var(--font-body)
}

.board.stats .wide.rec {
    color: var(--boardink);
    font-weight: 600
}

.record {
    position: relative;
    z-index: 1;
    margin: 0;
    font: 700 13px var(--font-body);
    color: var(--boardink);
    background: var(--board);
    padding: 3px 12px;
    border-radius: 999px;
    text-align: center;
    max-width: 100%
}

.board.stats .wide {
    grid-column: span 2;
    text-align: center;
    color: #6b5a48;
    font-weight: 500
}

@media (max-height:640px) {
    .board.name {
        font-size: 32px;
        padding: 10px 20px
    }

    .post {
        gap: 7px
    }
}

@media (prefers-reduced-motion:no-preference) {

    .post>.board,
    .post>.title-logo,
    .post>.row,
    .post>.row-label {
        animation: hang .5s cubic-bezier(.3, 1.4, .5, 1) backwards
    }

    .post>:nth-child(3) {
        animation-delay: .06s
    }

    .post>:nth-child(4) {
        animation-delay: .1s
    }

    .post>:nth-child(5) {
        animation-delay: .14s
    }

    .post>:nth-child(6) {
        animation-delay: .18s
    }

    .post>:nth-child(7) {
        animation-delay: .22s
    }

    .post>:nth-child(8) {
        animation-delay: .26s
    }
}

@keyframes hang {
    0% {
        opacity: 0;
        transform: translateY(-14px) rotate(-3deg)
    }

    100% {
        opacity: 1;
        transform: none
    }
}

.char {
    position: fixed;
    bottom: 2vh;
    z-index: 0;
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    height: min(38vh, 340px);
    transition: transform .25s, filter .25s, opacity .25s
}

.char img {
    height: 100%;
    width: auto;
    display: block;
    filter: drop-shadow(0 6px 0 rgb(0 0 0 / .18))
}

.char.hiker {
    left: max(2vw, calc(50% - 600px))
}

.char.biker {
    right: max(2vw, calc(50% - 600px))
}

.char.biker img {
    transform: scale(-1.13, 1.13);
    /* mirrored; the picture includes the whole bike, so a bit bigger to match the hiker */
    transform-origin: 50% 100%
}

.char[aria-pressed="false"] {
    opacity: .55;
    filter: saturate(.4);
    transform: scale(.9)
}

.char[aria-pressed="true"] {
    transform: scale(1.04)
}

.title.ending .char {
    display: none
}

.endchar {
    position: relative;
    z-index: 1;
    height: min(26vh, 200px);
    margin-bottom: -14px;
    filter: drop-shadow(0 6px 0 rgb(0 0 0 / .18))
}

@media (prefers-reduced-motion:no-preference) {
    .endchar {
        animation: hop 1.1s ease-in-out infinite
    }

    .endchar.sad {
        animation: none
    }
}

@keyframes hop {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-10px)
    }
}

@media (max-width:700px) {
    .char {
        height: 22vh;
        bottom: 1vh;
        z-index: 0
    }

    .char.hiker {
        left: -10px
    }

    .char.biker {
        right: -10px
    }
}

.av.face {
    background-repeat: no-repeat;
    font-size: 0
}

.av.face img.emo {
    display: none
}

.p0 .av.face {
    background-image: url(art/hiker.webp);
    background-size: 250%;
    background-position: 66% 6%
}

.p1 .av.face {
    background-image: url(art/biker.webp);
    background-size: 313%;
    background-position: 63.9% 9.1%
}

.board.name .kicker {
    display: block;
    margin-bottom: 2px;
    font: 700 clamp(15px, 4vw, 19px) var(--font-display);
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--blaze)
}

/* online play on the title signpost */
.online {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%
}

.board.code {
    flex: 1;
    min-width: 0;
    padding: 8px;
    border-radius: 6px;
    font: 800 22px var(--font-data);
    letter-spacing: .3em;
    text-align: center;
    text-transform: uppercase;
    cursor: text
}

.ostatus {
    padding: 10px 14px;
    border-radius: 6px;
    font: 600 15px var(--font-body);
    text-align: center;
    cursor: default
}

.ostatus .roomcode {
    display: block;
    margin: 2px 0 6px;
    font: 800 30px var(--font-data);
    letter-spacing: .25em
}

.ostatus button {
    margin: 6px 4px 0;
    font-size: 14px
}

.ostatus.err {
    color: #a3261c
}

/* drawers */
.drawer h2 small {
    display: block;
    font: 500 13px var(--font-body);
    color: var(--muted)
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 92vw);
    box-sizing: border-box;
    padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    background: var(--panel);
    border-left: 1px solid var(--line);
    box-shadow: -10px 0 30px rgb(0 0 0 / .2);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto
}

.drawer header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    /* the title and ✕ stay put while the drawer scrolls */
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -16px;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--line)
}

.drawer h2 {
    margin: 0;
    font: 800 20px var(--font-display)
}

.drawer h3 {
    margin: 4px 0 0;
    font: 700 12px var(--font-data);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted)
}

.drawer p {
    margin: 0;
    font-size: 14px;
    color: var(--muted)
}

.drawer p b {
    color: var(--ink)
}

.fxleg span {
    font-size: 13.5px
}

.fxleg span.bad {
    color: var(--bad)
}

.attrib a {
    color: inherit
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / .3);
    z-index: 19
}

.player {
    border: 1px solid var(--line);
    border-left: 5px solid var(--pc);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px
}

.player.p0 {
    --pc: var(--blue)
}

.player.p1 {
    --pc: var(--orange)
}

.player .top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px
}

.player .who {
    font: 800 16px var(--font-display);
    color: var(--pc)
}

.player .stats {
    font-family: var(--font-data);
    font-size: 12px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    flex-wrap: wrap
}

.player svg {
    width: 100%;
    height: 42px;
    display: block
}

.player.active {
    box-shadow: 0 0 0 2px var(--pc)
}

.log {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13.5px;
    color: var(--muted)
}

.log li b {
    color: var(--ink)
}

.log .lg {
    margin-bottom: 2px
}

.log li {
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px
}

.log li:last-child {
    border-bottom: 0
}

.log .hit {
    color: var(--bad);
    font-weight: 700
}

.log .miss {
    color: var(--muted)
}

.log .find {
    font-size: 15px
}

.log .c0 {
    color: var(--blue)
}

.log .c1 {
    color: var(--orange)
}

.log li .rd {
    font: 600 11px var(--font-data);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-right: 6px
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px
}

.seg {
    display: inline-flex;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    overflow: hidden
}

.seg button {
    border: 0;
    border-radius: 0
}

.seg button[aria-pressed="true"] {
    background: var(--line)
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13.5px;
    color: var(--ink)
}

.legend i {
    display: inline-block;
    width: 20px;
    height: 3px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 8px
}

.attrib {
    color: var(--muted);
    font-size: 11.5px;
    margin: 0
}

/* overlays */
.win {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--paper) 60%, transparent);
    backdrop-filter: blur(3px);
    z-index: 10;
    padding: 16px
}

.win>div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px 26px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    max-width: 420px;
    box-shadow: 0 14px 40px rgb(0 0 0 / .28)
}

.win h2 {
    margin: 0;
    font: 800 30px var(--font-display);
    text-wrap: balance
}

.win p {
    margin: 0;
    color: var(--muted)
}

/* map effects */
@keyframes pop {
    0% {
        opacity: 0;
        transform: translateY(8px) scale(.7)
    }

    12% {
        opacity: 1;
        transform: translateY(0) scale(1.15)
    }

    22% {
        transform: translateY(0) scale(1)
    }

    75% {
        opacity: 1;
        transform: translateY(-16px)
    }

    100% {
        opacity: 0;
        transform: translateY(-30px)
    }
}

.pop {
    animation: pop 3.2s ease-out forwards
}

@keyframes drop {
    0% {
        opacity: 0;
        transform: translateY(-40px) scale(1.5)
    }

    60% {
        opacity: 1;
        transform: translateY(3px) scale(.95)
    }

    100% {
        transform: none
    }
}

.drop {
    animation: drop .6s ease-out
}

@keyframes flash {

    0%,
    100% {
        opacity: .9
    }

    50% {
        opacity: .25
    }
}

.flash {
    animation: flash .45s ease-in-out 3
}

@keyframes ringPulse {
    0% {
        opacity: .9;
        transform: scale(.8)
    }

    70% {
        opacity: 0;
        transform: scale(1.6)
    }

    100% {
        opacity: 0;
        transform: scale(1.6)
    }
}

.newring {
    animation: ringPulse 1.4s ease-out infinite;
    transform-box: fill-box;
    transform-origin: center
}

.optlbl {
    cursor: pointer
}

.shake {
    animation: shake .6s cubic-bezier(.36, .07, .19, .97)
}

@keyframes shake {

    10%,
    90% {
        transform: translate(-3px, 2px)
    }

    20%,
    80% {
        transform: translate(7px, -3px)
    }

    30%,
    50%,
    70% {
        transform: translate(-10px, 4px)
    }

    40%,
    60% {
        transform: translate(10px, -2px)
    }
}

.shake-s {
    animation: shakeS .4s cubic-bezier(.36, .07, .19, .97)
}

@keyframes shakeS {

    20%,
    80% {
        transform: translate(3px, -1px)
    }

    40%,
    60% {
        transform: translate(-5px, 2px)
    }
}

.burst {
    animation: burst .9s ease-out forwards;
    transform-box: fill-box;
    transform-origin: center
}

@keyframes burst {
    0% {
        opacity: 1;
        transform: scale(.6)
    }

    100% {
        opacity: 0;
        transform: scale(3.2)
    }
}

.spark {
    animation: spark 1.3s cubic-bezier(.2, .7, .3, 1) forwards
}

@keyframes spark {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1)
    }

    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(.4)
    }
}

@media (prefers-reduced-motion:reduce) {

    .shake-s,
    .shake,
    .burst,
    .spark {
        animation: none
    }

    .burst,
    .spark {
        opacity: 0
    }

    .pop,
    .drop,
    .flash {
        animation: none
    }

    .pop {
        opacity: 0
    }

    .newring {
        animation: none;
        opacity: .6
    }
}

/* dust puffs behind the biker */
.dust {
    fill: var(--muted);
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation: dust .65s ease-out
}

@keyframes dust {
    0% {
        opacity: .5;
        transform: scale(.5)
    }

    100% {
        opacity: 0;
        transform: scale(1.7) translateY(-3px)
    }
}

/* cows: the button, and the little cow next to the rockfall triangles while it is still unused */
.cowbtn .cow-ic {
    font-size: 15px;
    line-height: 1
}

.cowbtn .cow-ic img.emo {
    width: 16px;
    height: 16px;
    vertical-align: -3px
}

.rkrow {
    display: inline-flex;
    align-items: center;
    gap: 4px
}

.p1 .rkrow {
    flex-direction: row-reverse
}

.cw {
    font-size: 11px;
    line-height: 1
}

.cw img.emo {
    width: 12px;
    height: 12px;
    vertical-align: middle
}

/* narrow phones: the two action buttons show only their icon and count */
@media (max-width: 420px) {

    .rockbtn[aria-pressed="false"] #rockLbl,
    .rockbtn[aria-pressed="false"] #cowLbl {
        display: none
    }
}

@media (max-width: 400px) {
    .cw {
        display: none
    }
}

.legend .leg-cow {
    display: inline-block;
    width: 14px;
    margin-right: 8px;
    font-size: 13px;
    vertical-align: middle
}

.legend .leg-cow img.emo {
    width: 15px;
    height: 15px
}

/* the logo: inside the loading spinner, and on top of the signpost on the title screen */
.logo-spin {
    position: relative;
    width: 108px;
    height: 108px;
    display: grid;
    place-items: center
}

.logo-spin img {
    width: 78px;
    height: 78px;
    border-radius: 18px;
    box-shadow: 0 3px 10px rgb(0 0 0 / .18)
}

.logo-spin .spin {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    border-width: 5px
}

.title-logo {
    position: relative;
    z-index: 1;
    width: 68px;
    height: 68px;
    border-radius: 16px;
    box-shadow: 0 4px 0 rgb(0 0 0 / .18);
    margin-bottom: -2px
}

@media (max-height: 700px) {
    .title-logo {
        display: none
    }
}

/* joining a friend's room: the creator picks the characters */
.rolelocked #tHiker,
.rolelocked #tBiker {
    opacity: .45;
    cursor: not-allowed
}

.rolelocked .char {
    pointer-events: none
}

/* title: one big Play button; character and online choices fold away under "more" */
.board.go-board#tPlay {
    font-size: 28px;
    padding: 18px 64px
}

.play-as {
    position: relative;
    z-index: 1;
    margin: -2px 0 0;
    padding: 3px 10px;
    border-radius: 6px;
    background: rgb(255 255 255 / .6);
    color: var(--boardink);
    font: 600 14px var(--font-body)
}

.more {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%
}

.more[hidden] {
    display: none
}

/* first race: the routes on the map pulse gently, so it's clear they can be tapped */
.optpulse {
    animation: optpulse 1.3s ease-in-out infinite
}

@keyframes optpulse {
    50% {
        opacity: .55
    }
}

@media (prefers-reduced-motion:reduce) {
    .optpulse {
        animation: none
    }
}

/* the minutes in the top bar say what they are: minutes to the hut */
/* under the race rail: what the big numbers are */
.mid .midnote {
    font: 600 10px var(--font-body);
    color: var(--muted);
    white-space: nowrap
}

/* rockfalls left: a rock and a number */
.rk {
    align-items: center;
    gap: 1px;
    font: 700 12px var(--font-data)
}

.rk .emo {
    width: 13px;
    height: 13px
}

.rk.none {
    opacity: .35
}

/* round summary card: minutes before → after, and why */
.reveal .sumrow {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-top: 1px solid var(--line)
}

.reveal .sumhead {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 15px
}

.reveal .sumtot {
    font: 700 15px var(--font-data);
    white-space: nowrap
}

.reveal .sumparts {
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink)
}

.reveal .good {
    color: var(--good)
}

.reveal .bad {
    color: var(--bad)
}

.reveal .cm {
    color: var(--muted)
}

.reveal .sumlead {
    font-weight: 700;
    text-align: center;
    padding-top: 4px;
    border-top: 1px solid var(--line)
}

/* help: four lines to start, the rest folded away */
.drawer .quick {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--gold) 10%, var(--panel));
    border: 1px solid var(--line)
}

.drawer .quick p {
    color: var(--ink)
}

.drawer .quick .example {
    font-size: 13px;
    color: var(--muted)
}

.drawer details.more-rules {
    display: flex;
    flex-direction: column;
    gap: 10px
}

.drawer details.more-rules summary {
    cursor: pointer;
    font: 700 14px var(--font-body);
    color: var(--ink);
    padding: 4px 0
}

.drawer details.more-rules[open]>*:not(summary) {
    margin-top: 10px
}

/* choosing a route: the trails you can't take this move fade back */
#svg .edges,
#svg .casing {
    transition: opacity .3s
}

#svg.calm .edges {
    opacity: .38
}

#svg.calm .casing {
    opacity: .5
}

/* only one route this move: the rockfall button nudges, because blocking is the other choice */
.rockbtn.nudge {
    animation: nudge 1.4s ease-in-out 3
}

@keyframes nudge {
    50% {
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc, var(--blue)) 35%, transparent)
    }
}

@media (prefers-reduced-motion:reduce) {
    .rockbtn.nudge {
        animation: none;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc, var(--blue)) 35%, transparent)
    }
}

/* dusk: huts glow warm */
#svg .glow {
    display: none
}

#svg.dusk .glow {
    display: inline;
    animation: glow 3s ease-in-out infinite
}

@keyframes glow {
    50% {
        opacity: .7
    }
}

@media (prefers-reduced-motion:reduce) {
    #svg.dusk .glow {
        animation: none
    }
}

/* the map is the game world: it keeps its own colours whatever the system's dark mode is,
   and only the time of day (morning, noon, dusk) changes how it looks. Panels and bars still follow dark mode. */
#svg {
    color-scheme: light;
    --paper: #e9eee9;
    --panel: #f7f9f6;
    --ink: #1b282b;
    --muted: #5b696b;
    --line: #cbd4cd;
    --blue: #1d5fd8;
    --orange: #dc5b23;
    --path: #2f6f45;
    --track: #8d6127;
    --road: #7b8587;
    --bike: #8a3fb8;
    --gold: #b98512;
    --good: #2f7a3e;
    --bad: #b8402a;
    --closed: #1b282b;
    --t-low: #c9d9c0;
    --t-high: #f2efe8;
    --shade: #4a5a50;
    --contour: #a08f6c;
    --casing: rgb(255 255 255 / .7)
}

/* dusk: hiker lantern and bike headlight (hidden at other times of day) */
#svg .dusklight {
    display: none
}

#svg.dusk .dusklight {
    display: inline
}

/* the race clock, centred on the record row under the race rail */
.race .clock {
    grid-row: 2;
    grid-column: 2;
    justify-self: center;
    margin-top: 7px;
    font: 700 12px var(--font-data);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    white-space: nowrap;
    line-height: 1.2
}

/* the round summary: compact, see-through to taps, never in the way */
.reveal.compact {
    pointer-events: none;
    gap: 2px;
    padding: 8px 12px;
    opacity: .96
}

.reveal.compact .sumrow {
    padding: 3px 0
}

.reveal.compact .sumrow:first-child {
    border-top: 0
}

.reveal.compact .sumhead,
.reveal.compact .sumtot {
    font-size: 13px
}

.reveal.compact .sumparts {
    font-size: 12px;
    line-height: 1.35
}

.reveal.compact .sumlead {
    font-size: 13px;
    padding-top: 3px
}