#scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: linear-gradient(#0a1230, #3a337f 45%, #a8618f 62%, #12173f 64%, #070b24); }
#scene canvas { width: 100%; height: 100%; display: block; }
.aurora, .aurora::before, .aurora::after { position: absolute; inset: -4% -20% 44%; pointer-events: none; mix-blend-mode: screen; }
.aurora::before, .aurora::after { content: ""; inset: 0; }
.aurora { opacity: .5; -webkit-mask: linear-gradient(transparent, #000 25%, #000 45%, transparent 85%); mask: linear-gradient(transparent, #000 25%, #000 45%, transparent 85%); }
.aurora::before { background: repeating-linear-gradient(98deg, transparent 0 7%, rgb(70 220 190 / .34) 11%, rgb(120 160 255 / .2) 16%, transparent 22% 29%); animation: aurora 34s ease-in-out infinite alternate; }
.aurora::after { background: repeating-linear-gradient(84deg, transparent 0 11%, rgb(160 120 255 / .26) 17%, rgb(80 230 200 / .2) 21%, transparent 27% 38%); animation: aurora 47s ease-in-out infinite alternate-reverse; }
.twinkle { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 1px rgb(200 220 255 / .8); animation: twinkle 4s ease-in-out infinite; }
.meteor { position: absolute; left: 62%; top: 4%; width: 11rem; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #fff, transparent); opacity: 0; rotate: -24deg; animation: meteor 31s linear 9s infinite; }
@keyframes aurora { from { transform: translateX(-7%) skewX(-5deg); } to { transform: translateX(7%) skewX(6deg); } }
@keyframes twinkle { 0%, 100% { opacity: .08; } 50% { opacity: .85; } }
@keyframes meteor { 0% { opacity: 0; transform: none; } .4% { opacity: .9; } 2.6% { opacity: 0; transform: translateX(-34rem); } 100% { opacity: 0; transform: translateX(-34rem); } }
@media (prefers-reduced-motion: reduce) {
  .aurora::before, .aurora::after { animation: none; }
  .twinkle, .meteor { display: none; }
}

/* Each background brings its own colors. The plain table takes the theme's, and whether it is light or dark. */
html[data-backdrop="plain"] {
  --surface: var(--sw-surface); --surface-deep: var(--sw-raised); --glass: var(--sw-raised); --panel: var(--sw-raised);
  --slot: color-mix(in srgb, var(--sw-raised) 60%, transparent); --slot-line: var(--sw-border); --slot-mark: var(--sw-muted);
  --on-scene: var(--sw-on-surface); --on-scene-target: var(--sw-accent); --scene-shadow: transparent;
  --line: var(--sw-border); --text: var(--sw-on-raised); --muted: var(--sw-muted); --action: var(--sw-action); --on-action: var(--sw-on-action);
  --target: var(--sw-accent); --heading: var(--sw-display);
}
html[data-backdrop="plain"] #scene { background: radial-gradient(ellipse at 50% 42%, var(--sw-raised), var(--sw-surface) 78%); }
html[data-backdrop="lake"] {
  --surface: #141b45; --surface-deep: #141c46; --glass: rgb(12 18 52 / .62); --slot: rgb(10 16 48 / .5);
  --slot-line: rgb(190 202 255 / .42); --slot-mark: rgb(190 202 255 / .5); --panel: rgb(14 20 56 / .95);
  --line: #7f90cf; --text: #f2f6fb; --muted: #c3d3e6; --action: #f2bd4e; --on-action: #16243f; --target: #8fe3d2;
  --heading: Rockwell, "Roboto Slab", "Rockwell Nova", "Bookman Old Style", serif;
}
html:not([data-backdrop="lake"], [data-backdrop="heavens"]) :is(.aurora, .meteor) { display: none; }
html:not([data-backdrop="lake"], [data-backdrop="heavens"], [data-backdrop="jerusalem"]) .twinkle { display: none; }
html[data-backdrop="manor"] {
  --surface: #1f2a22; --surface-deep: #24332a; --glass: rgb(22 29 23 / .8); --slot: rgb(18 26 19 / .55);
  --slot-line: rgb(238 222 178 / .45); --slot-mark: rgb(238 222 178 / .55); --panel: rgb(26 36 29 / .96);
  --line: #a3966d; --text: #f8f3e4; --muted: #d8cfb4; --action: #dcb765; --on-action: #231a0d; --target: #b4e6bb;
  --heading: Didot, "Bodoni MT", Baskerville, "Libre Baskerville", Georgia, serif;
}
html[data-backdrop="jerusalem"] {
  --surface: #14244a; --surface-deep: #172c59; --glass: rgb(14 27 60 / .78); --slot: rgb(13 25 58 / .55);
  --slot-line: rgb(240 220 170 / .45); --slot-mark: rgb(240 220 170 / .55); --panel: rgb(17 32 68 / .96);
  --line: #8fa5d6; --text: #fbf6e8; --muted: #d5dbea; --action: #e3c069; --on-action: #1a2344; --target: #a5e6ea;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="throne"] {
  --surface: #33101c; --surface-deep: #421526; --glass: rgb(40 10 20 / .78); --slot: rgb(34 8 18 / .55);
  --slot-line: rgb(240 206 138 / .48); --slot-mark: rgb(240 206 138 / .55); --panel: rgb(48 15 27 / .96);
  --line: #c49a5a; --text: #fdf3e2; --muted: #e2cbb4; --action: #e6bd5c; --on-action: #2a0e16; --target: #b3ddff;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="deco"] {
  --surface: #12100c; --surface-deep: #1f1a12; --glass: rgb(16 14 10 / .8); --slot: rgb(14 12 8 / .6);
  --slot-line: rgb(226 184 98 / .5); --slot-mark: rgb(226 184 98 / .55); --panel: rgb(22 19 13 / .97);
  --line: #a98845; --text: #f8efd9; --muted: #d8c8a2; --action: #e2b653; --on-action: #1a140b; --target: #93e6cd;
  --heading: Futura, "Century Gothic", "Avenir Next", sans-serif;
}
html[data-backdrop="meadow"] {
  --surface: #4a2746; --surface-deep: #582d53; --glass: rgb(82 38 76 / .84); --slot: rgb(92 44 84 / .45);
  --on-scene: #4a1c38; --on-scene-target: #8a1458; --scene-shadow: #fff;
  --slot-line: rgb(255 236 246 / .7); --slot-mark: rgb(255 236 246 / .75); --panel: rgb(78 38 73 / .97);
  --line: #dfa3c8; --text: #fff5fa; --muted: #f3d3e4; --action: #ffb3cf; --on-action: #4a1c38; --target: #ffe682;
  --heading: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", Nunito, sans-serif;
}
html[data-backdrop="heavens"] {
  --surface: #12123a; --surface-deep: #1b1c50; --glass: rgb(14 14 48 / .75); --slot: rgb(12 12 44 / .5);
  --slot-line: rgb(216 212 255 / .45); --slot-mark: rgb(216 212 255 / .55); --panel: rgb(18 18 58 / .96);
  --line: #9a91d6; --text: #f5f2ff; --muted: #cfcaf0; --action: #f0c869; --on-action: #1b1740; --target: #a2eadb;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="christmas"] {
  --surface: #16332e; --surface-deep: #102820; --glass: rgb(13 33 29 / .91); --slot: rgb(11 29 26 / .7);
  --slot-line: rgb(237 210 152 / .62); --slot-mark: rgb(253 232 189 / .76); --panel: rgb(18 40 34 / .98);
  --line: #ad9c6f; --text: #fff4df; --muted: #dfd8c4; --action: #edc478; --on-action: #302013; --target: #f5d695;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="christmas"] #scene { background: linear-gradient(#102534, #203b46 48%, #516e72); }
html[data-backdrop="garden"] {
  --surface: #16243f; --surface-deep: #182a47; --glass: rgb(13 22 42 / .84); --slot: rgb(12 20 38 / .5);
  --slot-line: rgb(222 232 214 / .42); --slot-mark: rgb(222 232 214 / .55); --panel: rgb(17 30 50 / .96);
  --line: #7f9bb0; --text: #f5f6ec; --muted: #cdd8d6; --action: #f3c76b; --on-action: #24301f; --target: #a8e6b4;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="garden"] #scene { background: linear-gradient(#0a1030, #27386a 42%, #1b3638 50%, #0f2226); }
.garden, .garden > * { position: absolute; inset: 0; }
.garden-dawn { opacity: calc(var(--light, 0) * (1.1 - .1 * var(--light, 0))); transition: opacity 1.7s ease-out; }
.garden-moon { width: 5.2vmin; height: 5.2vmin; inset: 0 auto auto 0; border-radius: 50%; background: radial-gradient(circle at 38% 36%, #fffdf0, #f3ead0 55%, #d8cdb4);
  box-shadow: 0 0 3vmin 1vmin rgb(255 246 214 / .38), 0 0 14vmin 6vmin rgb(206 214 255 / .16);
  translate: calc(35vw - 2.6vmin + 2vw * var(--light, 0)) calc(19vh + 9vh * var(--light, 0)); opacity: calc(1.35 - 1.6 * var(--light, 0)); transition: translate 1.7s ease-out, opacity 1.7s ease-out; }
.garden[data-spider="true"] .garden-moon { translate: calc(15vw - 2.6vmin + 2vw * var(--light, 0)) calc(19vh + 9vh * var(--light, 0)); }
.garden-sun { opacity: 0; mix-blend-mode: screen; background: radial-gradient(circle at 36% 27%, #fff8e0 0 3.6vmin, rgb(255 228 160 / .8) 4.1vmin, rgb(255 204 128 / .4) 13vmin, rgb(255 186 116 / .14) 38vmin, rgb(255 190 120 / 0) 80vmin); transition: opacity 1.7s ease-out; }
.garden[data-won="true"] .garden-sun { opacity: 1; }
.garden-shine { opacity: calc(1.05 - var(--light, 0)); transition: opacity 1.7s ease-out; }
.garden-wash { background: linear-gradient(transparent 38%, rgb(8 20 56 / .2) 48%); opacity: calc(1 - var(--light, 0)); transition: opacity 1.7s ease-out; }
.garden-mist { opacity: calc(var(--mist, 0) * .85); transition: opacity 2.4s ease-out; background:
  radial-gradient(ellipse 34% 5% at 10% 58%, rgb(176 194 226 / .5), transparent), radial-gradient(ellipse 40% 5.5% at 58% 61%, rgb(170 188 222 / .44), transparent),
  radial-gradient(ellipse 30% 6% at 94% 66%, rgb(176 194 226 / .46), transparent), radial-gradient(ellipse 44% 5% at 28% 74%, rgb(166 186 220 / .36), transparent),
  radial-gradient(ellipse 40% 5% at 78% 81%, rgb(166 186 220 / .34), transparent), radial-gradient(ellipse 50% 5% at 30% 93%, rgb(160 180 216 / .26), transparent); }
/* Once it is won the garden is the thing to look at. */
body:has(.garden[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { opacity: 0; transition: opacity 1.4s; }
@media (prefers-reduced-motion: reduce) {
  .garden > *, body:has(.garden[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { transition: none; }
}

html[data-backdrop="ballet"] {
  --surface: #2a1a33; --surface-deep: #342140; --glass: rgb(33 19 42 / .86); --slot: rgb(24 13 32 / .5);
  --slot-line: rgb(255 226 222 / .45); --slot-mark: rgb(255 226 222 / .55); --panel: rgb(38 24 47 / .96);
  --line: #b493b4; --text: #fff5f2; --muted: #e6cfd8; --action: #f0c27a; --on-action: #33201a; --target: #a9e4e0;
  --heading: Didot, "Bodoni MT", Baskerville, "Libre Baskerville", Georgia, serif;
}
html[data-backdrop="ballet"] #scene { background: linear-gradient(#2a1430, #4a2444 45%, #6a4030 50%, #1c0f14); }
.ballet, .ballet > * { position: absolute; inset: 0; }
.ballet-loft { overflow: hidden; inset: 0 0 auto; box-shadow: inset 0 -14px 22px -12px rgb(20 6 16 / .55); }
#scene .ballet-drop { translate: 0 calc(-101% * var(--drop, 0)); transition: translate 1.8s cubic-bezier(.3, 0, .2, 1); }
.ballet-cool { background: linear-gradient(rgb(22 26 84 / .3), rgb(24 34 128 / .66) 46%, rgb(18 22 92 / .7)); opacity: calc(1 - var(--drop, 0)); transition: opacity 1.8s ease-out; }
#scene .ballet-curtain { inset: 0 auto auto 0; width: 50%; height: 96.5%; transform-origin: left; transform: scaleX(calc(.54 - .42 * var(--open, 0))); transition: transform 1.8s cubic-bezier(.3, 0, .2, 1); filter: drop-shadow(0 0 14px rgb(10 0 10 / .5)); }
#scene .ballet-right { inset: 0 0 auto auto; transform-origin: right; }
/* Once it is won the dance is the thing to look at. */
body:has(.ballet[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { opacity: 0; transition: opacity 1.4s; }
@media (prefers-reduced-motion: reduce) {
  .ballet > *, #scene .ballet-drop, #scene .ballet-curtain, body:has(.ballet[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { transition: none; }
}

html[data-backdrop="aquarium"] {
  --surface: #0c3347; --surface-deep: #10405a; --glass: rgb(8 38 54 / .86); --slot: rgb(6 34 50 / .46);
  --slot-line: rgb(214 246 250 / .5); --slot-mark: rgb(214 246 250 / .6); --panel: rgb(10 44 62 / .96);
  --line: #74aec0; --text: #f0fbfa; --muted: #c9e3e6; --action: #ffc866; --on-action: #2a1c06; --target: #a6f2da;
  --heading: ui-rounded, "SF Pro Rounded", "Avenir Next", Avenir, "Segoe UI", sans-serif;
}
html[data-backdrop="aquarium"] #scene { background: linear-gradient(#4cc4d4, #1f8fb4 45%, #0f5f86 82%, #c9b684); }
.aquarium, .aquarium > * { position: absolute; inset: 0; }
.aquarium-night { background: linear-gradient(rgb(4 22 62 / .7), rgb(5 30 70 / .62) 60%, rgb(6 24 48 / .66)); opacity: calc(1 - var(--light, 0)); transition: opacity 1.8s ease-out; }
.aquarium-dusk { background: linear-gradient(rgb(4 22 62 / .2), rgb(5 26 62 / .26)); opacity: calc(1 - var(--light, 0)); transition: opacity 1.8s ease-out; }
.aquarium.asleep > :is(.aquarium-night, .aquarium-dusk) { opacity: 1.2; }
.aquarium-rays { inset: -10% -20%; opacity: calc(.18 + .62 * var(--light, 0)); mix-blend-mode: screen; transform-origin: 46% -20%; transition: opacity 1.8s ease-out;
  background: repeating-conic-gradient(from 150deg at 46% -18%, transparent 0 4deg, rgb(230 255 250 / .2) 6deg 7deg, transparent 9deg 12deg, rgb(230 255 250 / .13) 13.4deg, transparent 15deg 19deg);
  -webkit-mask: linear-gradient(#000, rgb(0 0 0 / .5) 45%, transparent 82%); mask: linear-gradient(#000, rgb(0 0 0 / .5) 45%, transparent 82%); animation: aquarium-rays 23s ease-in-out infinite alternate; }
@keyframes aquarium-rays { from { transform: rotate(-2.4deg); } to { transform: rotate(2.8deg); } }
.aquarium.kept-still .aquarium-rays { animation: none; }
/* Once it is won the tank is the thing to look at. */
body:has(.aquarium[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { opacity: 0; transition: opacity 1.4s; }
@media (prefers-reduced-motion: reduce) {
  .aquarium-rays { animation: none; }
  .aquarium > *, body:has(.aquarium[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { transition: none; }
}

/* The chooser's previews. */
.theme-preview { position: relative; display: flex; justify-content: center; align-items: center; gap: .4rem; width: 100%; height: 7.2rem; border-radius: .4rem; overflow: hidden; }
.theme-preview canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.theme-preview .card { position: relative; flex: none; width: 64px; box-shadow: 0 2px 6px rgb(0 0 0 / .5); }
.backdrop-preview { height: 5.2rem; }
.sound-mark { font-size: 1.6rem; line-height: 1; }

html[data-backdrop="harbor"] {
  --surface: #121a38; --surface-deep: #172246; --glass: rgb(10 15 38 / .86); --slot: rgb(8 12 32 / .55);
  --slot-line: rgb(255 220 160 / .45); --slot-mark: rgb(255 220 160 / .58); --panel: rgb(16 23 50 / .96);
  --line: #8f8fb8; --text: #fff5e4; --muted: #d8d2dc; --action: #ffc46a; --on-action: #2a1a08; --target: #ffe2a6;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="harbor"] #scene { background: linear-gradient(#070b20, #18234a 46%, #0e1a3a 47%, #070f24 91%, #141a2c); }
.harbor, .harbor > * { position: absolute; inset: 0; }
/* Highlighted cards are lit from within, like the lanterns. */
html[data-backdrop="harbor"] .can-move > .card { box-shadow: 0 0 .9rem .25rem rgb(255 190 92 / .72), 0 2px 5px rgb(4 8 28 / .45); }
/* Once it is won the harbor is the thing to look at. */
body:has(.harbor[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { opacity: 0; transition: opacity 1.4s; }
@media (prefers-reduced-motion: reduce) {
  body:has(.harbor[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { transition: none; }
}

html[data-backdrop="glass"] {
  --surface: #1d1928; --surface-deep: #2a2438; --glass: rgb(19 16 28 / .88); --slot: rgb(12 10 20 / .58);
  --slot-line: rgb(226 208 172 / .45); --slot-mark: rgb(236 220 186 / .58); --panel: rgb(27 23 37 / .97);
  --line: #9c90a6; --text: #f8f0e2; --muted: #d6cbd4; --action: #f3c766; --on-action: #2a1c06; --target: #ffe9b0;
  --heading: "Cormorant Garamond", "Iowan Old Style", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="glass"] #scene { background: linear-gradient(#0d0b16, #231f2e 52%, #191621 52.2%, #14111b); }
.glass-nave, .glass-nave > * { position: absolute; inset: 0; }
.glass-nave > canvas { width: 100%; height: 100%; }
/* Highlighted cards have the sun behind them. */
html[data-backdrop="glass"] .can-move > .card { box-shadow: 0 0 .9rem .25rem rgb(255 226 150 / .74), 0 2px 5px rgb(8 6 16 / .5); }
/* Once it is won the windows are the thing to look at. */
body:has(.glass-nave[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { opacity: 0; transition: opacity 1.4s; }
@media (prefers-reduced-motion: reduce) {
  body:has(.glass-nave[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { transition: none; }
}

html[data-backdrop="tide"] {
  --surface: #2b3a3c; --surface-deep: #344648; --glass: rgb(26 38 40 / .88); --slot: rgb(14 30 34 / .5);
  --slot-line: rgb(230 244 236 / .5); --slot-mark: rgb(236 248 240 / .62); --panel: rgb(30 42 44 / .97);
  --line: #9fb4b0; --text: #f6f3ea; --muted: #d4dcd6; --action: #ffb36b; --on-action: #2a1606; --target: #c9f2e8;
  --heading: "Iowan Old Style", "Palatino Nova", Palatino, "Book Antiqua", Georgia, serif;
}
html[data-backdrop="tide"] #scene { background: radial-gradient(ellipse at 50% 55%, #2f7a82, #5a5650 62%, #48443e); }
.tidepool, .tidepool > * { position: absolute; inset: 0; }
.tidepool > canvas { width: 100%; height: 100%; }
.tidepool > .tide-dusk { background: linear-gradient(#0a1430, #1a1c3a); opacity: 0; }
/* Highlighted cards catch the sun off the water. */
html[data-backdrop="tide"] .can-move > .card { box-shadow: 0 0 .9rem .25rem rgb(190 255 240 / .72), 0 2px 5px rgb(4 20 24 / .45); }
/* Once it is won the pool is the thing to look at. */
body:has(.tidepool[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { opacity: 0; transition: opacity 1.4s; }
@media (prefers-reduced-motion: reduce) {
  body:has(.tidepool[data-won="true"]) #table[data-status="won"] :is(.columns, .slot, .key) { transition: none; }
}
