/* Translucent CSS layers keep the selected theme color visible underneath. */
:where(.none-texture, .paper-texture, .tartan-texture,
    .boxes-texture, .dotted-texture, .striped-texture, .circles-texture,
    .isometric-texture, .abstract-texture, .watercolor-texture, .rainbow-texture,
    .linen-texture, .woven-texture, .chevron-texture, .diamonds-texture,
    .blueprint-texture, .waves-texture, .aurora-texture,
    .topographic-texture, .starfield-texture, .pastel-watercolor-texture,
    .frosted-glass-texture, .liquid-glass-texture, .theme-glass-texture,
    .nebula-texture, .deep-space-texture, .black-hole-texture, .hologram-texture, .orbital-texture,
    .eclipse-texture, .pulsar-texture, .supernova-texture,
    .synthwave-texture, .cyberpunk-texture, .custom-image-texture) {
    background-color: var(--background-texture-base, #5f8895);
    background-position: 0 0;
    background-size: auto;
    background-repeat: repeat;
}

/* A separate grain and corner-shading layer works with every texture, including blurred uploads.
   Stack above the negative-index artwork/custom image, below the instance panels.
   Bake alpha into the bitmap/gradient, avoiding live filters and group opacity. */
#acas-instance-container {
    position: relative;
    isolation: isolate;
}

#acas-instance-container::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
    background-image:
        var(--background-grain-image, none),
        linear-gradient(to bottom right, rgb(0 0 0 / 2%), rgb(0 0 0 / 15%) 48%, rgb(0 0 0 / 38%));
    background-size: 160px 160px, 100% 100%;
    background-repeat: repeat, no-repeat;
}

.none-texture {
    background-image: none;
}

.chess-texture {
    background-color: #eee;
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.04) 75%, rgba(255, 255, 255, 0.04)),
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.04) 75%, rgba(255, 255, 255, 0.04));
    background-size: 127px 127px;
    background-position: 0 0, 61.2px 61.2px;
}
@media (pointer: coarse) {
    .chess-texture {
        background-color: #f2f2f2;
        background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.08) 75%, rgba(255, 255, 255, 0.08)),
        linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.08) 75%, rgba(255, 255, 255, 0.08));
    }
}

.paper-texture {
    background-image:
        linear-gradient(rgb(0 0 0 / 20%), rgb(0 0 0 / 20%)),
        repeating-linear-gradient(0deg, rgb(255 255 255 / 5%) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(90deg, rgb(0 0 0 / 3%) 0 1px, transparent 1px 6px),
        linear-gradient(120deg, rgb(255 244 216 / 18%), rgb(255 255 255 / 4%));
}

.tartan-texture {
    background-image:
        repeating-linear-gradient(0deg,
            transparent 0 22px, rgb(255 255 255 / 18%) 22px 24px,
            transparent 24px 28px, rgb(0 0 0 / 12%) 28px 30px,
            transparent 30px 48px, rgb(0 0 0 / 16%) 48px 72px, transparent 72px 96px),
        repeating-linear-gradient(90deg,
            transparent 0 22px, rgb(255 255 255 / 18%) 22px 24px,
            transparent 24px 28px, rgb(0 0 0 / 12%) 28px 30px,
            transparent 30px 48px, rgb(0 0 0 / 16%) 48px 72px, transparent 72px 96px),
        repeating-linear-gradient(135deg, rgb(255 255 255 / 4%) 0 1px, transparent 1px 4px);
}

.boxes-texture {
    background-image:
        linear-gradient(rgb(255 255 255 / 15%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(255 255 255 / 15%) 1px, transparent 1px);
    background-size: 48px 48px;
    background-position: -1px -1px;
}

.dotted-texture {
    background-image: radial-gradient(circle, rgb(255 255 255 / 32%) 1.2px, transparent 1.7px);
    background-size: 22px 22px;
}

.striped-texture {
    background-image: repeating-linear-gradient(135deg,
        rgb(255 255 255 / 10%) 0 2px, transparent 2px 14px);
}

.circles-texture {
    background-image: repeating-radial-gradient(circle at center,
        transparent 0 13px, rgb(255 255 255 / 14%) 13px 14px,
        transparent 14px 27px, rgb(0 0 0 / 8%) 27px 28px);
    background-size: 112px 112px;
}

.isometric-texture {
    background-image:
        linear-gradient(30deg, rgb(255 255 255 / 12%) 12%, transparent 12.5% 87%, rgb(255 255 255 / 12%) 87.5%),
        linear-gradient(150deg, rgb(255 255 255 / 12%) 12%, transparent 12.5% 87%, rgb(255 255 255 / 12%) 87.5%),
        linear-gradient(30deg, rgb(255 255 255 / 12%) 12%, transparent 12.5% 87%, rgb(255 255 255 / 12%) 87.5%),
        linear-gradient(150deg, rgb(255 255 255 / 12%) 12%, transparent 12.5% 87%, rgb(255 255 255 / 12%) 87.5%),
        linear-gradient(60deg, rgb(0 0 0 / 10%) 25%, transparent 25.5% 75%, rgb(0 0 0 / 10%) 75.5%),
        linear-gradient(60deg, rgb(0 0 0 / 10%) 25%, transparent 25.5% 75%, rgb(0 0 0 / 10%) 75.5%);
    background-size: 80px 138.564px;
    background-position: 0 0, 0 0, 40px 69.282px, 40px 69.282px, 0 0, 40px 69.282px;
}

.abstract-texture {
    background-image:
        linear-gradient(rgb(0 0 0 / 28%), rgb(0 0 0 / 28%)),
        linear-gradient(145deg, transparent 44%, rgb(255 255 255 / 12%) 44% 62%, transparent 62%),
        linear-gradient(35deg, rgb(0 0 0 / 13%) 28%, transparent 28% 72%, rgb(255 255 255 / 8%) 72%),
        radial-gradient(ellipse at 75% 20%, rgb(196 232 255 / 24%), transparent 65%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.watercolor-texture {
    background-image:
        linear-gradient(
            rgb(20 8 45 / 12%),
            rgb(20 8 45 / 12%)
        ),
        radial-gradient(
            ellipse at 12% 18%,
            rgb(255 45 149 / 85%),
            transparent 48%
        ),
        radial-gradient(
            ellipse at 82% 12%,
            rgb(153 65 255 / 85%),
            transparent 48%
        ),
        radial-gradient(
            ellipse at 90% 65%,
            rgb(0 220 255 / 78%),
            transparent 45%
        ),
        radial-gradient(
            ellipse at 65% 100%,
            rgb(255 112 67 / 85%),
            transparent 48%
        ),
        radial-gradient(
            ellipse at 25% 85%,
            rgb(255 214 51 / 82%),
            transparent 45%
        ),
        radial-gradient(
            ellipse at 45% 40%,
            rgb(255 80 190 / 55%),
            transparent 55%
        ),
        radial-gradient(
            ellipse at 5% 55%,
            rgb(0 255 170 / 65%),
            transparent 42%
        ),
        radial-gradient(
            ellipse at 100% 100%,
            rgb(111 76 255 / 75%),
            transparent 45%
        );

    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* The entire spectrum stays visible, without continuous background repaints. */
.rainbow-texture {
    background-image:
        linear-gradient(rgb(0 0 0 / 28%), rgb(0 0 0 / 28%)),
        linear-gradient(0deg, rgb(0 0 0 / 12%), transparent),
        linear-gradient(125deg, rgb(235 55 85 / 90%), rgb(239 122 35 / 90%),
            rgb(225 190 45 / 90%), rgb(40 201 115 / 90%),
            rgb(48 137 239 / 90%), rgb(169 69 231 / 90%));
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.linen-texture {
    background-image:
        repeating-linear-gradient(0deg, rgb(255 255 255 / 9%) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(90deg, rgb(0 0 0 / 10%) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(0deg, rgb(0 0 0 / 3%) 0 2px, transparent 2px 8px);
}

.woven-texture {
    background-image:
        repeating-linear-gradient(0deg, transparent 0 10px, rgb(0 0 0 / 14%) 10px 12px,
            transparent 12px 22px, rgb(255 255 255 / 12%) 22px 24px),
        repeating-linear-gradient(90deg, transparent 0 10px, rgb(255 255 255 / 12%) 10px 12px,
            transparent 12px 22px, rgb(0 0 0 / 14%) 22px 24px),
        conic-gradient(from 90deg, rgb(255 255 255 / 8%) 25%, transparent 0 50%,
            rgb(255 255 255 / 8%) 0 75%, transparent 0);
    background-size: auto, auto, 24px 24px;
}

.chevron-texture {
    background-image:
        linear-gradient(135deg, rgb(255 255 255 / 11%) 25%, transparent 25%),
        linear-gradient(225deg, rgb(255 255 255 / 11%) 25%, transparent 25%),
        linear-gradient(315deg, rgb(255 255 255 / 11%) 25%, transparent 25%),
        linear-gradient(45deg, rgb(255 255 255 / 11%) 25%, transparent 25%);
    background-size: 48px 48px;
    background-position: -24px 0, -24px 0, 0 0, 0 0;
}

.diamonds-texture {
    background-image:
        repeating-linear-gradient(45deg, transparent 0 27px, rgb(255 255 255 / 15%) 27px 28px, transparent 28px 56px),
        repeating-linear-gradient(135deg, transparent 0 27px, rgb(255 255 255 / 15%) 27px 28px, transparent 28px 56px);
}

.blueprint-texture {
    background-image:
        linear-gradient(rgb(255 255 255 / 20%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(255 255 255 / 20%) 1px, transparent 1px),
        linear-gradient(rgb(255 255 255 / 7%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(255 255 255 / 7%) 1px, transparent 1px),
        linear-gradient(rgb(18 54 99 / 42%), rgb(18 54 99 / 42%));
    background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px, 100% 100%;
    background-position: -1px -1px;
}

.waves-texture {
    background-image:
        radial-gradient(ellipse at 50% 100%, transparent 68%, rgb(255 255 255 / 16%) 69% 71%, transparent 72%),
        radial-gradient(ellipse at 50% 100%, transparent 68%, rgb(0 0 0 / 9%) 69% 71%, transparent 72%);
    background-size: 64px 32px;
    background-position: 0 0, 32px 16px;
}

.aurora-texture {
    background-image:
        /* Midnight atmospheric depth */
        linear-gradient(
            180deg,
            rgb(9 12 38 / 18%) 0%,
            rgb(10 18 48 / 8%) 45%,
            rgb(4 12 32 / 42%) 100%
        ),

        /* Violet aurora bloom */
        radial-gradient(
            ellipse 75% 85% at 12% 0%,
            rgb(166 91 255 / 72%) 0%,
            rgb(135 91 255 / 38%) 32%,
            transparent 72%
        ),

        /* Emerald green northern lights */
        radial-gradient(
            ellipse 65% 100% at 72% -8%,
            rgb(39 255 174 / 64%) 0%,
            rgb(27 230 194 / 35%) 36%,
            transparent 72%
        ),

        /* Electric cyan glow */
        radial-gradient(
            ellipse 55% 85% at 95% 42%,
            rgb(35 203 255 / 58%) 0%,
            rgb(42 145 255 / 28%) 42%,
            transparent 75%
        ),

        /* Flowing magenta aurora ribbon */
        linear-gradient(
            115deg,
            transparent 8%,
            rgb(255 66 197 / 0%) 22%,
            rgb(255 66 197 / 32%) 35%,
            rgb(176 91 255 / 48%) 43%,
            rgb(104 145 255 / 26%) 52%,
            transparent 68%
        ),

        /* Teal and blue light curtain */
        linear-gradient(
            72deg,
            transparent 15%,
            rgb(0 255 213 / 0%) 28%,
            rgb(0 255 213 / 24%) 42%,
            rgb(43 168 255 / 36%) 52%,
            rgb(105 106 255 / 18%) 63%,
            transparent 78%
        ),

        /* Soft luminous central haze */
        radial-gradient(
            ellipse 90% 65% at 48% 38%,
            rgb(90 118 255 / 22%) 0%,
            rgb(74 91 207 / 12%) 45%,
            transparent 75%
        ),

        /* Subtle warm horizon glow */
        radial-gradient(
            ellipse 80% 38% at 50% 105%,
            rgb(92 65 185 / 32%) 0%,
            rgb(40 46 115 / 20%) 45%,
            transparent 78%
        ),

        /* Deep space base */
        linear-gradient(
            145deg,
            rgb(12 16 49 / 100%) 0%,
            rgb(10 31 61 / 100%) 48%,
            rgb(7 14 39 / 100%) 100%
        );

    background-size: 100% 100%;
    background-repeat: no-repeat;
    animation: aurora-breathe 12s ease-in-out infinite alternate;
}

@keyframes aurora-breathe {
    0% {
        background-position: 0% 0%;
        filter: hue-rotate(0deg) brightness(1);
    }

    50% {
        background-position: 2% 3%;
        filter: hue-rotate(12deg) brightness(1.08);
    }

    100% {
        background-position: -2% 1%;
        filter: hue-rotate(-8deg) brightness(1.03);
    }
}

@media (prefers-reduced-motion: reduce) {
    .aurora-texture {
        animation: none;
    }
}

.topographic-texture {
    background-image:
        repeating-radial-gradient(ellipse 150% 180% at -45% -70%,
            transparent 0 46px, rgb(255 255 255 / 17%) 47px 48px, transparent 49px 72px),
        repeating-radial-gradient(ellipse 170% 160% at 150% 180%,
            transparent 0 76px, rgb(0 0 0 / 10%) 77px 78px, transparent 79px 112px);
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* Unequal tile sizes and offsets scatter fine dust, mid-distance stars and
   occasional bright points without a uniform dotted-grid appearance. */
:where(.starfield-texture, .nebula-texture, .deep-space-texture, .orbital-texture,
    .black-hole-texture, .eclipse-texture, .pulsar-texture, .supernova-texture) {
    --space-stars:
        radial-gradient(circle at 13px 27px, rgb(230 238 255 / 38%) 0.45px, transparent 1px),
        radial-gradient(circle at 59px 11px, rgb(255 255 255 / 28%) 0.5px, transparent 1.1px),
        radial-gradient(circle at 37px 73px, rgb(182 210 255 / 48%) 0.6px, transparent 1.2px),
        radial-gradient(circle at 101px 43px, rgb(255 230 209 / 40%) 0.55px, transparent 1.15px),
        radial-gradient(circle at 71px 113px, rgb(255 255 255 / 65%) 0.7px, transparent 1.4px),
        radial-gradient(circle at 149px 61px, rgb(201 223 255 / 58%) 0.8px, transparent 1.5px),
        radial-gradient(circle at 43px 157px, rgb(255 215 237 / 48%) 0.65px, transparent 1.3px),
        radial-gradient(circle at 191px 137px, rgb(255 255 255 / 74%) 0.85px, transparent 1.6px),
        radial-gradient(circle at 127px 211px, rgb(188 216 255 / 62%) 0.9px, transparent 1.7px),
        radial-gradient(circle at 223px 89px, rgb(255 237 214 / 76%) 1px, transparent 1.9px),
        radial-gradient(circle at 79px 233px, rgb(255 255 255 / 90%) 1.1px,
            rgb(168 204 255 / 22%) 1.8px, transparent 4px),
        radial-gradient(circle at 277px 181px, rgb(223 236 255 / 88%) 1.3px,
            rgb(166 192 255 / 18%) 2px, transparent 5px);
    --space-star-sizes: 83px 109px, 127px 89px, 151px 167px, 181px 131px,
        211px 197px, 239px 223px, 269px 251px, 307px 283px,
        353px 317px, 397px 367px, 457px 419px, 541px 487px;
    --space-star-positions: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0,
        0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
}

.starfield-texture {
    background-image:
        var(--space-stars),
        radial-gradient(ellipse at 65% 25%, rgb(148 139 205 / 25%), transparent 65%),
        linear-gradient(125deg, rgb(10 20 42 / 65%), rgb(10 20 42 / 48%));
    background-size: var(--space-star-sizes), 100% 100%, 100% 100%;
}

/* Animate only a few extra points, never the whole scene or its grain layer. */
.starfield-animation {
    display: none;
}

#acas-instance-container.starfield-texture > .starfield-animation {
    display: block;
    position: absolute;
    inset: 0;
    /* Above the grain/vignette (0), still below the instance panels (10). */
    z-index: 1;
    overflow: hidden;
    contain: paint;
    border-radius: inherit;
    pointer-events: none;
}

.starfield-star {
    position: absolute;
    border-radius: 50%;
    box-shadow: 0 0 5px 1px rgb(180 208 255 / 28%);
    opacity: 0.6;
    animation: starfield-twinkle var(--starfield-period) ease-in-out var(--starfield-delay) infinite;
}

.starfield-dipper {
    position: absolute;
    top: calc(var(--acas-header-height, 0px) + 32px);
    left: clamp(18px, 5vw, 80px);
    width: min(260px, 68%);
    aspect-ratio: 13 / 7;
}

@keyframes starfield-twinkle {
    0%, 100% { opacity: 0.18; }
    18% { opacity: 0.45; }
    33% { opacity: 0.22; }
    47% { opacity: 1; }
    58% { opacity: 0.38; }
    76% { opacity: 0.7; }
    89% { opacity: 0.24; }
}

@media (prefers-reduced-motion: reduce) {
    .starfield-star {
        animation: none;
    }
}

.nebula-texture {
    background-image:
        var(--space-stars),
        radial-gradient(ellipse at 48% 46%, rgb(7 9 24 / 70%), transparent 34%),
        radial-gradient(ellipse at 32% 68%, rgb(9 11 30 / 60%), transparent 29%),
        radial-gradient(ellipse at 36% 36%, rgb(245 180 222 / 24%), transparent 19%),
        radial-gradient(ellipse at 26% 44%, rgb(175 75 205 / 64%), transparent 44%),
        radial-gradient(ellipse at 62% 65%, rgb(58 150 206 / 50%), transparent 39%),
        radial-gradient(ellipse at 78% 24%, rgb(89 75 174 / 54%), transparent 47%),
        radial-gradient(ellipse at 12% 82%, rgb(109 50 131 / 48%), transparent 42%),
        linear-gradient(118deg, transparent 24%, rgb(193 111 178 / 15%) 39%,
            rgb(109 158 216 / 18%) 52%, transparent 70%),
        linear-gradient(140deg, #090d1d, #171126 48%, #0c1a2b 78%, #100e20);
    background-size: var(--space-star-sizes),
        100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%,
        100% 100%, 100% 100%, 100% 100%, 100% 100%;
}

.deep-space-texture {
    background-image:
        /* Distinct worlds frame a dark central lane, rather than duplicate icons. */
        url('../images/deep-space-planet.svg'),
        url('../images/deep-space-moon.svg'),
        var(--space-stars),
        radial-gradient(ellipse at 47% 54%, rgb(1 3 10 / 94%) 10%, transparent 65%),
        radial-gradient(ellipse at 91% 16%, rgb(58 106 151 / 36%), transparent 48%),
        radial-gradient(ellipse at 8% 85%, rgb(84 61 119 / 26%), transparent 44%),
        linear-gradient(128deg, transparent 22%, rgb(111 131 165 / 9%) 34%,
            rgb(2 5 14 / 78%) 39%, transparent 45%, rgb(84 111 151 / 8%) 53%, transparent 64%),
        linear-gradient(150deg, #02050c, #091220 56%, #060812);
    background-size: min(60%, 820px) auto, min(15%, 180px) auto, var(--space-star-sizes),
        100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: 110% calc(8% + var(--background-scene-offset, 0px)),
        9% calc(84% + var(--background-scene-offset, 0px)),
        var(--space-star-positions), 0 0, 0 0, 0 0, 0 0, 0 0;
    background-repeat: no-repeat, no-repeat,
        repeat, repeat, repeat, repeat, repeat, repeat,
        repeat, repeat, repeat, repeat, repeat, repeat,
        no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
}

/* The immense silhouette stays black; only the background artwork drifts.
   No transform or filter is applied to boards, text or their popovers. */
.black-hole-texture {
    position: relative;
    isolation: isolate;
    background-image:
        radial-gradient(ellipse at 50% 50%, rgb(0 0 0 / 98%) 12%, rgb(0 0 0 / 75%) 42%, transparent 82%),
        var(--space-stars),
        linear-gradient(#050509, #08070c);
    background-size: 100% 100%, var(--space-star-sizes), 100% 100%;
}

.black-hole-texture::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: url('../images/black-hole.svg') 50% 48% / 112% auto no-repeat;
    background-position: 50% calc(48% + var(--background-scene-offset, 0px));
    animation: black-hole-drift 180s ease-in-out infinite alternate;
}

@keyframes black-hole-drift {
    to {
        background-size: 120% auto;
        background-position: 51% calc(52% + var(--background-scene-offset, 0px));
        opacity: 0.82;
    }
}

@media (prefers-reduced-motion: reduce) {
    .black-hole-texture::before {
        animation: none;
    }
}

.hologram-texture {
    background-image:
        repeating-linear-gradient(0deg, rgb(138 246 244 / 5%) 0 1px, transparent 1px 5px),
        linear-gradient(rgb(110 235 236 / 13%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(110 235 236 / 13%) 1px, transparent 1px),
        radial-gradient(ellipse at 25% 18%, rgb(35 153 172 / 32%), transparent 65%),
        linear-gradient(135deg, #0a1926, #102b35);
    background-size: auto, 64px 64px, 64px 64px, 100% 100%, 100% 100%;
}

/* Full-scene local artwork shares Black Hole's centered, edge-framing scale.
   Static layers avoid repainting detailed SVG filters on every animation frame. */
:is(.orbital-texture, .eclipse-texture, .pulsar-texture, .supernova-texture) {
    background-image:
        var(--celestial-art),
        var(--space-stars),
        radial-gradient(ellipse at 50% 50%, rgb(1 3 9 / 75%) 12%, transparent 76%),
        linear-gradient(135deg, #04070e, #0a1020);
    background-size: 112% auto, var(--space-star-sizes), 100% 100%, 100% 100%;
    background-position: center calc(50% + var(--background-scene-offset, 0px)),
        var(--space-star-positions), 0 0, 0 0;
    background-repeat: no-repeat,
        repeat, repeat, repeat, repeat, repeat, repeat,
        repeat, repeat, repeat, repeat, repeat, repeat,
        no-repeat, no-repeat;
}

.orbital-texture { --celestial-art: url('../images/orbital.svg'); }
.eclipse-texture { --celestial-art: url('../images/eclipse.svg'); }
.pulsar-texture { --celestial-art: url('../images/pulsar.svg'); }
.supernova-texture { --celestial-art: url('../images/supernova.svg'); }

/* Keep the circular composition large enough to frame a narrow viewport. */
@media (max-width: 600px) {
    #acas-instance-container.deep-space-texture {
        background-size: 94% auto, 23% auto, var(--space-star-sizes),
            100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
        background-position: 240% calc(6% + var(--background-scene-offset, 0px)),
            3% calc(88% + var(--background-scene-offset, 0px)),
            var(--space-star-positions), 0 0, 0 0, 0 0, 0 0, 0 0;
    }

    #acas-instance-container:is(.orbital-texture, .eclipse-texture, .pulsar-texture, .supernova-texture) {
        background-size: auto 100%, var(--space-star-sizes), 100% 100%, 100% 100%;
    }
}

.synthwave-texture {
    background-image:
        repeating-linear-gradient(0deg, rgb(12 6 29 / 16%) 0 1px, transparent 1px 5px),
        radial-gradient(circle at 50% 32%, #ffc67e 0%, #f477b1 9%, rgb(244 119 177 / 0%) 9.4%),
        linear-gradient(180deg, #160e2c 0%, rgb(22 14 44 / 90%) 45%, rgb(22 14 44 / 0%) 63%),
        repeating-conic-gradient(from -45deg at 50% 52%, transparent 0deg 8.7deg,
            rgb(222 100 255 / 36%) 8.8deg 9deg, transparent 9.1deg 18deg),
        repeating-linear-gradient(0deg, transparent 0 31px, rgb(230 105 255 / 32%) 31px 32px),
        linear-gradient(180deg, #24113c, #3d154b 58%, #15112f);
    background-size: auto, 100% 100%, 100% 100%, 100% 100%, 100% 46%, 100% 100%;
    background-position: 0 0, 0 0, 0 0, 0 0, center bottom, 0 0;
    background-repeat: no-repeat;
}

.cyberpunk-texture {
    background-image:
        repeating-linear-gradient(0deg, rgb(0 0 0 / 14%) 0 1px, transparent 1px 4px),
        linear-gradient(125deg, transparent 19%, rgb(68 239 246 / 36%) 19.1% 19.3%, transparent 19.5%),
        linear-gradient(125deg, transparent 73%, rgb(255 88 189 / 36%) 73.1% 73.4%, transparent 73.6%),
        linear-gradient(rgb(128 108 199 / 9%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(128 108 199 / 9%) 1px, transparent 1px),
        radial-gradient(ellipse at 0% 80%, rgb(20 184 201 / 32%), transparent 55%),
        radial-gradient(ellipse at 100% 15%, rgb(211 42 145 / 36%), transparent 60%),
        linear-gradient(140deg, #101322, #20132d);
    background-size: auto, 100% 100%, 100% 100%, 48px 48px, 48px 48px,
        100% 100%, 100% 100%, 100% 100%;
}

/* Only the image layer is filtered; boards, text and overlays stay sharp. */
.custom-image-texture {
    background-image: var(--custom-background-image, linear-gradient(135deg, rgb(255 255 255 / 12%), transparent));
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#acas-instance-container.custom-image-texture {
    position: relative;
    isolation: isolate;
    background-image: none;
}

.custom-background-layer {
    display: none;
}

/* Clip the oversized blur inside a background-only wrapper, not the boards or
   their menus. clip-path on the filtered layer alone still allows scroll overflow. */
#acas-instance-container.custom-image-texture > .custom-background-layer {
    display: block;
    position: absolute;
    inset: 0;
    overflow: hidden;
    overflow: clip;
    contain: paint;
    border-radius: inherit;
    z-index: -1;
    pointer-events: none;
}

.custom-background-layer::before {
    --custom-background-bleed: calc(var(--custom-background-blur, 0px) * 3);
    content: "";
    position: absolute;
    inset: calc(0px - var(--custom-background-bleed));
    /* Extra cover height shifts the image center below the header while the
       wrapper clips the overscan, leaving no blank strip or page overflow. */
    bottom: calc(0px - var(--custom-background-bleed) - var(--acas-header-height, 0px));
    background-image: var(--custom-background-image, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(var(--custom-background-blur, 0px));
}

.custom-background-layer::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / var(--custom-background-dim, 0));
}

.background-texture-preview > .custom-image-texture {
    filter: blur(var(--custom-background-blur, 0px)) brightness(calc(1 - var(--custom-background-dim, 0)));
}

.background-texture-setting > .floaty-wrapper {
    flex-shrink: 0;
}

#custom-background-floaty {
    box-sizing: border-box;
    width: min(520px, calc(100vw - 32px));
    max-width: calc(100vw - 24px);
}

/* Keep the background visible at its real sharpness while adjusting blur. */
#custom-background-floaty::backdrop {
    background: rgb(0 0 0 / 15%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

#custom-background-floaty .title {
    min-width: 0;
}

#custom-background-floaty .custom-background-controls {
    gap: 14px;
    padding: 16px;
}

#custom-background-floaty .book-upload-row {
    width: 100%;
}

#custom-background-status {
    overflow-wrap: anywhere;
}

#custom-background-status:empty {
    display: none;
}

.custom-background-controls > .file-input {
    justify-content: flex-start;
}

/* Full-surface washes: soft transitions, no tiled seams or content filters. */
.pastel-watercolor-texture,
.frosted-glass-texture,
.liquid-glass-texture,
.theme-glass-texture {
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.pastel-watercolor-texture {
    background-image:
        /* Soft shadow for depth, without muddying the colors */
        linear-gradient(
            135deg,
            rgb(48 35 70 / 12%) 0%,
            rgb(48 35 70 / 4%) 45%,
            rgb(35 45 75 / 14%) 100%
        ),

        /* Rosy pink pigment bloom */
        radial-gradient(
            ellipse 75% 68% at 12% 16%,
            rgb(255 153 194 / 78%) 0%,
            rgb(255 183 207 / 52%) 30%,
            rgb(255 205 219 / 24%) 55%,
            transparent 78%
        ),

        /* Dreamy lavender wash */
        radial-gradient(
            ellipse 72% 78% at 88% 12%,
            rgb(174 151 255 / 76%) 0%,
            rgb(202 181 255 / 46%) 34%,
            rgb(222 204 255 / 20%) 58%,
            transparent 78%
        ),

        /* Peach and apricot watercolor */
        radial-gradient(
            ellipse 82% 72% at 76% 94%,
            rgb(255 174 119 / 72%) 0%,
            rgb(255 204 157 / 44%) 34%,
            rgb(255 225 191 / 20%) 58%,
            transparent 80%
        ),

        /* Fresh mint pigment */
        radial-gradient(
            ellipse 76% 76% at 7% 88%,
            rgb(104 231 196 / 68%) 0%,
            rgb(155 240 214 / 42%) 34%,
            rgb(192 246 226 / 18%) 58%,
            transparent 78%
        ),

        /* Powder blue bleeding through the center */
        radial-gradient(
            ellipse 65% 62% at 48% 42%,
            rgb(148 208 255 / 42%) 0%,
            rgb(186 225 255 / 24%) 38%,
            transparent 74%
        ),

        /* Butter-yellow glow */
        radial-gradient(
            ellipse 55% 48% at 48% 100%,
            rgb(255 231 143 / 48%) 0%,
            rgb(255 239 184 / 22%) 45%,
            transparent 76%
        ),

        /* Subtle lilac and rose pigment overlap */
        radial-gradient(
            ellipse 58% 52% at 100% 58%,
            rgb(255 163 221 / 36%) 0%,
            rgb(222 183 255 / 24%) 42%,
            transparent 76%
        ),

        /* Warm paper-like base */
        linear-gradient(
            135deg,
            rgb(255 244 246 / 35%) 0%,
            rgb(248 240 255 / 28%) 50%,
            rgb(239 250 255 / 32%) 100%
        );

    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.frosted-glass-texture {
    background-image:
        linear-gradient(rgb(0 0 0 / 48%), rgb(0 0 0 / 48%)),
        linear-gradient(125deg, rgb(255 255 255 / 24%) 0%,
            rgb(255 255 255 / 6%) 38%, rgb(255 255 255 / 16%) 100%),
        radial-gradient(ellipse at 28% -15%, rgb(248 251 255 / 56%) 0%,
            rgb(248 251 255 / 12%) 40%, rgb(248 251 255 / 0%) 72%),
        radial-gradient(ellipse at 95% 28%, rgb(205 196 244 / 58%) 0%,
            rgb(205 196 244 / 18%) 35%, rgb(205 196 244 / 0%) 70%),
        radial-gradient(ellipse at 8% 95%, rgb(175 222 232 / 58%) 0%,
            rgb(175 222 232 / 16%) 38%, rgb(175 222 232 / 0%) 74%),
        radial-gradient(ellipse at 78% 110%, rgb(239 209 224 / 42%) 0%,
            rgb(239 209 224 / 0%) 64%),
        linear-gradient(160deg, rgb(218 230 243 / 16%), rgb(96 120 152 / 18%));
}

/* Curved light rims suggest liquid glass using only background gradients. */
.liquid-glass-texture {
    background-image:
        /* Subtle depth overlay */
        linear-gradient(
            135deg,
            rgb(12 8 35 / 24%) 0%,
            rgb(22 12 55 / 10%) 45%,
            rgb(8 22 48 / 26%) 100%
        ),

        /* Main iridescent glass rim - bottom right */
        radial-gradient(
            ellipse 85% 125% at 100% 112%,
            transparent 43%,
            rgb(255 255 255 / 8%) 46%,
            rgb(255 255 255 / 72%) 48%,
            rgb(178 235 255 / 48%) 49%,
            rgb(255 155 232 / 32%) 50%,
            rgb(255 255 255 / 14%) 51%,
            transparent 55%
        ),

        /* Upper-left curved glass reflection */
        radial-gradient(
            ellipse 105% 145% at -12% -32%,
            transparent 42%,
            rgb(255 255 255 / 8%) 46%,
            rgb(255 255 255 / 48%) 48%,
            rgb(195 177 255 / 28%) 49%,
            rgb(255 255 255 / 12%) 50%,
            transparent 54%
        ),

        /* Prismatic light refraction */
        linear-gradient(
            118deg,
            rgb(255 255 255 / 28%) 0%,
            rgb(255 120 218 / 10%) 16%,
            transparent 32%,
            rgb(110 220 255 / 12%) 48%,
            rgb(255 255 255 / 20%) 54%,
            transparent 62%,
            rgb(180 130 255 / 12%) 78%,
            rgb(255 255 255 / 16%) 88%,
            transparent 100%
        ),

        /* Electric blue glow */
        radial-gradient(
            ellipse at 12% 18%,
            rgb(64 155 255 / 68%) 0%,
            rgb(85 120 255 / 32%) 30%,
            transparent 66%
        ),

        /* Vibrant violet and pink iridescence */
        radial-gradient(
            ellipse at 91% 10%,
            rgb(226 105 255 / 62%) 0%,
            rgb(255 105 190 / 28%) 34%,
            transparent 65%
        ),

        /* Liquid turquoise glow */
        radial-gradient(
            ellipse at 72% 105%,
            rgb(55 255 218 / 52%) 0%,
            rgb(55 185 255 / 24%) 38%,
            transparent 68%
        ),

        /* Warm pearlescent light */
        radial-gradient(
            ellipse at 42% 48%,
            rgb(255 191 225 / 18%) 0%,
            rgb(177 155 255 / 12%) 32%,
            transparent 62%
        ),

        /* Deep, colorful glass base */
        linear-gradient(
            145deg,
            rgb(44 35 92 / 68%) 0%,
            rgb(35 55 105 / 58%) 38%,
            rgb(24 39 78 / 72%) 72%,
            rgb(34 25 76 / 68%) 100%
        );

    background-size: 100% 100%;
    background-repeat: no-repeat;

    /* Optional glass polish */
    background-blend-mode: normal;
}

/* Neutral light layers pastelize the actual theme hue, without a fixed palette. */
.theme-glass-texture {
    background-image:
        linear-gradient(rgb(0 0 0 / 46%), rgb(0 0 0 / 46%)),
        radial-gradient(ellipse 78% 135% at 100% 115%,
            rgb(255 255 255 / 5%) 0%, rgb(255 255 255 / 2%) 43%,
            rgb(255 255 255 / 10%) 47%, rgb(255 255 255 / 38%) 49%,
            rgb(255 255 255 / 12%) 50.5%, rgb(255 255 255 / 0%) 55%),
        radial-gradient(ellipse 95% 150% at -12% -35%,
            rgb(255 255 255 / 12%) 0%, rgb(255 255 255 / 3%) 43%,
            rgb(255 255 255 / 24%) 48%, rgb(255 255 255 / 5%) 50%,
            rgb(255 255 255 / 0%) 55%),
        radial-gradient(ellipse at 18% 12%, rgb(255 255 255 / 42%) 0%,
            rgb(255 255 255 / 16%) 32%, rgb(255 255 255 / 0%) 72%),
        radial-gradient(ellipse at 82% 88%, rgb(255 255 255 / 28%) 0%,
            rgb(255 255 255 / 8%) 36%, rgb(255 255 255 / 0%) 70%),
        radial-gradient(ellipse at 92% 25%, rgb(0 0 0 / 8%) 0%,
            rgb(0 0 0 / 0%) 65%),
        linear-gradient(125deg, rgb(255 255 255 / 22%) 0%,
            rgb(255 255 255 / 10%) 45%, rgb(255 255 255 / 24%) 100%);
}

/* Swatches use the same classes and theme color as the real background. */
.background-texture-picker .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.background-texture-preview {
    display: block;
    flex: 0 0 70px;
    height: 50px;
    overflow: hidden;
    border-radius: 5px 0 0 0;
    box-sizing: border-box;
    pointer-events: none;
    border-right: 2px solid rgba(255, 255, 255, 0.2);
}

.background-texture-preview > span {
    display: block;
    width: 144px;
    height: 96px;
    transform: scale(0.5);
    transform-origin: top left;
}

/* The real Chess surface gets an inline theme fill; its swatch needs it too. */
.background-texture-preview > .chess-texture {
    background-color: var(--background-texture-base, #5f8895);
}
