* {
    margin: 0;
    box-sizing: border-box;
    font-family: "Saira Stencil", sans-serif;
    font-weight: 800;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    background-color: black;
    color: white;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100dvh;
    padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 4px);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
}

svg {
    display: block;
    width: 1em;
    height: 1em;
    fill: currentColor;
}

header {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 640px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding-bottom: 8px;

    &>* {
        flex-shrink: 0;
    }
}

.btn {
    position: relative;
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid white;
    background-color: black;
    color: white;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    touch-action: manipulation;
    transition: background-color .3s, color .3s, opacity .3s;

    &:hover,
    &.on {
        background-color: white;
        color: black;
    }

    &:disabled {
        opacity: .3;
        pointer-events: none;
    }

    &.big {
        width: 88px;
        height: 56px;
        font-size: 22px;
    }
}

.back {
    font-size: 16px;

    & svg {
        transition: transform .3s;
    }

    &:hover svg {
        transform: translateX(-3px);
    }
}

.hud,
.hr {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip {
    height: 36px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    font-size: 15px;

    & svg {
        font-size: 13px;
    }
}

#hearts {
    gap: 4px;

    & svg {
        font-size: 15px;
        transition: opacity .3s, transform .3s;
    }

    & .lost {
        opacity: .2;
        transform: scale(.8);
    }

    & .hit {
        animation: lose .5s;
    }
}

@keyframes lose {
    30% {
        transform: scale(1.5);
    }
}

main {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    touch-action: none;
}

#stage3 {
    position: absolute;
    inset: 0;
    cursor: grab;
}

#setup {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    max-height: 100%;
}

#setup>:not(.lvls) {
    flex-shrink: 0;
}

.opts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;

    & .btn {
        width: 64px;
        height: 52px;
        font-size: 22px;
        gap: 1px;

        & small {
            font-size: 12px;
            align-self: flex-start;
            margin-top: 6px;
        }
    }
}

.lvls {
    display: grid;
    grid-template-columns: repeat(auto-fill, 46px);
    justify-content: center;
    gap: 6px;
    width: min(100%, 520px);
    max-height: 42dvh;
    min-height: 88px;
    overflow-y: auto;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
    touch-action: pan-y;

    & .btn {
        position: relative;
        height: 38px;
        min-width: 0;
        padding: 0;
        font-size: 14px;
        border-color: #666;
    }

    & .btn.done {
        border-color: white;
        background-color: #262626;
    }

    & .btn.perfect::after {
        content: "";
        position: absolute;
        top: 3px;
        right: 3px;
        width: 5px;
        height: 5px;
        background-color: currentColor;
    }

    & .btn.on {
        border-color: white;
        background-color: white;
        color: black;
    }
}

.lvinfo {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 15px;

    &>div {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    & svg {
        font-size: 14px;
    }

    & b {
        font-size: 26px;
    }

    & small {
        font-size: 10px;
        align-self: flex-start;
        margin-left: -5px;
    }
}

.score {
    display: flex;
    gap: 14px;
    font-size: 15px;

    &>div {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    & svg {
        font-size: 13px;
    }
}

#ctl {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px 0 4px;

    & .btn {
        height: 44px;
        min-width: 52px;
        font-size: 16px;
    }

    & .seg {
        display: flex;

        & .btn+.btn {
            border-left: none;
        }
    }
}

.axes {
    display: grid;
    grid-template-columns: repeat(2, 18px);
    gap: 2px 4px;
    align-content: center;
    font-size: 13px;
    line-height: 1;

    & i {
        font-style: normal;
        text-align: center;
        padding-bottom: 2px;
        border-bottom: 3px solid currentColor;
    }

    & i:nth-child(1) {
        color: #ff5a5a;
    }

    & i:nth-child(2) {
        color: #5ad15a;
    }

    & i:nth-child(3) {
        color: #4fa3ff;
    }

    & i:nth-child(4) {
        color: #ffc83d;
    }
}

body.setup :is(.hud, .hr, #stage3, #ctl),
body.play #setup {
    display: none;
}

footer {
    padding: 4px 0;
    text-align: center;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, .35);

    & a {
        color: inherit;
        font-weight: inherit;
    }
}

#loader {
    position: fixed;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    background-color: black;
    transition: opacity .4s;

    &.hidden {
        opacity: 0;
        pointer-events: none;
    }

    & .spin {
        width: 28px;
        height: 28px;
        border: 2px solid white;
        animation: spin 1.2s cubic-bezier(.65, 0, .35, 1) infinite;
    }

    & .acts {
        display: flex;
        gap: 8px;

        & .btn {
            width: 64px;
            height: 52px;
            font-size: 22px;
        }
    }
}

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

#end {
    position: fixed;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: rgba(0, 0, 0, .7);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;

    &.on {
        opacity: 1;
        pointer-events: auto;
    }

    & .card {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 18px;
        padding: 28px 32px;
        border: 1px solid white;
        background-color: black;
        transform: translateY(12px);
        transition: transform .4s;
    }

    &.on .card {
        transform: none;
    }

    & .bigi {
        font-size: 44px;
    }

    & .acts {
        display: flex;
        gap: 8px;

        & .btn {
            width: 64px;
            height: 52px;
            font-size: 22px;
        }
    }
}

#tip {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 60px);
    left: 50%;
    z-index: 9;
    max-width: calc(100vw - 32px);
    padding: 8px 14px;
    border: 1px solid white;
    background-color: black;
    box-shadow: 0 0 24px rgba(255, 255, 255, .15);
    color: white;
    font-size: 14px;
    line-height: 1.3;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -6px);
    transition: opacity .2s, transform .2s;

    &.on {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

[data-tip]:not(button):not(a) {
    cursor: help;
}

.btn[hidden] {
    display: none;
}
