* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none
}

html,
body {
    margin: 0;
    height: 100%;
    background: #15181c;
    color: #eee;
    font-family: system-ui, sans-serif;
    overflow: hidden
}

[hidden] {
    display: none !important
}

.screen {
    position: fixed;
    inset: 0
}

#menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    overflow: auto
}

#menu input {
    padding: 8px;
    border-radius: 6px;
    border: 0;
    font-size: 16px
}

#swatches {
    display: grid;
    grid-template-columns: repeat(9, 32px);
    gap: 6px
}

#swatches .sw {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer
}

#swatches .sw.sel {
    border-color: #fff
}

#swatches input {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: none
}

button {
    font: inherit;
    color: #fff;
    background: #e53935;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px
}

button.big {
    min-width: 260px;
    font-size: 18px;
    padding: 14px
}

button.alt {
    background: #37474f
}

#menuMsg {
    color: #ffb74d;
    min-height: 1.2em;
    text-align: center
}

#cv {
    width: 100%;
    height: 100%;
    display: block
}

#hud {
    --control-size: clamp(56px, 8.85vh, 84px);
    position: absolute;
    inset: 0;
    pointer-events: none;
    font-weight: 700;
    text-shadow: 0 2px 5px #000b
}

#hud span {
    display: block;
    font-size: clamp(15px, 2.4vh, 20px);
    line-height: 1.15
}

#hud strong {
    display: block;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 1.1
}

.hud-timing {
    position: absolute;
    top: 14px;
    left: 14px
}

.hud-timing>div+div {
    margin-top: 4px
}

.hud-position {
    position: absolute;
    left: 14px;
    bottom: calc(var(--control-size) + 22px)
}

.hud-lap {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: clamp(24px, 4.2vw, 40px);
    line-height: 1.1
}

.hud-speed {
    position: absolute;
    right: 14px;
    bottom: calc(var(--control-size) + 22px);
    text-align: right
}

#hud .hud-speed strong {
    font-size: clamp(28px, 4.2vw, 40px);
    white-space: nowrap
}

#board {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #000b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 15px;
    min-width: 260px;
    max-height: 96%;
    overflow: auto
}

#board table {
    width: 100%;
    border-collapse: collapse
}

#board td,
#board th {
    padding: 2px 6px;
    text-align: left
}

#board i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px
}

#banner {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translateX(-50%);
    font-size: min(14vw, 110px);
    font-weight: 800;
    text-shadow: 0 4px 12px #000;
    text-align: center
}

.countdown-enter {
    animation: countdown-shrink 300ms cubic-bezier(.2, .8, .25, 1) both
}

@keyframes countdown-shrink {
    from {
        transform: translateX(-50%) scale(2.6)
    }

    to {
        transform: translateX(-50%) scale(1)
    }
}

#panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #000e;
    padding: 18px 22px;
    border-radius: 12px;
    min-width: 280px;
    max-width: 95vw;
    max-height: 85vh;
    overflow: auto;
    text-align: center
}

#panel h2 {
    margin: 0 0 10px
}

#panel a {
    color: #90caf9
}

.lobby-qr {
    display: block;
    width: min(180px, 30vh);
    height: auto;
    margin: 0 auto 8px;
    background: #fff
}

.lobby-racers {
    list-style: none;
    padding: 0;
    margin: 8px auto;
    max-height: 20vh;
    overflow: auto;
    text-align: left;
    width: max-content;
    max-width: 100%
}

.lobby-racers li {
    overflow-wrap: anywhere
}

.lobby-racers i {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 1px solid #fff;
    vertical-align: middle
}

#touch {
    --control-size: clamp(56px, 8.85vh, 84px);
    position: absolute;
    inset: auto 0 8px 0;
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    pointer-events: none
}

#touch>div {
    display: flex;
    gap: 8px
}

#touch button {
    pointer-events: auto;
    width: var(--control-size);
    height: var(--control-size);
    font-size: clamp(14px, 2.4vh, 18px);
    background: #fff3;
    border: 2px solid #fff6;
    touch-action: none
}

#touch button.on {
    background: #e53935aa
}

#leaveBtn {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #000a;
    border: 1px solid #ffffff44;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    z-index: 5
}

#confirmOverlay {
    position: absolute;
    inset: 0;
    background: #000a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20
}

#confirmBox {
    background: #1b1f24;
    padding: 20px 24px;
    border-radius: 12px;
    min-width: 240px;
    text-align: center;
    box-shadow: 0 8px 24px #0008
}

#confirmBox p {
    margin: 0 0 16px;
    font-size: 16px
}

#confirmBox .row {
    display: flex;
    gap: 10px;
    justify-content: center
}

#trackPicker {
    position: fixed;
    inset: 0;
    background: #000c;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 12px
}

#trackPickerBox {
    background: #1b1f24;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto
}

#trackOptions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 12px 0
}

.track-option {
    background: #37474f;
    min-width: 130px
}

.track-option svg {
    display: block;
    width: 130px;
    height: 95px;
    margin: 0 auto 6px
}