@keyframes scroll {
    from {
        transform: translate3d(calc(var(--lead) * var(--pitch)), 0, 0);
    }

    to {
        transform: translate3d(-100%, 0, 0);
    }
}

:root {
    --led: #ffa32b;
    --led2: #ff4d00;

    --body: #131214;
    --body-hsl: 150 25% 2%;
    --surface: #d6d6c6;
    --grey: color-mix(in srgb, var(--surface) 40%, var(--body));
    --surface1: color-mix(in srgb, var(--surface) 50%, var(--body));
    --pixel: #1a1715;
    --pixel-light: color-mix(in srgb, color-mix(in srgb, var(--led) 40%, transparent) 90%, white 10%);
    --conic: transparent 90deg, var(--pixel-light) 110deg, var(--pixel-light) 250deg, transparent 270deg;

    --pitch: 5rem;
    --screen-w: 73rem;

    --lead: 15;
    --screen-h: 33rem;
    --bezel: 8rem;

    --panel-half: 24.5rem;

    --col-time: 90ms;

    &:has(#hue-cyan:checked) {
        --led: cyan;
        --led2: magenta;
    }

    &:has(#hue-magenta:checked) {
        --led: #ff2d95;
        --led2: #6a00ff;
    }

    &:has(#hue-lime:checked) {
        --led: #7cff3d;
        --led2: #00ffa3;
    }

    &:has(#hue-ice:checked) {
        --led: #eaf6ff;
        --led2: #6fb3ff;
    }

    &:has(#spd-slow:checked) { --col-time: 150ms; }
    &:has(#spd-fast:checked) { --col-time: 45ms; }
}

html,
body {
    font-size: 1vmin;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--body);
}

body {
    &:before,
    &:after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 200;
        pointer-events: none;
    }

    &:before {
        background: linear-gradient(transparent, var(--led));
        mix-blend-mode: overlay;
        opacity: .1;
    }

    &:after {
        background: linear-gradient(90deg, #0005, transparent);
        box-shadow: inset 0 0 3rem var(--body);
    }
}

main {
    display: flex;
    flex-direction: column-reverse;
    height: 100%;

    &:after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(var(--led2), transparent);
        z-index: 200;
        pointer-events: none;
        mix-blend-mode: soft-light;
        opacity: .35;
    }
}

background,
foreground {
    display: block;
    height: 50%;
}

background {
    background: linear-gradient(var(--grey), #0001 70%, #0000000D, #0003), var(--grey);
    z-index: 1;
}

foreground {
    background: linear-gradient(var(--surface1), #fff1), var(--surface1);
}

pixel-grid,
shadow {
    position: absolute;
    inset: 0;
    margin: auto;
    background: var(--body);
    width: var(--screen-w);
    height: var(--screen-h);
    padding: var(--bezel);
    border-radius: 1rem;
    box-sizing: content-box;
}

shadow {
    &:before,
    &:after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        filter: blur(.6rem);
    }

    &:before {
        width: 100%;
        height: 100%;
        background: linear-gradient(-90deg, hsl(var(--body-hsl) / .35), transparent 55%);
        transform: translate3d(-42rem, 0, 0) skewY(8deg);
        transform-origin: 100%;
    }

    &:after {
        width: 100%;
        height: 70%;
        background: linear-gradient(hsl(var(--body-hsl) / .35) 45%, transparent 60%);
        transform: translate3d(-.1rem, 30rem, 0);
        border-radius: 50%;
    }
}

pixel-grid {
    z-index: 200;
    background: radial-gradient(at left bottom, #1e1c1e, var(--body));
    box-shadow: inset 0 0 2rem #000a;
    -webkit-box-reflect: below 0 linear-gradient(transparent, #0001, transparent);

    &:before {
        content: '';
        position: absolute;
        inset: -18rem;
        z-index: -1;
        border-radius: 50%;
        background: radial-gradient(closest-side, color-mix(in srgb, var(--led) 18%, transparent), transparent);
        filter: blur(4rem);
        pointer-events: none;
    }
}

screen {
    display: block;
    position: relative;
    width: var(--screen-w);
    height: var(--screen-h);
    overflow: hidden;
    background-image: radial-gradient(circle at 1.5rem 1.5rem, var(--pixel) 0 1.5rem, transparent 1.55rem);
    background-size: var(--pitch) var(--pitch);
}

strip {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    height: 100%;

    font-size: 0;
    white-space: nowrap;

    filter: blur(.1rem) brightness(1.25)
        drop-shadow(0 0 .6rem color-mix(in srgb, var(--led) 80%, transparent))
        drop-shadow(0 0 1.8rem color-mix(in srgb, var(--led) 35%, transparent));
    animation:
        scroll
        calc((var(--chars) * 6 + var(--lead)) * var(--col-time))
        steps(calc(var(--chars) * 6 + var(--lead)))
        infinite;

    b {
        position: relative;
        display: inline-block;
        vertical-align: top;
        width: calc(6 * var(--pitch));
        height: calc(7 * var(--pitch) - 2rem);

        &:before {
            content: '';
            position: absolute;
            left: calc(var(--pitch) * -1);
            top: 0;
            width: 3rem;
            height: 3rem;
            border-radius: 50%;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        animation-play-state: paused;
    }
}

backlight {
    position: absolute;
    height: 100%;
    width: 100%;
    z-index: 2;

    u {
        width: 100rem;
        height: calc(50% + var(--panel-half));
        position: absolute;
        top: 0;
        left: 50%;
        z-index: 1;
        opacity: .25;

        &:before,
        &:after {
            content: '';
            position: absolute;
            top: 0;
            width: 200%;
            height: 100%;
            background: conic-gradient(from 270deg at 85% 100%, transparent, var(--body));
        }

        &:before {
            left: auto;
            right: 100%;
        }

        &:after {
            left: 0;
            transform: scaleX(-1);
        }
    }
}

surfacelight {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate3d(0, var(--panel-half), 0);
    z-index: 1;

    u {
        height: 100%;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        opacity: .1;

        &:nth-of-type(1) { background: conic-gradient(from 0deg at calc(50% - 36rem) 0, var(--conic)); }
        &:nth-of-type(2) { background: conic-gradient(from 0deg at calc(50% - 27rem) 0, var(--conic)); }
        &:nth-of-type(3) { background: conic-gradient(from 0deg at calc(50% - 18rem) 0, var(--conic)); }
        &:nth-of-type(4) { background: conic-gradient(from 0deg at calc(50% - 9rem) 0, var(--conic)); }
        &:nth-of-type(5) { background: conic-gradient(from 0deg at calc(50%) 0, var(--conic)); }
        &:nth-of-type(6) { background: conic-gradient(from 0deg at calc(50% + 9rem) 0, var(--conic)); }
        &:nth-of-type(7) { background: conic-gradient(from 0deg at calc(50% + 18rem) 0, var(--conic)); }
        &:nth-of-type(8) { background: conic-gradient(from 0deg at calc(50% + 27rem) 0, var(--conic)); }
        &:nth-of-type(9) { background: conic-gradient(from 0deg at calc(50% + 36rem) 0, var(--conic)); }
    }
}

settings {
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 2.5rem;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2.5rem;
    padding: 1.5rem 2.5rem;
    border-radius: 1.5rem;
    background: #0b0b0ccc;
    backdrop-filter: blur(1.2rem);
    border: .1rem solid #ffffff1a;
    box-shadow: 0 1rem 3rem #0006;
    font: 500 1.7rem/1 ui-sans-serif, system-ui, sans-serif;
    color: #e8e8e8;
    white-space: nowrap;

    fieldset {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin: 0;
        padding: 0;
        border: 0;
    }

    legend {
        float: left;
        padding: 0 1rem 0 0;
        color: #8c8c8c;
        font-size: 1.4rem;
        text-transform: uppercase;
        letter-spacing: .1rem;
    }

    label {
        cursor: pointer;
    }

    input {
        position: absolute;
        width: 0;
        height: 0;
        opacity: 0;
        margin: 0;
    }

    :focus-visible + b,
    label:has(:focus-visible) {
        outline: .2rem solid #fff;
        outline-offset: .3rem;
    }

    @media (max-width: 700px) {
        gap: 1.5rem;
        padding: 1.2rem 1.5rem;
        font-size: 1.5rem;
    }
}

.hues {
    b {
        display: block;
        width: 2.2rem;
        height: 2.2rem;
        border-radius: 50%;
        background: var(--sw);
        box-shadow: 0 0 0 .2rem #ffffff1a;
        transition: box-shadow .15s, transform .15s;
    }

    label:hover b {
        transform: scale(1.15);
    }

    input:checked + b {
        box-shadow: 0 0 0 .2rem #fff, 0 0 1.2rem var(--sw);
    }
}

.speeds {
    label {
        padding: .5rem 1rem;
        border-radius: .8rem;
        color: #9a9a9a;
        transition: background .15s, color .15s;

        &:hover {
            color: #e8e8e8;
        }

        &:has(input:checked) {
            background: #ffffff1f;
            color: #fff;
        }
    }
}

.toggle {
    display: flex;
    align-items: center;
    gap: .8rem;
    color: #8c8c8c;
    font-size: 1.5rem;

    &:before {
        content: '';
        width: 1.6rem;
        height: 1.6rem;
        border-radius: .4rem;
        border: .1rem solid #ffffff3d;
    }

    &:has(:checked) {
        color: #e8e8e8;

        &:before {
            background: var(--led);
            border-color: var(--led);
        }
    }

    @media (max-width: 700px) {
        &:last-child {
            display: none;
        }
    }
}

:root:has(#pause:checked) strip {
    animation-play-state: paused;
}

:root:has(#fast:checked) strip {
    filter: none;
}
