/* Shared nebula colors and star layers for the Galaxy collection. */
:is([data-card-back="galaxy-back"], [data-frame="galaxy-frame"], [data-table-theme="galaxy-table"], [data-badge="galaxy-badge"],
    [data-dice-theme="galaxy-dice-ur"], [data-dice-theme="galaxy-dice-foundry"], [data-piece-theme="galaxy-pieces"]) {
    --galaxy-nebula:
        radial-gradient(ellipse at 0% 12%, #bb43ad 0%, transparent 52%),
        radial-gradient(ellipse at 65% 48%, #436ad1 0%, transparent 59%),
        radial-gradient(ellipse at 17% 96%, #632ccb 0%, transparent 67%),
        #111938;
    --galaxy-stars:
        radial-gradient(circle at 13% 13%, #f3e6ff 0 .8px, transparent 1.5px),
        radial-gradient(circle at 67% 11%, #d6deff 0 .65px, transparent 1.3px),
        radial-gradient(circle at 83% 24%, #f7f4ff 0 1px, transparent 1.6px),
        radial-gradient(circle at 26% 36%, #e9ebff 0 1px, transparent 1.6px),
        radial-gradient(circle at 92% 53%, #d2eaff 0 .7px, transparent 1.3px),
        radial-gradient(circle at 14% 72%, #f5e2ff 0 .75px, transparent 1.4px),
        radial-gradient(circle at 72% 75%, #e3eeff 0 1px, transparent 1.7px),
        radial-gradient(circle at 39% 87%, #f9f1ff 0 .7px, transparent 1.3px),
        radial-gradient(circle at 89% 94%, #f2e6ff 0 .75px, transparent 1.4px);
}
[data-card-back="galaxy-back"] { --deck-border: #a59ae9; }
[data-card-back="galaxy-back"] .card.flipped {
    container-type: inline-size;
    overflow: hidden;
    isolation: isolate;
    background: var(--galaxy-nebula);
    border-color: var(--deck-border);
}
[data-card-back="galaxy-back"] .card.flipped::before {
    content: '';
    position: absolute;
    inset: -16%;
    pointer-events: none;
    background: var(--galaxy-stars), var(--galaxy-nebula);
    opacity: .9;
}
[data-card-back="galaxy-back"] .card.flipped::after {
    content: '✦';
    position: absolute;
    inset: 5%;
    display: grid;
    place-items: center;
    pointer-events: none;
    border: 1px solid #eee4ff60;
    border-radius: inherit;
    color: #fff4ff;
    text-shadow: 0 0 .4em #baadff;
    font-size: 39cqw;
    line-height: 1;
}
.profile-avatar[data-frame="galaxy-frame"] {
    border: 3px solid transparent;
    background: var(--galaxy-stars), var(--galaxy-nebula);
    background-origin: border-box;
    box-shadow: 0 0 .45rem #8b5edc70;
}
[data-table-theme="galaxy-table"] .card-table,
.theme-preview[data-table-theme="galaxy-table"],
:is(.badge-preview, .profile-badge)[data-badge="galaxy-badge"] {
    background: var(--galaxy-stars), var(--galaxy-nebula);
    color: #f8eeff;
    border-color: #7765a0;
}
[data-table-theme="galaxy-table"] .card-table {
    --control: #25264f;
    --table-panel: #191c3a;
    --table-line: #8c83ac;
    background-image: linear-gradient(#11152e90, #11152eb0), var(--galaxy-stars), var(--galaxy-nebula);
}
@media (prefers-reduced-motion: no-preference) {
    [data-card-back="galaxy-back"] .card.flipped::before { animation: galaxy-drift 14s ease-in-out infinite alternate; }
    .theme-preview[data-table-theme="galaxy-table"],
    .badge-preview[data-badge="galaxy-badge"],
    .frame-preview[data-frame="galaxy-frame"] { background-size: 145% 145%; animation: galaxy-pan 12s ease-in-out infinite alternate; }
    @keyframes galaxy-drift { from { transform: translate(-6%, -4%) rotate(-6deg); } to { transform: translate(7%, 5%) rotate(8deg); } }
    @keyframes galaxy-pan { from { background-position: 10% 15%; } to { background-position: 85% 80%; } }
}
@media (prefers-reduced-motion: no-preference) {
    [data-table-theme="galaxy-table"] .card-table {
        background-size: 100% 100%, 112% 112%, 112% 112%, 112% 112%, 112% 112%;
        animation: galaxy-pan 30s ease-in-out infinite alternate;
    }
}

:is(#game-mount, .theme-preview)[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) {
    --theme-light: hsl(var(--theme-hue, 254) 46% 78%);
    --theme-dark: hsl(var(--theme-hue, 254) 38% 40%);
    --theme-surface: hsl(var(--theme-hue, 254) 32% 20%);
    --theme-trim: hsl(var(--theme-hue, 254) 38% 52%);
    --theme-piece-light: hsl(var(--theme-hue, 254) 68% 96%);
    --theme-piece-dark: hsl(calc(var(--theme-hue, 254) + 165) 72% 58%);
}
#game-mount[data-table-theme="galaxy-table"], .theme-preview[data-table-theme="galaxy-table"] {
    --theme-light: #b5a5e4;
    --theme-dark: #43447c;
    --theme-surface: #171a38;
    --theme-trim: #846cd0;
    --theme-piece-light: #dffaff;
    --theme-piece-dark: #f6a2d2;
}
.theme-preview[data-table-theme]:not([data-table-theme="default-table"], [data-table-theme="galaxy-table"]) {
    background: conic-gradient(var(--theme-light) 25%, var(--theme-dark) 0 50%, var(--theme-light) 0 75%, var(--theme-dark) 0);
}
:is(#game-mount, .theme-preview)[data-table-theme][data-table-theme^="win-"] {
    --theme-trim: #d7b580;
}
#game-mount[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) :is(.board-table, .party-table, .card-table) {
    --control: color-mix(in srgb, var(--theme-surface) 65%, var(--theme-trim));
    --table-panel: var(--theme-surface);
    --table-line: var(--theme-trim);
    --party-surface: var(--control);
    --ink: #faf7ff;
    color-scheme: dark;
    color: var(--ink);
    background-color: var(--theme-surface);
    border-radius: .9rem;
}
#game-mount[data-table-theme="galaxy-table"] :is(.board-table, .party-table) {
    background-image: linear-gradient(#11152eb0, #11152ed9), var(--galaxy-stars), var(--galaxy-nebula);
}
#game-mount[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .board-grid {
    border-color: var(--theme-trim);
    background-color: var(--theme-surface);
}
:is(#game-mount, .chess-theme-preview)[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .board-cell:not(.dark, .in-check, .board-selected) {
    background-color: var(--theme-light);
    color: #17152a;
}
:is(#game-mount, .chess-theme-preview)[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .board-cell.dark:not(.board-selected) {
    background-color: var(--theme-dark);
    color: #fff;
}
:is(#game-mount, .chess-theme-preview)[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .board-piece {
    color: var(--ur-token-color, var(--theme-piece-light));
    text-shadow: 0 1px 1px #151027, 0 0 3px #151027, 0 0 3px #151027;
}
:is(#game-mount, .chess-theme-preview)[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .board-piece:is(.ink, .red, .connect-red) {
    color: var(--ur-token-color, var(--theme-piece-dark));
}
:is([data-dice-theme="galaxy-dice-ur"], [data-dice-theme="galaxy-dice-foundry"]) .board-die {
    --die-shading: linear-gradient(145deg, #ffffff18, transparent 45%, #080a284d);
    color: #eff9ff;
    background: var(--die-shading), var(--galaxy-stars), var(--galaxy-nebula);
}
[data-dice-theme="galaxy-dice-ur"] .binary-die {
    --die-shading: conic-gradient(from 60deg at 50% 67%, #21174b33 0 120deg, #0b102b80 120deg 240deg, #ffffff22 240deg);
}
@media (prefers-reduced-motion: no-preference) {
    :is([data-dice-theme="galaxy-dice-ur"], [data-dice-theme="galaxy-dice-foundry"]) .board-die:not(.dice-tumble) {
        background-size: 100% 100%, 145% 145%;
        animation: galaxy-pan 12s ease-in-out infinite alternate;
    }
}
[data-dice-theme="galaxy-dice-ur"] .binary-die .die-pip { background: #e5fbff; }
[data-piece-theme="galaxy-pieces"] :is(.ur-token, .board-piece):is(.ivory, .connect-yellow) {
    --piece-tint: #1467cc88;
}
[data-piece-theme="galaxy-pieces"] :is(.ur-token, .board-piece):is(.ink, .red, .connect-red) {
    --piece-tint: #a936cd99;
}
[data-piece-theme="galaxy-pieces"] :is(.ur-token:not(.waiting), .board-piece) {
    background: var(--galaxy-stars), linear-gradient(var(--piece-tint), var(--piece-tint)), var(--galaxy-nebula);
}
[data-piece-theme="galaxy-pieces"] .ur-token:not(.waiting) { border-color: var(--ur-token-color); }
[data-piece-theme="galaxy-pieces"] .board-piece:is(.ivory, .ink, .red, .connect-red, .connect-yellow) {
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 0 1px var(--ur-token-color));
}
@media (prefers-reduced-motion: no-preference) {
    [data-piece-theme="galaxy-pieces"] :is(.ur-token:not(.waiting), .board-piece:not(.moved, .captured)) {
        background-size: 145% 145%;
        animation: galaxy-pan 12s ease-in-out infinite alternate;
    }
}

#game-mount[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .ur-token.ivory {
    --ur-token-color: var(--theme-piece-light);
}
#game-mount[data-table-theme]:not([data-table-theme=""], [data-table-theme="default-table"]) .ur-token.red {
    --ur-token-color: var(--theme-piece-dark);
}
:is(#game-mount, .ur-piece-preview)[data-piece-theme="galaxy-pieces"] :is(.ur-token, .board-piece):is(.ivory, .connect-yellow) { --ur-token-color: #86c7ff; }
:is(#game-mount, .ur-piece-preview)[data-piece-theme="galaxy-pieces"] :is(.ur-token, .board-piece):is(.ink, .red, .connect-red) { --ur-token-color: #df9aff; }
[data-piece-theme="win-ur-pieces"] :is(.ur-token, .board-piece):is(.ivory, .connect-yellow) { --ur-token-color: #315ac2; }
[data-piece-theme="win-ur-pieces"] :is(.ur-token, .board-piece):is(.ink, .red, .connect-red) { --ur-token-color: #ffbb42; }
:is(#game-mount, .board-piece-preview)[data-piece-theme="win-ur-pieces"] .board-piece {
    color: var(--ur-token-color);
    text-shadow: 0 0 2px #151027;
}

:is(#game-mount, .chess-theme-preview)[data-table-theme="galaxy-table"] .board-cell.dark:not(.board-selected, .in-check) {
    background: linear-gradient(#151a4240, #151a4260), var(--galaxy-stars), var(--galaxy-nebula);
}
@media (prefers-reduced-motion: no-preference) {
    :is(#game-mount, .chess-theme-preview)[data-table-theme="galaxy-table"] .board-cell.dark:not(.board-selected, .in-check) {
        background-size: 100% 100%, 145% 145%;
        animation: galaxy-pan 12s ease-in-out infinite alternate;
    }
}
