:root {
    --led: cyan;
    --led2: magenta;
    --led3: #ff9900;

    --body: #131214;
    --body-hsl: 150 25% 2%;
    --surface: #efefde;
    --grey: color-mix(in srgb, var(--surface) 40%, var(--body));
    --surface1: color-mix(in srgb, var(--surface) 50%, var(--body));
    --pixel: #242625;
    --pixel-light: color-mix(in srgb, color-mix(in srgb, var(--led) 40%, transparent) 90%, white 10%);
    --dark: #0002;
    --stencil: color-mix(in srgb, var(--led) 22%, transparent);

    --decay-pixel: 1.6s linear;
    --decay-room: 3s linear;

    --conic: transparent 90deg, var(--pixel-light) 110deg, var(--pixel-light) 250deg, transparent 270deg;

    --grid-size: 43rem;
    --pitch: 5rem;

    --room: 0;
}

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

:root:has(#hue-amber:checked) {
    --led: #ffa32b;
    --led2: #ff4d00;
    --led3: #fff0a0;
}

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

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

:root:has(input:checked ~ input:checked ~ input:checked) {
    --room: 1;
}

:root:has(input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked) {
    --room: 2;
}

:root:has(input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked ~ input:checked) {
    --room: 3;
}

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

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

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

body:before {
    background: linear-gradient(transparent, var(--led));
    mix-blend-mode: overlay;
    opacity: calc(var(--room) * 0.05);
    transition: opacity var(--decay-room);
}

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

main: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: .5;
}

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);
}

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

shadow:before {
    width: 100%;
    height: 100%;
    background: linear-gradient(-90deg, hsl(var(--body-hsl) / .3), transparent 50%);
    transform: translate3d(calc(var(--grid-size) - 104rem), 0, 0) skewY(10deg);
    transform-origin: 100%;
}

shadow:after {
    width: 100%;
    height: 80%;
    background: linear-gradient(hsl(var(--body-hsl) / .3) 50%, transparent 60%);
    transform: translate3d(-.1rem, 39rem, 0);
    border-radius: 50%;
}

pixel-grid,
shadow {
    position: absolute;
    inset: 0;
    margin: auto;
    background: var(--body);
    width: var(--grid-size);
    aspect-ratio: 1/1;
    display: flex;
    align-items: start;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 10rem;
    border-radius: .5rem;
    box-sizing: content-box;
    flex-shrink: 0;
}

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

form {
    display: contents;
}

pixel-grid > input {
    position: absolute;
    width: 0;
    height: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

pixel-grid > label {
    position: relative;
    z-index: 10;
    display: block;
    width: 3rem;
    aspect-ratio: 1/1;
    border-radius: .25rem;
    background: var(--pixel);
    background-image: linear-gradient(to bottom, transparent 50%, #1e1e1d 50%);
    background-size: 3rem 1.2rem;
    box-shadow: inset -.1rem 0 0 var(--grey), inset .1rem 0 0 transparent, inset 0 0 0 .5rem var(--pixel), -.6rem .1rem .3rem var(--dark);
    filter: blur(.1rem);
    cursor: pointer;
    transition: box-shadow var(--decay-pixel);
}

pixel-grid > label:before,
pixel-grid > label:after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    width: 3rem;
    aspect-ratio: 1/1;
    border-radius: .25rem;
    filter: blur(.5rem);
    transition: opacity var(--decay-pixel), background var(--decay-pixel);
}

pixel-grid > label:after {
    opacity: 0;
}

pixel-grid > label:before {
    background-image: linear-gradient(to bottom, transparent 50%, var(--led3) 50%);
    background-size: 3rem 1.2rem;
    box-shadow: inset 0 0 0 .5rem var(--pixel);
    opacity: 0;
    filter: blur(.2rem);
}

input:checked + label:after {
    background: var(--led);
    opacity: 1;
    filter: blur(.1rem) brightness(1.4);
    box-shadow: 0 0 .5rem var(--led), 0 0 1.5rem var(--led), 0 0 3rem #fff8;
    transition: none;
}

input:checked + label:before {
    opacity: 1;
    transition: none;
}

input:checked:not([c="9"]) + label + input + label {
    box-shadow: inset -.1rem 0 0 var(--grey), inset .1rem 0 0 var(--pixel-light), inset 0 0 0 .5rem var(--pixel), .8rem .1rem .4rem var(--dark);
    transition: none;
}

label:has(+ input:checked:not([c="1"])) {
    box-shadow: inset -.1rem 0 0 var(--pixel-light), inset .1rem 0 0 transparent, inset 0 0 0 .5rem var(--pixel), -.6rem .1rem .3rem var(--dark);
    transition: none;
}

input:checked + label + input + label + input + label + input + label + input + label + input + label + input + label + input + label + input + label + input + label {
    box-shadow: inset -.1rem 0 0 var(--grey), inset 0 .1rem 0 var(--pixel-light), inset 0 0 0 .5rem var(--pixel), -.1rem .8rem .4rem var(--dark);
    transition: none;
}

label:has(+ input + label + input + label + input + label + input + label + input + label + input + label + input + label + input + label + input:checked) {
    box-shadow: inset -.1rem 0 0 var(--grey), inset 0 -.1rem 0 var(--pixel-light), inset 0 0 0 .5rem var(--pixel), -.1rem -.8rem .4rem var(--dark);
    transition: none;
}

@media (hover: hover) {
    input:not(:checked) + label:hover:after {
        background: var(--led);
        opacity: .35;
        filter: blur(.4rem);
        transition: none;
    }
}

pixel-grid > input:focus-visible + label {
    outline: .3rem solid color-mix(in srgb, var(--led) 70%, white);
    outline-offset: .4rem;
}

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

backlight u {
    width: 100rem;
    height: calc(50% + var(--grid-size) - 11.5rem);
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 1;
    opacity: 0;
    transition: opacity var(--decay-room);
}

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

backlight u:before {
    left: auto;
    right: 100%;
}

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

main:has([c="1"]:checked) backlight u:nth-of-type(1),
main:has([c="2"]:checked) backlight u:nth-of-type(2),
main:has([c="3"]:checked) backlight u:nth-of-type(3),
main:has([c="4"]:checked) backlight u:nth-of-type(4),
main:has([c="5"]:checked) backlight u:nth-of-type(5),
main:has([c="6"]:checked) backlight u:nth-of-type(6),
main:has([c="7"]:checked) backlight u:nth-of-type(7),
main:has([c="8"]:checked) backlight u:nth-of-type(8),
main:has([c="9"]:checked) backlight u:nth-of-type(9),
main:has([r="1"]:checked) backlight u:nth-of-type(1),
main:has([r="2"]:checked) backlight u:nth-of-type(2),
main:has([r="3"]:checked) backlight u:nth-of-type(3),
main:has([r="4"]:checked) backlight u:nth-of-type(4),
main:has([r="5"]:checked) backlight u:nth-of-type(5),
main:has([r="6"]:checked) backlight u:nth-of-type(6),
main:has([r="7"]:checked) backlight u:nth-of-type(7),
main:has([r="8"]:checked) backlight u:nth-of-type(8),
main:has([r="9"]:checked) backlight u:nth-of-type(9) {
    opacity: .12;
    transition: none;
}

surfacelight {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate3d(0, calc(var(--grid-size) - 11rem), 0);
    z-index: 1;
}

surfacelight u {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity var(--decay-room);
}

surfacelight u:nth-of-type(1) { background: conic-gradient(from 0deg at calc(50% - 20rem) 0, var(--conic)); }
surfacelight u:nth-of-type(2) { background: conic-gradient(from 0deg at calc(50% - 15rem) 0, var(--conic)); }
surfacelight u:nth-of-type(3) { background: conic-gradient(from 0deg at calc(50% - 10rem) 0, var(--conic)); }
surfacelight u:nth-of-type(4) { background: conic-gradient(from 0deg at calc(50% - 5rem) 0, var(--conic)); }
surfacelight u:nth-of-type(5) { background: conic-gradient(from 0deg at calc(50%) 0, var(--conic)); }
surfacelight u:nth-of-type(6) { background: conic-gradient(from 0deg at calc(50% + 5rem) 0, var(--conic)); }
surfacelight u:nth-of-type(7) { background: conic-gradient(from 0deg at calc(50% + 10rem) 0, var(--conic)); }
surfacelight u:nth-of-type(8) { background: conic-gradient(from 0deg at calc(50% + 15rem) 0, var(--conic)); }
surfacelight u:nth-of-type(9) { background: conic-gradient(from 0deg at calc(50% + 20rem) 0, var(--conic)); }

main:has([c="1"]:checked) surfacelight u:nth-of-type(1),
main:has([c="2"]:checked) surfacelight u:nth-of-type(2),
main:has([c="3"]:checked) surfacelight u:nth-of-type(3),
main:has([c="4"]:checked) surfacelight u:nth-of-type(4),
main:has([c="5"]:checked) surfacelight u:nth-of-type(5),
main:has([c="6"]:checked) surfacelight u:nth-of-type(6),
main:has([c="7"]:checked) surfacelight u:nth-of-type(7),
main:has([c="8"]:checked) surfacelight u:nth-of-type(8),
main:has([c="9"]:checked) surfacelight u:nth-of-type(9) {
    opacity: .12;
    transition: none;
}

stencil {
    position: absolute;
    left: 10rem;
    top: 10rem;
    width: 3rem;
    height: 3rem;
    border-radius: .25rem;
    z-index: 300;
    pointer-events: none;
}

:root:has(#st-heart:checked) stencil {
    box-shadow:
        10rem 5rem 0 0 var(--stencil),
        15rem 5rem 0 0 var(--stencil),
        25rem 5rem 0 0 var(--stencil),
        30rem 5rem 0 0 var(--stencil),
        5rem 10rem 0 0 var(--stencil),
        10rem 10rem 0 0 var(--stencil),
        15rem 10rem 0 0 var(--stencil),
        20rem 10rem 0 0 var(--stencil),
        25rem 10rem 0 0 var(--stencil),
        30rem 10rem 0 0 var(--stencil),
        35rem 10rem 0 0 var(--stencil),
        5rem 15rem 0 0 var(--stencil),
        10rem 15rem 0 0 var(--stencil),
        15rem 15rem 0 0 var(--stencil),
        20rem 15rem 0 0 var(--stencil),
        25rem 15rem 0 0 var(--stencil),
        30rem 15rem 0 0 var(--stencil),
        35rem 15rem 0 0 var(--stencil),
        5rem 20rem 0 0 var(--stencil),
        10rem 20rem 0 0 var(--stencil),
        15rem 20rem 0 0 var(--stencil),
        20rem 20rem 0 0 var(--stencil),
        25rem 20rem 0 0 var(--stencil),
        30rem 20rem 0 0 var(--stencil),
        35rem 20rem 0 0 var(--stencil),
        10rem 25rem 0 0 var(--stencil),
        15rem 25rem 0 0 var(--stencil),
        20rem 25rem 0 0 var(--stencil),
        25rem 25rem 0 0 var(--stencil),
        30rem 25rem 0 0 var(--stencil),
        15rem 30rem 0 0 var(--stencil),
        20rem 30rem 0 0 var(--stencil),
        25rem 30rem 0 0 var(--stencil),
        20rem 35rem 0 0 var(--stencil);
}

:root:has(#st-invader:checked) stencil {
    box-shadow:
        10rem 0rem 0 0 var(--stencil),
        30rem 0rem 0 0 var(--stencil),
        15rem 5rem 0 0 var(--stencil),
        25rem 5rem 0 0 var(--stencil),
        10rem 10rem 0 0 var(--stencil),
        15rem 10rem 0 0 var(--stencil),
        20rem 10rem 0 0 var(--stencil),
        25rem 10rem 0 0 var(--stencil),
        30rem 10rem 0 0 var(--stencil),
        5rem 15rem 0 0 var(--stencil),
        10rem 15rem 0 0 var(--stencil),
        20rem 15rem 0 0 var(--stencil),
        30rem 15rem 0 0 var(--stencil),
        35rem 15rem 0 0 var(--stencil),
        0rem 20rem 0 0 var(--stencil),
        5rem 20rem 0 0 var(--stencil),
        10rem 20rem 0 0 var(--stencil),
        15rem 20rem 0 0 var(--stencil),
        20rem 20rem 0 0 var(--stencil),
        25rem 20rem 0 0 var(--stencil),
        30rem 20rem 0 0 var(--stencil),
        35rem 20rem 0 0 var(--stencil),
        40rem 20rem 0 0 var(--stencil),
        0rem 25rem 0 0 var(--stencil),
        10rem 25rem 0 0 var(--stencil),
        15rem 25rem 0 0 var(--stencil),
        20rem 25rem 0 0 var(--stencil),
        25rem 25rem 0 0 var(--stencil),
        30rem 25rem 0 0 var(--stencil),
        40rem 25rem 0 0 var(--stencil),
        0rem 30rem 0 0 var(--stencil),
        10rem 30rem 0 0 var(--stencil),
        30rem 30rem 0 0 var(--stencil),
        40rem 30rem 0 0 var(--stencil),
        10rem 35rem 0 0 var(--stencil),
        15rem 35rem 0 0 var(--stencil),
        25rem 35rem 0 0 var(--stencil),
        30rem 35rem 0 0 var(--stencil);
}

:root:has(#st-smile:checked) stencil {
    box-shadow:
        10rem 5rem 0 0 var(--stencil),
        30rem 5rem 0 0 var(--stencil),
        10rem 10rem 0 0 var(--stencil),
        30rem 10rem 0 0 var(--stencil),
        5rem 25rem 0 0 var(--stencil),
        35rem 25rem 0 0 var(--stencil),
        10rem 30rem 0 0 var(--stencil),
        15rem 30rem 0 0 var(--stencil),
        20rem 30rem 0 0 var(--stencil),
        25rem 30rem 0 0 var(--stencil),
        30rem 30rem 0 0 var(--stencil);
}

:root:has(#st-skull:checked) stencil {
    box-shadow:
        10rem 0rem 0 0 var(--stencil),
        15rem 0rem 0 0 var(--stencil),
        20rem 0rem 0 0 var(--stencil),
        25rem 0rem 0 0 var(--stencil),
        30rem 0rem 0 0 var(--stencil),
        5rem 5rem 0 0 var(--stencil),
        10rem 5rem 0 0 var(--stencil),
        15rem 5rem 0 0 var(--stencil),
        20rem 5rem 0 0 var(--stencil),
        25rem 5rem 0 0 var(--stencil),
        30rem 5rem 0 0 var(--stencil),
        35rem 5rem 0 0 var(--stencil),
        0rem 10rem 0 0 var(--stencil),
        5rem 10rem 0 0 var(--stencil),
        10rem 10rem 0 0 var(--stencil),
        15rem 10rem 0 0 var(--stencil),
        20rem 10rem 0 0 var(--stencil),
        25rem 10rem 0 0 var(--stencil),
        30rem 10rem 0 0 var(--stencil),
        35rem 10rem 0 0 var(--stencil),
        40rem 10rem 0 0 var(--stencil),
        0rem 15rem 0 0 var(--stencil),
        5rem 15rem 0 0 var(--stencil),
        15rem 15rem 0 0 var(--stencil),
        20rem 15rem 0 0 var(--stencil),
        25rem 15rem 0 0 var(--stencil),
        35rem 15rem 0 0 var(--stencil),
        40rem 15rem 0 0 var(--stencil),
        0rem 20rem 0 0 var(--stencil),
        5rem 20rem 0 0 var(--stencil),
        15rem 20rem 0 0 var(--stencil),
        20rem 20rem 0 0 var(--stencil),
        25rem 20rem 0 0 var(--stencil),
        35rem 20rem 0 0 var(--stencil),
        40rem 20rem 0 0 var(--stencil),
        0rem 25rem 0 0 var(--stencil),
        5rem 25rem 0 0 var(--stencil),
        10rem 25rem 0 0 var(--stencil),
        15rem 25rem 0 0 var(--stencil),
        20rem 25rem 0 0 var(--stencil),
        25rem 25rem 0 0 var(--stencil),
        30rem 25rem 0 0 var(--stencil),
        35rem 25rem 0 0 var(--stencil),
        40rem 25rem 0 0 var(--stencil),
        5rem 30rem 0 0 var(--stencil),
        10rem 30rem 0 0 var(--stencil),
        15rem 30rem 0 0 var(--stencil),
        20rem 30rem 0 0 var(--stencil),
        25rem 30rem 0 0 var(--stencil),
        30rem 30rem 0 0 var(--stencil),
        35rem 30rem 0 0 var(--stencil),
        10rem 35rem 0 0 var(--stencil),
        20rem 35rem 0 0 var(--stencil),
        30rem 35rem 0 0 var(--stencil);
}

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;
}

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

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

settings label {
    cursor: pointer;
}

.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;
}

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

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

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

.stencils label:hover {
    color: #e8e8e8;
}

.stencils input:checked + label,
.stencils label:has(input:checked) {
    background: #ffffff1f;
    color: #fff;
}

settings input[type="radio"],
settings input[type="checkbox"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    margin: 0;
}

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

settings button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    padding: .7rem 1.6rem;
    border-radius: .8rem;
    border: .1rem solid #ffffff26;
    background: #ffffff0f;
    transition: background .15s;
}

settings button:hover {
    background: #ffffff26;
}

.fast {
    display: flex;
    align-items: center;
    gap: .8rem;
    color: #8c8c8c;
    font-size: 1.4rem;
}

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

.fast:has(:checked) {
    color: #e8e8e8;
}

.fast:has(:checked):before {
    background: var(--led);
    border-color: var(--led);
}

:root:has(#fast:checked) main * {
    filter: none !important;
    transition: none !important;
}

:root:has(#fast:checked) {
    --decay-pixel: 0s;
    --decay-room: 0s;
}

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

    .fast {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --decay-pixel: 0s;
        --decay-room: 0s;
    }
}
