:root{
    --text: #f1f4ff;
    --text-muted: #a9b0d6;
    --accent: #2de2e6;
    --accent-text: #0a0a18;
    --hot: #ff3b6b;
    --panel: rgba(10, 10, 24, .82);
    --dialog: #14142c;
    --font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

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

html{
    touch-action: manipulation;
}

body{
    min-height: 100dvh;
    background: #0a0a18;
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.noscript{
    padding: 24px;
    font-size: 18px;
}

.noscript a{
    color: var(--accent);
}

/* Fills the screen and keeps clear of the iPhone notch and home bar. */
.app{
    position: fixed;
    inset: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    user-select: none;
    -webkit-user-select: none;
}

/* The game fills the whole window: the track turns to run along its long side. */
.screen{
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    container-type: size;
    touch-action: none;
    -webkit-touch-callout: none;
}

.game-canvas{
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------- Score and buttons over the game ---------- */

.hud{
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 12px;
    pointer-events: none;
}

.hud__score{
    font-size: 30px;
    font-weight: bold;
    line-height: 1;
    color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 10px rgba(45, 226, 230, .6), 0 2px 0 rgba(0, 0, 0, .5);
}

.hud__unit{
    font-size: 18px;
}

.hud__score small{
    display: block;
    margin-top: 4px;
    font-size: 13px;
    opacity: .85;
}

.hud__buttons{
    display: flex;
    gap: 8px;
}

.round{
    width: 42px;
    height: 42px;
    font-size: 18px;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
}

.round[hidden]{
    display: none;
}

/* On the title screen the arrow flies by itself: its distance is not a score. */
.screen[data-phase="title"] .hud__score{
    visibility: hidden;
}

/* ---------- Title, pause and game over ---------- */

.panel{
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: var(--panel);
    animation: fade-in .3s ease-out;
}

.panel[hidden]{
    display: none;
}

/* The title screen lets the flying arrow show through. */
.panel[data-panel="title"]{
    background: radial-gradient(ellipse at center, rgba(10, 10, 24, .85) 30%, rgba(10, 10, 24, .35) 80%);
}

@keyframes fade-in{
    from{ opacity: 0; }
}

.panel__title{
    font-size: clamp(44px, 14cqmin, 72px);
    font-weight: bold;
    line-height: 1;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 0 6px var(--accent), 0 0 18px var(--accent), 0 0 36px rgba(45, 226, 230, .5);
}

.panel[data-panel="over"] .panel__title{
    text-shadow: 0 0 6px var(--hot), 0 0 18px var(--hot), 0 0 36px rgba(255, 59, 107, .5);
}

.panel__text{
    max-width: 300px;
    font-size: 18px;
}

.panel__score{
    font-size: 64px;
    font-weight: bold;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.panel__help{
    max-width: 320px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Each device sees the controls it has. */
.panel__help--touch{
    display: none;
}

@media (pointer: coarse){
    .panel__help--touch{
        display: block;
    }

    .panel__help--keys{
        display: none;
    }
}

.panel__links,
.panel__row{
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.panel[data-panel="title"] .panel__links .button{
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
}

.button{
    min-height: 44px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: bold 16px var(--font);
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    cursor: pointer;
    transition: transform .1s;
}

.button:active,
.round:active{
    transform: scale(.94);
}

.button[hidden]{
    display: none;
}

.button:focus-visible,
.round:focus-visible{
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.button--accent{
    color: var(--accent-text);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 18px rgba(45, 226, 230, .45);
}

.button--big{
    min-height: 56px;
    min-width: 200px;
    font-size: 22px;
}

.panel[data-panel="title"] .panel__links .button--ranks{
    color: #ffe14d;
    border-color: #ffe14d;
}

/* A short message over the game (a new zone, a Top 50 player passed). */
.toast{
    position: absolute;
    left: 50%;
    top: 70px;
    z-index: 3;
    max-width: calc(100% - 32px);
    padding: 10px 18px;
    font-weight: bold;
    text-align: center;
    color: var(--accent-text);
    background: var(--accent);
    border-radius: 999px;
    transform: translateX(-50%);
    box-shadow: 0 0 20px rgba(45, 226, 230, .5);
    pointer-events: none;
}

.toast[hidden]{
    display: none;
}

/* How to steer, at the start of a new player's first runs. */
.coach{
    position: absolute;
    left: 50%;
    bottom: 12%;
    z-index: 1;
    width: max-content;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    font-size: 17px;
    font-weight: bold;
    white-space: pre;
    text-align: center;
    color: #fff;
    background: rgba(10, 10, 24, .8);
    border: 2px solid var(--accent);
    border-radius: 16px;
    transform: translateX(-50%);
    pointer-events: none;
    animation: coach-in .35s ease-out;
}

.coach[hidden]{
    display: none;
}

@keyframes coach-in{
    from{ opacity: 0; transform: translate(-50%, 10px); }
}

/* A toast during a run goes above the hint instead of covering it. */
.screen:has(.coach:not([hidden])) .toast{
    top: 110px;
}

/* ---------- Top 50 ---------- */
.ranks{
    width: min(480px, calc(100% - 24px));
    max-height: min(680px, calc(100dvh - 24px));
    margin: auto;
    padding: 0;
    display: none;
    flex-direction: column;
    color: var(--text);
    background: var(--dialog);
    border: 1px solid rgba(45, 226, 230, .35);
    border-radius: 20px;
    box-shadow: 0 0 40px rgba(45, 226, 230, .15), 0 20px 60px rgba(0, 0, 0, .6);
    font-family: var(--font);
}

.ranks[open]{
    display: flex;
}

.ranks::backdrop{
    background: rgba(5, 5, 12, .7);
}

.ranks__header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.ranks__title{
    font-size: 26px;
    color: #ffe14d;
}

.ranks__status{
    margin-top: 2px;
    font-size: 14px;
    color: var(--text-muted);
}

.ranks__close{
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    font-size: 18px;
    color: var(--text);
    background: rgba(255, 255, 255, .1);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.ranks__name{
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.ranks__name.is-asking{
    background: rgba(45, 226, 230, .12);
}

.ranks__name-label{
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: bold;
}

.ranks__name-hint{
    display: none;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--accent);
}

.ranks__name.is-asking .ranks__name-hint{
    display: block;
}

.ranks__name-row{
    display: flex;
    gap: 8px;
}

/* 16px or more, so iPhone does not zoom in when the field gets the focus. */
.ranks__name-input{
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    font: 16px var(--font);
    color: var(--accent-text);
    background: var(--text);
    border: 0;
    border-radius: 12px;
}

.ranks__name-save{
    min-height: 44px;
    padding: 0 18px;
    font: bold 15px var(--font);
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.ranks__list{
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 12px 10px;
    list-style: none;
}

.ranks__row{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    font-size: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.ranks__row.is-you{
    background: rgba(45, 226, 230, .16);
    border-radius: 10px;
}

.ranks__rank{
    flex: 0 0 32px;
    font-weight: bold;
    color: var(--text-muted);
    text-align: center;
}

.ranks__player{
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ranks__score{
    font-weight: bold;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.ranks__you{
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    font-size: 14px;
    font-weight: bold;
    color: #ffe14d;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.ranks__you:empty{
    display: none;
}
