* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Space Mono', monospace;
    background-color: #0c0a1a;
    height: 100vh;
    /* Use full viewport height */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
    /* Prevent any scrollbars */
    position: relative;
    margin: 0;
    padding: 0;
}

:root {
    --lock-ripple-border-color: rgba(100, 200, 255, 0.8);
    --lock-ripple-shadow-color: rgba(100, 200, 255, 0.6);
    --sb-logo-loading-width: min(380px, 68vw, 72svh);
    --sb-logo-title-width: min(520px, 70vw, 80svh);
    --sb-logo-menu-width: min(180px, 50vw, 52svh);
    --sb-logo-pulse-duration: 2.8s;
    /* The loading language (First Light): every surface that covers the game while it prepares
       (the boot's loading screen, each mode's loading cover, the countdowns, Odyssey's covers)
       is the opening world's first frame: a near-black void, abyssal light rising from below, a
       faint violet nebula, a cool halo. One set of values, so the surfaces cannot drift apart. */
    --sb-void-sky:
        radial-gradient(130% 62% at 50% 118%, #093542 0%, #051f29 34%, transparent 72%),
        radial-gradient(70% 42% at 50% 46%, #120c2b80 0%, transparent 70%),
        linear-gradient(180deg, #03040a 0%, #04060f 38%, #070a17 66%, #0a0f22 100%);
    --sb-void-light:
        radial-gradient(44% 46% at 24% 66%, #2a1e6e5c, transparent 74%),
        radial-gradient(50% 50% at 52% 72%, #007a8c54, transparent 76%),
        radial-gradient(40% 44% at 80% 67%, #007a7842, transparent 74%),
        radial-gradient(76% 34% at 50% 86%, #09354240, transparent 80%);
    --sb-void-halo: radial-gradient(closest-side, #d1e6ff26 0%, #8a6bff22 26%, #4ad8ff10 54%, transparent 100%);
    --sb-void-vignette: radial-gradient(ellipse at 50% 44%, transparent 42%, #03040a8c 100%);
}

/* The loading screen: the opening world's first frame, painted in CSS. Every motion here is
   transform or opacity, so it keeps moving on the compositor while the boot compiles shaders
   behind it (ADR-0020). It breathes with the world: in for 4 s, out for 6 s
   (--sb-breath: one breath; 40 % of it is the inhale). */
.startup-shell {
    --sb-breath: 10s;
    --sb-breath-delay: 1.2s;
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: grid;
    place-items: center;
    overflow: hidden;
    isolation: isolate;
    color: #d7e6ee;
    opacity: 1;
    transition: opacity 560ms ease-in-out;
}
/* The sky of the world's first frame: a near-black void, abyssal teal toward the light below. */
.startup-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--sb-void-sky);
}
/* ---- The loading language's parts, shared by the boot's loading screen (index.html) and
   every mode's loading cover (cinematic-loading-overlay.js). A host sets --sb-breath (one
   breath, 40 % of it the inhale) and --sb-breath-delay. Motion is transform/opacity only,
   so it keeps moving on the compositor while shaders compile behind it (ADR-0020). ---- */
/* The light rising from below: deep violet, abyssal teal and sea-green, glowing in the dark. */
.sb-void-light {
    position: absolute;
    left: -12%;
    right: -12%;
    bottom: -14%;
    height: 64%;
    pointer-events: none;
    background: var(--sb-void-light);
    transform-origin: 50% 100%;
    animation: sb-breath-haze var(--sb-breath) ease-in-out var(--sb-breath-delay) infinite both;
    will-change: transform, opacity;
}
/* Points of light rising through it, two depths (the world's motes). */
.sb-void-motes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.sb-void-motes i {
    position: absolute;
    left: -5%;
    width: 110%;
    top: 0;
    height: 200vh;
    background-image:
        radial-gradient(1.3px 1.3px at 37px 61px, #fff6e9e6 70%, transparent),
        radial-gradient(1px 1px at 141px 19vh, #c9bcffd9 70%, transparent),
        radial-gradient(1.6px 1.6px at 227px 11vh, #bdf2f4cc 70%, transparent);
    /* Tiles a quarter of the screen tall: the rise loops seamlessly after one screen. */
    background-size: 263px 25vh;
    opacity: 0.55;
    animation: sb-motes-rise 70s linear infinite;
    will-change: transform;
}
.sb-void-motes i + i {
    background-image:
        radial-gradient(2px 2px at 91px 7vh, #fff6e9b3 65%, transparent),
        radial-gradient(1.4px 1.4px at 301px 16vh, #b8a4ffb3 70%, transparent);
    background-size: 389px 33.3333vh;
    opacity: 0.42;
    animation-duration: 44s;
}
.sb-starfield {
    position: absolute;
    inset: -8%;
    pointer-events: none;
    animation: sb-star-drift 36s linear infinite alternate;
    will-change: transform;
}
/* Separate star groups breathe at different rates. Only opacity changes, so
   the twinkle keeps running on the compositor during CPU-heavy loading. */
.sb-starfield::before,
.sb-starfield::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.55;
    animation: sb-star-twinkle 4.8s ease-in-out -1.6s infinite;
    animation-play-state: inherit;
    will-change: opacity;
}
/* Each star tiles at its own coprime period, so no row or column of them lines up. */
.sb-starfield::before {
    background-image:
        radial-gradient(1px 1px at 23px 31px, #e2f6ff 90%, transparent),
        radial-gradient(1px 1px at 113px 97px, #93b8c7 90%, transparent),
        radial-gradient(1.5px 1.5px at 227px 167px, #b5dace 70%, transparent),
        radial-gradient(1px 1px at 71px 211px, #d9e4ff 90%, transparent),
        radial-gradient(1.2px 1.2px at 331px 59px, #fff3e0cc 80%, transparent),
        radial-gradient(1px 1px at 157px 283px, #b9c9f2 90%, transparent);
    background-size: 197px 193px, 257px 239px, 467px 397px, 353px 311px, 599px 521px, 431px 449px;
}
.sb-starfield::after {
    --sb-star-min: 0.18;
    --sb-star-max: 0.7;
    background-image:
        radial-gradient(1px 1px at 53px 159px, #cfc0ef 90%, transparent),
        radial-gradient(1.5px 1.5px at 179px 67px, #c9eeff 75%, transparent),
        radial-gradient(1px 1px at 311px 241px, #b7dbe5 90%, transparent),
        radial-gradient(1px 1px at 97px 373px, #e8e0ff 90%, transparent),
        radial-gradient(1.3px 1.3px at 419px 131px, #d4f4f2 80%, transparent);
    background-size: 307px 283px, 389px 347px, 509px 431px, 461px 409px, 683px 557px;
    animation-duration: 6.7s;
    animation-delay: -4.3s;
}
.sb-void-stars {
    opacity: 0.8;
    /* Stars thin out toward the light below, as the world's do. */
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 52%, transparent 92%);
    mask-image: linear-gradient(180deg, #000 0%, #000 52%, transparent 92%);
}
.sb-void-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: var(--sb-void-vignette);
}
/* The halo behind the name: the world's first light, breathing. Its host places it. */
.sb-void-halo {
    position: absolute;
    background: var(--sb-void-halo);
    animation: sb-breath-halo var(--sb-breath) ease-in-out var(--sb-breath-delay) infinite both;
    pointer-events: none;
    will-change: transform, opacity;
}
/* A guide to breathe by while the space is prepared: the words cross on the breath. */
.sb-breath-guide {
    display: grid;
    place-items: center;
    font-size: 9px;
    line-height: 1;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: #cfe0ee;
    white-space: nowrap;
}
.sb-breath-guide__word {
    grid-area: 1 / 1;
    padding-left: 0.34em;
    opacity: 0;
    animation: sb-breath-in var(--sb-breath) ease-in-out var(--sb-breath-delay) infinite both;
}
.sb-breath-guide__word--out { animation-name: sb-breath-out; }
.sb-breath-guide__word--still { display: none; animation: none; opacity: 0.7; }
/* Progress: a hairline that follows real milestones (--sb-progress, 0..1) and never runs back. */
.sb-progress-line {
    position: relative;
    width: min(168px, 42vw);
    height: 1px;
    overflow: hidden;
    border-radius: 1px;
    background: #c8d6e61f;
}
.sb-progress-line__fill {
    position: absolute;
    inset: 0;
    transform-origin: 0 50%;
    transform: scaleX(var(--sb-progress, 0.05));
    transition: transform 1.4s cubic-bezier(0.22, 0.8, 0.24, 1);
    background: linear-gradient(90deg, #b8a4ff, #9ee8ed 55%, #c5f1cf);
    will-change: transform;
}
/* Light keeps running along the line between milestones, so a long warm never looks stuck. */
.sb-progress-line::after {
    content: '';
    position: absolute;
    inset: 0;
    width: 34%;
    background: linear-gradient(90deg, transparent, #fff6e9cc, transparent);
    transform: translateX(-110%);
    animation: sb-progress-glint 2.6s cubic-bezier(0.45, 0, 0.3, 1) 1.4s infinite;
    will-change: transform;
}
.startup-logo {
    position: relative;
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 32px;
    transform: translateY(var(--sb-logo-y, -8px));
    animation: sb-logo-arrive 1.6s ease-out both;
}
/* The halo behind the logo (.sb-void-halo). */
.startup-logo__glow { inset: -34vh -26vw; }
.startup-logo__name {
    position: relative;
    width: var(--sb-logo-loading-width);
    line-height: 0;
}
.startup-logo__tile {
    transform-box: fill-box;
    transform-origin: center;
    animation: sb-block-settle 1.35s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}
.startup-logo__name-text {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    transform-origin: center;
    animation: sb-wordmark-pulse var(--sb-logo-pulse-duration) ease-in-out infinite;
}
.startup-logo__tagline {
    color: #c8d6e6;
    font-size: clamp(8px, 1vw, 10px);
    letter-spacing: 0.24em;
    word-spacing: 0.12em;
    padding-left: 0.24em;
    text-transform: uppercase;
    white-space: nowrap;
}
.startup-logo__image {
    display: block;
    max-width: min(70vw, 400px);
    max-height: 180px;
    object-fit: contain;
}
.startup-logo__image[hidden] { display: none; }
.startup-shell.has-image-logo .startup-logo__name { width: min(280px, 64vw); }
.startup-loading {
    position: absolute;
    bottom: max(9%, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 18px;
}
/* The breath guide (.sb-breath-guide) and the boot's progress (.sb-progress-line), which follows
   the boot's real milestones (src/ui/startup-progress.js). */
.startup-shell.is-ready .startup-breath { opacity: 0; transition: opacity 400ms ease-out; }
/* A failure before the game is up (index.html __serenityStartupShell.fail). */
.startup-shell--failed .startup-loading { display: none; }
.startup-failure {
    position: absolute;
    bottom: max(9%, env(safe-area-inset-bottom));
    width: min(560px, calc(100vw - 48px));
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 14px;
    text-align: center;
}
.startup-failure[hidden] { display: none; }
.startup-failure__title {
    margin: 0;
    color: #e3eef6;
    font-size: 13px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.startup-failure__detail {
    margin: 0;
    max-height: 7.5em;
    overflow: auto;
    color: #9fb4c8;
    font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    user-select: text;
}
.startup-failure__detail:empty { display: none; }
.startup-failure__button {
    padding: 9px 26px;
    border: 1px solid #9adae066;
    border-radius: 999px;
    background: #0b1a33cc;
    color: #e6f4ff;
    font: inherit;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
}
.startup-failure__button:hover,
.startup-failure__button:focus-visible {
    border-color: #9adae0;
    background: #13284acc;
    outline: none;
}
/* A synchronous compile would freeze moving loops mid-frame (startup-ident-hold.js): hold still.
   Never through the exit: that motion is the handoff itself (the wordmark travelling into the
   title, the cover dissolving). Held there, a phone without WebGPU (always the static hold) kept
   its wordmark in place beside the arriving title until the cover was removed. */
.startup-shell:is(.sb-lit--static, .sb-lit--paused):not(.is-warp-out) :is(
    .startup-shell__haze, .startup-shell__motes i, .startup-shell__stars,
    .startup-logo__glow, .startup-logo__name-text, .startup-logo__tile,
    .startup-breath__word, .startup-progress::after
) { animation-play-state: paused !important; }
.startup-shell.sb-lit--static .startup-logo__tile { animation: none; }
.startup-shell.sb-lit--static :is(.startup-breath__word--in, .startup-breath__word--out) { display: none; }
.startup-shell.sb-lit--static .startup-breath__word--still { display: block; }
.startup-shell.sb-warp-arming .startup-logo__glow,
.startup-shell.sb-warp-arming .startup-logo__name-text,
.startup-shell.sb-warp-arming .startup-logo { animation: none; }
.startup-shell.sb-warp-arming .startup-logo__glow { opacity: 0.87; transform: scale(1.04); }
.startup-shell.is-warp-out { pointer-events: none; }
.startup-shell.is-warp-out::before,
.startup-shell.is-warp-out > :not(.startup-logo),
.startup-shell.is-warp-out .startup-logo__glow,
.startup-shell.is-warp-out .startup-logo__image {
    animation: sb-background-open var(--sb-opening-duration, 3200ms) ease-in-out both;
}
.startup-shell.is-warp-out .startup-loading,
.startup-shell.is-warp-out .startup-logo__tagline {
    /* Clear the supporting copy before the growing wordmark reaches its line. */
    animation: sb-tagline-release 240ms ease-out both;
}
.startup-shell.is-warp-out .startup-logo__name-text {
    transform-origin: center;
    animation: sb-wordmark-connect var(--sb-opening-duration, 3200ms) cubic-bezier(0.22, 1, 0.36, 1) both;
}
.startup-shell.is-hidden { opacity: 0; pointer-events: none; transition-duration: 1.2s; }
.startup-shell.is-hidden .startup-logo { animation: sb-logo-depart 1.2s ease-in-out both; }
@keyframes sb-breath-haze {
    0%, 100% { opacity: 0.6; transform: translate3d(0, 2%, 0) scale(1); }
    40% { opacity: 1; transform: translate3d(0, 0, 0) scale(1.05); }
}
@keyframes sb-breath-halo {
    0%, 100% { opacity: 0.5; transform: scale(0.9); }
    40% { opacity: 1; transform: scale(1.06); }
}
@keyframes sb-breath-in {
    0% { opacity: 0; transform: translateY(3px); }
    7%, 33% { opacity: 0.74; transform: translateY(0); }
    40%, 100% { opacity: 0; transform: translateY(-3px); }
}
@keyframes sb-breath-out {
    0%, 40% { opacity: 0; transform: translateY(3px); }
    47%, 91% { opacity: 0.74; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-3px); }
}
@keyframes sb-motes-rise { to { transform: translate3d(0, -100vh, 0); } }
/* Shared with the mode-loading overlay (public/styles/cinematic-loading.css). */
@keyframes sb-aurora-drift {
    from { transform: translate3d(-1.5%, 0, 0) rotate(-2deg) scale(1); opacity: 0.8; }
    to { transform: translate3d(2%, 3%, 0) rotate(1deg) scale(1.05); opacity: 1; }
}
@keyframes sb-nebula-breathe { to { opacity: 0.65; transform: translate3d(2%, -2%, 0) scale(1.08); } }
@keyframes sb-logo-breathe {
    0%, 100% { opacity: 0.95; transform: scale(1.06); }
    50% { opacity: 0.6; transform: scale(0.95); }
}
@keyframes sb-progress-glint {
    0% { transform: translateX(-110%); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateX(310%); opacity: 0; }
}
@keyframes sb-block-settle {
    from { opacity: 0; transform: translateY(-32px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes sb-star-drift { to { transform: translate3d(18px, -12px, 0); } }
@keyframes sb-star-twinkle {
    0%, 100% { opacity: var(--sb-star-min, 0.28); }
    50% { opacity: var(--sb-star-max, 0.95); }
}
@media (prefers-reduced-motion: reduce) {
    .sb-starfield, .sb-starfield::before, .sb-starfield::after { animation: none !important; }
}
@keyframes sb-logo-arrive {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(var(--sb-logo-y, -8px)); }
}
@keyframes sb-wordmark-pulse {
    /* Start at the handoff's exact resting pose and stay within the logo's bounds. */
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.88; transform: scale(0.976); }
}
@keyframes sb-logo-depart { to { opacity: 0; transform: translateY(-20px) scale(1.025); } }
@keyframes sb-background-open {
    0% { opacity: 1; }
    75%, 100% { opacity: 0; }
}
@keyframes sb-tagline-release { to { opacity: 0; } }
@keyframes sb-wordmark-connect {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    84% { opacity: 1; transform: translate(var(--sb-title-x, 0px), var(--sb-title-y, 0px)) scale(var(--sb-title-scale-x, 1), var(--sb-title-scale-y, 1)); }
    94%, 100% { opacity: 0; transform: translate(var(--sb-title-x, 0px), var(--sb-title-y, 0px)) scale(var(--sb-title-scale-x, 1), var(--sb-title-scale-y, 1)); }
}
@media (max-width: 480px) {
    .startup-logo { gap: 26px; }
    .startup-logo__tagline { font-size: 9px; }
    .startup-logo__glow { inset: -30vh -40vw; }
}
@media (max-height: 480px) {
    .startup-logo { gap: 12px; --sb-logo-y: -16px; }
    .startup-loading { bottom: 6%; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .startup-shell *, .startup-shell *::before, .startup-shell *::after { animation: none !important; }
    .startup-shell.is-hidden, .startup-shell.is-warp-out { transition-duration: 250ms; }
    .startup-shell :is(.startup-breath__word--in, .startup-breath__word--out) { display: none; }
    .startup-shell .startup-breath__word--still { display: block; }
    /* The loading language holds still: no rising, breathing or running light; the still word. */
    .sb-void-light, .sb-void-motes i, .sb-void-halo, .sb-breath-guide__word,
    .sb-progress-line::after { animation: none !important; }
    :is(.sb-breath-guide__word--in, .sb-breath-guide__word--out) { display: none; }
    .sb-breath-guide__word--still { display: block; }
    .sb-progress-line__fill { transition-duration: 300ms; }
}

/* --- Background Container --- */
.background-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

#background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    /* Above theme containers to show particles */
    pointer-events: none;
}

body.serenity-hub-open #background-canvas,
body.serenity-hub-open .phaser-board-container,
body.serenity-hub-open .theme-container.active {
    pointer-events: none;
}

.theme-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 2.5s ease-in-out, visibility 0s linear 2.5s;
    /* Fade out, then hide */
    z-index: 1;
    /* Ensure theme container is above background but below particles */
}

.theme-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    /* Position it with other particles */
    pointer-events: none;
    /* Make sure it doesn't block interactions */
}

.theme-container.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 2.5s ease-in-out;
    /* Fade in */
}

/* The same for inactive theme containers: the DOM layers left in index.html by the CSS-era themes
   (golden-forest's parallax and god rays, the synthwave and chromadelic layers) animate forever behind whichever theme is playing. Paused until active. */
.theme-container:not(.active) * {
    animation-play-state: paused !important;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 5s infinite ease-in-out;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Forest Theme --- */
/* The forest itself is drawn on a canvas ForestTheme adds here. This night-blue ground is
   what shows while that canvas is being made. */
#forest-theme {
    background: radial-gradient(ellipse at 50% 120%,
            #142238 0%,
            #0b1424 30%,
            #060b16 60%,
            #02040a 100%);
    overflow: hidden;
}

.wind-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000"><filter id="wind"><feTurbulence type="fractalNoise" baseFrequency="0.02 0.005" numOctaves="2" seed="2" result="turbulence"/><feDisplacementMap in="SourceGraphic" in2="turbulence" scale="30" xChannelSelector="R" yChannelSelector="G"/></filter><rect width="1000" height="1000" fill="transparent"><animate attributeName="fill" values="rgba(255,255,255,0.0);rgba(255,255,255,0.03);rgba(255,255,255,0.0);" dur="8s" repeatCount="indefinite"/></rect><rect width="1000" height="1000" fill="rgba(255,255,255,0.03)" filter="url(%23wind)"/></svg>');
    background-size: 150% 150%;
    animation: wind-pan 15s linear infinite alternate;
    opacity: 0.5;
    z-index: 4;
    /* Between mid and front snow layers */
}

@keyframes wind-pan {
    from {
        background-position: 0% 0%;
    }

    to {
        background-position: 100% 100%;
    }
}

/* --- Ocean Theme --- */
#ocean-theme {
    overflow: hidden;
}

.ocean-water-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Very deep, dark underwater gradient - true abyss feeling */
    background: radial-gradient(circle at 50% -40%, #063853 0%, #032238 20%, #011528 45%, #000205 100%);
    z-index: 1;
}

.ocean-deep-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Very strong vignette for deep ocean mystery */
    background: radial-gradient(circle at 50% 50%, transparent 20%, rgba(0, 2, 5, 0.75) 60%, rgba(0, 0, 2, 0.98) 100%);
    pointer-events: none;
    /* Below particles so they're visible */
    z-index: 2;
}

.ocean-parallax {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 30%;
    will-change: transform;
    pointer-events: none;
    background: transparent !important;
}

#ocean-floor-bg {
    animation: slide 320s linear infinite;
    z-index: 3;
    filter: brightness(0.7);
    pointer-events: none;
}

#ocean-floor-mid {
    animation: slide 240s linear infinite;
    z-index: 4;
    filter: brightness(0.85);
    pointer-events: none;
}

#ocean-floor-fg {
    animation: slide 160s linear infinite;
    z-index: 5;
    pointer-events: none;
}

.ocean-god-rays {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    transform-origin: center;
    animation: ocean-ray-anim 90s ease-in-out infinite alternate;
    z-index: 7;
    pointer-events: none;
    /* GPU acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.ocean-god-ray {
    position: absolute;
    top: 0;
    /* Realistic deep ocean god rays - very subtle blue-white light */
    background: linear-gradient(to bottom,
            rgba(120, 160, 200, 0.12) 0%,
            rgba(80, 130, 170, 0.08) 15%,
            rgba(60, 110, 150, 0.04) 40%,
            transparent 70%);
    transform-origin: top center;
    mix-blend-mode: screen;
    /* No blur for performance */
}

@keyframes ocean-ray-anim {
    from {
        transform: rotate(-20deg);
    }

    to {
        transform: rotate(20deg);
    }
}

.caustics-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: center;
    animation: slow-pan 120s linear infinite alternate;
    z-index: 11;
    mix-blend-mode: screen;
    /* Completely disabled - no caustics */
    display: none;
}

@keyframes slow-pan {
    from {
        transform: translateX(-5%) scale(1.1);
    }

    to {
        transform: translateX(5%) scale(1.1);
    }
}

.caustic-light {
    position: absolute;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><defs><filter id="w"><feTurbulence type="fractalNoise" baseFrequency="0.015" numOctaves="4" seed="8"/><feDiffuseLighting in="SourceGraphic" lighting-color="white" surfaceScale="5"><feDistantLight azimuth="45" elevation="50"/></feDiffuseLighting></filter></defs><rect width="300" height="300" fill="rgba(60,120,160,0.03)" filter="url(%23w)" fill-opacity="1"/></svg>');
    background-size: 300% 300%;
    width: 100%;
    height: 100%;
    animation: caustics-anim 25s ease-in-out infinite alternate;
    /* Much more subtle - very low opacity */
    opacity: 0.08;
    mix-blend-mode: screen;
    filter: blur(2px);
}

.caustic-light-2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><defs><filter id="w"><feTurbulence type="fractalNoise" baseFrequency="0.02" numOctaves="3" seed="5"/><feDiffuseLighting in="SourceGraphic" lighting-color="white" surfaceScale="3"><feDistantLight azimuth="135" elevation="60"/></feDiffuseLighting></filter></defs><rect width="300" height="300" fill="rgba(50,100,140,0.02)" filter="url(%23w)" fill-opacity="1"/></svg>');
    background-size: 250% 250%;
    animation: caustics-anim-2 35s ease-in-out infinite alternate-reverse;
    /* Extremely subtle secondary caustics */
    opacity: 0.05;
    mix-blend-mode: screen;
    pointer-events: none;
}

@keyframes caustics-anim {
    from {
        background-position: 0% 0%;
    }

    to {
        background-position: 100% 100%;
    }
}

@keyframes caustics-anim-2 {
    from {
        background-position: 0% 0%;
    }

    to {
        background-position: 100% 100%;
    }
}

#jellyfish-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: none;
}

.jellyfish {
    position: absolute;
    animation: swim-jellyfish 20s ease-in-out infinite;
}

.jelly-body {
    width: 50px;
    height: 30px;
    background: radial-gradient(ellipse at top, rgba(100, 200, 255, 0.7), rgba(50, 150, 255, 0.3));
    border-radius: 50% 50% 20% 20%;
    animation: pulse-jelly 4s ease-in-out infinite;
}

.jelly-tentacles {
    position: absolute;
    top: 25px;
    left: 25px;
}

.tentacle {
    position: absolute;
    width: 2px;
    background: linear-gradient(to bottom, rgba(100, 200, 255, 0.6), transparent);
    animation: wave-tentacle 4s ease-in-out infinite;
}

@keyframes swim-jellyfish {
    from {
        transform: translate(var(--x-start), var(--y-start)) rotate(-10deg);
    }

    to {
        transform: translate(var(--x-end), var(--y-end)) rotate(10deg);
    }
}

@keyframes pulse-jelly {

    0%,
    100% {
        transform: scale(1, 1);
    }

    50% {
        transform: scale(1.1, 0.9);
    }
}

@keyframes wave-tentacle {

    0%,
    100% {
        transform: rotate(-10deg) scaleY(1);
    }

    50% {
        transform: rotate(10deg) scaleY(1.2);
    }
}

#ocean-sediment-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Above vignette */
    z-index: 8;
    pointer-events: none;
}

.ocean-sediment {
    position: absolute;
    /* Bright, glowing marine snow - highly visible */
    background: rgba(220, 240, 255, 0.9);
    border-radius: 50%;
    animation: drift-sediment ease-in-out infinite;
    /* Strong glow for visibility */
    box-shadow: 0 0 12px rgba(240, 255, 255, 0.8);
}

@keyframes drift-sediment {
    0% {
        left: var(--x-start);
        top: var(--y-start);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        left: var(--x-end);
        top: var(--y-end);
        opacity: 0;
    }
}

/* Simple floating animation for particles */

#ocean-plankton-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Above vignette */
    z-index: 9;
    pointer-events: none;
}

.ocean-plankton {
    position: absolute;
    /* Very bright glowing plankton - cyan/blue-green */
    background: rgba(100, 255, 230, 1.0);
    border-radius: 50%;
    animation: drift-plankton 10s ease-in-out infinite alternate;
    /* Intense glow */
    box-shadow: 0 0 16px rgba(120, 255, 240, 0.9);
}

@keyframes drift-plankton {
    from {
        left: var(--x-start);
        top: var(--y-start);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    to {
        left: var(--x-end);
        top: var(--y-end);
        opacity: 0;
    }
}

#bubbles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.bubble {
    position: absolute;
    background: rgba(173, 216, 230, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    animation: rise-deep ease-in-out infinite;
}

@keyframes rise-deep {
    0% {
        bottom: -20px;
        transform: translateX(0) scale(1);
        opacity: 0.8;
    }

    25% {
        transform: translateX(calc(var(--x-drift) * 0.5)) scale(1.1);
    }

    50% {
        transform: translateX(var(--x-drift)) scale(1.05);
    }

    75% {
        transform: translateX(calc(var(--x-drift) * 1.2)) scale(1.1);
    }

    99% {
        opacity: 0.1;
    }

    100% {
        bottom: 105vh;
        transform: translateX(var(--x-drift-end)) scale(0.8);
        opacity: 0;
    }
}

/* Ocean Reactive Effects */
.burst-bubble {
    position: absolute;
    background: radial-gradient(circle, rgba(173, 216, 230, 0.6), rgba(100, 200, 255, 0.3));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: burst-bubble-rise 1.5s ease-out forwards;
    pointer-events: none;
    z-index: 12;
}

@keyframes burst-bubble-rise {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 1;
    }

    50% {
        transform: translateY(-30vh) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-60vh) scale(0.8);
        opacity: 0;
    }
}

.small-bubble-pop {
    position: absolute;
    background: radial-gradient(circle, rgba(200, 230, 255, 0.5), rgba(150, 200, 255, 0.2));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: small-pop 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 12;
}

@keyframes small-pop {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2) translateY(-20px);
        opacity: 0;
    }
}

.swimming-fish {
    position: absolute;
    width: 30px;
    height: 15px;
    background: linear-gradient(90deg,
            rgba(0, 150, 255, 0.6) 0%,
            rgba(0, 100, 200, 0.8) 50%,
            rgba(0, 50, 150, 0.6) 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: swim-across 4s linear forwards;
    pointer-events: none;
    z-index: 9;
    box-shadow: 0 0 10px rgba(0, 150, 255, 0.3);
}

.swimming-fish::before {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid rgba(0, 100, 200, 0.7);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

@keyframes swim-across {
    0% {
        transform: translateX(0) scaleX(var(--fish-direction, 1));
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateX(calc(var(--fish-direction, 1) * 110vw)) scaleX(var(--fish-direction, 1));
        opacity: 0;
    }
}

.ocean-shockwave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    border: 3px solid rgba(100, 200, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: shockwave-expand 2s ease-out forwards;
    pointer-events: none;
    z-index: 15;
    box-shadow:
        0 0 20px rgba(100, 200, 255, 0.5),
        inset 0 0 20px rgba(100, 200, 255, 0.3);
}

@keyframes shockwave-expand {
    0% {
        transform: translate(-50%, -50%) scale(0.1);
        opacity: 1;
        border-width: 5px;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-50%, -50%) scale(var(--shockwave-scale, 3));
        opacity: 0;
        border-width: 1px;
    }
}

.bioluminescent-glow {
    position: absolute;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle,
            rgba(0, 255, 200, 0.8) 0%,
            rgba(0, 200, 255, 0.6) 30%,
            rgba(0, 150, 255, 0.3) 60%,
            transparent 100%);
    border-radius: 50%;
    animation: bio-pulse 1.5s ease-in-out forwards;
    pointer-events: none;
    z-index: 13;
    filter: blur(3px);
}

@keyframes bio-pulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    30% {
        transform: scale(1.5);
        opacity: 1;
    }

    70% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(0.5);
        opacity: 0;
    }
}

/* --- Sunset Theme (the lantern sea: a WebGPU canvas, src/themes/sunset/) --- */
#sunset-theme {
    background: #0b0a14;
    overflow: hidden;
}

/* Painted Ages: striped badlands rendered by src/themes/painted-ages/. */
#painted-ages-theme {
    background: #5a4a66;
    overflow: hidden;
}

/* --- High Coast Theme (the rising land over a pine archipelago: a WebGPU canvas, src/themes/high-coast/) --- */
#high-coast-theme {
    background: #41587a;
    overflow: hidden;
}

/* --- Winter Theme --- */
/* The night is drawn entirely on the theme's own canvas (src/themes/winter). */
#winter-theme {
    background: #050810;
    overflow: hidden;
}

/* --- Fall Theme --- */
/* The grove is drawn entirely on the theme's own canvas (src/themes/fall). */
#fall-theme {
    background: #0b0d14;
}

/* --- Summer Theme --- */
#summer-theme {
    background: #9fc0d8;
}

/* --- Sakura Twilight Theme --- */
@property --lantern-shift {
    syntax: '<length>';
    inherits: false;
    initial-value: 0px;
}

@property --lantern-scale {
    syntax: '<number>';
    inherits: false;
    initial-value: 1;
}

#sakura-twilight-theme {
    background: linear-gradient(to bottom,
            #0A0E1A 0%,
            /* Deep night blue at top */
            #151828 15%,
            /* Dark midnight blue */
            #1A1530 30%,
            /* Deep purple-blue */
            #1F1838 50%,
            /* Rich midnight purple */
            #231940 70%,
            /* Slightly lighter purple for depth */
            #1D1534 85%,
            /* Dark purple shadow */
            #0F0A18 100%);
    /* Very dark purple-black at bottom */
    overflow: hidden;
}

.sakura-sunset-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        /* Subtle purple glow near horizon */
        radial-gradient(ellipse 120% 30% at 50% 100%, rgba(80, 50, 120, 0.15) 0%, transparent 50%),
        /* Soft moonlight glow */
        radial-gradient(ellipse 60% 40% at 70% 20%, rgba(180, 190, 220, 0.08) 0%, rgba(150, 160, 200, 0.04) 30%, transparent 50%),
        /* Deep space atmosphere */
        radial-gradient(ellipse 100% 60% at 50% 40%, rgba(30, 30, 60, 0.3) 0%, transparent 60%);
    z-index: 1;
    animation: night-atmosphere 20s ease-in-out infinite alternate;
}

@keyframes night-atmosphere {
    0% {
        opacity: 0.7;
        filter: brightness(0.95);
    }

    50% {
        opacity: 0.85;
        filter: brightness(1.02);
    }

    100% {
        opacity: 0.7;
        filter: brightness(0.95);
    }
}

/* Starfield container */
#sakura-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 70%;
    z-index: 2;
    pointer-events: none;
}

.sakura-star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: star-twinkle ease-in-out infinite;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

@keyframes star-twinkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Sakura tree layers with parallax */
.sakura-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: repeat-x;
    background-position: bottom left;
}

#sakura-back {
    z-index: 2;
    animation: sakura-sway-back 280s linear infinite;
    opacity: 0.5;
}

#sakura-mid {
    z-index: 4;
    animation: sakura-sway-mid 200s linear infinite;
    opacity: 0.7;
}

#sakura-front {
    z-index: 7;
    animation: sakura-sway-front 120s linear infinite;
    opacity: 0.9;
}

@keyframes sakura-sway-back {
    from {
        background-position: 0 bottom;
    }

    to {
        background-position: 2048px bottom;
    }
}

@keyframes sakura-sway-mid {
    from {
        background-position: 0 bottom;
    }

    to {
        background-position: 2048px bottom;
    }
}

@keyframes sakura-sway-front {
    from {
        background-position: 0 bottom;
    }

    to {
        background-position: 2048px bottom;
    }
}

/* Glowing paper lanterns */
#sakura-lanterns {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
}

.sakura-lantern {
    position: absolute;
    width: 20px;
    height: 28px;
    background: linear-gradient(to bottom, #FFB8A0 0%, #FFAA88 50%, #FF9C78 100%);
    border-radius: 50% 50% 40% 40%;
    box-shadow:
        0 0 20px 6px rgba(255, 180, 150, 0.5),
        0 0 8px 2px rgba(255, 200, 170, 0.3),
        inset 0 -3px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 3px rgba(255, 220, 200, 0.4);
    --lantern-shift: 0px;
    --lantern-scale: 1;
    transform: translateX(var(--lantern-shift)) scale(var(--lantern-scale));
    transition: filter 0.5s ease-out, transform 0.5s ease-out;
    will-change: transform, filter;
    animation: lantern-gentle-glow 4s ease-in-out infinite alternate;
}

@keyframes lantern-gentle-glow {
    0% {
        filter: brightness(0.9);
    }

    100% {
        filter: brightness(1.1);
    }
}

.sakura-lantern::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 3px;
    background: #8B5A3C;
    border-radius: 2px;
}

.sakura-lantern::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 8px;
    background: rgba(139, 90, 60, 0.6);
}

@keyframes lantern-float {

    0%,
    100% {
        transform: translateY(0) translateX(0);
    }

    25% {
        transform: translateY(-10px) translateX(5px);
    }

    50% {
        transform: translateY(-5px) translateX(-5px);
    }

    75% {
        transform: translateY(-12px) translateX(3px);
    }
}

/* Flying birds */
#sakura-birds {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
}

.sakura-bird {
    position: absolute;
    width: 30px;
    height: 8px;
    animation: bird-fly linear infinite;
}

.sakura-bird::before,
.sakura-bird::after {
    content: '';
    position: absolute;
    top: 0;
    width: 15px;
    height: 8px;
    background: #4A2F2F;
    border-radius: 50% 50% 0 0;
    animation: wing-flap 0.8s ease-in-out infinite;
}

.sakura-bird::before {
    left: 0;
    transform-origin: right center;
}

.sakura-bird::after {
    right: 0;
    transform-origin: left center;
    animation-delay: 0.4s;
}

@keyframes bird-fly {
    from {
        left: -50px;
    }

    to {
        left: calc(100% + 50px);
    }
}

@keyframes wing-flap {

    0%,
    100% {
        transform: rotateX(0deg);
    }

    50% {
        transform: rotateX(60deg);
    }
}

/* Glowing mysterious eyes in the forest */
#sakura-eyes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
}

.sakura-eye {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #E8C5E8 0%, #D8A8D8 30%, #C890C8 60%, transparent 100%);
    border-radius: 50%;
    box-shadow: 0 0 10px 3px rgba(220, 180, 220, 0.5), 0 0 5px 1px rgba(232, 197, 232, 0.3);
    animation: eye-twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
    animation-delay: var(--twinkle-delay, 0s);
    opacity: 0;
}

@keyframes eye-twinkle {

    0%,
    100% {
        opacity: 0;
    }

    5% {
        opacity: 0.9;
    }

    10% {
        opacity: 0;
    }

    15% {
        opacity: 0.9;
    }

    20%,
    80% {
        opacity: 0.7;
    }

    85% {
        opacity: 0;
    }

    90% {
        opacity: 0.8;
    }

    95% {
        opacity: 0;
    }
}

/* Falling cherry blossom petals */
.sakura-petal {
    position: absolute;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #FFBCC8 0%, #FFB0BE 50%, #FFA8B8 100%);
    border-radius: 50% 0% 50% 0%;
    top: -20px;
    /* z-index set by JS for depth layers */
    animation: petal-fall linear infinite;
    filter: drop-shadow(0 0 3px rgba(255, 190, 200, 0.4));
    /* opacity and transform scale set by JS for depth layers */
    will-change: transform, opacity;
}

@keyframes petal-fall {
    0% {
        opacity: 0;
        transform: translateX(var(--x-start)) translateY(-20px) rotate(var(--r-start)) scale(var(--petal-scale, 1));
    }

    10% {
        opacity: var(--petal-opacity, 0.8);
    }

    90% {
        opacity: var(--petal-opacity, 0.8);
    }

    100% {
        opacity: 0;
        transform: translateX(var(--x-end)) translateY(100vh) rotate(var(--r-end)) scale(var(--petal-scale, 1));
    }
}

/* Combo effect animations */

/* Additional firefly and sparkle animations for line clears */

/* --- Aurora Theme --- */
#aurora-theme {
    background: linear-gradient(to bottom,
            #000208 0%,
            #00030f 30%,
            #000515 60%,
            #00061a 100%);
    overflow: hidden;
}

#aurora-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#aurora-horizon-glow {
    position: absolute;
    bottom: -10%;
    left: -5%;
    width: 110%;
    height: 50%;
    background: linear-gradient(180deg,
            rgba(38, 82, 64, 0.0) 0%,
            rgba(64, 178, 118, 0.32) 40%,
            rgba(44, 158, 104, 0.5) 65%,
            rgba(18, 66, 56, 0.15) 85%,
            rgba(5, 20, 28, 0.0) 100%);
    filter: blur(30px);
    opacity: 0.32;
    mix-blend-mode: screen;
    animation: aurora-horizon-pulse 10s ease-in-out infinite alternate;
    z-index: 2;
}

#aurora-veil-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
    mix-blend-mode: screen;
}

#aurora-shimmers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
}

.aurora-star {
    position: absolute;
    background-color: rgba(245, 255, 250, 0.85);
    border-radius: 50%;
    box-shadow:
        0 0 2px 0.5px rgba(245, 255, 250, 0.5),
        0 0 4px 1px rgba(180, 220, 255, 0.3);
    animation: aurora-star-twinkle 10s ease-in-out infinite;
    will-change: opacity;
}

@keyframes aurora-star-twinkle {

    0%,
    100% {
        opacity: var(--base-opacity, 0.5);
        filter: brightness(1);
    }

    20% {
        opacity: calc(var(--base-opacity, 0.5) * 1.15);
        filter: brightness(1.1);
    }

    40% {
        opacity: calc(var(--base-opacity, 0.5) * 0.75);
        filter: brightness(0.9);
    }

    60% {
        opacity: calc(var(--base-opacity, 0.5) * 0.85);
        filter: brightness(0.95);
    }

    80% {
        opacity: calc(var(--base-opacity, 0.5) * 1.08);
        filter: brightness(1.05);
    }
}

.aurora-veil {
    position: absolute;
    /* ORGANIC: Multi-layer gradient for rich, natural aurora colors */
    background:
        radial-gradient(ellipse var(--aurora-ellipse-x, 140%) var(--aurora-ellipse-y, 100%) at 48% 45%,
            hsla(calc(var(--aurora-hue, 125) - 15), 75%, 65%, 0) 0%,
            hsla(calc(var(--aurora-hue, 125) - 8), 88%, 68%, 0.15) 12%,
            hsla(calc(var(--aurora-hue, 125) - 3), 92%, 66%, 0.45) 22%,
            hsla(var(--aurora-hue, 125), 95%, 64%, 0.75) 32%,
            hsla(calc(var(--aurora-hue, 125) + 5), 93%, 60%, 0.85) 40%,
            hsla(calc(var(--aurora-hue, 125) + 10), 90%, 58%, 0.72) 50%,
            hsla(calc(var(--aurora-hue, 125) + 8), 87%, 56%, 0.55) 62%,
            hsla(calc(var(--aurora-hue, 125) + 15), 82%, 52%, 0.32) 74%,
            hsla(calc(var(--aurora-hue, 125) + 20), 78%, 50%, 0.15) 85%,
            hsla(calc(var(--aurora-hue, 125) + 22), 72%, 48%, 0.05) 93%,
            transparent 100%),
        radial-gradient(ellipse calc(var(--aurora-ellipse-x, 140%) * 0.7) calc(var(--aurora-ellipse-y, 100%) * 1.2) at 52% 55%,
            hsla(calc(var(--aurora-hue, 125) + 18), 85%, 62%, 0.3) 0%,
            hsla(calc(var(--aurora-hue, 125) + 12), 80%, 58%, 0.2) 40%,
            transparent 70%);
    opacity: 0;
    /* SUBTLE: Ultra-soft blur for seamless, ethereal blending */
    filter: blur(50px) saturate(80%) brightness(0.8);
    /* ORGANIC: Irregular border-radius for natural, flowing shapes */
    border-radius: var(--aurora-shape, 45% 55% 52% 48% / 48% 58% 42% 52%);
    transform: scale(0.95);
    transform-origin: 50% 50%;
    mix-blend-mode: screen;
    will-change: opacity, filter, transform;
    animation:
        aurora-fade-in 4.5s cubic-bezier(0.25, 0.1, 0.25, 1) forwards,
        aurora-wave var(--aurora-duration, 18s) cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite alternate,
        aurora-glow var(--aurora-glow, 9s) cubic-bezier(0.4, 0, 0.6, 1) infinite alternate,
        aurora-ripple calc(var(--aurora-duration, 18s) * 0.7) ease-in-out infinite,
        aurora-morph calc(var(--aurora-duration, 18s) * 1.3) cubic-bezier(0.42, 0, 0.58, 1) infinite;
}

.aurora-veil::before {
    display: none;
}

/* Aurora Shimmer Particles - Enhanced Natural Motion */
.aurora-shimmer {
    display: none;
}

/* SMOOTH: Ultra-gradual fade-in to prevent any popping */
@keyframes aurora-fade-in {
    0% {
        opacity: 0;
        filter: blur(50px) saturate(80%) brightness(0.8);
        transform: scale(0.95);
    }

    30% {
        opacity: calc(var(--aurora-opacity, 0.36) * 0.2);
        filter: blur(48px) saturate(90%) brightness(0.85);
        transform: scale(0.97);
    }

    60% {
        opacity: calc(var(--aurora-opacity, 0.36) * 0.5);
        filter: blur(42px) saturate(105%) brightness(0.92);
        transform: scale(0.99);
    }

    100% {
        opacity: var(--aurora-opacity, 0.36);
        filter: blur(35px) saturate(120%) brightness(1);
        transform: scale(1);
    }
}

/* FLUID: Ultra-smooth aurora movement with seamless, subtle transitions */
@keyframes aurora-wave {
    0% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * -1 + var(--aurora-drift, 0%) * 0),
                calc(var(--aurora-rise-var, 0%) * 0.1),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * 0.6)) scale(calc(var(--aurora-scale-start, 1) * 0.97));
    }

    16% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * -0.6 + var(--aurora-drift, 0%) * 0.2),
                calc(var(--aurora-rise, -4%) * 0.2 + var(--aurora-rise-var, 0%) * 0.3),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * 0.3)) scale(calc(var(--aurora-scale-start, 1) * 0.99));
    }

    33% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * -0.15 + var(--aurora-drift, 0%) * 0.45),
                calc(var(--aurora-rise, -4%) * 0.4 + var(--aurora-rise-var, 0%) * 0.55),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * 0)) scale(calc(var(--aurora-scale-start, 1) * 1.02));
    }

    50% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * 0.35 + var(--aurora-drift, 0%) * 0.7),
                calc(var(--aurora-rise, -4%) * 0.6 + var(--aurora-rise-var, 0%) * 0.75),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * -0.4)) scale(calc(var(--aurora-scale-mid, 1) * 1.05));
    }

    66% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * 0.7 + var(--aurora-drift, 0%) * 0.88),
                calc(var(--aurora-rise, -4%) * 0.8 + var(--aurora-rise-var, 0%) * 0.9),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * -0.75)) scale(calc(var(--aurora-scale-mid, 1) * 1.04));
    }

    83% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * 0.9 + var(--aurora-drift, 0%) * 0.97),
                calc(var(--aurora-rise, -4%) * 0.92 + var(--aurora-rise-var, 0%) * 0.98),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * -1)) scale(calc(var(--aurora-scale-end, 1) * 1.01));
    }

    100% {
        transform:
            translate3d(calc(var(--aurora-offset, -4%) * 1 + var(--aurora-drift, 0%) * 1),
                calc(var(--aurora-rise, -4%) * 1 + var(--aurora-rise-var, 0%) * 1),
                0) rotate(calc(var(--aurora-base-rotation, 0deg) + var(--aurora-tilt, 2deg) * -1.1)) scale(calc(var(--aurora-scale-end, 1) * 0.98));
    }
}

/* SUBTLE: Gentle aurora glow with minimal, seamless fade */
@keyframes aurora-glow {
    0% {
        opacity: calc(var(--aurora-opacity, 0.36) * 0.75);
        filter: blur(26px) saturate(115%) brightness(0.96);
    }

    25% {
        opacity: calc(var(--aurora-opacity, 0.36) * 0.95);
        filter: blur(29px) saturate(125%) brightness(1.08);
    }

    50% {
        opacity: calc(var(--aurora-opacity, 0.36) * 1.1);
        filter: blur(32px) saturate(132%) brightness(1.15);
    }

    75% {
        opacity: calc(var(--aurora-opacity, 0.36) * 0.92);
        filter: blur(30px) saturate(122%) brightness(1.04);
    }

    100% {
        opacity: calc(var(--aurora-opacity, 0.36) * 0.8);
        filter: blur(27px) saturate(118%) brightness(0.98);
    }
}

/* SUBTLE: Gentle ripple effect with minimal shimmer variation */
@keyframes aurora-ripple {
    0% {
        filter: blur(30px) saturate(125%) brightness(1) contrast(102%);
    }

    20% {
        filter: blur(32px) saturate(128%) brightness(1.04) contrast(103%);
    }

    40% {
        filter: blur(29px) saturate(123%) brightness(0.98) contrast(101%);
    }

    60% {
        filter: blur(31px) saturate(127%) brightness(1.02) contrast(103%);
    }

    80% {
        filter: blur(30px) saturate(125%) brightness(0.99) contrast(102%);
    }

    100% {
        filter: blur(30px) saturate(125%) brightness(1) contrast(102%);
    }
}

@keyframes aurora-horizon-pulse {
    0% {
        opacity: 0.25;
        transform: translateY(0);
    }

    50% {
        opacity: 0.4;
        transform: translateY(-1.5%);
    }

    100% {
        opacity: 0.28;
        transform: translateY(0);
    }
}

/* ORGANIC: Flowing shape morphing for natural aurora forms */
@keyframes aurora-morph {
    0% {
        border-radius: 45% 55% 52% 48% / 48% 58% 42% 52%;
    }

    14% {
        border-radius: 52% 48% 45% 55% / 55% 42% 58% 45%;
    }

    28% {
        border-radius: 48% 52% 58% 42% / 42% 55% 45% 58%;
    }

    42% {
        border-radius: 55% 45% 48% 52% / 58% 48% 52% 42%;
    }

    57% {
        border-radius: 42% 58% 55% 45% / 52% 45% 55% 48%;
    }

    71% {
        border-radius: 58% 42% 48% 52% / 45% 52% 48% 55%;
    }

    85% {
        border-radius: 48% 52% 55% 45% / 52% 48% 58% 42%;
    }

    100% {
        border-radius: 45% 55% 52% 48% / 48% 58% 42% 52%;
    }
}

/* Aurora Reactive Effects */
.aurora-wave {
    position: absolute;
    bottom: 20%;
    left: 50%;
    width: 80%;
    height: 100px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center,
            hsla(var(--wave-hue, 140), 85%, 65%, 0.6) 0%,
            hsla(var(--wave-hue, 140), 85%, 60%, 0.4) 30%,
            hsla(var(--wave-hue, 140), 85%, 55%, 0.2) 60%,
            transparent 100%);
    filter: blur(25px);
    mix-blend-mode: screen;
    animation: aurora-wave-expand 2s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}

@keyframes aurora-wave-expand {
    0% {
        opacity: 0;
        transform: translateX(-50%) scaleX(0.3) scaleY(0.5);
    }

    40% {
        opacity: 1;
        transform: translateX(-50%) scaleX(1) scaleY(1);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) scaleX(1.8) scaleY(1.5);
    }
}

.shooting-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 1);
    border-radius: 50%;
    box-shadow:
        0 0 6px 3px rgba(255, 255, 255, 0.9),
        0 0 12px 6px rgba(180, 220, 255, 0.7),
        0 0 20px 8px rgba(150, 200, 255, 0.4);
    animation: shooting-star-trail 1s ease-out forwards;
    pointer-events: none;
    z-index: 15;
}

.shooting-star::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(var(--shooting-angle, -45deg),
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.4) 20%,
            rgba(255, 255, 255, 0.7) 50%,
            rgba(255, 255, 255, 0.9) 80%,
            rgba(255, 255, 255, 1) 100%);
    transform-origin: left center;
    animation: shooting-star-trail-length 1s ease-out forwards;
}

@keyframes shooting-star-trail {
    0% {
        opacity: 0;
        transform: translate(0, 0) rotate(var(--shooting-angle, -45deg));
        filter: brightness(0.5);
    }

    5% {
        opacity: 1;
        filter: brightness(1.5);
    }

    15% {
        filter: brightness(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(250px, 250px) rotate(var(--shooting-angle, -45deg));
        filter: brightness(0.8);
    }
}

@keyframes shooting-star-trail-length {
    0% {
        width: 0;
    }

    25% {
        width: 120px;
    }

    100% {
        width: 0;
    }
}

/* --- Galaxy Theme --- */
/* The galaxy is drawn entirely on the theme's own canvas; this is only the colour behind it. */
#galaxy-theme {
    background: #010007;
    overflow: hidden;
}

/* --- Voltage Storm Theme --- */
/* The storm is drawn entirely on the theme's own canvas; this is only the colour behind it. */
#voltage-storm-theme {
    background: #020308;
    overflow: hidden;
}

#tornado-theme {
    background: #0a0c10;
    overflow: hidden;
}

/* --- Sunbraid Theme (a pale world under three coloured suns: a WebGPU canvas, src/themes/sunbraid/) --- */
#sunbraid-theme {
    background: #2c3350;
    overflow: hidden;
}

/* --- Koi Pond Theme --- the renderer's clear colour, shown until its canvas draws */
#koi-pond-theme {
    background: #010807;
    overflow: hidden;
}

/* --- Rainbark Theme (painted giants in blue air: a WebGPU canvas, src/themes/rainbark/) --- */
#rainbark-theme {
    background: #3a4a72;
    overflow: hidden;
}

/* --- Kaleidosonic Theme (a ray-marched fractal temple of resonant light: a WebGPU canvas, src/themes/kaleidosonic/) --- */
#kaleidosonic-theme {
    background: #07020f;
    overflow: hidden;
}


/* --- Starlight Theme (WebGPU/TSL) --- */
#starlight-theme {
    background-color: #05060f;
    overflow: hidden;
}

#starlight-theme canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Geode Theme --- */
/* The geode is drawn entirely on the theme's own canvas; this is only the colour behind it. */
#geode-theme {
    background: #050208;
    overflow: hidden;
}

/* --- Bioluminescence Theme --- */
#bioluminescence-theme {
    background-color: #080a0c;
    overflow: hidden;
}

/* --- Golden Forest Theme --- */
#golden-forest-theme {
    background: linear-gradient(to top, #0a141a, #1a2a3a);
    overflow: hidden;
}

.sf-parallax {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100%;
    will-change: transform;
}

#sf-layer-1 {
    animation: slide 240s linear infinite;
    z-index: 1;
}

#sf-layer-2 {
    animation: slide 180s linear infinite;
    z-index: 3;
}

#sf-layer-3 {
    animation: slide 120s linear infinite;
    z-index: 5;
}

.god-ray-container {
    position: absolute;
    top: -10%;
    left: 0;
    width: 100%;
    height: 110%;
    animation: god-ray-anim 60s ease-in-out infinite alternate;
    transform-origin: center top;
    z-index: 2;
}

.god-ray {
    position: absolute;
    top: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 220, 0.15) 0%, rgba(255, 255, 220, 0) 70%);
    transform-origin: top center;
}

@keyframes god-ray-anim {
    from {
        transform: rotate(-10deg);
    }

    to {
        transform: rotate(10deg);
    }
}

.mist {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 25%;
    background: linear-gradient(to top, rgba(150, 160, 170, 0.2) 0%, rgba(150, 160, 170, 0) 100%);
    animation: mist-anim 90s linear infinite;
    z-index: 4;
}

@keyframes mist-anim {
    from {
        transform: translateX(0%);
    }

    to {
        transform: translateX(-50%);
    }
}

.forest-spirit {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: rgba(180, 220, 255, 0.5);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(180, 220, 255, 0.7), 0 0 20px rgba(180, 220, 255, 0.5);
    animation: spirit-drift 25s ease-in-out infinite alternate;
    z-index: 6;
}

@keyframes spirit-drift {
    from {
        transform: translate(var(--x-start), var(--y-start)) scale(1);
        opacity: 0.7;
    }

    to {
        transform: translate(var(--x-end), var(--y-end)) scale(1.2);
        opacity: 0.9;
    }
}

/* --- Desert Oasis Theme - Enchanted Desert Night --- */
#desert-oasis-theme {
    background: linear-gradient(175deg,
            #050510 0%,
            #0a0820 10%,
            #10102a 25%,
            #1a1840 45%,
            #252050 65%,
            #2d2858 80%,
            #352d5a 100%);
    overflow: hidden;
}

/* Base Sky Layer */
.oasis-sky-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 150% 100% at 80% 10%, rgba(80, 50, 120, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse 100% 80% at 15% 25%, rgba(40, 60, 100, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse 80% 50% at 50% 80%, rgba(60, 40, 80, 0.15) 0%, transparent 50%);
    z-index: 1;
}

/* Aurora-like Desert Lights */
.oasis-aurora {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background:
        linear-gradient(180deg,
            transparent 0%,
            rgba(100, 60, 140, 0.08) 20%,
            rgba(60, 100, 140, 0.06) 40%,
            transparent 60%);
    animation: aurora-drift 20s ease-in-out infinite;
    z-index: 1;
}

@keyframes aurora-drift {

    0%,
    100% {
        transform: translateX(-5%) skewX(-2deg);
        opacity: 0.6;
    }

    50% {
        transform: translateX(5%) skewX(2deg);
        opacity: 1;
    }
}

/* Distant Mountains Silhouette */
.oasis-mountains {
    position: absolute;
    bottom: 25%;
    left: 0;
    width: 100%;
    height: 35%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200'%3E%3Cpath d='M0,200 L0,150 Q100,80 200,130 Q280,60 380,110 Q450,40 550,100 Q650,30 750,90 Q850,50 950,120 Q1050,70 1100,100 L1200,80 L1200,200 Z' fill='rgba(15,12,25,0.7)'/%3E%3Cpath d='M0,200 L0,160 Q150,100 280,140 Q380,80 500,130 Q620,70 750,120 Q880,90 1000,140 L1200,110 L1200,200 Z' fill='rgba(20,15,35,0.5)'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: bottom;
    z-index: 3;
}

/* Stars Container */
#desert-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Individual Stars */
.oasis-star {
    position: absolute;
    background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.6) 60%, transparent 100%);
    border-radius: 50%;
    animation: oasis-star-twinkle var(--twinkle-duration, 4s) ease-in-out infinite;
    animation-delay: var(--twinkle-delay, 0s);
    will-change: opacity;
}

.oasis-star.colored-star {
    background: radial-gradient(circle, var(--star-color, #fff) 0%, rgba(255, 255, 255, 0.4) 70%, transparent 100%);
}

@keyframes oasis-star-twinkle {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* Shooting Stars */
.oasis-shooting-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #fff;
    border-radius: 50%;
    animation: oasis-shoot 1.8s ease-out forwards;
    will-change: transform, opacity;
}

.oasis-shooting-star::after {
    content: '';
    position: absolute;
    top: 0;
    right: 3px;
    width: 60px;
    height: 2px;
    background: linear-gradient(to left, transparent, rgba(255, 255, 255, 0.8), transparent);
    transform: rotate(var(--angle, 40deg));
    transform-origin: right center;
}

@keyframes oasis-shoot {
    0% {
        transform: translate(0, 0);
        opacity: 1;
    }

    100% {
        transform: translate(120vw, 80vh);
        opacity: 0;
    }
}

/* Moon Container */
#desert-moon {
    position: absolute;
    top: 8%;
    right: 12%;
    width: 80px;
    height: 80px;
    z-index: 3;
    pointer-events: none;
}

/* Crescent Moon */
.oasis-moon {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 35% 35%,
            #fff8e8 0%,
            #ffe8c0 40%,
            #ffd090 70%,
            rgba(255, 200, 140, 0.6) 100%);
    border-radius: 50%;
    box-shadow:
        0 0 30px rgba(255, 230, 180, 0.6),
        0 0 60px rgba(255, 220, 150, 0.4),
        inset -15px -10px 20px rgba(0, 0, 0, 0.15);
}

.moon-inner-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90px;
    height: 90px;
    background: radial-gradient(circle, rgba(255, 240, 200, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: moon-glow 6s ease-in-out infinite alternate;
}

.moon-outer-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255, 230, 180, 0.15) 0%, transparent 60%);
    border-radius: 50%;
}

@keyframes moon-glow {
    0% {
        opacity: 0.7;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Sand Dune Silhouettes */
.oasis-dune {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
}

.oasis-dune-back {
    height: 35%;
    background: linear-gradient(to top,
            #1a1228 0%,
            #221830 60%,
            transparent 100%);
    clip-path: polygon(0% 100%, 0% 70%, 8% 55%, 20% 65%, 35% 45%, 50% 60%,
            65% 40%, 78% 55%, 90% 48%, 100% 58%, 100% 100%);
    z-index: 4;
    opacity: 0.8;
}

.oasis-dune-mid {
    height: 30%;
    background: linear-gradient(to top,
            #251a35 0%,
            #2d2040 70%,
            transparent 100%);
    clip-path: polygon(0% 100%, 0% 60%, 12% 50%, 25% 65%, 40% 45%, 55% 55%,
            70% 40%, 85% 50%, 100% 55%, 100% 100%);
    z-index: 6;
    opacity: 0.9;
}

.oasis-dune-front {
    height: 25%;
    background: linear-gradient(to top,
            #2f2242 0%,
            #3a2850 60%,
            #4a3560 90%,
            transparent 100%);
    clip-path: polygon(0% 100%, 0% 55%, 15% 40%, 30% 55%, 45% 35%, 60% 50%,
            75% 38%, 90% 48%, 100% 42%, 100% 100%);
    z-index: 8;
}

/* Sand Particles Container */
#desert-sand-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9;
    pointer-events: none;
}

/* Gentle Sand Drift */
.oasis-sand-particle {
    position: absolute;
    background: rgba(200, 170, 130, 0.6);
    border-radius: 50%;
    animation: oasis-sand-drift var(--duration, 20s) linear infinite;
    will-change: transform, opacity;
    contain: layout paint;
}

@keyframes oasis-sand-drift {
    0% {
        transform: translate(var(--start-x), var(--start-y));
        opacity: 0;
    }

    10% {
        opacity: 0.5;
    }

    90% {
        opacity: 0.4;
    }

    100% {
        transform: translate(calc(var(--start-x) + var(--drift-x)), calc(var(--start-y) + var(--drift-y)));
        opacity: 0;
    }
}

/* Oasis Water Pool */
#desert-oasis-water {
    position: absolute;
    bottom: 12%;
    left: 35%;
    width: 30%;
    height: 18%;
    z-index: 5;
    pointer-events: none;
}

.oasis-water-pool {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse 100% 60% at 50% 60%,
            rgba(40, 80, 120, 0.5) 0%,
            rgba(30, 60, 100, 0.4) 40%,
            rgba(20, 50, 90, 0.3) 70%,
            transparent 100%);
    border-radius: 50%;
    animation: water-pool-shimmer 8s ease-in-out infinite;
}

.oasis-water-shimmer {
    position: absolute;
    width: 80%;
    height: 60%;
    top: 20%;
    left: 10%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(100, 150, 200, 0.15) 20%,
            rgba(150, 200, 230, 0.25) 50%,
            rgba(100, 150, 200, 0.15) 80%,
            transparent 100%);
    border-radius: 50%;
    animation: water-shimmer-move 6s ease-in-out infinite;
}

.oasis-water-reflection {
    position: absolute;
    width: 40%;
    height: 30%;
    top: 30%;
    left: 30%;
    background: radial-gradient(ellipse, rgba(255, 240, 200, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: moon-reflection 4s ease-in-out infinite alternate;
}

@keyframes water-pool-shimmer {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.02);
    }
}

@keyframes water-shimmer-move {

    0%,
    100% {
        transform: translateX(-5%) scaleX(0.9);
        opacity: 0.6;
    }

    50% {
        transform: translateX(5%) scaleX(1.1);
        opacity: 0.9;
    }
}

@keyframes moon-reflection {
    0% {
        opacity: 0.3;
        transform: scale(0.95);
    }

    100% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

.oasis-water-pool.oasis-pulse {
    filter: brightness(var(--pulse-intensity, 1.2));
    transition: filter 0.3s ease-out;
}

.oasis-water-shimmer.shimmer-pulse {
    opacity: 1 !important;
    transform: scaleX(1.2) !important;
    transition: all 0.3s ease-out;
}

/* Palm Trees Container */
#desert-palms {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 7;
    pointer-events: none;
}

/* SVG-based Palm Tree */
.oasis-palm {
    position: absolute;
    bottom: var(--palm-bottom, 15%);
    width: var(--palm-width, 100px);
    height: var(--palm-height, 180px);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 180'%3E%3C!-- Trunk --%3E%3Cpath d='M48,180 Q47,140 50,100 Q53,60 50,40' stroke='%23151020' stroke-width='8' fill='none' stroke-linecap='round'/%3E%3C!-- Trunk texture --%3E%3Cpath d='M45,160 Q50,158 55,160 M44,140 Q50,137 56,140 M45,120 Q50,117 55,120 M46,100 Q50,97 54,100 M47,80 Q50,77 53,80 M48,60 Q50,58 52,60' stroke='%23100a18' stroke-width='1.5' fill='none'/%3E%3C!-- Fronds --%3E%3Cpath d='M50,40 Q20,30 5,50' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q25,20 15,35' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q40,10 30,15' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q55,5 50,5' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q60,10 70,15' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q75,20 85,35' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q80,30 95,50' stroke='%23100a18' stroke-width='3' fill='none' stroke-linecap='round'/%3E%3C!-- Drooping fronds --%3E%3Cpath d='M50,40 Q15,45 0,70' stroke='%23100a18' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3Cpath d='M50,40 Q85,45 100,70' stroke='%23100a18' stroke-width='2.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    transform-origin: bottom center;
    animation: palm-sway var(--sway-duration, 10s) ease-in-out infinite;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.3));
}

@keyframes palm-sway {

    0%,
    100% {
        transform: rotate(calc(var(--sway-amount, 1.5deg) * -1)) scaleX(var(--scale-x, 1));
    }

    50% {
        transform: rotate(var(--sway-amount, 1.5deg)) scaleX(var(--scale-x, 1));
    }
}

/* Floating Lanterns Container */
#desert-lanterns {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Floating Lantern */
.oasis-lantern {
    position: absolute;
    width: 12px;
    height: 16px;
    background: radial-gradient(ellipse 100% 120% at 50% 30%,
            rgba(255, 200, 100, 0.95) 0%,
            rgba(255, 160, 60, 0.8) 40%,
            rgba(255, 120, 40, 0.6) 70%,
            transparent 100%);
    border-radius: 30% 30% 50% 50%;
    box-shadow:
        0 0 20px rgba(255, 180, 80, 0.6),
        0 0 40px rgba(255, 150, 50, 0.3);
    animation:
        lantern-glow var(--glow-duration, 3s) ease-in-out infinite,
        lantern-float var(--float-duration, 15s) ease-in-out infinite;
    will-change: transform, opacity;
}

.oasis-lantern::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: rgba(255, 220, 150, 0.8);
    border-radius: 50%;
}

@keyframes lantern-glow {

    0%,
    100% {
        opacity: 0.7;
        filter: brightness(0.9);
    }

    50% {
        opacity: 1;
        filter: brightness(1.1);
    }
}

@keyframes lantern-float {

    0%,
    100% {
        transform: translate(0, 0) rotate(-3deg);
    }

    25% {
        transform: translate(var(--drift-x, 10px), calc(var(--drift-y, -20px) * 0.5)) rotate(2deg);
    }

    50% {
        transform: translate(calc(var(--drift-x, 10px) * 1.5), var(--drift-y, -20px)) rotate(-2deg);
    }

    75% {
        transform: translate(var(--drift-x, 10px), calc(var(--drift-y, -20px) * 0.7)) rotate(1deg);
    }
}

.oasis-lantern.lantern-flash {
    filter: brightness(1.5) !important;
    box-shadow:
        0 0 30px rgba(255, 200, 100, 0.9),
        0 0 60px rgba(255, 160, 60, 0.5);
    transition: all 0.2s ease-out;
}

/* Oasis Vegetation Container */
#desert-vegetation {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    z-index: 7;
    pointer-events: none;
}

/* Oasis Reeds/Grass */
.oasis-reed {
    position: absolute;
    bottom: var(--reed-bottom, 12%);
    width: 3px;
    height: var(--reed-height, 40px);
    background: linear-gradient(to top,
            rgba(20, 15, 30, 0.9) 0%,
            rgba(25, 20, 40, 0.7) 70%,
            rgba(30, 25, 45, 0.5) 100%);
    border-radius: 1px 1px 0 0;
    transform-origin: bottom center;
    animation: reed-sway var(--sway-duration, 4s) ease-in-out infinite;
}

.oasis-reed::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 10px;
    background: radial-gradient(ellipse, rgba(25, 20, 35, 0.8) 0%, transparent 70%);
    border-radius: 50%;
}

@keyframes reed-sway {

    0%,
    100% {
        transform: rotate(calc(var(--sway-amount, 5deg) * -1));
    }

    50% {
        transform: rotate(var(--sway-amount, 5deg));
    }
}

/* Effects Container */
#desert-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 11;
    pointer-events: none;
    overflow: hidden;
    contain: layout style;
}

/* ===== COMBO EFFECTS ===== */

/* Sand Swirl Effect */
.sand-swirl {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
            transparent 0deg,
            rgba(200, 170, 130, 0.4) 90deg,
            transparent 180deg,
            rgba(180, 150, 110, 0.3) 270deg,
            transparent 360deg);
    animation: sand-swirl-spin 1.2s ease-out forwards;
    will-change: transform, opacity;
    contain: layout paint;
}

@keyframes sand-swirl-spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(0.3);
        opacity: 0;
    }

    20% {
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) rotate(720deg) scale(1.5);
        opacity: 0;
    }
}

/* Oasis Water Ripple */
.oasis-ripple {
    position: absolute;
    width: 20px;
    height: 12px;
    border: 2px solid rgba(100, 160, 200, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: oasis-ripple-expand 1s ease-out forwards;
    will-change: transform, opacity;
    contain: layout paint;
}

@keyframes oasis-ripple-expand {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }

    100% {
        transform: translate(-50%, -50%) scale(5);
        opacity: 0;
    }
}

/* Lantern Spark Particle */
.lantern-spark {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, var(--glow-color, #ffcc70) 0%, rgba(255, 180, 60, 0.5) 50%, transparent 80%);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--glow-color, #ffcc70);
    animation: lantern-spark-anim 0.75s ease-out forwards;
    will-change: transform, opacity;
    contain: layout paint;
}

@keyframes lantern-spark-anim {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    15% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }

    100% {
        transform: translate(calc(-50% + var(--burst-x, 0)), calc(-50% + var(--burst-y, 0))) scale(0.2);
        opacity: 0;
    }
}

/* Moonbeam Ray */
.moonbeam {
    position: absolute;
    width: 3px;
    height: 150px;
    background: linear-gradient(to bottom,
            rgba(255, 240, 200, 0.4) 0%,
            rgba(255, 230, 180, 0.2) 50%,
            transparent 100%);
    transform-origin: top center;
    transform: rotate(var(--beam-angle, 20deg));
    animation: moonbeam-shine 1.5s ease-out forwards;
    will-change: transform, opacity;
    contain: layout paint;
}

@keyframes moonbeam-shine {
    0% {
        opacity: 0;
        transform: rotate(var(--beam-angle, 20deg)) scaleY(0);
    }

    30% {
        opacity: 0.8;
        transform: rotate(var(--beam-angle, 20deg)) scaleY(1);
    }

    100% {
        opacity: 0;
        transform: rotate(var(--beam-angle, 20deg)) scaleY(1.2);
    }
}

/* Sand Puff (piece lock) */
.sand-puff {
    position: absolute;
    width: 25px;
    height: 25px;
    background: radial-gradient(circle, rgba(180, 150, 110, 0.5) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: sand-puff-anim 0.5s ease-out forwards;
    will-change: transform, opacity;
    contain: layout paint;
}

@keyframes sand-puff-anim {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.6;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Desert Sparkle Effect */
.desert-sparkle {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    animation: desert-sparkle-anim 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 12;
}

.desert-sparkle::before,
.desert-sparkle::after {
    content: '';
    position: absolute;
    background: #ffe8cc;
    border-radius: 50%;
}

.desert-sparkle::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
    box-shadow: 0 0 8px rgba(255, 200, 100, 0.8);
}

.desert-sparkle::after {
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
    box-shadow: 0 0 8px rgba(255, 200, 100, 0.8);
}

@keyframes desert-sparkle-anim {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
    }

    40% {
        transform: translate(-50%, -50%) scale(1) rotate(45deg);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(0) rotate(90deg);
        opacity: 0;
    }
}

/* --- Grainfields Theme (ripe barley under a breaking storm, Lapporten on the horizon: a WebGPU canvas, src/themes/grainfields/) --- */
#grainfields-theme {
    background: #5a6678;
    overflow: hidden;
}

/* --- Simplified Waves Theme --- */
#waves-theme {
    background: linear-gradient(to top, #3a6073, #16222a);
    overflow: hidden;
}

.waves-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="f"><feGaussianBlur stdDeviation="2"/></filter><g filter="url(%23f)"><circle cx="20" cy="80" r="30" fill="%233a6073"/><circle cx="80" cy="70" r="40" fill="%2316222a"/></g></svg>');
    background-size: cover;
    filter: blur(5px);
    transform: scale(1.2);
    z-index: 1;
}

.wave-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background-repeat: repeat-x;
    background-position: 0 bottom;
    animation: slide linear infinite;
    will-change: transform;
    opacity: 0.8;
}

#waves-layer-back {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 100"><path d="M0 50 C 200 20, 400 80, 800 50 L 800 100 L 0 100 Z" fill="rgba(255,255,255,0.1)"/></svg>');
    animation-duration: 45s;
    z-index: 2;
    filter: blur(2px);
}

#waves-layer-mid {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 100"><path d="M0 60 C 250 10, 350 110, 800 60 L 800 100 L 0 100 Z" fill="rgba(255,255,255,0.15)"/></svg>');
    animation-duration: 30s;
    z-index: 4;
    filter: blur(1px);
}

#waves-layer-front {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 100"><path d="M0 70 C 300 -20, 500 120, 800 70 L 800 100 L 0 100 Z" fill="rgba(255,255,255,0.2)"/></svg>');
    animation-duration: 20s;
    z-index: 6;
}

.wave-particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: wave-particle-drift 15s ease-in-out infinite alternate;
    z-index: 3;
}

@keyframes wave-particle-drift {
    from {
        transform: translate(var(--x-start), var(--y-start));
        opacity: 0;
    }

    50% {
        opacity: 0.8;
    }

    to {
        transform: translate(var(--x-end), var(--y-end));
        opacity: 0;
    }
}

/* --- Spring Theme (a Norrland river in its spring flood: a WebGPU canvas, src/themes/spring/) --- */
#spring-theme {
    background: #8ea6c4;
    overflow: hidden;
}

/* --- Moonlit Greenhouse Theme (the night garden under glass: a WebGPU canvas, src/themes/moonlit-greenhouse/) --- */
#moonlit-greenhouse-theme {
    background: #03080b;
    overflow: hidden;
}

body:has(#moonlit-greenhouse-theme.active) .single-player-stage[data-board='well']:not(:where(.infinity-mode-active, [data-odyssey-board], [data-stillfall])) {
    --sp-hue: #a9e4cd;
    --sp-hue-rgb: 169, 228, 205;
}

body:has(#moonlit-greenhouse-theme.active) .single-player-stage[data-board='well']:not(:where(.infinity-mode-active, [data-odyssey-board], [data-stillfall], [data-danger], [data-still-air])) {
    --sp-wall: #619c8d;
    --sp-wall-glow: rgb(75 150 138 / 24%);
}

body:has(#moonlit-greenhouse-theme.active) .single-player-stage[data-board='well']:not(:where(.infinity-mode-active, [data-odyssey-board], [data-stillfall])) .single-player-stats-bar {
    --sb-text-faint: #b9cec6;
    border-color: rgb(190 153 95 / 44%);
    background: linear-gradient(152deg, rgb(21 48 45 / 97%), rgb(12 23 33 / 97%) 72%);
}

/* --- Thermal Bloom Theme (a steaming hydrothermal basin: a WebGPU canvas, src/themes/thermal-bloom/) --- */
#thermal-bloom-theme {
    background: #7e97a8;
    overflow: hidden;
}

/* --- Ice Temple Theme --- */
#ice-temple-theme {
    background: #01030a;
    overflow: hidden;
}

/* --- Himalayan Peak Theme --- */
#himalayan-peak-theme {
    background: #05070f;
    overflow: hidden;
}

/* Shared: the sliding layers of several DOM themes animate with this. */
@keyframes slide {
    from {
        transform: translateX(0%);
    }

    to {
        transform: translateX(-50%);
    }
}

.game-container {
    display: flex;
    flex-direction: row;
    gap: 30px;
    padding: 0;
    animation: fadeIn 0.5s ease;
    position: relative;
    z-index: 1;
    min-height: 720px;
    min-width: 900px;
    justify-content: center;
    align-items: flex-start;
    box-sizing: content-box;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    gap: 12px;
}

/* Next pieces container - Updated to match FFA multiplayer style */
.next-pieces-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    margin-bottom: 12px;
    min-height: 80px;
}

.next-piece-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 4px;
    padding: 4px;
    transition: all 0.2s ease;
}

.next-piece-box.main {
    transform: scale(1.2);
    margin-right: 10px;
    background: rgba(102, 126, 234, 0.15);
    border: 2px solid rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.next-piece-label {
    font-size: 10px;
    color: #a0aec0;
    text-transform: uppercase;
    font-weight: bold;
}

.next-piece-box canvas {
    background: transparent;
    border-radius: 6px;
    padding: 4px;
}

/* Single Player Layout */
.game-container.single-player-layout {
    grid-column: 2;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    min-width: auto;
    padding: 0;
    width: auto;
}

.game-container.single-player-layout.infinity-mode-active {
    flex-direction: row;
    /* Center align all panels vertically */
    align-items: center;
    justify-content: center;
    /* Reduced gap to fit all panels */
    gap: clamp(16px, 2.5vw, 40px);
    width: 100%;
    min-width: 0;
    /* More conservative padding */
    padding: clamp(10px, 1.5vh, 24px) clamp(12px, 2vw, 48px);
    box-sizing: border-box;
}

.single-player-stage.infinity-mode-active {
    display: flex;
    gap: clamp(16px, 2.5vw, 40px);
    /* Center align all panels vertically */
    align-items: center;
    width: 100%;
    max-width: none;
    margin: 0;
    /* More conservative padding to fit all panels */
    padding: clamp(10px, 1.5vh, 24px) clamp(8px, 2vw, 32px);
    min-height: 100vh;
    max-height: 100vh;
    /* leave breathing room at top/bottom */
    box-sizing: border-box;
    overflow: hidden;
}

#single-player-container.infinity-mode-active .floating-settings-btn {
    order: 4;
    align-self: flex-start;
    margin-top: 4px;
    margin-left: auto;
}

/* Infinity HUD - Left side */
#single-player-container.infinity-mode-active #infinity-hud {
    order: 1;
    align-self: center;
    /* Fit within viewport, accounting for padding and spacing */
    max-height: calc(100vh - 120px);
    overflow: hidden;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    /* Scale font size to fit content */
    font-size: clamp(9px, 0.85vw, 13px);
    box-sizing: border-box;
    padding: clamp(12px, 1.5vw, 20px) !important;
    /* Keep scale at 1.0 but make the dimensions responsive */
    transform: none;
    background:
        radial-gradient(120% 50% at 50% -10%, rgba(var(--cs-lavender-rgb), 0.14), transparent 60%),
        linear-gradient(180deg, rgba(19, 18, 32, 0.92) 0%, rgba(10, 9, 18, 0.95) 100%) !important;
}

/* HUD sections - compact spacing */
#single-player-container.infinity-mode-active #infinity-hud .hud-section {
    margin-bottom: clamp(8px, 1vh, 12px) !important;
    padding-bottom: clamp(6px, 0.8vh, 10px) !important;
}

/* HUD title - smaller */
#single-player-container.infinity-mode-active #infinity-hud .hud-title {
    font-size: clamp(11px, 1vw, 14px) !important;
    margin-bottom: clamp(8px, 1vh, 12px) !important;
}

/* Game board - Center */
#single-player-container.infinity-mode-active .single-player-card {
    order: 2;
    align-self: center;
    --player-primary: #00e5ff;
    --player-primary-light: #64ffc8;
    --player-glow: rgba(0, 229, 255, 0.35);
    /* More conservative sizing for 3-panel layout (HUD + Board + Minimap) */
    /* Account for: next pieces (~100px), padding, margins, gaps = ~280px vertical space */
    --board-width: min(clamp(260px, 25vw, 360px), calc((100vh - 280px) / 2));
    --board-height: calc(var(--board-width) * 2);
    flex: 0 1 auto;
    padding: clamp(4px, 1vw, 12px);
    width: calc(var(--board-width) + clamp(6px, 1vw, 16px));
    max-width: calc(var(--board-width) + clamp(6px, 1vw, 16px));
    /* Ensure card doesn't overflow - leave room for next pieces section */
    max-height: calc(100vh - 60px);
    overflow: visible;
    box-sizing: border-box;
    border-radius: 20px;
    background: linear-gradient(165deg,
            rgba(15, 20, 40, 0.85) 0%,
            rgba(8, 12, 28, 0.92) 50%,
            rgba(5, 8, 20, 0.95) 100%);
}

#single-player-container.infinity-mode-active .single-player-body {
    gap: clamp(4px, 0.8vw, 10px);
    max-height: 100%;
    overflow: visible;
}

#single-player-container.infinity-mode-active .single-player-main {
    gap: clamp(6px, 1vw, 12px);
    max-height: 100%;
    overflow: visible;
}

#single-player-container.infinity-mode-active .player-next-pieces {
    gap: clamp(4px, 0.6vw, 8px);
    padding: clamp(4px, 0.8vw, 10px);
    /* Revert player variables to purple for the next-piece highlighting */
    --player-primary: #8b5cf6;
    --player-glow: rgba(139, 92, 246, 0.35);
}

#single-player-container.infinity-mode-active .player-next-piece {
    width: clamp(50px, 6vw, 72px);
    height: clamp(50px, 6vw, 72px);
}

/* The carried-over single-player next-queue fade is too dim against the darker
   Infinity board — lift the 2nd/3rd previews so they stay readable. */
#single-player-container.infinity-mode-active .player-next-piece:nth-child(2) {
    opacity: 0.9;
}

#single-player-container.infinity-mode-active .player-next-piece:nth-child(3) {
    opacity: 0.75;
}

/* Infinity Minimap - Right side */
#single-player-container.infinity-mode-active #infinity-minimap {
    order: 3;
    align-self: center;
    /* Fit within viewport, accounting for padding and title */
    max-height: calc(100vh - 120px);
    overflow: hidden;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    /* Ensure content fits */
    padding: clamp(8px, 1vw, 12px) !important;
    /* Keep scale at 1.0 but make the dimensions responsive */
    transform: none;
    background:
        radial-gradient(120% 40% at 50% -8%, rgba(var(--cs-lavender-rgb), 0.12), transparent 60%),
        linear-gradient(180deg, rgba(19, 18, 32, 0.92) 0%, rgba(10, 9, 18, 0.95) 100%) !important;
    border-radius: 20px !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Minimap canvas - scale to fit */
#single-player-container.infinity-mode-active #infinity-minimap canvas {
    max-height: calc(100vh - 200px) !important;
    width: 100% !important;
    height: auto !important;
    object-fit: contain;
}

/* Minimap title - ensure visible */
#single-player-container.infinity-mode-active #infinity-minimap .minimap-title {
    font-size: clamp(8px, 0.7vw, 10px) !important;
    margin-top: 0 !important;
    margin-bottom: clamp(6px, 0.8vh, 10px) !important;
}

.single-player-stage.infinity-mode-active .single-player-stats-bar {
    display: none !important;
}

.single-player-card {
    --player-primary: #8b5cf6;
    --player-primary-light: #c4b5fd;
    --player-glow: rgba(139, 92, 246, 0.35);
    /* Reduced size to show more background */
    --board-width: min(clamp(220px, 22vw, 300px), calc((100vh - 250px) / 2));
    --board-height: calc(var(--board-width) * 2);
    width: auto;
    align-items: stretch;
    gap: 18px;
    padding: 20px;
    border-color: var(--player-primary);
    box-shadow:
        0 0 26px var(--player-glow),
        inset 0 0 12px rgba(139, 92, 246, 0.18);
}

.single-player-body {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    width: auto;
}

.single-player-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.single-player-card .player-next-pieces {
    width: var(--board-width);
    justify-content: center;
    margin: 0;
    background: rgba(10, 8, 24, 0.4);
    border: 4px solid rgba(139, 92, 246, 0.9);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 12px 0;
    box-shadow:
        0 0 30px rgba(139, 92, 246, 0.45),
        inset 0 0 18px rgba(139, 92, 246, 0.35);
}

/* Opacity fade for next pieces queue in single player */
.single-player-card .player-next-piece:nth-child(1) {
    opacity: 1;
    transform: scale(1.05);
    border: 2px solid rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.35);
}

.single-player-card .player-next-piece:nth-child(2) {
    opacity: 0.75;
    transform: scale(0.95);
}

.single-player-card .player-next-piece:nth-child(3) {
    opacity: 0.55;
    transform: scale(0.9);
}

.single-player-card .player-next-piece:nth-child(n+4) {
    opacity: 0.4;
    transform: scale(0.85);
}

.single-player-card .player-board-section {
    width: var(--board-width);
    height: var(--board-height);
}

.single-player-card .phaser-board-container {
    border: 2px solid rgba(139, 92, 246, 0.45);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow:
        inset 0 0 18px rgba(139, 92, 246, 0.15),
        0 0 30px rgba(139, 92, 246, 0.25);
}

#single-player-border {
    border-color: rgba(139, 92, 246, 0.9);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow:
        0 0 30px rgba(139, 92, 246, 0.45),
        inset 0 0 18px rgba(139, 92, 246, 0.35);
}

.board-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 12px;
    z-index: 2;
}

body.phaser-hud-ready .next-pieces-container {
    display: none;
}

/* Hide old DOM canvases when using Phaser for multiplayer */
body.phaser-multiplayer-active #p1-canvas,
body.phaser-multiplayer-active #p2-canvas {
    display: none;
}

/* Line Clear Flash Effect - Container */
#line-clear-flash {
    z-index: 2;
    overflow: hidden;
}

.score-popups-layer {
    z-index: 3;
}

#single-player-card #phaser-game-container {
    position: relative;
    display: block;
    width: var(--board-width);
    height: var(--board-height);
    margin: 0;
    padding: 0;
}

#single-player-card #phaser-game-container canvas {
    width: var(--board-width) !important;
    height: var(--board-height) !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
}

.single-player-stats-bar {
    position: absolute;
    left: 50%;
    top: 50%;
    /* Offset: Half board width + card padding (24px) + gap (30px) */
    transform: translate(calc(var(--board-width) / 2 + 60px), -50%);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    width: fit-content;
    z-index: 10;
}

.single-player-stat {
    width: 140px;
    padding: 8px 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(24, 20, 64, 0.85), rgba(8, 9, 24, 0.75));
    border: 1px solid rgba(139, 92, 246, 0.35);
    box-shadow:
        0 10px 22px rgba(10, 8, 24, 0.45),
        inset 0 0 12px rgba(99, 102, 241, 0.18);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.single-player-stat .stat-icon {
    font-size: 18px;
    line-height: 1;
    filter: saturate(0.85);
}

.single-player-stat .stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.single-player-stat:first-child {
    border-color: rgba(52, 211, 153, 0.5);
    box-shadow:
        0 12px 32px rgba(16, 185, 129, 0.35),
        inset 0 0 18px rgba(16, 185, 129, 0.2);
}

.single-player-stat-label {
    font-family: 'Space Mono', monospace;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    font-size: 9px;
    color: rgba(209, 213, 219, 0.7);
}

.single-player-stat-value {
    font-family: 'Orbitron', 'Space Mono', monospace;
    font-weight: 700;
    font-size: 18px;
    line-height: 1.05;
    color: #ffffff;
    text-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

/* Typography Hierarchy Adjustments */
.single-player-stat.stat-score .single-player-stat-value,
.single-player-stat.stat-lines .single-player-stat-value,
.single-player-stat.stat-level .single-player-stat-value,
.single-player-stat.stat-next-level .single-player-stat-value {
    font-size: 24px;
}

.single-player-stat.stat-speed,
.single-player-stat.stat-bpm,
.single-player-stat.stat-ppm {
    padding: 4px 8px;
    opacity: 0.85;
}

.single-player-stat.stat-speed .single-player-stat-value,
.single-player-stat.stat-bpm .single-player-stat-value,
.single-player-stat.stat-ppm .single-player-stat-value {
    font-size: 14px;
}

/* Color-coded stat values */
.single-player-stat.stat-score .single-player-stat-value,
.single-player-stat.stat-score .stat-icon {
    color: #34d399;
    text-shadow: 0 0 18px rgba(52, 211, 153, 0.55);
    filter: drop-shadow(0 0 12px rgba(52, 211, 153, 0.55));
}

.single-player-stat.stat-lines .single-player-stat-value,
.single-player-stat.stat-lines .stat-icon {
    color: #60a5fa;
    text-shadow: 0 0 14px rgba(96, 165, 250, 0.5);
    filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.5));
}

.single-player-stat.stat-level .single-player-stat-value,
.single-player-stat.stat-level .stat-icon {
    color: #a78bfa;
    text-shadow: 0 0 14px rgba(167, 139, 250, 0.5);
    filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.5));
}

.single-player-stat.stat-next-level .single-player-stat-value,
.single-player-stat.stat-next-level .stat-icon {
    color: #fbbf24;
    text-shadow: 0 0 14px rgba(251, 191, 36, 0.5);
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.5));
}

.single-player-stat.stat-speed .single-player-stat-value,
.single-player-stat.stat-speed .stat-icon {
    color: #f472b6;
    text-shadow: 0 0 14px rgba(244, 114, 182, 0.5);
    filter: drop-shadow(0 0 10px rgba(244, 114, 182, 0.5));
}

.single-player-stat.stat-bpm .single-player-stat-value,
.single-player-stat.stat-bpm .stat-icon {
    color: #22d3ee;
    text-shadow: 0 0 14px rgba(34, 211, 238, 0.5);
    filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.5));
}

.single-player-stat.stat-ppm .single-player-stat-value,
.single-player-stat.stat-ppm .stat-icon {
    color: #fb923c;
    text-shadow: 0 0 14px rgba(251, 146, 60, 0.5);
    filter: drop-shadow(0 0 10px rgba(251, 146, 60, 0.5));
}

/* Pulse animation for value changes */
.single-player-stat-value.pulse {
    animation: sp-stat-pulse 0.3s ease-out;
}

@keyframes sp-stat-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.12);
        filter: brightness(1.3);
    }

    100% {
        transform: scale(1);
    }
}

@media (max-width: 820px) {
    .single-player-stage {
        display: flex;
        flex-direction: column;
        max-width: calc(100% - 40px);
        padding: 10px;
    }

    .single-player-card {
        /* Smaller sizing for mobile */
        --board-width: min(clamp(280px, 80vw, 350px), calc((100vh - 250px) / 2));
    }

    .single-player-stats-bar {
        position: static;
        transform: none;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        margin-top: 20px;
    }

    .single-player-stat {
        width: calc(50% - 12px);
    }
}

/* Individual line flash bars */
.line-flash-bar {
    position: absolute;
    left: 0;
    width: 100%;
    pointer-events: none;
    opacity: 0;
    transform: scaleX(0.95);
    transition: opacity 0.05s ease-out, transform 0.05s ease-out;
}

/* Multi-layered flash effect */
.line-flash-bar::before,
.line-flash-bar::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Main flash layer with gradient */
.line-flash-bar::before {
    background: linear-gradient(to right,
            transparent 0%,
            rgba(100, 200, 255, 0.15) 10%,
            rgba(255, 255, 255, 0.5) 50%,
            rgba(100, 200, 255, 0.15) 90%,
            transparent 100%);
    box-shadow:
        0 0 20px rgba(100, 200, 255, 0.8),
        0 0 40px rgba(255, 255, 255, 0.4),
        inset 0 0 15px rgba(255, 255, 255, 0.3);
    filter: blur(0.5px);
}

/* Scanline sweep overlay */
.line-flash-bar::after {
    background: repeating-linear-gradient(90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0.1) 4px);
    mix-blend-mode: overlay;
}

.line-flash-bar.active {
    animation: lineFlashPulse 0.22s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.line-flash-bar.active::before {
    animation: flashGlow 0.22s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.line-flash-bar.active::after {
    animation: scanlineSweep 0.22s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes lineFlashPulse {
    0% {
        opacity: 0;
        transform: scaleX(0.9) scaleY(0.8);
    }

    25% {
        opacity: 1;
        transform: scaleX(1.03) scaleY(1.2);
    }

    60% {
        opacity: 0.7;
        transform: scaleX(1.01) scaleY(1.05);
    }

    100% {
        opacity: 0;
        transform: scaleX(1) scaleY(1);
    }
}

@keyframes flashGlow {
    0% {
        filter: blur(0.5px) brightness(1);
        box-shadow:
            0 0 20px rgba(100, 200, 255, 0.8),
            0 0 40px rgba(255, 255, 255, 0.4),
            inset 0 0 15px rgba(255, 255, 255, 0.3);
    }

    20% {
        filter: blur(1px) brightness(1.5);
        box-shadow:
            0 0 30px rgba(100, 200, 255, 1),
            0 0 60px rgba(255, 255, 255, 0.6),
            inset 0 0 20px rgba(255, 255, 255, 0.5),
            0 2px 0 rgba(255, 255, 255, 0.8),
            0 -2px 0 rgba(100, 200, 255, 0.8);
    }

    100% {
        filter: blur(2px) brightness(0.8);
        box-shadow:
            0 0 10px rgba(100, 200, 255, 0.4),
            0 0 20px rgba(255, 255, 255, 0.2);
    }
}

@keyframes scanlineSweep {
    0% {
        opacity: 0;
        transform: translateX(-100%) skewX(-10deg);
    }

    30% {
        opacity: 0.8;
        transform: translateX(0%) skewX(-5deg);
    }

    100% {
        opacity: 0;
        transform: translateX(100%) skewX(0deg);
    }
}

/* Line-clear particle system */
.line-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
            hsla(var(--particle-hue), 100%, 80%, 1) 0%,
            hsla(var(--particle-hue), 100%, 60%, 0.6) 50%,
            transparent 100%);
    box-shadow:
        0 0 6px hsla(var(--particle-hue), 100%, 70%, 0.8),
        0 0 12px hsla(var(--particle-hue), 100%, 60%, 0.4);
    animation: particleBurst 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform-origin: center;
}

@keyframes particleBurst {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--tx)),
                calc(-50% + var(--ty))) scale(0.3);
    }
}

/* Radial Energy Burst */
.radial-burst {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.radial-burst::before,
.radial-burst::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
}

/* Outer expanding ring */
.radial-burst::before {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle,
            transparent 30%,
            rgba(100, 200, 255, 0.4) 40%,
            rgba(255, 255, 255, 0.6) 50%,
            rgba(100, 200, 255, 0.4) 60%,
            transparent 70%);
    animation: burstExpand 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Inner glow pulse */
.radial-burst::after {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(100, 200, 255, 0.6) 30%,
            transparent 60%);
    animation: burstPulse 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Intense burst for a quad (4-line clear) */
.radial-burst.intense::before {
    background: radial-gradient(circle,
            transparent 20%,
            rgba(255, 100, 255, 0.5) 30%,
            rgba(100, 200, 255, 0.6) 40%,
            rgba(255, 255, 255, 0.8) 50%,
            rgba(100, 200, 255, 0.6) 60%,
            rgba(255, 100, 255, 0.5) 70%,
            transparent 80%);
    animation: burstExpandIntense 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.radial-burst.intense::after {
    background: radial-gradient(circle,
            rgba(255, 255, 255, 1) 0%,
            rgba(255, 100, 255, 0.8) 20%,
            rgba(100, 200, 255, 0.7) 40%,
            transparent 70%);
}

@keyframes burstExpand {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(15);
    }
}

@keyframes burstExpandIntense {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(20) rotate(180deg);
    }
}

@keyframes burstPulse {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(3);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(6);
    }
}

/* Piece Lock Ripple Effect */
.lock-ripple {
    position: absolute;
    width: 8px;
    height: 8px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    border-radius: 50%;
    border: 2px solid var(--lock-ripple-border-color, rgba(100, 200, 255, 0.8));
    box-shadow: 0 0 8px var(--lock-ripple-shadow-color, rgba(100, 200, 255, 0.6));
    animation: lockRippleExpand 0.4s cubic-bezier(0.4, 0.0, 0.6, 1) forwards;
}

@keyframes lockRippleExpand {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
        border-width: 2px;
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(4);
        border-width: 0.5px;
    }
}

/* Background Pulse Effect on Line Clear */
.background-pulse {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    background: radial-gradient(circle at center,
            rgba(100, 200, 255, 0.05) 0%,
            transparent 70%);
    animation: backgroundPulseAnim 0.8s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.background-pulse.medium {
    background: radial-gradient(circle at center,
            rgba(100, 200, 255, 0.08) 0%,
            rgba(139, 92, 246, 0.04) 40%,
            transparent 70%);
}

.background-pulse.strong {
    background: radial-gradient(circle at center,
            rgba(100, 200, 255, 0.12) 0%,
            rgba(139, 92, 246, 0.06) 40%,
            transparent 70%);
}

.background-pulse.intense {
    background: radial-gradient(circle at center,
            rgba(255, 100, 255, 0.15) 0%,
            rgba(100, 200, 255, 0.10) 30%,
            rgba(139, 92, 246, 0.08) 50%,
            transparent 75%);
}

@keyframes backgroundPulseAnim {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    30% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.3);
    }
}

/* Block Merge Glow - Micro Detail */
.merge-glow {
    position: absolute;
    width: 3px;
    height: 3px;
    pointer-events: none;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(100, 200, 255, 0.6) 30%,
            transparent 70%);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
    animation: mergeGlowPulse 0.12s ease-out forwards;
}

/* Directional glow shapes */
.merge-glow.left,
.merge-glow.right {
    width: 2px;
    height: 6px;
}

.merge-glow.top,
.merge-glow.bottom {
    width: 6px;
    height: 2px;
}

@keyframes mergeGlowPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Sidebar - Updated to complement FFA multiplayer design */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(18, 23, 31, 0.85);
    backdrop-filter: blur(10px);
    border-right: 2px solid rgba(102, 126, 234, 0.3);
}

.panel {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 20px;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.panel h2 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: #ffffff;
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
    background: rgba(102, 126, 234, 0.1);
    padding: 10px;
    margin: -20px -20px 15px -20px;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
}

.stat-label {
    color: #a78bfa;
    font-weight: 400;
}

.stat-value {
    color: #ffffff;
    font-weight: 700;
}

.stat-value.danger {
    color: #ef4444;
    text-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
    animation: pulse 0.5s infinite;
}

.stat-value.warning {
    color: #fbbf24;
    text-shadow: 0 0 5px rgba(251, 191, 36, 0.5);
}

/* Enhanced Action Buttons */

/* Enhanced Modal System */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    /* The dark scrim separates menus without resampling the live full viewport. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal.visible {
    opacity: 1;
    visibility: visible;
    animation: fadeIn 0.3s ease;
}

/* A hidden modal is opacity 0 + visibility hidden, which does NOT stop its CSS animations: the start
   modal's infinite idles (the stage art drift, the mode-card icons, the ascent dots, whose SVG
   transforms also re-lay out) restyled the page every frame of every game, about 2 ms of main thread
   per frame (trace, 2026-10-14). They resume where they were when the modal shows. */
.modal:not(.visible) * {
    animation-play-state: paused !important;
}

/* The floating menu buttons and the player card fade to opacity 0 when not shown (in play): their
   glows and the avatar skeleton's shimmer stop with them. */
.replays-icon:not(.visible) *,
.highscores-icon:not(.visible) *,
.main-menu-player-card:not(.visible) * {
    animation-play-state: paused !important;
}

/* Settings modal must appear above the Serenity Hub (z-index: 2000) */
#settings-modal.visible {
    z-index: 2100;
}

/* Keep the shared modal scrim equally bounded in desktop builds. */
body.electron-app .modal {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.electron-app #settings-modal .modal-content {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.electron-app .modal:not(.visible) .modal-content,
body.electron-app #settings-modal:not(.visible) .modal-content {
    will-change: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg,
            rgba(30, 20, 50, 0.98) 0%,
            rgba(20, 30, 50, 0.98) 50%,
            rgba(25, 20, 45, 0.98) 100%);
    border: 2px solid rgba(139, 92, 246, 0.5);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow:
        0 0 60px rgba(139, 92, 246, 0.4),
        0 0 120px rgba(0, 255, 255, 0.2),
        inset 0 0 80px rgba(139, 92, 246, 0.05);
    color: #e0e7ff;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

/* Glowing corner accents */
.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 20px;
    padding: 2px;
    background: linear-gradient(135deg,
            rgba(0, 255, 255, 0.3) 0%,
            transparent 20%,
            transparent 80%,
            rgba(139, 92, 246, 0.3) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}

/* Subtle scan line effect */
.modal-content::after {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(139, 92, 246, 0.03) 50%,
            transparent 100%);
    animation: scanLine 8s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes scanLine {
    0% {
        top: -100%;
    }

    100% {
        top: 100%;
    }
}

/* Pause scan line animation when modal is hidden to save compositor resources */
.modal:not(.visible) .modal-content::after {
    animation-play-state: paused;
}

/* Coverage is maintained on menu roots by ModalManager, including nested menus.
 * Preserve every animation's phase so uncovering a menu never replays its entrance. */
.menu-covered,
.menu-covered *,
.menu-covered::before,
.menu-covered::after,
.menu-covered *::before,
.menu-covered *::after {
    animation-play-state: paused !important;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal h1 {
    font-family: 'Orbitron', 'Space Mono', monospace;
    font-weight: 900;
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }
}

/* Start Modal Specific */
#start-modal .modal-content {
    border-color: rgba(0, 255, 255, 0.5);
    max-width: 750px;
    width: 90%;
}

#start-modal h1 {
    background: linear-gradient(135deg, #00ffff, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Game Over & Settings Modals */
#game-over-modal .modal-content,
#settings-modal .modal-content {
    border-color: rgba(139, 92, 246, 0.5);
}

#settings-modal .modal-content {
    min-width: 800px;
    max-width: 950px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow:
        0 0 0 1px rgba(139, 92, 246, 0.1),
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(139, 92, 246, 0.15);
    border-radius: 24px;
    box-shadow:
        0 0 0 1px rgba(139, 92, 246, 0.1),
        0 20px 50px rgba(0, 0, 0, 0.6),
        0 0 100px rgba(139, 92, 246, 0.1);
}

/* Settings header with close button */
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding: 32px 40px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), transparent);
}

.settings-header h1 {
    margin: 0;
    flex-shrink: 0;
}

/* Modal close button (red X in corner) */

/* Settings scroll container - desktop */
.settings-scroll-container {
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    margin: 0;
    padding: 0 32px 32px;
}

/* Scrollbar for settings-scroll-container - always auto, only visible when needed */
.settings-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.settings-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.settings-scroll-container::-webkit-scrollbar-thumb {
    background: #8b5cf6;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.5);
}

.settings-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #7c3aed;
}

/* Firefox scrollbar */
.settings-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: #8b5cf6 rgba(0, 0, 0, 0.3);
}

/* Settings modal scroll performance mode */
#settings-modal .settings-scroll-container {
    contain: layout paint;
}

#settings-modal .setting {
    content-visibility: auto;
    contain-intrinsic-size: 56px;
}

#settings-modal.is-scrolling .settings-scroll-container {
    will-change: scroll-position;
}

body.settings-scroll-active #settings-modal .settings-tab,
body.settings-scroll-active #settings-modal .controls-subtab,
body.settings-scroll-active #settings-modal .controls-nav-action,
body.settings-scroll-active #settings-modal .controls-subtab-action,
body.settings-scroll-active #settings-modal .setting,
body.settings-scroll-active #settings-modal .setting-select,
body.settings-scroll-active #settings-modal .key-input {
    transition: none !important;
}

body.settings-scroll-active #settings-modal .settings-tab:hover,
body.settings-scroll-active #settings-modal .controls-subtab:hover,
body.settings-scroll-active #settings-modal .controls-subtab:focus-visible,
body.settings-scroll-active #settings-modal .key-input:hover,
body.settings-scroll-active #settings-modal .setting-select:hover {
    transform: none !important;
}

body.settings-scroll-active #settings-modal .modal-content::after {
    animation-play-state: paused;
}

/* Exempt interactive buttons from scroll transition suppression so
   expandable sections and tab buttons remain responsive during scroll */
body.settings-scroll-active #settings-modal .setting-button,
body.settings-scroll-active #settings-modal .settings-tab {
    transition: background 0.15s ease !important;
    pointer-events: auto !important;
}

body.electron-app #settings-modal.is-scrolling .settings-scroll-container {
    /* contain: strict removed — it changes the containing block and forces
       layout recalculation on every scroll class toggle, causing visible
       flickering and size changes in Electron's compositor. */
    will-change: scroll-position;
}

.settings-scroll-container {
    overscroll-behavior: contain;
}

.desktop-gpu-remediation {
    position: fixed;
    right: 20px;
    bottom: 22px;
    z-index: 2200;
    width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(248, 113, 113, 0.35);
    background: rgba(9, 13, 24, 0.94);
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.42);
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.45;
}

.desktop-gpu-remediation--degraded {
    border-color: rgba(250, 204, 21, 0.45);
}

.desktop-gpu-remediation--unsafe {
    border-color: rgba(248, 113, 113, 0.5);
}

.desktop-gpu-remediation__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.desktop-gpu-remediation__dismiss {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    font-size: 18px;
    cursor: pointer;
}

.desktop-gpu-remediation__status,
.desktop-gpu-remediation__detail,
.desktop-gpu-remediation__meta {
    margin-top: 6px;
}

.desktop-gpu-remediation__steps {
    margin: 10px 0 0 18px;
    padding: 0;
}

#game-over-modal h1,
#settings-modal h1 {
    background: linear-gradient(135deg, #00ffff, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#game-over-modal h1 {
    font-size: 36px;
    margin-bottom: 8px;
    line-height: 1;
}

/* The game-over restart prompt pulses. (This was `.modal p`, which made every
   paragraph in every menu pulse and turn violet.) */
#game-over-modal .modal-content > p {
    font-size: 18px;
    color: #c4b5fd;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Game Over Stats HUD */
.game-over-stats-hud {
    max-width: 850px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 30px;
}

.stats-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px;
    margin: 8px 0;
}

/* Custom scrollbar for stats */
.stats-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.stats-scroll-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.stats-scroll-container::-webkit-scrollbar-thumb {
    background: #8b5cf6;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.5);
}

.stats-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #7c3aed;
}

/* Firefox scrollbar */
.stats-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: #8b5cf6 rgba(0, 0, 0, 0.3);
}

/* Stats Header */
.stats-header {
    text-align: center;
    margin-bottom: 12px;
    position: relative;
}

.score-display {
    font-size: 42px;
    font-weight: 900;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
    margin-bottom: 6px;
    line-height: 1;
}

.ranking-display {
    font-size: 17px;
    font-weight: 700;
    color: #00ffff;
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.stat-badge-gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.stat-badge-purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

/* Stats Grid - 2x2 Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 0 auto;
    width: 100%;
}

/* Stat Cards */
.stat-card {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid;
    border-radius: 10px;
    padding: 10px 12px;
    backdrop-filter: blur(5px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

/* Color-coded card borders and headers */
.stat-card-purple {
    border-color: rgba(139, 92, 246, 0.5);
}

.stat-card-purple:hover {
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.stat-card-purple .stat-card-header {
    color: #a78bfa;
}

.stat-card-cyan {
    border-color: rgba(0, 255, 255, 0.5);
}

.stat-card-cyan:hover {
    box-shadow: 0 4px 20px rgba(0, 255, 255, 0.3);
}

.stat-card-cyan .stat-card-header {
    color: #00ffff;
}

.stat-card-gold {
    border-color: rgba(251, 191, 36, 0.5);
}

.stat-card-gold:hover {
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
}

.stat-card-gold .stat-card-header {
    color: #fbbf24;
}

.stat-card-green {
    border-color: rgba(16, 185, 129, 0.5);
}

.stat-card-green:hover {
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.stat-card-green .stat-card-header {
    color: #10b981;
}

/* Card Header */
.stat-card-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.2;
}

/* Stat Rows */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 13px;
    line-height: 1.3;
}

.stat-label {
    color: rgba(224, 231, 255, 0.7);
    font-weight: 500;
}

.stat-value {
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
}

.stat-comparison {
    font-size: 13px;
}

/* Responsive Design - Tablet */
@media (max-width: 768px) {
    .game-over-stats-hud {
        max-width: 95%;
        padding: 30px 20px;
    }

    .stats-grid {
        gap: 12px;
    }

    .score-display {
        font-size: 40px;
    }

    .ranking-display {
        font-size: 18px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card-header {
        font-size: 13px;
    }

    .stat-row {
        font-size: 13px;
    }

    .stat-value {
        font-size: 15px;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 600px) {
    .game-over-stats-hud {
        max-width: 100%;
        padding: 25px 15px;
        max-height: 90vh;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .score-display {
        font-size: 36px;
    }

    .ranking-display {
        font-size: 16px;
    }

    .stat-badge {
        font-size: 11px;
        padding: 5px 12px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card-header {
        font-size: 12px;
        margin-bottom: 10px;
    }

    .stat-row {
        font-size: 12px;
        padding: 5px 0;
    }

    .stat-value {
        font-size: 14px;
    }

    #game-over-modal h1 {
        font-size: 36px;
    }

    #game-over-modal .modal-content > p {
        font-size: 16px;
    }
}

/* Very Small Mobile Devices */
@media (max-width: 400px) {
    .score-display {
        font-size: 32px;
    }

    .stat-card-header {
        font-size: 11px;
    }

    .stat-row {
        font-size: 11px;
    }

    .stat-value {
        font-size: 13px;
    }

    #game-over-modal h1 {
        font-size: 28px;
    }
}

.settings-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px;
    margin: 0 40px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

#settings-modal h1 {
    flex-shrink: 0;
    font-size: 32px;
    letter-spacing: 0.02em;
    margin: 0;
    font-weight: 800;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.settings-tab {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(224, 231, 255, 0.6);
    padding: 10px 24px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Space Mono', monospace;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.settings-tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.settings-tab.active {
    color: #ffffff;
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
}



.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

/* Controls layout & navigation */
.controls-layout {
    display: grid;
    grid-template-columns: minmax(220px, 260px) 1fr;
    gap: 24px;
    align-items: flex-start;
}

.controls-nav {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.controls-nav-group {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.controls-nav-heading {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(224, 231, 255, 0.6);
}

.controls-subtabs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.controls-subtab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(224, 231, 255, 0.65);
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Space Mono', monospace;
    transition: all 0.2s ease;
    border-radius: 12px;
    text-align: left;
}

.controls-subtab:hover,
.controls-subtab:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.controls-subtab.active {
    color: #ffffff;
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.controls-subtab-icon {
    flex-shrink: 0;
}

.controls-subtab-label {
    flex: 1;
}

.controls-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.6);
    box-shadow: 0 0 8px rgba(148, 163, 184, 0.4);
}

.controls-status-dot.connected {
    background: #34d399;
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.6);
}

.controls-status-dot.controller-1.connected {
    background: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.controls-status-dot.controller-2.connected {
    background: #a78bfa;
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.6);
}

.controls-status-dot.controller-3.connected {
    background: #fbbf24;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

.controls-status-dot.controller-4.connected {
    background: #f472b6;
    box-shadow: 0 0 12px rgba(244, 114, 182, 0.6);
}

.controls-content {
    min-height: 100%;
}

.controls-nav-action {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.25), rgba(129, 140, 248, 0.25));
    border: 1px solid rgba(129, 140, 248, 0.4);
    color: #e0f2fe;
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.controls-nav-action.ghost {
    background: transparent;
    border: 1px dashed rgba(129, 140, 248, 0.4);
    color: rgba(224, 231, 255, 0.75);
}

.controls-nav-action:hover,
.controls-nav-action:focus-visible {
    color: #f0f9ff;
    border-color: rgba(94, 234, 212, 0.7);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.2);
}

.controls-subtab-content {
    display: none;
}

.controls-subtab-content.active {
    display: block;
}

.controls-helper-card {
    background: rgba(17, 24, 39, 0.55);
    border: 1px solid rgba(129, 140, 248, 0.25);
    border-radius: 14px;
    padding: 18px 20px;
    margin-top: 24px;
    color: rgba(224, 231, 255, 0.8);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.08);
}

.controls-helper-card h5 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: #c4b5fd;
}

.controls-helper-card p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.controls-subtab-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}

.controls-subtab-action {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(167, 139, 250, 0.2));
    border: 1px solid rgba(129, 140, 248, 0.35);
    color: rgba(224, 231, 255, 0.9);
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.controls-subtab-action:hover,
.controls-subtab-action:focus-visible {
    color: #f0f9ff;
    border-color: rgba(94, 234, 212, 0.7);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}

@media (max-width: 960px) {
    .controls-layout {
        grid-template-columns: 1fr;
    }

    .controls-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    .controls-nav-group {
        flex: 1 1 260px;
    }
}

.controls-subtab-content {
    display: none;
}

.controls-subtab-content.active {
    display: block;
}

/* Serenity Mode Controls Styling */

.controls-section {
    margin-bottom: 35px;
    padding: 20px;
    background: rgba(139, 92, 246, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.controls-section-title {
    color: #c4b5fd;
    font-size: 16px;
    margin: 0 0 20px 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-input.readonly {
    opacity: 0.9;
    cursor: default;
    background: rgba(0, 0, 0, 0.3);
}

.key-input.readonly:hover {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(0, 0, 0, 0.3);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 20px 0;
    width: 100%;
}

.setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-radius: 12px;
    transition: background 0.2s ease;
}

.setting:hover {
    background: rgba(255, 255, 255, 0.04);
}

.setting label {
    flex: 1;
    text-align: left;
    font-size: 15px;
    color: rgba(224, 231, 255, 0.9);
    font-weight: 500;
    padding-right: 24px;
}

/* Enhanced Input Styling */
.key-input,
.setting-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #e0e7ff;
    padding: 12px 16px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
    width: 260px;
    /* Fixed width for alignment */
    flex-shrink: 0;
    justify-self: end;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.key-input:hover,
.setting-select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
}

.key-input:focus,
.setting-select:focus {
    outline: none;
    background: rgba(15, 23, 42, 0.8);
    border-color: #00ffff;
    box-shadow:
        0 0 0 4px rgba(0, 255, 255, 0.15),
        0 0 20px rgba(0, 255, 255, 0.1);
}

.key-input {
    text-align: center;
    font-weight: 600;
}

.setting-select {
    text-align: left;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23c4b5fd' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.key-input.listening {
    border-color: rgba(251, 191, 36, 0.8);
    background: rgba(251, 191, 36, 0.1);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
    animation: listeningPulse 1.5s ease-in-out infinite;
}

@keyframes listeningPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
    }

    50% {
        box-shadow: 0 0 30px rgba(251, 191, 36, 0.6);
    }
}

/* Enhanced Slider Styling */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
    width: 340px;
    /* Fixed width for alignment */
    flex-shrink: 0;
    justify-self: end;
}

.slider-container span {
    min-width: 45px;
    text-align: center;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: #00ffff;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 13px;
    white-space: nowrap;
}

/* Render Quality slider - needs more space for longer labels */
#render-quality-value {
    min-width: 130px;
    padding: 6px 12px;
    font-size: 12px;
}

.slider-container input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    cursor: pointer;
    background: transparent;
}

.slider-container input[type=range]::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    height: 6px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.slider-container input[type=range]:hover::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.15);
}

.slider-container input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -7px;
    background: #00ffff;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    border: 2px solid rgba(15, 23, 42, 0.5);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-container input[type=range]::-webkit-slider-thumb:hover {
    background: #ffffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
    transform: scale(1.2);
}

.slider-container input[type=range]::-moz-range-track {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(139, 92, 246, 0.3);
    height: 8px;
    border-radius: 6px;
}

.slider-container input[type=range]::-moz-range-thumb {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    height: 18px;
    width: 18px;
    border-radius: 50%;
    border: 2px solid rgba(167, 139, 253, 0.5);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
    cursor: pointer;
}

#piece-lock-ripple-color {
    position: absolute;
    inset: 0;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.setting-button {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    color: #e0e7ff;
    padding: 12px 16px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
    max-width: 300px;
    width: 100%;
    transition: all 0.3s ease;
    text-align: center;
}

.setting-button:hover {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(0, 0, 0, 0.5);
}

.setting-button:active {
    border-color: rgba(139, 92, 246, 0.8);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.setting-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.score-popup {
    position: absolute;
    color: #fbbf24;
    font-weight: bold;
    font-size: 24px;
    pointer-events: none;
    animation: scorePop 1s ease-out forwards;
}

@keyframes scorePop {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -150%) scale(1.5);
        opacity: 0;
    }
}

.combo-popup {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%) scale(var(--combo-scale, 1));
    color: var(--combo-color, #22d3ee);
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(28px, 2.4vw, 42px);
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    pointer-events: none;
    filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.65));
    animation: comboPop 1.1s ease-out forwards;
}

@keyframes comboPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -20%) scale(calc(var(--combo-scale, 1) * 0.85));
    }

    25% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(calc(var(--combo-scale, 1) * 1.1));
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -130%) scale(calc(var(--combo-scale, 1) * 1.05));
    }
}

.line-flash {
    animation: flash 0.5s ease;
}

@keyframes flash {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(2);
    }
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
        align-items: flex-start;
        padding: 10px;
        padding-bottom: env(safe-area-inset-bottom);
        /* Add safe area padding */
    }

    .game-container {
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 15px;
        padding: 0;
    }

    /* Keep multiplayer in horizontal layout even on small screens */
    .multiplayer-container.multiplayer-container {
        flex-direction: row !important;
        overflow-x: auto;
    }

    .game-area {
        order: -1;
        /* Game area at the top */
    }

    .next-pieces-container {
        flex-wrap: wrap;
        justify-content: center;
        max-width: 100%;
        padding: 8px;
        gap: 8px;
        min-height: 600px;
        /* Visible playing field: ROWS * BLOCK_SIZE = 20 * 30 = 600px */
        border-width: 2px;
    }

    .next-piece-box.main {
        transform: none;
        margin-right: 0;
    }

    .sidebar {
        order: 1;
        /* Sidebar at the bottom */
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-template-areas:
            "stats stats stats stats"
            "btn1  btn2  btn3  btn4";
        gap: 10px;
    }

    .sidebar .panel {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .sidebar .panel:nth-of-type(1) {
        grid-area: stats;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-around;
        background: rgba(0, 0, 0, 0.6);
        border: 2px solid #8b5cf6;
        border-radius: 12px;
        padding: 5px;
    }

    .sidebar .panel:nth-of-type(2) {
        display: none;
        /* Hide controls panel on mobile */
    }

    .sidebar .panel h2 {
        display: none;
    }

    .stat-row {
        font-size: 12px;
        flex: 1 1 auto;
        padding: 5px;
        text-align: center;
        display: flex;
        flex-direction: column;
        gap: 4px;
        margin-bottom: 0;
        /* Override default margin */
    }

    .stat-label {
        font-size: 10px;
        order: 1;
    }

    #next-track-btn {
        grid-area: btn2;
    }

    #fullscreen-toggle {
        grid-area: btn3;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
        max-height: 85dvh;
        display: flex;
        flex-direction: column;
    }

    .modal h1 {
        font-size: 36px;
        flex-shrink: 0;
        /* Prevent title from shrinking */
    }

    /* Mobile-specific adjustments for scroll container */
    .settings-scroll-container {
        padding-right: 15px;
        /* More space for scrollbar on mobile */
        -webkit-overflow-scrolling: touch;
        /* Momentum scrolling for iOS */
    }

    /* Mobile close button - slightly larger touch target */

    #game-over-modal .modal-content > p {
        font-size: 16px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .setting label {
        justify-self: start;
        font-size: 14px;
    }

    .key-input,
    .setting-select,
    .slider-container {
        width: 100%;
        justify-self: start;
    }

    .key-input,
    .setting-select {
        padding: 12px;
        font-size: 16px;
    }

    /* Mobile Serenity Controls */
    .controls-subtabs {
        gap: 5px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .controls-subtab {
        padding: 8px 12px;
        font-size: 11px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .controls-section {
        padding: 15px;
        margin-bottom: 20px;
    }

    .controls-section-title {
        font-size: 14px;
        margin-bottom: 15px;
    }
}

/* --- Fluid Dreams Theme --- */
/* The dreaming sea is drawn entirely on the theme's own canvas; this is only the colour behind it. */
#fluid-dreams-theme {
    background: #04020c;
    overflow: hidden;
}

/* --- Crystal Cave Theme --- */
/* The cave is drawn entirely on the theme's own canvas; this is only the colour behind it. */
#crystal-cave-theme {
    background: #020308;
    overflow: hidden;
}

/* --- Candlelit Monastery Theme --- */
#wolfhour-theme {
    background: transparent;
    overflow: hidden;
}

#wolfhour-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #080808;
    z-index: 1;
}

#wolfhour-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.wolfhour-star {
    position: absolute;
    background: #e0e0e0;
    box-shadow: 0 0 2px rgba(220, 220, 220, 0.8);
    border-radius: 50%;
    animation: wolfhour-twinkle var(--twinkle-duration, 3s) ease-in-out infinite;
    animation-delay: var(--twinkle-delay, 0s);
    will-change: opacity;
}

@keyframes wolfhour-twinkle {

    0%,
    100% {
        opacity: var(--min-opacity, 0.3);
    }

    50% {
        opacity: var(--max-opacity, 1);
    }
}

.wolfhour-shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 0 4px 2px rgba(255, 255, 255, 0.8);
    animation: wolfhour-shoot var(--shoot-duration, 2s) linear;
    z-index: 3;
    will-change: transform, opacity;
}

@keyframes wolfhour-shoot {
    from {
        transform: translate(0, 0) translateZ(0);
        opacity: 1;
    }

    to {
        transform: translate(var(--shoot-x, -200px), var(--shoot-y, 200px)) translateZ(0);
        opacity: 0;
    }
}

#wolfhour-nebula-back,
#wolfhour-nebula-mid {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    opacity: 0.4;
    z-index: 3;
    animation: wolfhour-nebula-drift linear infinite;
    background-repeat: repeat-x;
    background-size: 2000px 100%;
    will-change: transform;
    transform: translateZ(0);
}

#wolfhour-nebula-back {
    animation-duration: 180s;
    opacity: 0.3;
}

#wolfhour-nebula-mid {
    animation-duration: 120s;
    opacity: 0.5;
    z-index: 4;
}

@keyframes wolfhour-nebula-drift {
    from {
        transform: translateX(0) translateZ(0);
    }

    to {
        transform: translateX(-50%) translateZ(0);
    }
}

#wolfhour-mountains-distant {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 60%;
    z-index: 5;
    animation: wolfhour-parallax-slow 200s linear infinite;
    background-repeat: repeat-x;
    background-position: bottom;
    opacity: 0.6;
    will-change: transform;
    transform: translateZ(0);
}

#wolfhour-mountains-fore {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 50%;
    z-index: 7;
    animation: wolfhour-parallax-fast 100s linear infinite;
    background-repeat: repeat-x;
    background-position: bottom;
    opacity: 0.9;
    will-change: transform;
    transform: translateZ(0);
}

@keyframes wolfhour-parallax-slow {
    from {
        transform: translateX(0) translateZ(0);
    }

    to {
        transform: translateX(-50%) translateZ(0);
    }
}

@keyframes wolfhour-parallax-fast {
    from {
        transform: translateX(0) translateZ(0);
    }

    to {
        transform: translateX(-50%) translateZ(0);
    }
}

#wolfhour-fog {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 30%;
    background: linear-gradient(to top, rgba(120, 120, 120, 0.15) 0%, transparent 100%);
    z-index: 6;
    animation: wolfhour-fog-drift 80s linear infinite;
    will-change: transform;
    transform: translateZ(0);
}

@keyframes wolfhour-fog-drift {
    from {
        transform: translateX(0) translateZ(0);
    }

    to {
        transform: translateX(-50%) translateZ(0);
    }
}

#wolfhour-grain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    z-index: 10;
    pointer-events: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" /></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.5"/></svg>');
    animation: wolfhour-grain-shift 2s steps(4) infinite;
    will-change: transform;
}

@keyframes wolfhour-grain-shift {

    0%,
    100% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-2px, 2px);
    }

    50% {
        transform: translate(2px, -2px);
    }

    75% {
        transform: translate(-2px, -2px);
    }
}

/* Mystical light rays from sky */
#wolfhour-light-rays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.wolfhour-light-ray {
    position: absolute;
    top: -20%;
    width: 2px;
    height: 120%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(200, 200, 200, 0.15) 20%,
            rgba(180, 180, 180, 0.1) 50%,
            transparent 100%);
    transform-origin: top center;
    animation: wolfhour-ray-sway var(--ray-duration, 8s) ease-in-out infinite;
    animation-delay: var(--ray-delay, 0s);
    filter: blur(1px);
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes wolfhour-ray-sway {

    0%,
    100% {
        transform: rotate(var(--ray-angle-start, 0deg)) translateX(0) translateZ(0);
        opacity: 0.3;
    }

    50% {
        transform: rotate(var(--ray-angle-end, 3deg)) translateX(10px) translateZ(0);
        opacity: 0.6;
    }
}

/* Cosmic rifts - glowing cracks in space */
#wolfhour-cosmic-rifts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    pointer-events: none;
}

.wolfhour-cosmic-rift {
    position: absolute;
    width: 1px;
    height: var(--rift-length, 150px);
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(220, 220, 220, 0.4) 30%,
            rgba(200, 200, 200, 0.6) 50%,
            rgba(220, 220, 220, 0.4) 70%,
            transparent 100%);
    box-shadow: 0 0 10px rgba(200, 200, 200, 0.5),
        0 0 20px rgba(200, 200, 200, 0.3);
    animation: wolfhour-rift-pulse var(--rift-duration, 4s) ease-in-out infinite;
    animation-delay: var(--rift-delay, 0s);
    filter: blur(0.5px);
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes wolfhour-rift-pulse {

    0%,
    100% {
        opacity: 0.2;
        transform: scaleY(0.8) translateZ(0);
    }

    50% {
        opacity: 0.7;
        transform: scaleY(1.2) translateZ(0);
    }
}

/* Ethereal spirits floating */
#wolfhour-spirits {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: none;
}

.wolfhour-spirit {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle at center,
            rgba(255, 255, 255, 0.4) 0%,
            rgba(200, 200, 200, 0.2) 50%,
            transparent 100%);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3),
        0 0 30px rgba(200, 200, 200, 0.2);
    animation: wolfhour-spirit-float var(--spirit-duration, 20s) ease-in-out infinite;
    animation-delay: var(--spirit-delay, 0s);
    filter: blur(2px);
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes wolfhour-spirit-float {
    0% {
        transform: translate(var(--spirit-x-start, 0), var(--spirit-y-start, 0)) scale(0.8) translateZ(0);
        opacity: 0;
    }

    10% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.7;
        transform: translate(var(--spirit-x-mid, 50px), var(--spirit-y-mid, -100px)) scale(1.2) translateZ(0);
    }

    90% {
        opacity: 0.5;
    }

    100% {
        transform: translate(var(--spirit-x-end, 100px), var(--spirit-y-end, -200px)) scale(0.8) translateZ(0);
        opacity: 0;
    }
}

/* --- Lunara Theme --- */
/* --- Luminous Tides Theme (the glowing shore: a WebGPU canvas, src/themes/luminous-tides/) --- */
#luminous-tides-theme {
    background: #03050c;
    overflow: hidden;
}

#lunara-theme {
    background: transparent;
    overflow: hidden;
}

/* --- Solar Eclipse Theme (Three.js 3D) --- */
#solar-eclipse-theme {
    background: #000000;
    overflow: hidden;
}

#solar-eclipse-theme canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* --- Sunfall Theme (WebGPU) --- */
#sunfall-theme {
    background: #5d8087;
    overflow: hidden;
}

/* --- Black Hole Theme --- */
#black-hole-theme {
    background: transparent;
    overflow: hidden;
    contain: layout style paint;
    /* CSS containment for better performance */
}

/* Deep space background */
#stellar-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 50%,
            #0a0515 0%,
            #050210 30%,
            #020108 60%,
            #000000 100%);
    z-index: 1;
    contain: strict;
    /* Strict containment for static background */
}

/* Nebula Cloud Layers - Optimized blur for performance */
.stellar-nebula-cloud {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    /* Reduced from 60px for better performance */
    mix-blend-mode: screen;
    opacity: 0.7;
    pointer-events: none;
    will-change: transform;
    /* GPU acceleration hint */
    transform: translateZ(0);
    /* Force GPU compositing */
}

/* Pink/Magenta nebula (upper right) */
#stellar-nebula-layer-1 {
    top: 10%;
    right: 10%;
    width: 600px;
    height: 500px;
    background: radial-gradient(ellipse,
            rgba(255, 100, 180, 0.75) 0%,
            rgba(255, 120, 200, 0.55) 20%,
            rgba(240, 80, 160, 0.35) 45%,
            rgba(220, 60, 140, 0.18) 70%,
            transparent 100%);
    z-index: 2;
    animation: stellar-nebula-drift-1 40s ease-in-out infinite alternate;
}

@keyframes stellar-nebula-drift-1 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-30px, 20px) scale(1.05);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

/* Cyan/Blue nebula (left side) */
#stellar-nebula-layer-2 {
    top: 20%;
    left: 5%;
    width: 550px;
    height: 600px;
    background: radial-gradient(ellipse,
            rgba(80, 180, 255, 0.7) 0%,
            rgba(120, 200, 255, 0.5) 25%,
            rgba(60, 160, 240, 0.3) 50%,
            rgba(40, 140, 220, 0.15) 75%,
            transparent 100%);
    z-index: 2;
    animation: stellar-nebula-drift-2 45s ease-in-out infinite alternate;
}

@keyframes stellar-nebula-drift-2 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    50% {
        transform: translate(20px, -30px) scale(1.08) rotate(3deg);
    }

    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
}

/* Orange/Coral nebula (center right) */
#stellar-nebula-layer-3 {
    top: 40%;
    right: 20%;
    width: 500px;
    height: 450px;
    background: radial-gradient(ellipse,
            rgba(255, 150, 80, 0.7) 0%,
            rgba(255, 170, 100, 0.5) 25%,
            rgba(240, 130, 60, 0.3) 50%,
            rgba(220, 110, 40, 0.15) 75%,
            transparent 100%);
    z-index: 3;
    animation: stellar-nebula-drift-3 50s ease-in-out infinite alternate;
}

@keyframes stellar-nebula-drift-3 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(25px, 25px) scale(1.06);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

/* Purple/Violet nebula (lower center) - Hidden on low-power mode for performance */
#stellar-nebula-layer-4 {
    bottom: 15%;
    left: 30%;
    width: 480px;
    height: 520px;
    background: radial-gradient(ellipse,
            rgba(180, 100, 255, 0.7) 0%,
            rgba(200, 130, 255, 0.5) 25%,
            rgba(160, 80, 240, 0.3) 50%,
            rgba(140, 60, 220, 0.15) 75%,
            transparent 100%);
    z-index: 2;
    animation: stellar-nebula-drift-4 48s ease-in-out infinite alternate;
}

/* Hide nebula layer 4 on lower power devices */
@media (prefers-reduced-motion: reduce),
(max-width: 768px) {
    #stellar-nebula-layer-4 {
        display: none;
    }
}

@keyframes stellar-nebula-drift-4 {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    50% {
        transform: translate(-20px, 15px) scale(1.07) rotate(-2deg);
    }

    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
}

/* Teal/Aqua nebula (top center) - Hidden on low-power mode for performance */
#stellar-nebula-layer-5 {
    top: 5%;
    left: 40%;
    width: 420px;
    height: 380px;
    background: radial-gradient(ellipse,
            rgba(100, 220, 255, 0.65) 0%,
            rgba(140, 230, 255, 0.45) 25%,
            rgba(80, 200, 240, 0.25) 50%,
            rgba(60, 180, 220, 0.12) 75%,
            transparent 100%);
    z-index: 2;
    animation: stellar-nebula-drift-5 42s ease-in-out infinite alternate;
}

/* Hide nebula layer 5 on lower power devices or when performance is critical */
@media (prefers-reduced-motion: reduce),
(max-width: 768px) {
    #stellar-nebula-layer-5 {
        display: none;
    }
}

@keyframes stellar-nebula-drift-5 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(15px, -20px) scale(1.05);
    }

    100% {
        transform: translate(0, 0) scale(1);
    }
}

/* Black Hole */
#stellar-black-hole {
    position: absolute;
    top: 50%;
    left: 35%;
    width: 300px;
    height: 300px;
    margin-top: -150px;
    margin-left: -150px;
    z-index: 4;
    pointer-events: none;
    contain: layout style;
    /* Containment for better layer optimization */
}

/* Event Horizon (the black center) */
.black-hole-event-horizon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin-top: -60px;
    margin-left: -60px;
    background: radial-gradient(circle,
            rgba(0, 0, 0, 1) 0%,
            rgba(5, 5, 10, 0.95) 60%,
            rgba(10, 10, 15, 0.8) 80%,
            transparent 100%);
    border-radius: 50%;
    z-index: 4;
    animation: black-hole-pulse 8s ease-in-out infinite;
}

@keyframes black-hole-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow:
            0 0 30px rgba(0, 0, 0, 0.8),
            inset 0 0 20px rgba(0, 0, 0, 1);
    }

    50% {
        transform: scale(1.05);
        box-shadow:
            0 0 40px rgba(0, 0, 0, 0.9),
            inset 0 0 25px rgba(0, 0, 0, 1);
    }
}

/* Accretion Disk - Optimized for performance */
.black-hole-accretion-disk {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 280px;
    height: 280px;
    margin-top: -140px;
    margin-left: -140px;
    background: conic-gradient(from 0deg,
            rgba(255, 150, 80, 0.6) 0deg,
            rgba(255, 100, 180, 0.5) 60deg,
            rgba(80, 180, 255, 0.4) 120deg,
            rgba(180, 100, 255, 0.5) 180deg,
            rgba(255, 170, 100, 0.6) 240deg,
            rgba(100, 220, 255, 0.4) 300deg,
            rgba(255, 150, 80, 0.6) 360deg);
    border-radius: 50%;
    z-index: 2;
    clip-path: ellipse(50% 15% at 50% 50%);
    transform-origin: center center;
    animation: black-hole-accretion-spin 20s linear infinite;
    filter: blur(2px);
    /* Reduced from 3px */
    will-change: transform;
    transform: translateZ(0);
}

@keyframes black-hole-accretion-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Accretion Disk Glow - Optimized blur */
.black-hole-accretion-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    margin-top: -150px;
    margin-left: -150px;
    background: radial-gradient(ellipse 50% 20% at 50% 50%,
            rgba(255, 180, 120, 0.4) 0%,
            rgba(255, 150, 180, 0.3) 30%,
            rgba(180, 150, 255, 0.2) 60%,
            transparent 100%);
    border-radius: 50%;
    z-index: 1;
    animation: black-hole-glow-pulse 6s ease-in-out infinite alternate;
    filter: blur(10px);
    /* Reduced from 15px */
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes black-hole-glow-pulse {
    0% {
        opacity: 0.6;
        transform: scale(1) rotate(0deg);
    }

    100% {
        opacity: 0.9;
        transform: scale(1.1) rotate(10deg);
    }
}

/* Gravitational Lensing Effect */
.black-hole-gravitational-lens {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    margin-top: -100px;
    margin-left: -100px;
    border-radius: 50%;
    z-index: 3;
    animation: gravitational-lens-distort 10s ease-in-out infinite;
}

.black-hole-gravitational-lens::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: rgba(255, 200, 150, 0.3);
    border-right-color: rgba(180, 150, 255, 0.25);
    border-bottom-color: rgba(100, 220, 255, 0.2);
    border-left-color: rgba(255, 150, 180, 0.25);
    animation: lens-ring-rotate 15s linear infinite;
    filter: blur(1px);
    /* Reduced from 2px */
    will-change: transform;
}

.black-hole-gravitational-lens::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
    border-radius: 50%;
    border: 1px solid transparent;
    border-top-color: rgba(255, 150, 80, 0.2);
    border-right-color: rgba(255, 100, 180, 0.15);
    border-bottom-color: rgba(80, 180, 255, 0.15);
    border-left-color: rgba(200, 130, 255, 0.2);
    animation: lens-ring-rotate 12s linear infinite reverse;
    /* Removed blur(1px) - minimal impact, better performance */
    will-change: transform;
}

@keyframes gravitational-lens-distort {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.08) rotate(5deg);
        opacity: 1;
    }
}

@keyframes lens-ring-rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Star Field */
#stellar-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
}

.stellar-star {
    position: absolute;
    border-radius: 50%;
    animation: stellar-star-twinkle 6s ease-in-out infinite;
    will-change: opacity, transform;
}

.stellar-star-bright {
    animation: stellar-star-bright-pulse 4s ease-in-out infinite;
}

@keyframes stellar-star-twinkle {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Removed expensive filter: brightness() for performance */
@keyframes stellar-star-bright-pulse {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.5);
    }
}

/* Stardust Canvas */
#stellar-stardust-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
    mix-blend-mode: screen;
    contain: strict;
    /* Strict containment for canvas */
}

/* Star Bursts */
#stellar-bursts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 7;
    pointer-events: none;
}

.stellar-star-burst {
    position: absolute;
    width: 150px;
    height: 150px;
    margin-left: -75px;
    margin-top: -75px;
    background: radial-gradient(circle,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(200, 220, 255, 0.6) 20%,
            rgba(255, 200, 180, 0.3) 40%,
            transparent 70%);
    border-radius: 50%;
    animation: stellar-burst-expand 1.5s ease-out forwards;
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes stellar-burst-expand {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: scale(3) rotate(180deg);
        opacity: 0;
    }
}

/* Supernova Effect */
#stellar-supernova {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: none;
}

.stellar-supernova {
    position: absolute;
    width: 400px;
    height: 400px;
    margin-left: -200px;
    margin-top: -200px;
    animation: stellar-supernova-explosion 2.5s ease-out forwards;
}

@keyframes stellar-supernova-explosion {
    0% {
        background: radial-gradient(circle,
                rgba(255, 255, 255, 1) 0%,
                rgba(200, 220, 255, 0.9) 10%,
                rgba(255, 200, 180, 0.7) 20%,
                rgba(255, 150, 200, 0.5) 35%,
                transparent 50%);
        transform: scale(0);
        opacity: 1;
    }

    20% {
        background: radial-gradient(circle,
                rgba(255, 255, 255, 1) 0%,
                rgba(200, 220, 255, 0.95) 15%,
                rgba(255, 200, 180, 0.8) 30%,
                rgba(255, 150, 200, 0.6) 45%,
                transparent 60%);
        opacity: 1;
    }

    100% {
        background: radial-gradient(circle,
                rgba(255, 255, 255, 0.3) 0%,
                rgba(200, 220, 255, 0.2) 20%,
                rgba(255, 200, 180, 0.1) 40%,
                transparent 70%);
        transform: scale(4);
        opacity: 0;
    }
}

/* Bright star cluster effect - Optimized */
.stellar-star-cluster {
    position: absolute;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(220, 235, 255, 0.6) 25%,
            rgba(200, 220, 255, 0.3) 50%,
            transparent 75%);
    border-radius: 50%;
    filter: blur(2px);
    /* Reduced from 3px */
    animation: stellar-cluster-glow 8s ease-in-out infinite;
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* Removed expensive filter animations for better performance */
@keyframes stellar-cluster-glow {

    0%,
    100% {
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Gravitational Wave Effect - Optimized */
.gravitational-wave {
    position: absolute;
    width: 300px;
    height: 300px;
    margin-left: -150px;
    margin-top: -150px;
    border: 3px solid rgba(255, 200, 150, 0.7);
    border-radius: 50%;
    box-shadow:
        0 0 15px rgba(255, 200, 150, 0.5),
        inset 0 0 15px rgba(255, 200, 150, 0.3);
    /* Reduced blur for performance */
    animation: gravitational-wave-expand 2s ease-out forwards;
    pointer-events: none;
    will-change: transform, opacity;
    transform: translateZ(0);
}

@keyframes gravitational-wave-expand {
    0% {
        transform: scale(0);
        opacity: 1;
        border-width: 3px;
    }

    50% {
        opacity: 0.8;
        border-width: 2px;
    }

    100% {
        transform: scale(4);
        opacity: 0;
        border-width: 1px;
    }
}

/* --- Supernova Theme --- */
/* The star and its nebula are drawn entirely on the theme's own canvas; this is only the colour behind it. */
#supernova-theme {
    background: #020006;
    overflow: hidden;
}

/* --- Cosmic Noir Theme --- */
/* The smoke, the lantern and the print are drawn entirely on the theme's own canvas; this is only the black behind it. */
#cosmic-noir-theme {
    background: #020202;
    overflow: hidden;
    contain: layout style paint;
}

/* === NIMBUS VEIL THEME === */
/* What shows for the moment before the scene's first frame: the first hour's sky over its deck. */
#nimbus-veil-theme {
    background: linear-gradient(180deg,
            #2b4f9e 0%,
            #a39cd0 34%,
            #ffcb92 56%,
            #f1c9c0 72%,
            #cdb6d6 100%);
    overflow: hidden;
}

/* === PYRESTORM THEME === */
#pyrestorm-theme {
    background: transparent;
    overflow: hidden;
}

/* Layer 1 - Sky */
#pyrestorm-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            #1a0000 0%,
            #3d0a0a 20%,
            #5c1010 40%,
            #8b1a1a 60%,
            #c44000 80%,
            #ff6b1a 100%);
    z-index: 1;
    animation: pyrestorm-sky-flicker 8s ease-in-out infinite;
}

@keyframes pyrestorm-sky-flicker {

    0%,
    100% {
        filter: brightness(1) contrast(1);
        opacity: 1;
    }

    15% {
        filter: brightness(1.3) contrast(1.1);
    }

    18% {
        filter: brightness(1) contrast(1);
    }

    45% {
        filter: brightness(1.2) contrast(1.05);
    }

    47% {
        filter: brightness(1) contrast(1);
    }

    70% {
        filter: brightness(1.4) contrast(1.15);
    }

    73% {
        filter: brightness(1) contrast(1);
    }
}

/* Layer 2 - Volcano Peaks */
#pyrestorm-volcano-peaks {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.pyrestorm-volcano {
    position: absolute;
    bottom: 0;
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-bottom: 400px solid #0a0000;
    filter: drop-shadow(0 0 30px rgba(255, 100, 0, 0.5));
}

.pyrestorm-volcano-crack {
    position: absolute;
    width: 2px;
    background: linear-gradient(to bottom,
            rgba(255, 200, 0, 0.9) 0%,
            rgba(255, 100, 0, 0.7) 50%,
            rgba(200, 50, 0, 0) 100%);
    box-shadow: 0 0 10px rgba(255, 150, 0, 0.8);
    animation: pyrestorm-crack-pulse 3s ease-in-out infinite;
}

@keyframes pyrestorm-crack-pulse {

    0%,
    100% {
        opacity: 0.6;
        filter: brightness(1);
    }

    50% {
        opacity: 1;
        filter: brightness(1.5);
    }
}

.pyrestorm-eruption {
    position: absolute;
    width: 50px;
    height: 200px;
    background: radial-gradient(ellipse at bottom,
            rgba(255, 200, 0, 0.9) 0%,
            rgba(255, 100, 0, 0.6) 40%,
            rgba(200, 50, 0, 0.2) 70%,
            transparent 100%);
    filter: blur(8px);
    opacity: 0;
    animation: pyrestorm-eruption var(--eruption-duration, 8s) ease-out infinite;
    animation-delay: var(--eruption-delay, 0s);
}

@keyframes pyrestorm-eruption {

    0%,
    90%,
    100% {
        opacity: 0;
        transform: translateY(0) scale(1);
    }

    5% {
        opacity: 0.9;
        transform: translateY(-100px) scale(1.5);
    }

    20% {
        opacity: 0.6;
        transform: translateY(-200px) scale(2);
    }

    40% {
        opacity: 0.3;
        transform: translateY(-250px) scale(2.5);
    }
}

/* Layer 3 - Lava Rivers */
#pyrestorm-lava-rivers {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 85%;
    z-index: 2.5;
    pointer-events: none;
}

.pyrestorm-lava-river {
    position: absolute;
    width: 150px;
    height: 100%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(255, 150, 0, 0.2) 40%,
            rgba(255, 100, 0, 0.6) 60%,
            rgba(255, 200, 0, 0.9) 80%,
            rgba(255, 220, 0, 1) 100%);
    filter: blur(5px);
    opacity: 0.9;
    animation: pyrestorm-lava-flow var(--flow-speed, 15s) linear infinite;
}

.pyrestorm-lava-splash {
    position: absolute;
    width: 20px;
    height: 30px;
    background: radial-gradient(ellipse,
            rgba(255, 220, 0, 1) 0%,
            rgba(255, 150, 0, 0.8) 50%,
            transparent 100%);
    filter: blur(3px);
    opacity: 0;
    animation: pyrestorm-lava-splash var(--splash-duration, 3s) ease-out infinite;
    animation-delay: var(--splash-delay, 0s);
}

@keyframes pyrestorm-lava-flow {
    from {
        transform: translateY(0);
        opacity: 0.9;
    }

    to {
        transform: translateY(50px);
        opacity: 0.8;
    }
}

@keyframes pyrestorm-lava-splash {

    0%,
    90%,
    100% {
        opacity: 0;
        transform: translateY(0) scale(1);
    }

    10% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }

    40% {
        opacity: 0.6;
        transform: translateY(-15px) scale(0.8);
    }
}

/* Layer 4 - Foreground Rocks */
#pyrestorm-foreground-rocks {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 4;
    pointer-events: none;
}

.pyrestorm-rock {
    position: absolute;
    bottom: 0;
    background: #050000;
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    filter: drop-shadow(0 0 20px rgba(255, 100, 0, 0.4));
}

.pyrestorm-rock-crack {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right,
            transparent 0%,
            rgba(255, 180, 0, 0) 20%,
            rgba(255, 180, 0, 0.8) 50%,
            rgba(255, 180, 0, 0) 80%,
            transparent 100%);
    box-shadow: 0 0 15px rgba(255, 150, 0, 0.6);
    animation: pyrestorm-rock-crack-pulse var(--crack-duration, 4s) ease-in-out infinite;
    animation-delay: var(--crack-delay, 0s);
}

@keyframes pyrestorm-rock-crack-pulse {

    0%,
    100% {
        opacity: 0.5;
        filter: brightness(1);
    }

    50% {
        opacity: 1;
        filter: brightness(1.8);
    }
}

/* Layer 5 - Atmospheric Overlay */
#pyrestorm-embers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.pyrestorm-ember {
    position: absolute;
    width: 3px;
    height: 3px;
    background: radial-gradient(circle,
            rgba(255, 220, 0, 1) 0%,
            rgba(255, 150, 0, 0.8) 50%,
            transparent 100%);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 180, 0, 0.8);
    opacity: 0;
    animation: pyrestorm-ember-float var(--ember-duration, 10s) ease-in infinite;
    animation-delay: var(--ember-delay, 0s);
}

@keyframes pyrestorm-ember-float {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0) scale(1);
    }

    10% {
        opacity: 1;
    }

    70% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
        transform: translateY(-100vh) translateX(var(--ember-drift, 50px)) scale(0.3);
    }
}

#pyrestorm-smoke {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
}

.pyrestorm-smoke-plume {
    position: absolute;
    width: 200px;
    height: 300px;
    background: radial-gradient(ellipse at bottom,
            rgba(40, 20, 10, 0.6) 0%,
            rgba(60, 30, 15, 0.4) 40%,
            rgba(80, 40, 20, 0.2) 70%,
            transparent 100%);
    filter: blur(25px);
    opacity: 0;
    animation: pyrestorm-smoke-rise var(--smoke-duration, 15s) ease-out infinite;
    animation-delay: var(--smoke-delay, 0s);
}

@keyframes pyrestorm-smoke-rise {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0) scale(0.8);
    }

    20% {
        opacity: 0.6;
    }

    100% {
        opacity: 0;
        transform: translateY(-120vh) translateX(var(--smoke-drift, 100px)) scale(2.5);
    }
}

#pyrestorm-heat-distortion {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 7;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg,
            transparent 0px,
            rgba(255, 100, 0, 0.02) 1px,
            transparent 2px),
        repeating-linear-gradient(90deg,
            transparent 0px,
            rgba(255, 150, 0, 0.02) 1px,
            transparent 2px);
    animation: pyrestorm-heat-wave 1.5s ease-in-out infinite;
}

@keyframes pyrestorm-heat-wave {

    0%,
    100% {
        transform: skewY(0deg) translateY(0);
        opacity: 0.3;
    }

    25% {
        transform: skewY(0.3deg) translateY(1px);
        opacity: 0.5;
    }

    50% {
        transform: skewY(0deg) translateY(0);
        opacity: 0.3;
    }

    75% {
        transform: skewY(-0.3deg) translateY(-1px);
        opacity: 0.5;
    }
}

/* =================================================================================
   🌆 NEON DUSK THEME - Synthwave Retro-Futuristic Theme
   ================================================================================= */

#neon-dusk-theme {
    background: linear-gradient(to bottom,
            #0a0015 0%,
            #1a0030 20%,
            #2d1b4e 40%,
            #4a2d6e 60%,
            #8b4d8b 80%,
            #c96db5 100%);
}

/* All visual elements now rendered via WebGL canvases - no legacy DOM CSS needed */

/* =================================================================================
   🌆 SYNTHWAVE SUNSET THEME - 80s Retrowave City Sunset
   ================================================================================= */

#synthwave-sunset-theme {
    background: linear-gradient(to bottom,
            #1f0828 0%,
            #380a38 4%,
            #510d47 8%,
            #6a1055 12%,
            #831562 16%,
            #9c1a6e 20%,
            #b52078 24%,
            #cd2780 28%,
            #e53086 32%,
            #fb3b89 36%,
            #ff4889 40%,
            #ff5887 44%,
            #ff6a83 48%,
            #ff7c7e 52%,
            #ff8e78 56%,
            #ffa071 60%,
            #ffb26b 64%,
            #ffc465 68%,
            #ffd660 72%,
            #ffe85c 76%,
            #fff959 80%,
            #fffa57 85%,
            #fffa57 90%,
            #fffa57 100%);
    overflow: hidden;
}

/* Sky - Intense hot pink/red glow */
#synthwave-sunset-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 50%,
            rgba(255, 220, 100, 1) 0%,
            rgba(255, 170, 90, 0.98) 4%,
            rgba(255, 120, 100, 0.95) 8%,
            rgba(255, 90, 120, 0.9) 12%,
            rgba(255, 72, 137, 0.85) 16%,
            rgba(251, 59, 137, 0.75) 20%,
            rgba(229, 48, 134, 0.65) 24%,
            rgba(205, 39, 128, 0.5) 28%,
            rgba(181, 32, 120, 0.35) 32%,
            rgba(156, 26, 110, 0.2) 36%,
            transparent 45%);
    z-index: 1;
}

/* Sun Container - Positioned at horizon behind city */
#synthwave-sunset-sun {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 550px;
    height: 550px;
    z-index: 3;
}

/* Main Sun - Bright orange/red */
.synthwave-sun {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 550px;
    height: 550px;
    border-radius: 50%;
    background: radial-gradient(circle at 45% 40%,
            #fff5e6 0%,
            #ffe8b3 3%,
            #ffd480 8%,
            #ffbe5a 15%,
            #ffa640 23%,
            #ff8d30 32%,
            #ff7428 42%,
            #f85d25 53%,
            #e54828 65%,
            #cc3c30 78%,
            #b03038 92%,
            #8f253e 100%);
    box-shadow:
        0 0 120px rgba(255, 160, 60, 1),
        0 0 200px rgba(255, 120, 50, 0.95),
        0 0 280px rgba(248, 93, 69, 0.85),
        0 0 360px rgba(204, 70, 93, 0.7),
        inset 0 -70px 120px rgba(143, 37, 62, 0.5);
    animation: synthwave-sun-pulse 8s ease-in-out infinite;
}

/* Sun Glow Layers - Intense orange/red glow */
.synthwave-sun-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    opacity: 0.8;
}

.glow-layer-0 {
    width: 680px;
    height: 680px;
    background: radial-gradient(circle at center,
            rgba(255, 160, 60, 0.6) 0%,
            rgba(255, 120, 50, 0.35) 40%,
            transparent 70%);
    animation: synthwave-glow-pulse 8s ease-in-out infinite;
}

.glow-layer-1 {
    width: 840px;
    height: 840px;
    background: radial-gradient(circle at center,
            rgba(255, 120, 50, 0.5) 0%,
            rgba(248, 93, 69, 0.3) 40%,
            transparent 70%);
    animation: synthwave-glow-pulse 8s ease-in-out infinite 0.7s;
}

.glow-layer-2 {
    width: 1020px;
    height: 1020px;
    background: radial-gradient(circle at center,
            rgba(248, 93, 69, 0.4) 0%,
            rgba(204, 70, 93, 0.2) 40%,
            transparent 70%);
    animation: synthwave-glow-pulse 8s ease-in-out infinite 1.4s;
}

@keyframes synthwave-sun-pulse {

    0%,
    100% {
        box-shadow:
            0 0 120px rgba(255, 160, 60, 1),
            0 0 200px rgba(255, 120, 50, 0.95),
            0 0 280px rgba(248, 93, 69, 0.85),
            0 0 360px rgba(204, 70, 93, 0.7),
            inset 0 -70px 120px rgba(143, 37, 62, 0.5);
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        box-shadow:
            0 0 140px rgba(255, 160, 60, 1),
            0 0 230px rgba(255, 120, 50, 1),
            0 0 320px rgba(248, 93, 69, 0.9),
            0 0 410px rgba(204, 70, 93, 0.8),
            inset 0 -70px 120px rgba(143, 37, 62, 0.6);
        transform: translate(-50%, -50%) scale(1.015);
    }
}

@keyframes synthwave-glow-pulse {

    0%,
    100% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.06);
    }
}

/* City Glow - Warm light coming from between buildings */
#synthwave-sunset-city-glow {
    position: absolute;
    bottom: 32%;
    left: 0;
    width: 100%;
    height: 42%;
    z-index: 5;
    overflow: visible;
    pointer-events: none;
    mix-blend-mode: screen;
}

.synthwave-city-glow-beam {
    position: absolute;
    bottom: 0;
    height: 100%;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at bottom,
            rgba(80, 8, 5, 1) 0%,
            rgba(100, 12, 8, 0.9) 8%,
            rgba(120, 18, 12, 0.75) 16%,
            rgba(140, 24, 16, 0.55) 28%,
            rgba(160, 30, 20, 0.35) 42%,
            rgba(180, 36, 24, 0.18) 60%,
            transparent 80%);
    filter: blur(35px);
    opacity: 1;
    animation: cityGlowPulse 4s ease-in-out infinite;
}

@keyframes cityGlowPulse {

    0%,
    100% {
        opacity: 0.85;
        transform: translateX(-50%) scaleY(1);
    }

    50% {
        opacity: 1;
        transform: translateX(-50%) scaleY(1.2);
    }
}

/* City Skyline - Back Layer */
#synthwave-sunset-city-back {
    position: absolute;
    bottom: 44%;
    left: 0;
    width: 100%;
    height: 14%;
    z-index: 6;
    opacity: 0.85;
}

/* City Skyline - Front Layer */
#synthwave-sunset-city-front {
    position: absolute;
    bottom: 36%;
    left: 0;
    width: 100%;
    height: 18%;
    z-index: 7;
}

.synthwave-city-svg {
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));
}

/* Ground Layer - Blocks sun under grid */
#synthwave-sunset-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 62%;
    z-index: 4;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(10, 2, 15, 0.3) 10%,
            rgba(8, 1, 12, 0.6) 20%,
            rgba(5, 0, 10, 0.85) 35%,
            rgba(3, 0, 8, 0.95) 50%,
            #000000 70%,
            #000000 100%);
}

/* Grid Floor */
#synthwave-sunset-grid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    z-index: 5;
    overflow: hidden;
}

.synthwave-grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Scanlines - CRT Effect */
#synthwave-sunset-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.15) 2px,
            rgba(0, 0, 0, 0.15) 4px);
    z-index: 100;
    pointer-events: none;
    opacity: 0.4;
    animation: synthwave-scanline-flicker 0.1s infinite;
}

@keyframes synthwave-scanline-flicker {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.38;
    }

    100% {
        opacity: 0.4;
    }
}

/* ================== STILLWATER THEME ================== */

#stillwater-theme {
    background: #04141b;
    overflow: hidden;
}

/* =================================================================
   MULTIPLAYER MODE STYLES
   ================================================================= */

/* Game mode selector buttons */

/* Responsive: Stack buttons on smaller screens */

/* Mode description styles */

/* Enhanced Start Game Button */
.start-game-btn {
    padding: 18px 50px;
    font-family: 'Orbitron', 'Space Mono', monospace;
    font-size: 20px;
    font-weight: 900;
    background: linear-gradient(135deg, #00ffff, #00d4d4);
    border: 2px solid #00ffff;
    border-radius: 12px;
    color: #0a0a0a;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 30px;
    box-shadow: 0 6px 25px rgba(0, 255, 255, 0.4);
    position: relative;
    overflow: hidden;
    animation: startButtonPulse 2s ease-in-out infinite;
}

.start-game-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

/* Shimmer effect */
.start-game-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.3) 50%,
            transparent 100%);
    transform: rotate(45deg);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {

    0%,
    100% {
        transform: translateX(-100%) rotate(45deg);
        opacity: 0;
    }

    50% {
        transform: translateX(100%) rotate(45deg);
        opacity: 1;
    }
}

.start-game-btn:hover {
    background: linear-gradient(135deg, #00d4d4, #00b8b8);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 35px rgba(0, 255, 255, 0.6);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.start-game-btn:hover::before {
    width: 400px;
    height: 400px;
}

.start-game-btn:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 20px rgba(0, 255, 255, 0.5);
}

.start-game-btn:disabled {
    background: rgba(100, 100, 100, 0.2);
    border-color: rgba(100, 100, 100, 0.4);
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
    animation: none;
    box-shadow: none;
}

@keyframes startButtonPulse {

    0%,
    100% {
        box-shadow: 0 6px 25px rgba(0, 255, 255, 0.4);
    }

    50% {
        box-shadow: 0 6px 35px rgba(0, 255, 255, 0.7);
    }
}

/* Multiplayer container layout */
.multiplayer-container.multiplayer-container {
    display: none !important;
    /* Hidden by default */
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 20px;
    align-items: center !important;
    justify-content: center;
    padding: 20px;
    width: 100%;
    min-width: 1200px;
    height: 100vh;
    position: relative;
}

/* Show multiplayer container when multiplayer is active */
body.phaser-multiplayer-active .multiplayer-container.multiplayer-container {
    display: flex !important;
}

/* Hide single player container when multiplayer is active */
body.phaser-multiplayer-active #single-player-container {
    display: none !important;
}

/* Wrapper for multiplayer boards */
.multiplayer-game-area {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-shrink: 0;
    order: 0;
}

/* Wrapper for both player boards */
#phaser-multiplayer-wrapper {
    position: relative;
    display: flex;
    gap: 90px;
    flex-shrink: 0;
}

/* Wrapper for each player's board and border */
.multiplayer-board-wrapper {
    position: relative;
    width: 300px;
    height: 600px;
}

/* Container for each Phaser game instance */
.phaser-board-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: transparent;
    backdrop-filter: none;
}

.phaser-board-container canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    pointer-events: none;
    position: relative;
    z-index: 1;
}

/* Border overlays for each board */
.board-border-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid #8b5cf6;
    border-radius: 12px;
    box-shadow:
        0 0 30px rgba(139, 92, 246, 0.5),
        0 0 60px rgba(139, 92, 246, 0.3),
        0 0 90px rgba(139, 92, 246, 0.1);
    pointer-events: none;
    z-index: 4;
}

/* Player board labels (P1, P2, P3, P4) */
.player-board-label {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    color: #8b5cf6;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    letter-spacing: 1px;
    background: #050510;
    padding: 2px 16px;
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
    pointer-events: none;
}

/* Player board stats (frags) */
.player-board-stats {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
}

.board-frag-display {
    font-family: 'Space Mono', monospace;
    font-size: 16px;
    font-weight: 700;
    color: #10b981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    border: 2px solid rgba(16, 185, 129, 0.3);
}

/* ============================================
   PLAYER COLOR SCHEME
   ============================================ */

/* Player 1 - Blue */
.player-card[data-player="1"] .player-board-label {
    color: #3B82F6;
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

#p1-border {
    border-color: #3B82F6;
    box-shadow:
        0 0 30px rgba(59, 130, 246, 0.5),
        inset 0 0 20px rgba(59, 130, 246, 0.3);
}

#p1-phaser-container {
    border: 2px solid #3B82F6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

/* Player 2 - Red */
.player-card[data-player="2"] .player-board-label {
    color: #EF4444;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

#p2-border {
    border-color: #EF4444;
    box-shadow:
        0 0 30px rgba(239, 68, 68, 0.5),
        inset 0 0 20px rgba(239, 68, 68, 0.3);
}

#p2-phaser-container {
    border: 2px solid #EF4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

/* Player 3 - Green */
.player-card[data-player="3"] .player-board-label {
    color: #10B981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

#p3-border {
    border-color: #10B981;
    box-shadow:
        0 0 30px rgba(16, 185, 129, 0.5),
        inset 0 0 20px rgba(16, 185, 129, 0.3);
}

#p3-phaser-container {
    border: 2px solid #10B981;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

/* Player 4 - Amber/Orange */
.player-card[data-player="4"] .player-board-label {
    color: #F59E0B;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

#p4-border {
    border-color: #F59E0B;
    box-shadow:
        0 0 30px rgba(245, 158, 11, 0.5),
        inset 0 0 20px rgba(245, 158, 11, 0.3);
}

#p4-phaser-container {
    border: 2px solid #F59E0B;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

/* ============================================
   PLAYER CARD LAYOUT (NEW)
   ============================================ */

/* Main multiplayer container - centered layout */
.multiplayer-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 20px;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 100 !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Game area with CSS Grid */
.multiplayer-game-area {
    --board-width: 300px;
    --board-height: 600px;
    display: grid;
    gap: 80px;
    width: 100%;
    justify-content: center;
    justify-items: center;
    align-content: center;
    margin: 0 auto;
    position: relative;
    transform: none !important;
}

/* 2 players - 1 row × 2 columns */
.multiplayer-game-area.players-2 {
    /* --board-width is set by JS */
    grid-template-columns: repeat(2, calc(var(--board-width) + 30px));
    grid-template-rows: 1fr;
    gap: var(--board-gap, 60px);
    align-items: center;
    justify-content: center;
}

/* 3 players - 1 row × 3 columns */
.multiplayer-game-area.players-3 {
    /* --board-width is set by JS */
    grid-template-columns: repeat(3, calc(var(--board-width) + 30px));
    grid-template-rows: 1fr;
    gap: var(--board-gap, 40px);
    align-items: center;
    justify-content: center;
}

/* 4 players - 1 row × 4 columns */
.multiplayer-game-area.players-4 {
    /* --board-width is set by JS */
    grid-template-columns: repeat(4, calc(var(--board-width) + 30px));
    grid-template-rows: 1fr;
    gap: var(--board-gap, 30px);
    align-items: center;
    justify-content: center;
}

/* Individual player card */
.player-card {
    --player-primary: #8b5cf6;
    --player-primary-light: #c4b5fd;
    --player-glow: rgba(139, 92, 246, 0.4);
    --player-glow: rgba(139, 92, 246, 0.4);
    /* Dynamic dimensions set by JS */
    /* Variables inherited from parent or set by JS */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    width: min-content;
    /* Allow card to shrink/grow with board */
    min-width: min-content;
    max-width: none;
    /* Constrain width */
    box-sizing: border-box;
    background: transparent;
    border-radius: 24px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: none;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.player-card.single-player-card {
    /* Responsive sizing matching .single-player-card */
    /* Responsive sizing matching .single-player-card */
    /* Variables inherited from parent or set by JS */
    --player-primary: #8b5cf6;
    --player-primary-light: #c4b5fd;
    --player-glow: rgba(139, 92, 246, 0.35);
    padding: 24px;
    gap: 20px;
}

/* Player card color variations - Enhanced visual separation */
.player-card[data-player="1"] {
    border-color: rgba(59, 130, 246, 0.8);
    border-width: 3px;
    box-shadow:
        0 0 30px rgba(59, 130, 246, 0.4),
        inset 0 0 20px rgba(59, 130, 246, 0.1);
    background: linear-gradient(145deg,
            rgba(0, 0, 0, 0.5),
            rgba(59, 130, 246, 0.05));
}

.player-card[data-player="2"] {
    border-color: rgba(239, 68, 68, 0.8);
    border-width: 3px;
    box-shadow:
        0 0 30px rgba(239, 68, 68, 0.4),
        inset 0 0 20px rgba(239, 68, 68, 0.1);
    background: linear-gradient(145deg,
            rgba(0, 0, 0, 0.5),
            rgba(239, 68, 68, 0.05));
}

.player-card[data-player="3"] {
    border-color: rgba(16, 185, 129, 0.8);
    border-width: 3px;
    box-shadow:
        0 0 30px rgba(16, 185, 129, 0.4),
        inset 0 0 20px rgba(16, 185, 129, 0.1);
    background: linear-gradient(145deg,
            rgba(0, 0, 0, 0.5),
            rgba(16, 185, 129, 0.05));
}

.player-card[data-player="4"] {
    border-color: rgba(245, 158, 11, 0.8);
    border-width: 3px;
    box-shadow:
        0 0 30px rgba(245, 158, 11, 0.4),
        inset 0 0 20px rgba(245, 158, 11, 0.1);
    background: linear-gradient(145deg,
            rgba(0, 0, 0, 0.5),
            rgba(245, 158, 11, 0.05));
}

/* Fix for Infinity LMS player header alignment */
.player-card.infinity-lms {
    justify-items: center;
    align-content: start;
}

/* Next pieces section - horizontal layout */
.player-card .player-next-pieces {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: var(--next-piece-gap, 8px);
    padding: var(--next-piece-gap, 8px);
    width: var(--board-width);
    margin: 0;
    margin-top: 12px;
    background: rgba(16, 16, 32, 0.55);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.45);
    backdrop-filter: none;
}

.player-card .player-next-piece {
    width: var(--next-piece-size, 60px);
    height: var(--next-piece-size, 60px);
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(12, 12, 22, 0.95), rgba(24, 24, 44, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, opacity 0.3s ease, width 0.2s ease, height 0.2s ease;
}

.player-card .player-next-piece.highlight {
    width: var(--next-piece-highlight-size, 70px);
    height: var(--next-piece-highlight-size, 70px);
    border-color: var(--player-primary, #8b5cf6);
    box-shadow:
        0 0 18px var(--player-glow, rgba(139, 92, 246, 0.45)),
        inset 0 0 18px rgba(255, 255, 255, 0.05);
}

.player-card .player-next-piece.empty {
    opacity: 0.35;
    transform: none;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
}

.player-card .player-next-piece canvas {
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    width: 100%;
    height: 100%;
    display: block;
}

/* Board section wrapper */
.player-board-section {
    position: relative;
    width: var(--board-width);
    height: var(--board-height);
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    margin-top: 10px;
}

/* Add spacing for player label in multiplayer to prevent overlap with next pieces */
/* Add spacing for player label in multiplayer to prevent overlap with next pieces */
.multiplayer-game-area .player-board-section {
    margin-top: 0;
}

/* Stats section - horizontal compact layout */
.player-stats-compact {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: var(--board-width);
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    font-family: 'Space Mono', monospace;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    position: relative;
}

.stat-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: 9px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

.stat-value {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

/* Highlight frags stat */
.stat-item:first-child .stat-value {
    color: #10b981;
    font-size: 16px;
}

/* Floating settings button - Serenity Hub inspired design */
.floating-settings-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.25));
    transform: scale(1);
}

.floating-settings-btn:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 16px rgba(255, 255, 255, 0.4));
}

.floating-settings-btn:active {
    transform: scale(0.95);
}

/* Settings button glow effect */
.floating-settings-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent);
    filter: blur(10px);
    animation: settings-gentle-glow 3s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes settings-gentle-glow {

    0%,
    100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* Settings icon SVG styling */
.settings-icon {
    width: 24px;
    height: 24px;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.floating-settings-btn:hover .settings-icon {
    color: rgba(255, 255, 255, 0.95);
    transform: rotate(45deg);
}

.floating-settings-btn:active .settings-icon {
    transform: rotate(90deg);
}

/* Board scaling - dynamic based on CSS variables */
.phaser-board-container,
.phaser-board-container canvas,
.board-border-overlay {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
/* 2 players - 1 row × 2 columns */
.multiplayer-game-area.players-2 {
    /* --board-width is set by JS */
    grid-template-columns: repeat(2, calc(var(--board-width) + 30px));
    grid-template-rows: 1fr;
    gap: var(--board-gap, 60px);
    align-items: center;
    justify-content: center;
}

/* 3 players - 1 row × 3 columns */
.multiplayer-game-area.players-3 {
    /* --board-width is set by JS */
    grid-template-columns: repeat(3, calc(var(--board-width) + 30px));
    grid-template-rows: 1fr;
    gap: var(--board-gap, 40px);
    align-items: center;
    justify-content: center;
}

/* 4 players - 1 row × 4 columns */
.multiplayer-game-area.players-4 {
    /* --board-width is set by JS */
    grid-template-columns: repeat(4, calc(var(--board-width) + 30px));
    grid-template-rows: 1fr;
    gap: var(--board-gap, 30px);
    align-items: center;
    justify-content: center;
}

/* Mobile (< 768px) - Stack all players vertically */
@media (max-width: 767px) {
    .multiplayer-game-area {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 20px;
        padding: 10px;
    }

    .player-card {
        padding: 10px;
    }

    .multiplayer-game-area {
        --board-width: min(280px, calc(100vw - 60px));
        --board-height: calc(var(--board-width) * 2);
    }

    .stat-value {
        font-size: 12px;
    }

    .stat-label {
        font-size: 9px;
    }

    .floating-settings-btn {
        width: 36px;
        height: 36px;
        bottom: 20px;
        right: 20px;
    }

    .settings-icon {
        width: 16px;
        height: 16px;
    }
}

/* ============================================
   REDESIGNED LOCAL MULTIPLAYER UI
   ============================================ */

/* Player Header with Avatar - COMPACT VERSION */
.player-header {
    display: none;
    /* Hide separate header - avatar now inline with next section */
}

.player-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(30, 30, 50, 0.9), rgba(10, 10, 20, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--player-primary, #8b5cf6);
    box-shadow:
        0 0 15px var(--player-glow, rgba(139, 92, 246, 0.4)),
        inset 0 0 10px rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.player-avatar .avatar-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    font-weight: 900;
    color: var(--player-primary, #8b5cf6);
    text-shadow: 0 0 6px var(--player-glow, rgba(139, 92, 246, 0.6));
    z-index: 2;
}

.player-avatar .avatar-glow {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--player-glow, rgba(139, 92, 246, 0.3)) 0%, transparent 70%);
    animation: avatar-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes avatar-pulse {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

.player-name {
    display: none;
    /* Hide player name - redundant with avatar */
}

/* Player color-specific avatar styles */
.player-card[data-player="1"] .player-avatar {
    border-color: #3B82F6;
    --player-primary: #3B82F6;
    --player-glow: rgba(59, 130, 246, 0.4);
}

.player-card[data-player="1"] .avatar-text {
    color: #3B82F6;
}

.player-card[data-player="2"] .player-avatar {
    border-color: #EF4444;
    --player-primary: #EF4444;
    --player-glow: rgba(239, 68, 68, 0.4);
}

.player-card[data-player="2"] .avatar-text {
    color: #EF4444;
}

.player-card[data-player="3"] .player-avatar {
    border-color: #10B981;
    --player-primary: #10B981;
    --player-glow: rgba(16, 185, 129, 0.4);
}

.player-card[data-player="3"] .avatar-text {
    color: #10B981;
}

.player-card[data-player="4"] .player-avatar {
    border-color: #F59E0B;
    --player-primary: #F59E0B;
    --player-glow: rgba(245, 158, 11, 0.4);
}

.player-card[data-player="4"] .avatar-text {
    color: #F59E0B;
}

/* Next Pieces Section - COMPACT with inline avatar */
.player-next-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

/* Move avatar into next section via CSS */
.player-card .player-header {
    display: contents;
    /* Let children flow into parent layout */
}

.next-label {
    display: none;
    /* Hidden - pieces are self-explanatory */
    font-family: 'Space Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Enhanced Next Pieces with opacity fade */
.player-card .player-next-piece.primary {
    opacity: 1;
    transform: scale(1.05);
    border: 2px solid var(--player-primary, rgba(139, 92, 246, 0.6));
    box-shadow:
        0 0 20px var(--player-glow, rgba(139, 92, 246, 0.3)),
        inset 0 0 15px rgba(255, 255, 255, 0.05);
}

.player-card .player-next-piece.secondary {
    opacity: 0.7;
    transform: scale(0.95);
}

.player-card .player-next-piece.tertiary {
    opacity: 0.45;
    transform: scale(0.9);
}

/* Board Wrapper with Garbage Indicator */
.player-board-wrapper {
    position: relative;
    display: flex;
    flex-direction: row;
    gap: 6px;
}

/* Garbage Indicator Bar */
.garbage-indicator {
    position: relative;
    width: 8px;
    height: var(--board-height, 200px);
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.garbage-indicator .garbage-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(to top,
            #ef4444 0%,
            #f97316 30%,
            #fbbf24 60%,
            #a3e635 100%);
    border-radius: 0 0 3px 3px;
    transition: height 0.3s ease-out;
}

.garbage-indicator .garbage-glow {
    position: absolute;
    bottom: 0;
    left: -4px;
    right: -4px;
    height: 0%;
    background: radial-gradient(ellipse at bottom, rgba(239, 68, 68, 0.6), transparent);
    filter: blur(4px);
    pointer-events: none;
    transition: height 0.3s ease-out;
}

/* Enhanced Stats Bar */
.player-stats-bar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    width: calc(var(--board-width) + 14px);
    padding: 8px 10px;
    background: linear-gradient(145deg, rgba(15, 15, 30, 0.9), rgba(5, 5, 15, 0.95));
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        inset 0 2px 10px rgba(0, 0, 0, 0.4),
        0 4px 15px rgba(0, 0, 0, 0.3);
    gap: 6px;
}

.player-stats-bar .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    padding: 4px 2px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s ease;
}

.player-stats-bar .stat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Score is the widest value (formatted, up to 6-7 digits) — give it ~2x the room
   of the 1-2 digit cells so it isn't ellipsis-truncated in the narrow strip. */
.player-stats-bar .stat-score {
    flex-grow: 2.2;
}

.player-stats-bar .stat-icon {
    font-size: 16px !important;
    line-height: 1;
    filter: saturate(0.8);
}

.player-stats-bar .stat-label {
    display: none !important;
}

.player-stats-bar .stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 15px !important;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    /* Never let a wide value (e.g. a 6-digit score) spill into the next cell. */
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stat-specific colors */
.player-stats-bar .stat-frags .stat-value,
.player-stats-bar .stat-frags .stat-icon {
    color: #10b981;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.5));
}

.player-stats-bar .stat-deaths .stat-value,
.player-stats-bar .stat-deaths .stat-icon {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

.player-stats-bar .stat-score .stat-value,
.player-stats-bar .stat-score .stat-icon {
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.5));
}

.player-stats-bar .stat-lines .stat-value,
.player-stats-bar .stat-lines .stat-icon {
    color: #60a5fa;
    text-shadow: 0 0 8px rgba(96, 165, 250, 0.5);
    filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.5));
}

.player-stats-bar .stat-level .stat-value,
.player-stats-bar .stat-level .stat-icon {
    color: #a78bfa;
    text-shadow: 0 0 8px rgba(167, 139, 250, 0.5);
    filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.5));
}

.player-stats-bar .stat-garbage .stat-value,
.player-stats-bar .stat-garbage .stat-icon {
    color: #f87171;
    text-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
    filter: drop-shadow(0 0 6px rgba(248, 113, 113, 0.5));
}

.player-stats-bar .stat-ceiling .stat-value,
.player-stats-bar .stat-ceiling .stat-icon {
    color: #f472b6;
    text-shadow: 0 0 8px rgba(244, 114, 182, 0.5);
    filter: drop-shadow(0 0 6px rgba(244, 114, 182, 0.5));
}

/* Animated value change pulse */
@keyframes stat-value-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
        filter: brightness(1.3);
    }

    100% {
        transform: scale(1);
    }
}

.stat-value.pulse {
    animation: stat-value-pulse 0.3s ease-out;
}

/* Hide old player-board-label (replaced by player-header) */
.player-card .player-board-label {
    display: none;
}

/* Adjust player card for new layout */
.multiplayer-container .player-card {
    gap: 6px;
    padding: 14px 12px;
}

/* ============================================
   HORIZONTAL LAYOUTS FOR 2-4 PLAYERS (OLD - KEEP FOR FALLBACK)
   ============================================ */

/* 2-Player Layout - Side by side (default) */
#phaser-multiplayer-wrapper.players-2 {
    gap: 90px;
}

/* 3-Player Layout - Horizontal row */
#phaser-multiplayer-wrapper.players-3 {
    gap: 50px;
}

#phaser-multiplayer-wrapper.players-3 .multiplayer-board-wrapper {
    width: 260px;
    height: 520px;
}

#phaser-multiplayer-wrapper.players-3 .phaser-board-container,
#phaser-multiplayer-wrapper.players-3 .phaser-board-container canvas,
#phaser-multiplayer-wrapper.players-3 .board-border-overlay {
    width: 260px;
    height: 520px;
}

/* 4-Player Layout - Horizontal row */
#phaser-multiplayer-wrapper.players-4 {
    gap: 30px;
}

#phaser-multiplayer-wrapper.players-4 .multiplayer-board-wrapper {
    width: 220px;
    height: 440px;
}

#phaser-multiplayer-wrapper.players-4 .phaser-board-container,
#phaser-multiplayer-wrapper.players-4 .phaser-board-container canvas,
#phaser-multiplayer-wrapper.players-4 .board-border-overlay {
    width: 220px;
    height: 440px;
}

/* Responsive adjustments for 3-4 players */
@media (max-width: 1400px) {
    #phaser-multiplayer-wrapper.players-3 {
        gap: 30px;
    }

    #phaser-multiplayer-wrapper.players-3 .multiplayer-board-wrapper {
        width: 240px;
        height: 480px;
    }

    #phaser-multiplayer-wrapper.players-3 .phaser-board-container,
    #phaser-multiplayer-wrapper.players-3 .phaser-board-container canvas,
    #phaser-multiplayer-wrapper.players-3 .board-border-overlay {
        width: 240px;
        height: 480px;
    }

    #phaser-multiplayer-wrapper.players-4 {
        gap: 20px;
    }

    #phaser-multiplayer-wrapper.players-4 .multiplayer-board-wrapper {
        width: 200px;
        height: 400px;
    }

    #phaser-multiplayer-wrapper.players-4 .phaser-board-container,
    #phaser-multiplayer-wrapper.players-4 .phaser-board-container canvas,
    #phaser-multiplayer-wrapper.players-4 .board-border-overlay {
        width: 200px;
        height: 400px;
    }
}

/* Stack vertically on small screens */
@media (max-width: 900px) {
    #phaser-multiplayer-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    #phaser-multiplayer-wrapper.players-3 .multiplayer-board-wrapper,
    #phaser-multiplayer-wrapper.players-4 .multiplayer-board-wrapper {
        width: 300px;
        height: 600px;
    }

    #phaser-multiplayer-wrapper.players-3 .phaser-board-container,
    #phaser-multiplayer-wrapper.players-3 .phaser-board-container canvas,
    #phaser-multiplayer-wrapper.players-3 .board-border-overlay,
    #phaser-multiplayer-wrapper.players-4 .phaser-board-container,
    #phaser-multiplayer-wrapper.players-4 .phaser-board-container canvas,
    #phaser-multiplayer-wrapper.players-4 .board-border-overlay {
        width: 300px;
        height: 600px;
    }
}

#p1-border {
    left: 0;
    top: 0;
}

#p2-border {
    left: 0;
    top: 0;
}

.multiplayer-container .player-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-width: 200px;
    max-width: 200px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.multiplayer-container>.player-sidebar:first-child {
    order: -1 !important;
}

.multiplayer-container>.player-sidebar:last-child {
    order: 1 !important;
}

.multiplayer-container>.multiplayer-game-area {
    order: 0 !important;
}

.player-sidebar .player-next-pieces {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.player-game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.player-game-area .board-impact {
    animation: board-impact-shake var(--impact-duration, 220ms) ease-out;
    animation-iteration-count: var(--impact-iterations, 1);
    transform-origin: center;
}

.player-game-area canvas {
    border: 4px solid #8b5cf6;
    border-radius: 12px;
    background: rgba(26, 26, 46, 0.8);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.5),
        0 0 60px rgba(139, 92, 246, 0.3),
        0 0 90px rgba(139, 92, 246, 0.1);
}

@keyframes board-impact-shake {
    0% {
        transform: translate3d(0, 0, 0);
    }

    20% {
        transform: translate3d(3px, -2px, 0);
    }

    45% {
        transform: translate3d(-4px, 3px, 0);
    }

    70% {
        transform: translate3d(2px, -3px, 0);
    }

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

.player-game-area .player-next-pieces {
    display: flex;
    gap: 8px;
    flex-direction: row;
}

.player-header {
    text-align: center;
    margin-bottom: 10px;
}

.player-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 24px;
    color: #00ffff;
    margin-bottom: 5px;
}

.player-controls-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Space Mono', monospace;
}

.player-stats {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 20px;
    min-width: 200px;
}

.player-stats .stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-family: 'Space Mono', monospace;
}

.player-stats .stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.player-stats .stat-value {
    color: #00ffff;
    font-weight: bold;
    font-size: 14px;
}

.multiplayer-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.vs-indicator {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: #ff00ff;
    text-shadow: 0 0 20px rgba(255, 0, 255, 0.8);
    animation: pulse 2s infinite;
}

.multiplayer-countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(72px, 12vw, 160px);
    font-weight: 900;
    color: #ffffff;
    text-shadow:
        0 0 20px rgba(0, 255, 255, 0.7),
        0 0 40px rgba(255, 0, 255, 0.6),
        0 0 60px rgba(111, 66, 193, 0.4);
    pointer-events: none;
    z-index: 15;
    letter-spacing: 6px;
    text-transform: uppercase;
}

.multiplayer-countdown.active {
    display: flex;
}

/* ============================================
   SERENITY MODE STYLES
   ============================================ */

/* Serenity mode - hide all game UI */
body.serenity-mode #game-container,
body.serenity-mode #stats-panel,
body.serenity-mode #next-pieces,
body.serenity-mode #game-controls {
    display: none !important;
}

/* Keyboard Shortcuts Overlay */
.serenity-shortcuts-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(10, 15, 30, 0.95);
    border: 2px solid rgba(100, 150, 255, 0.3);
    border-radius: 12px;
    padding: 30px 40px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.serenity-shortcuts-overlay.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out;
}

.shortcuts-content h3 {
    font-family: 'Space Mono', monospace;
    font-size: 24px;
    color: rgba(200, 220, 255, 0.95);
    margin-bottom: 20px;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 12px 0;
    font-family: 'Space Mono', monospace;
    font-size: 16px;
    color: rgba(180, 200, 230, 0.9);
}

.shortcut kbd {
    background: rgba(50, 70, 120, 0.5);
    border: 1px solid rgba(100, 150, 255, 0.4);
    border-radius: 4px;
    padding: 6px 12px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    color: rgba(200, 220, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    min-width: 80px;
    text-align: center;
}

/* Serenity Notification */
.serenity-notification {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(10, 15, 30, 0.9);
    border: 2px solid rgba(100, 150, 255, 0.4);
    border-radius: 8px;
    padding: 15px 30px;
    font-family: 'Space Mono', monospace;
    font-size: 16px;
    color: rgba(200, 220, 255, 0.95);
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
}

.serenity-notification.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Hide cursor in Serenity mode only when inactive */
body.serenity-mode.cursor-hidden {
    cursor: none;
}

body.serenity-mode.cursor-hidden * {
    cursor: none !important;
}

/* FPS Counter */
#fps-counter {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #0f0;
    padding: 8px 12px;
    font-family: 'Courier New', 'Space Mono', monospace;
    font-size: 14px;
    border-radius: 4px;
    z-index: 10000;
    user-select: none;
    pointer-events: none;
    border: 1px solid rgba(0, 255, 0, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    min-width: 80px;
    text-align: center;
}

#fps-counter.hidden {
    display: none;
}

.single-player-stage {
    /* Responsive board sizing that fits viewport at any zoom level */
    /* Calculate based on available viewport height, leaving room for UI elements */
    --board-width: min(clamp(300px, 35vw, 400px), calc((100vh - 200px) / 2));
    --board-height: calc(var(--board-width) * 2);

    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 0;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
    /* Ensure proper vertical centering */
    overflow: hidden;
}

/* === Floating Game Mode Cards (over intro animation) === */
.modal.game-mode-selection {
    background: transparent;
    align-items: safe center;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
}

body.electron-app #start-modal.modal.game-mode-selection {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.modal.game-mode-selection .floating-settings-btn {
    pointer-events: all;
    z-index: 1001;
}

.modal.game-mode-selection .start-modal-actions {
    pointer-events: all;
    position: relative;
    z-index: 1001;
}

.game-mode-cards-container {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 15px;
    padding-top: 90px;
    /* Make room for logo at top */
    padding-bottom: 15px;
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
    pointer-events: all;
    animation: cardsFloatIn 1s ease-out forwards;
}

body.start-modal-open .game-mode-cards-container {
    padding-top: 28px;
}

.main-menu-logo {
    grid-column: 1 / -1;
    justify-self: center;
    margin: 0 0 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.35rem, 2.6vw, 2.2rem);
    font-weight: 900;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: #f7fbff;
    text-align: center;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    text-shadow:
        0 0 3px rgba(240, 249, 255, 0.85),
        0 0 12px rgba(96, 165, 250, 0.28),
        0 2px 10px rgba(0, 0, 0, 0.35);
}

.main-menu-logo img {
    display: block;
    margin-inline: auto;
    width: var(--sb-logo-menu-width);
    height: auto;
    object-fit: contain;
}

.modal .main-menu-logo { animation: none; line-height: 1; }

@keyframes cardsFloatIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.game-mode-card {
    position: relative;
    background: rgba(15, 15, 30, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    border: 2px solid rgba(100, 200, 255, 0.3);
    border-radius: 20px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    animation: cardFloat 6s ease-in-out infinite;
}

/* Keep the main menu cards readable: no frosted blur and no idle 3D drift. */
body.start-modal-open .game-mode-card {
    background:
        linear-gradient(180deg,
            rgba(18, 22, 40, 0.94) 0%,
            rgba(10, 14, 28, 0.9) 100%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    animation: none;
    transform: none;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.36),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

body.start-modal-open .game-mode-card:hover,
body.start-modal-open .game-mode-card:active,
body.start-modal-open .game-mode-card.gamepad-focused,
body.start-modal-open .game-mode-card:focus-visible {
    transform: translateY(-6px) scale(1.01) !important;
}

.game-mode-card.steam-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.4);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.35),
        inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.game-mode-card.steam-disabled::after {
    content: attr(data-disabled-label);
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(10, 10, 20, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-mode-card.steam-disabled:hover,
.game-mode-card.steam-disabled:active,
.game-mode-card.steam-disabled.gamepad-focused,
.game-mode-card.steam-disabled:focus-visible {
    transform: none !important;
    border-color: rgba(100, 200, 255, 0.3);
    background: rgba(15, 15, 30, 0.7);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.35),
        inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.game-mode-card:nth-child(1) {
    animation-delay: 0s;
}

.game-mode-card:nth-child(2) {
    animation-delay: -1.5s;
}

.game-mode-card:nth-child(3) {
    animation-delay: -3s;
}

.game-mode-card:nth-child(4) {
    animation-delay: -4.5s;
}

@keyframes cardFloat {

    0%,
    100% {
        transform: translateY(0) rotateY(0deg);
    }

    25% {
        transform: translateY(-10px) rotateY(2deg);
    }

    75% {
        transform: translateY(-5px) rotateY(-2deg);
    }
}

.game-mode-card:hover {
    transform: translateY(-15px) scale(1.05) !important;
    border-color: rgba(139, 92, 246, 0.8);
    box-shadow:
        0 20px 60px rgba(139, 92, 246, 0.4),
        0 0 40px rgba(139, 92, 246, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    background: rgba(25, 25, 50, 0.85);
}

.game-mode-card:active {
    transform: translateY(-12px) scale(1.02) !important;
}

/* Gamepad focus state */
/* Gamepad focus state */
.game-mode-card.gamepad-focused,
.game-mode-card:focus-visible {
    transform: translateY(-15px) scale(1.05);
    border-color: rgba(100, 200, 255, 0.9);
    box-shadow:
        0 20px 60px rgba(100, 200, 255, 0.5),
        0 0 40px rgba(100, 200, 255, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    background: rgba(25, 25, 50, 0.85);
    outline: none;
    /* Remove default outline as we have custom styles */
}

.mode-card-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 12px rgba(100, 200, 255, 0.5));
    position: relative;
    z-index: 1;
    animation: iconBreathe 3s ease-in-out infinite;
}

.mode-card-icon svg {
    width: 42px;
    height: 42px;
    stroke: #64c8ff;
    transition: all 0.3s ease;
}

.game-mode-card:hover .mode-card-icon svg {
    stroke: #ffffff;
    filter: drop-shadow(0 0 8px rgba(100, 200, 255, 0.8));
    transform: scale(1.1);
}

@keyframes iconBreathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.mode-card-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #ffffff, #64c8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
    text-shadow: 0 0 20px rgba(100, 200, 255, 0.5);
}

.mode-card-desc {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.3;
    position: relative;
    z-index: 1;
    margin: 0;
}

.game-mode-card:hover .mode-card-desc {
    color: rgba(255, 255, 255, 0.9);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .game-mode-cards-container {
        gap: 10px;
        padding: 15px;
        padding-top: 80px;
    }

    .game-mode-card {
        padding: 15px;
    }

    .mode-card-icon {
        margin-bottom: 8px;
    }

    .mode-card-icon svg {
        width: 36px;
        height: 36px;
    }

    .mode-card-title {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .mode-card-desc {
        font-size: 0.7rem;
    }

    body.start-modal-open .game-mode-cards-container {
        padding-top: 20px;
    }

    .main-menu-logo {
        font-size: clamp(1.2rem, 2.8vw, 1.8rem);
        letter-spacing: 0.2em;
        margin-bottom: 6px;
    }
}

@media (max-width: 768px) {
    .game-mode-cards-container {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
        padding-top: 90px;
    }

    .game-mode-card {
        padding: 20px 18px;
    }

    .main-menu-logo {
        margin-bottom: 2px;
    }
}

@media (max-width: 480px) {
    .game-mode-cards-container {
        padding: 12px;
        padding-top: 75px;
        gap: 12px;
    }

    .mode-card-icon {
        margin-bottom: 8px;
    }

    .mode-card-icon svg {
        width: 32px;
        height: 32px;
    }

    body.start-modal-open .game-mode-cards-container {
        padding-top: 16px;
    }

    .main-menu-logo {
        font-size: 1.05rem;
        letter-spacing: 0.16em;
    }

    .mode-card-title {
        font-size: 1.1rem;
        margin-bottom: 6px;
    }

    .mode-card-desc {
        font-size: 0.7rem;
    }

    .game-mode-card {
        padding: 18px 15px;
    }
}

/* Reserve the profile card's top row when the logo is inside the scrolling menu.
   The card may appear after Steam initialization, so reserve this space up front. */
@media (max-width: 768px), (max-height: 700px) {
    body.start-modal-open .game-mode-cards-container { padding-top: 82px; }
}

/* === Headphone Recommendation Badge === */
.headphone-badge {
    position: absolute;
    bottom: 30px;
    left: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    animation: fadeInBadge 1s ease-out 1.5s forwards, floatBadge 3s ease-in-out 2.5s infinite;
}

@keyframes fadeInBadge {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes floatBadge {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.headphone-icon {
    width: 20px;
    height: 20px;
    color: #64c8ff;
    filter: drop-shadow(0 0 6px rgba(100, 200, 255, 0.6));
    flex-shrink: 0;
}

.headphone-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .headphone-badge {
        bottom: 20px;
        left: 20px;
        padding: 8px 16px;
        gap: 8px;
    }

    .headphone-icon {
        width: 18px;
        height: 18px;
    }

    .headphone-text {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .headphone-badge {
        bottom: 15px;
        left: 15px;
        padding: 7px 14px;
        gap: 7px;
    }

    .headphone-icon {
        width: 16px;
        height: 16px;
    }

    .headphone-text {
        font-size: 0.7rem;
    }
}

/* =============================================================================
   Blood Moon Theme
   ============================================================================= */

#blood-moon-theme {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
}

#blood-moon-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: auto;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

/* =============================================================================
   Serenity Mode Interactive Effects
   ============================================================================= */

/* Click ripple effect */
.serenity-click-ripple {
    position: fixed;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(100, 200, 255, 0.8);
    box-shadow:
        0 0 10px rgba(100, 200, 255, 0.6),
        0 0 20px rgba(100, 200, 255, 0.4);
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%) scale(0);
    animation: rippleExpand 1s ease-out forwards;
}

/* Cooldown ripple effect (red) */
.serenity-click-ripple.cooldown {
    border: 2px solid rgba(255, 80, 80, 0.8);
    box-shadow:
        0 0 10px rgba(255, 80, 80, 0.6),
        0 0 20px rgba(255, 80, 80, 0.4);
    animation: rippleExpandCooldown 0.5s ease-out forwards;
}

@keyframes rippleExpand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

@keyframes rippleExpandCooldown {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Cursor styles for Serenity Mode */
body.serenity-mode {
    cursor: crosshair;
}

body.cursor-hidden {
    cursor: none;
}

body.cursor-hidden * {
    cursor: none !important;
}

/* ================== CHROMADELIC HIGHWAY THEME ================== */

#chromadelic-highway-theme {
    background: radial-gradient(ellipse at 50% 60%,
            #0a0515 0%,
            #070312 30%,
            #040208 60%,
            #000000 100%);
    overflow: hidden;
}

/* Background - Subtle deep space gradient with gentle color hints */
#chromadelic-highway-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 60%,
            rgba(20, 10, 30, 0.4) 0%,
            rgba(15, 5, 20, 0.3) 30%,
            rgba(10, 3, 15, 0.2) 60%,
            rgba(0, 0, 0, 0) 100%);
    z-index: 1;
    animation: chromadelic-background-breathe 20s ease-in-out infinite;
}

@keyframes chromadelic-background-breathe {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 0.9;
    }
}

/* Rainbow Waves Container */
#chromadelic-highway-waves {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    overflow: hidden;
}

.chromadelic-wave-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1;
    filter: brightness(1.1) contrast(1.05);
    /* PERFORMANCE: GPU acceleration hints */
    will-change: transform;
    transform: translateZ(0);
}

/* Sparkles Container */
#chromadelic-highway-sparkles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    overflow: hidden;
    pointer-events: none;
}

.chromadelic-sparkle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.9;
    filter: brightness(1.2);
    /* PERFORMANCE: GPU acceleration hints */
    will-change: transform;
    transform: translateZ(0);
}

/* ==========================================================================
   DEMO / REPLAY SYSTEM STYLES
   ========================================================================== */

/* Demo Browser Modal */
.demo-browser-content {
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 800px;
}

.demo-browser-toolbar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.demo-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-right: 10px;
}

.demo-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.demo-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(100, 200, 255, 0.3);
    transform: translateY(-2px);
}

.demo-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.demo-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.demo-date {
    font-family: 'Space Mono', monospace;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.8);
}

.demo-mode {
    background: rgba(100, 200, 255, 0.2);
    color: #64c8ff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}

.demo-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
}

.demo-stats .stat {
    display: flex;
    align-items: center;
    gap: 5px;
}

.demo-actions {
    display: flex;
    gap: 10px;
}

.demo-actions button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    transition: all 0.2s ease;
}

.demo-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.demo-actions .btn-play:hover {
    background: rgba(100, 255, 100, 0.2);
    border-color: rgba(100, 255, 100, 0.4);
    color: #64ff64;
}

.demo-actions .btn-export:hover {
    background: rgba(100, 200, 255, 0.2);
    border-color: rgba(100, 200, 255, 0.4);
    color: #64c8ff;
}

.demo-actions .btn-delete:hover {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.4);
    color: #ff6464;
}

/* Playback Controls Overlay */
.playback-controls {
    position: fixed;
    bottom: 30px;
    right: 80px;
    left: auto;
    transform: none;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    /* Pill shape */
    padding: 12px 24px;
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    align-items: center;
    gap: 20px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    min-width: 500px;
    max-width: 90vw;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.playback-buttons {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.control-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

#pb-play-pause {
    background: rgba(100, 200, 255, 0.15);
    border-color: rgba(100, 200, 255, 0.3);
    color: #64c8ff;
}

#pb-play-pause:hover {
    background: rgba(100, 200, 255, 0.25);
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.3);
}

#pb-stop:hover {
    background: rgba(255, 100, 100, 0.15);
    border-color: rgba(255, 100, 100, 0.3);
    color: #ff6464;
}

.playback-info {
    font-family: 'Space Mono', monospace;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.playback-info .separator {
    color: rgba(255, 255, 255, 0.3);
}

#playback-time {
    color: #64c8ff;
    font-weight: bold;
}

.playback-progress-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    height: 100%;
    margin: 0;
}

#pb-progress {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: height 0.2s ease;
}

#pb-progress:hover {
    height: 6px;
}

#pb-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #64c8ff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.5);
    transition: transform 0.2s ease;
    margin-top: -4px;
    /* Center thumb relative to 4px track */
}

#pb-progress::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    background: #fff;
}

.playback-speed {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.speed-select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Space Mono', monospace;
    font-size: 0.8em;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.speed-select:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
}

.speed-select option {
    background: #1a1a2e;
    color: white;
}

/* Empty State */

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #64c8ff;
}

/* --- Black Hole Theme Lock Effect --- */
.black-hole-lock-ripple {
    position: absolute;
    width: 200px;
    height: 200px;
    margin-left: -100px;
    margin-top: -100px;
    border: 4px solid rgba(180, 100, 255, 0.9);
    border-radius: 50%;
    box-shadow:
        0 0 20px rgba(180, 100, 255, 0.6),
        inset 0 0 20px rgba(180, 100, 255, 0.4);
    animation: black-hole-lock-ripple-expand 0.6s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
    pointer-events: none;
    will-change: transform, opacity;
    z-index: 10;
    /* Above stardust */
}

@keyframes black-hole-lock-ripple-expand {
    0% {
        transform: scale(0.2);
        opacity: 1;
        border-width: 4px;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
        border-width: 0px;
    }
}

/* ===== Theme Transition Overlay (Phase 4 - Odyssey Mode) ===== */
.theme-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0;
    visibility: hidden;
    z-index: 10001;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.theme-transition-overlay.active {
    visibility: visible;
    pointer-events: all;
}

.theme-transition-overlay.fade-in {
    animation: theme-fade-in var(--transition-duration, 500ms) ease-out forwards;
}

.theme-transition-overlay.fade-out {
    animation: theme-fade-out var(--transition-duration, 500ms) ease-in forwards;
}

@keyframes theme-fade-in {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes theme-fade-out {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Crossfade screenshot overlay */
.theme-crossfade-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

.theme-crossfade-canvas.fading {
    animation: theme-crossfade var(--crossfade-duration, 1000ms) ease-out forwards;
}

@keyframes theme-crossfade {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ==========================================================================
   ODYSSEY MODE STYLES
   ========================================================================== */

/* Odyssey Container */
.odyssey-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: linear-gradient(135deg, #0a0515 0%, #150a25 50%, #0a0515 100%);
}

/* Odyssey Board (3D World) */
.odyssey-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.odyssey-board canvas {
    width: 100%;
    height: 100%;
}

/* Odyssey Gameplay Area */
.odyssey-gameplay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Odyssey HUD Animations */

/* Level Select UI Scrollbar */

/* Chapter Tabs Scrollbar */

/* Odyssey Mode Card Styles */
.game-mode-card[data-mode="odyssey"] {
    --card-glow-color: rgba(180, 130, 255, 0.4);
}

.game-mode-card[data-mode="odyssey"]:hover,
.game-mode-card[data-mode="odyssey"]:focus {
    border-color: rgba(180, 130, 255, 0.6);
    box-shadow: 0 0 40px rgba(180, 130, 255, 0.3);
}

.game-mode-card[data-mode="odyssey"] .mode-card-icon {
    color: rgba(180, 130, 255, 0.9);
}

.game-mode-card[data-mode="odyssey"]:hover .mode-card-icon,
.game-mode-card[data-mode="odyssey"]:focus .mode-card-icon {
    color: rgba(200, 160, 255, 1);
    filter: drop-shadow(0 0 15px rgba(180, 130, 255, 0.8));
}

/* Odyssey Progress Ring Animation */

/* Star Shimmer Effect */
@keyframes star-shimmer {
    0% {
        filter: drop-shadow(0 0 4px rgba(255, 200, 100, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 12px rgba(255, 200, 100, 0.8));
    }

    100% {
        filter: drop-shadow(0 0 4px rgba(255, 200, 100, 0.4));
    }
}

.odyssey-hud .star.earned {
    animation: star-shimmer 2s ease-in-out infinite;
}

/* Victory/Failure Banner Animations */

/* Responsive Adjustments */
@media (max-width: 768px) {
    .odyssey-level-select {
        padding: 10px;
    }
}

/* ===================================
   Demo Complete Modal Styles
   =================================== */

#demo-complete-modal .modal-content {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.95));
    border: 1px solid rgba(100, 200, 255, 0.3);
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(100, 200, 255, 0.1);
}

#demo-complete-modal h1 {
    font-size: 1.6rem;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 24px;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.demo-complete-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Demo Indicator - Watching Replay badge */
.demo-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 20px;
    z-index: 1000;
    animation: demo-indicator-pulse 2s ease-in-out infinite;
}

.demo-indicator.visible {
    display: flex;
}

.demo-indicator .demo-icon {
    color: #10b981;
    font-size: 0.9rem;
}

.demo-indicator .demo-text {
    color: #10b981;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

@keyframes demo-indicator-pulse {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }
}

/* Game Over Modal Buttons */
.game-over-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    margin-bottom: 10px;
    animation: slideUp 0.5s ease-out forwards;
}

#game-over-main-menu {
    min-width: 180px;
}

/* Steam Leaderboards Panel */
.steam-leaderboard-panel {
    margin-top: 16px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: rgba(10, 12, 22, 0.45);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.steam-leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(196, 181, 253, 0.9);
}

.steam-leaderboard-title {
    font-weight: 700;
}

.steam-leaderboard-updated {
    font-size: 11px;
    color: rgba(148, 163, 184, 0.8);
}

.steam-leaderboard-board-tabs,
.steam-leaderboard-view-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.steam-leaderboard-tab {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: rgba(226, 232, 240, 0.9);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.steam-leaderboard-tab.active {
    background: rgba(139, 92, 246, 0.35);
    border-color: rgba(139, 92, 246, 0.6);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

.steam-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.steam-leaderboard-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.steam-leaderboard-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 12px;
    color: rgba(226, 232, 240, 0.85);
}

.steam-leaderboard-row.self {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(16, 185, 129, 0.15);
    color: #ecfdf5;
}

.steam-leaderboard-row.pending {
    border-style: dashed;
    opacity: 0.8;
}

.steam-leaderboard-rank {
    font-weight: 700;
    color: rgba(148, 163, 184, 0.9);
}

.steam-leaderboard-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.steam-leaderboard-score {
    font-weight: 700;
    color: #fbbf24;
}

.steam-leaderboard-status,
.steam-leaderboard-empty,
.steam-leaderboard-notice {
    font-size: 11px;
    color: rgba(148, 163, 184, 0.8);
}

.steam-leaderboard-notice {
    padding-top: 6px;
    border-top: 1px dashed rgba(148, 163, 184, 0.2);
}
