@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-sub.woff") format("woff");
  font-weight: 300 700;
  font-display: swap;
}

:root, [data-swatch="classic"] {
  --night: #241a44;
  --night-2: #33265e;
  --night-3: #45357a;
  --ink: #fff8ec;
  --ink-2: #d9cff5;
  --dim: #a99cd0;
  --accent: #ffd166;
  --bad: #ff7a90;
  --radius: 14px;
  /* theme tokens (see Themes at the end): these are "classic" (Coven) */
  --deep: #1b1436; --panel: #251b47; --raised: #3e2f72; --shade: #160f2e; --big-bot: #2b2052; --resume-top: #4a3a7e;
  --on-accent: #2c2050; --accent-shadow: #b0862e; --banner-bg: rgba(36, 26, 68, .94);
  /* the table */
  --felt: radial-gradient(120% 70% at 50% 0%, #3d2f73 0%, #2a1f52 45%, #1f173f 100%);
  --slot: rgba(217, 207, 245, .28); --slot-bg: rgba(10, 6, 24, .18);
  /* the cards */
  --card-face: #fbf3e2; --card-edge: #cdb98f; --c-black: #2b2342; --c-red: #c4304f; --c-dia: #2c6fc4; --c-club: #2e8a4c;
  --fig-fill: #f6e6c4; --fig-accent: #e0a23a;
  --back-bg: #3a2a6e; --back-ink: #ffd166; --back-line: #9a86e0; --back-edge: #1c1438;
  --sky:
    radial-gradient(2px 2px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 82% 9%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 30%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 30% 6%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 74%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 6% 88%, #fff5 50%, transparent 51%),
    radial-gradient(60% 40% at 50% 0%, #4b3a8a 0%, transparent 70%),
    radial-gradient(50% 35% at 100% 100%, #3b2a6a 0%, transparent 70%),
    linear-gradient(#2a1f50, #1d1538);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* a still night sky */
.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--sky); }

.app {
  max-width: 680px; margin: 0 auto; min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom));
}
.screen { display: flex; flex-direction: column; min-height: calc(100dvh - 20px); }

/* ---------- Home ---------- */
#home { gap: 12px; padding: 8px 8px 0; }
.brand { text-align: center; margin-top: 3vh; }
.brand .logo { width: 84px; height: 84px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); overflow: visible; }
.lg-back { fill: var(--back-bg); stroke: var(--back-line); stroke-width: 1.6; }
.lg-face { fill: var(--card-face); stroke: var(--card-edge); stroke-width: 1.6; }
.lg-red { fill: var(--c-red); }
.lg-moon { fill: var(--accent); }
.brand h1 { margin: 2px 0 0; font-size: 38px; font-weight: 700; letter-spacing: .02em; color: var(--ink); text-shadow: 0 3px 0 var(--shade); }
.brand .tag { margin: 0; color: var(--dim); }

.big {
  display: block; width: 100%; text-align: left; border: 2px solid var(--night-3); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--night-2), var(--big-bot)); padding: 13px 18px; min-height: 60px;
  box-shadow: 0 4px 0 var(--shade);
}
.big b { display: block; font-size: 20px; font-weight: 600; }
.big small { display: block; color: var(--dim); font-size: 15px; margin-top: 2px; }
.big:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--shade); }
.big.resume { border-color: var(--accent); background: linear-gradient(180deg, var(--resume-top), var(--night-2)); }
.big.resume b { color: var(--accent); }
.big.daily-btn b::after { content: ""; display: inline-block; width: .8em; height: .8em; margin-left: 8px; vertical-align: -1px;
  background: var(--accent); -webkit-mask: radial-gradient(circle at 70% 35%, transparent 38%, #000 40%); mask: radial-gradient(circle at 70% 35%, transparent 38%, #000 40%); border-radius: 50%; }
.modes { display: grid; gap: 10px; }
.home-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 14px 0 6px; }
.chip-btn { flex: 1; border: 2px solid var(--night-3); background: var(--deep); border-radius: 99px; padding: 10px 14px; min-height: 46px; white-space: nowrap; }
.chip-btn[aria-pressed="false"] { color: var(--dim); }

/* ---------- Sheets (bottom drawers) ---------- */
.sheet-bg { position: fixed; inset: 0; background: var(--scrim, rgba(10, 6, 24, .6)); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 680px; margin: 0 auto;
  background: var(--night-2); border-radius: 22px 22px 0 0; border-top: 2px solid var(--night-3);
  padding: 18px 16px max(18px, env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto;
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.sheet h3 { margin: 14px 0 2px; font-size: 18px; font-weight: 600; color: var(--accent); }
.label { color: var(--dim); font-size: 14px; margin: 14px 0 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg.two { grid-template-columns: 1fr 1fr; }
.seg.four { grid-template-columns: repeat(4, 1fr); }
.seg button {
  background: var(--panel); border: 2px solid var(--night-3); border-radius: 12px; padding: 10px 6px; min-height: 52px; text-align: center;
}
.seg button b { display: block; font-weight: 600; }
.seg button small { display: block; color: var(--dim); font-size: 13px; line-height: 1.2; }
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--raised); }
.go {
  display: block; width: 100%; margin-top: 16px; min-height: 54px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--on-accent); font-size: 20px; font-weight: 600; box-shadow: 0 4px 0 var(--accent-shadow);
}
.go:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-shadow); }
.go.small { width: auto; margin: 0; padding: 0 22px; font-size: 18px; }
.go.ghost { background: var(--night-3); color: var(--ink); box-shadow: 0 4px 0 var(--shade); }
.go .tick { color: var(--accent); }
.joinrow { display: flex; gap: 8px; }
.joinrow input {
  flex: 1; min-width: 0; letter-spacing: .12em; text-align: center; font-size: 22px; font-weight: 600;
  background: var(--deep); border: 2px solid var(--night-3); border-radius: 14px; color: var(--ink); padding: 8px;
}
.joinrow input:focus { outline: none; border-color: var(--accent); }
.howto { color: var(--ink-2); line-height: 1.45; margin: 8px 0; }
.keys { color: var(--dim); font-size: 14px; line-height: 1.4; margin: 14px 0 0; }
.linkish { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--dim); text-decoration: underline; font-size: 15px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.opt-grid .go { font-size: 17px; min-height: 50px; margin-top: 10px; }
#opts-bug { margin-top: 12px; display: flex; }
#opts-bug .chip-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }

.daily-list { display: grid; gap: 8px; margin-top: 6px; }
.daily-list button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 14px; min-height: 58px;
  border-radius: 14px; border: 2px solid var(--night-3); background: var(--panel); }
.daily-list button b { flex: 1; font-weight: 600; }
.daily-list button small { color: var(--dim); font-size: 14px; display: block; font-weight: 400; }
.daily-list button .tick { color: var(--accent); font-weight: 600; white-space: nowrap; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stats-grid div { background: var(--panel); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stats-grid b { display: block; font-size: 24px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.stats-grid small { color: var(--dim); font-size: 13px; }
.stats-var { margin: 14px 0 0; font-weight: 600; color: var(--ink-2); }
#stats-tabs button { min-height: 44px; padding: 6px 2px; }

/* ---------- Game ---------- */
#game { height: calc(100dvh - max(8px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom))); min-height: 0; gap: 6px; }
.topbar { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 46px; height: 46px; flex: none; border-radius: 12px; border: 2px solid var(--night-3); background: var(--deep); display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 24px; height: 24px; }
.hud { flex: 1; min-width: 0; text-align: center; line-height: 1.2; }
.mode-label { color: var(--ink-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nums { display: flex; justify-content: center; gap: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nums i { font-style: normal; color: var(--dim); font-size: 13px; }
.nums b { font-weight: 600; }

.table { position: relative; isolation: isolate; flex: 1; min-height: 0; width: 100%; touch-action: none; overflow: hidden; border-radius: 16px;
  background: var(--felt); box-shadow: inset 0 0 0 2px rgba(255,255,255,.04), inset 0 10px 40px rgba(0,0,0,.25); outline: none; }


.slot { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); border-radius: var(--cr);
  border: 2px dashed var(--slot); background: var(--slot-bg); display: grid; place-items: center; color: var(--slot); }
.slot svg { width: 46%; height: 46%; fill: currentColor; }
.slot span { font-weight: 700; font-size: calc(var(--cw) * .42); }
.slot.stock { border-style: solid; cursor: pointer; }
.slot.stock.spent svg { opacity: .35; }
.slot.kcur { border-color: var(--accent); border-style: solid; }
.slot.hint { border-color: var(--accent); border-style: solid; box-shadow: 0 0 14px var(--accent); }

.card { position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); transition: transform .22s cubic-bezier(.2, .7, .3, 1); cursor: pointer; }
.card.drag { transition: none; z-index: 3000 !important; cursor: grabbing; }
.card.still { transition: none; }
.cin { position: absolute; inset: 0; border-radius: var(--cr); }
.card.drag .cin { box-shadow: 0 10px 18px rgba(0, 0, 0, .45); }
.face, .back { position: absolute; inset: 0; border-radius: var(--cr); overflow: hidden; }
.face { background: var(--card-face); border: 1px solid var(--card-edge); color: var(--c-black); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.face.h, .face.d { color: var(--c-red); }
.four .face.d { color: var(--c-dia); }
.four .face.c { color: var(--c-club); }
.back { background: var(--back-img, none) center / 100% 100% no-repeat, var(--back-bg); border: 1px solid var(--back-edge); box-shadow: 0 1px 1px rgba(0, 0, 0, .18); }
.card:not(.up) .face { visibility: hidden; }
.card.up .back { visibility: hidden; }
.ix { position: absolute; left: 6%; top: 2%; font-weight: 700; font-size: calc(var(--cw) * .38); line-height: 1; letter-spacing: -.05em; }
.su { position: absolute; right: 5%; top: 5%; width: calc(var(--cw) * .3); height: calc(var(--cw) * .3); fill: currentColor; }
.art { position: absolute; left: 14%; right: 14%; top: 40%; bottom: 8%; display: grid; place-items: center; }
.art svg { width: 100%; height: 100%; fill: currentColor; overflow: visible; }
.art.pip svg { width: 78%; }
.art.ace svg.pipbig { width: 92%; filter: drop-shadow(0 1px 0 rgba(0,0,0,.15)); }
.art.ace .st { position: absolute; width: 22%; height: 22%; fill: var(--fig-accent); }
.art.ace .st.a { left: -6%; top: 4%; } .art.ace .st.b { right: -6%; bottom: 0; width: 16%; height: 16%; }
.art.fig { left: 6%; right: 6%; top: 30%; bottom: 2%; }
.art.fig svg { stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; fill: none; }
.art.fig svg .fl { fill: var(--fig-fill); }
.art.fig svg .ac { fill: var(--fig-accent); }
.art.fig svg .ac-s { stroke: var(--fig-accent); }
.card.small .art { display: none; }       /* tiny cards (Spider on a small phone) keep only the corner */

/* turning a card over */
.card.flipping .cin { animation: flipx .24s ease-in-out; }
.card.flipping.up .face { animation: show-late .24s; }
.card.flipping.up .back { animation: hide-late .24s; }
.card.flipping:not(.up) .back { animation: show-late .24s; }
.card.flipping:not(.up) .face { animation: hide-late .24s; }
@keyframes flipx { 0% { transform: scaleX(1); } 50% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
@keyframes show-late { 0%, 49.9% { visibility: hidden; } 50%, 100% { visibility: visible; } }
@keyframes hide-late { 0%, 49.9% { visibility: visible; } 50%, 100% { visibility: hidden; } }

.card.hint .cin { animation: glow 1.4s ease-in-out; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 25%, 75% { box-shadow: 0 0 0 3px var(--accent), 0 0 16px var(--accent); } }
.card.sel .cin { box-shadow: 0 0 0 3px var(--accent), 0 0 12px var(--accent); }
.card.kcur .cin { box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--night); }
.card.sel.kcur .cin { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px var(--ink); }
.card.nope .cin { animation: nope .28s ease-in-out; }
@keyframes nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* the win: the cards drift into a ring and a few stars come out */
.spark { position: absolute; width: 14px; height: 14px; fill: var(--accent); pointer-events: none; opacity: 0; animation: twinkle 1.6s ease-in-out forwards; }
@keyframes twinkle { 0% { opacity: 0; transform: scale(.3) rotate(0deg); } 40% { opacity: .95; transform: scale(1) rotate(40deg); } 100% { opacity: 0; transform: scale(.6) rotate(90deg); } }

.banner { position: relative; text-align: center; padding: 10px 14px; margin: 0 auto; width: min(100%, 420px);
  background: var(--banner-bg); border: 2px solid var(--accent); border-radius: 14px; font-size: 17px; }
.banner .modal-buttons { margin-top: 8px; grid-template-columns: 1fr 1fr; }
.banner .go { min-height: 46px; font-size: 17px; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act { min-height: 52px; border-radius: 12px; border: 2px solid var(--night-3); background: var(--night-2); font-size: 16px; padding: 4px; line-height: 1.1; }
.act:disabled { opacity: .35; }
.act:active:not(:disabled) { background: var(--night-3); }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--scrim, rgba(10, 6, 24, .55)); padding: 16px; }
.card-modal { width: min(100%, 380px); background: var(--night-2); border: 2px solid var(--night-3); border-radius: 20px; padding: 20px 18px; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.5); animation: up .25s ease-out; }
.modal h3 { margin: 0 0 6px; font-size: 26px; font-weight: 600; }
.modal p { margin: 0 0 8px; color: var(--ink-2); }
/* the win: the card sits low so the ring of cards stays in view above it */
.modal.win { place-items: end center; background: linear-gradient(transparent 40%, var(--scrim, rgba(10, 6, 24, .55))); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.modal.win .card-modal { animation: up .4s ease-out; }
@media (orientation: landscape) and (max-height: 560px) { .modal.win { place-items: center end; background: linear-gradient(90deg, transparent 40%, var(--scrim, rgba(10, 6, 24, .55))); } }
.modal-buttons { display: grid; gap: 10px; margin-top: 14px; }
.modal-buttons .go { margin: 0; }
.won-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.won-nums div { background: var(--panel); border-radius: 12px; padding: 6px 4px; }
.won-nums b { display: block; font-size: 22px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.won-nums small { color: var(--dim); font-size: 13px; }
.won-best { color: var(--accent) !important; font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--night); padding: 10px 16px; border-radius: 12px; font-weight: 600; pointer-events: none;
  opacity: 0; transition: opacity .2s; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; }

/* Desktop: a wider table */
@media (min-width: 760px) and (min-height: 560px) {
  .app { max-width: 1180px; }
  #game .topbar, #game .actions { width: min(100%, 720px); margin: 0 auto; }
}
/* Landscape phones: the buttons go down the side so the cards get the height */
@media (orientation: landscape) and (max-height: 560px) {
  .app { max-width: none; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  #game { display: grid; grid-template-columns: 1fr 108px; grid-template-rows: auto 1fr; gap: 6px 10px;
    height: calc(100dvh - max(6px, env(safe-area-inset-top)) - max(6px, env(safe-area-inset-bottom))); }
  #game .topbar { grid-column: 1; grid-row: 1; }
  #game .table { grid-column: 1; grid-row: 2; }
  #game .banner { grid-column: 1; grid-row: 2; align-self: end; margin-bottom: 8px; z-index: 5; }
  #game .actions { grid-column: 2; grid-row: 1 / span 2; grid-template-columns: 1fr; align-content: end; }
  .act { min-height: 46px; }
  .icon-btn { width: 42px; height: 42px; }
  #home { display: grid; grid-template-columns: 1fr 1.3fr; grid-template-rows: auto 1fr; column-gap: 20px; row-gap: 8px; align-content: center; max-width: 900px; margin: 0 auto; }
  #home .brand { grid-column: 1; grid-row: 1; margin-top: 0; align-self: end; }
  #home .brand .logo { width: 56px; height: 56px; }
  #home .brand h1 { font-size: 30px; }
  #home .home-foot { grid-column: 1; grid-row: 2; margin-top: 0; align-self: start; padding-top: 4px; }
  #home #resume, #home .modes { grid-column: 2; }
  #home #resume { grid-row: 1; align-self: end; }
  #home .modes { grid-row: 1 / span 2; align-self: center; gap: 8px; }
  #home #resume:not([hidden]) ~ .modes { grid-row: 2; align-self: start; }
  .big { padding: 8px 14px; min-height: 50px; }
  .big small { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Themes ----------
   Each theme is a set of colour tokens on <html data-theme="...">. "classic" (Coven) is the :root values above.
   theme.js applies the saved one before the page is drawn; the picker is the Theme sheet. */
:root[data-theme="midnight"], [data-swatch="midnight"] {
  --night: #0e0f14; --night-2: #1a1c24; --night-3: #2c2f3b; --ink: #eef0f5; --ink-2: #c9ccd6; --dim: #9599a8;
  --accent: #8fb8ff; --on-accent: #0e1626; --accent-shadow: #4f6fa8; --bad: #ff7a85;
  --deep: #08090d; --panel: #15171e; --raised: #263147; --shade: #000; --big-bot: #14161c; --resume-top: #22283a; --banner-bg: rgba(14, 15, 20, .95);
  --sky: radial-gradient(60% 40% at 50% 0%, #1d2233 0%, transparent 70%), linear-gradient(#111319, #0a0b0f);
  --felt: radial-gradient(120% 70% at 50% 0%, #22283a 0%, #151821 55%, #0d0f15 100%); --slot: rgba(201, 204, 214, .25);
  --card-face: #f2f3f6; --card-edge: #9aa0b0; --c-black: #15171e; --c-red: #d13a4a; --c-dia: #2f6fd0; --c-club: #2b8a55;
  --fig-fill: #dfe4ee; --fig-accent: #5f8fe0;
  --back-bg: #1c2233; --back-ink: #8fb8ff; --back-line: #46516e; --back-edge: #05060a;
}
:root[data-theme="felt"], [data-swatch="felt"] {
  --night: #12241a; --night-2: #1b3426; --night-3: #2f5240; --ink: #f1f5ec; --ink-2: #d4e2cf; --dim: #a3bca6;
  --accent: #f2c14e; --on-accent: #22301f; --accent-shadow: #a8812a; --bad: #ff8a7a;
  --deep: #0c1a12; --panel: #17301f; --raised: #2c4a36; --shade: #07110b; --big-bot: #16301f; --resume-top: #2a4a35; --banner-bg: rgba(18, 36, 26, .96);
  --sky: radial-gradient(60% 40% at 50% 0%, #2c5238 0%, transparent 70%), linear-gradient(#173023, #0d1b13);
  --felt: radial-gradient(120% 75% at 50% 10%, #2f7a4a 0%, #1f5c36 50%, #164428 100%); --slot: rgba(230, 245, 230, .3); --slot-bg: rgba(0, 0, 0, .1);
  --card-face: #ffffff; --card-edge: #a9b4a6; --c-black: #1d1d24; --c-red: #cc2a36; --c-dia: #1f63c6; --c-club: #1d7a3a;
  --fig-fill: #f6edd6; --fig-accent: #d9a43a;
  --back-bg: #8c1f2c; --back-ink: #f2c14e; --back-line: #d86070; --back-edge: #4a0c14;
}
:root[data-theme="wood"], [data-swatch="wood"] {
  color-scheme: light;
  --night: #f3ead8; --night-2: #fffaf0; --night-3: #d8c7a4; --ink: #2e2214; --ink-2: #4a3a26; --dim: #6b573d;
  --accent: #a84a24; --on-accent: #fffaf0; --accent-shadow: #6e2f14; --bad: #b3261e;
  --deep: #fffdf8; --panel: #f7eedd; --raised: #f0dcc0; --shade: #c9b48e; --big-bot: #f5ead6; --resume-top: #fff3df; --banner-bg: rgba(255, 250, 240, .97);
  --sky: radial-gradient(60% 40% at 50% 0%, #fff7e6 0%, transparent 70%), linear-gradient(#f6eedd, #eadcc0);
  --felt: linear-gradient(100deg, rgba(255,255,255,.05) 0 2%, transparent 2% 30%, rgba(0,0,0,.04) 30% 31%, transparent 31%), radial-gradient(120% 80% at 50% 0%, #b9875a 0%, #9c6c41 55%, #7f5330 100%);
  --slot: rgba(255, 244, 220, .45); --slot-bg: rgba(60, 30, 10, .12);
  --card-face: #fffaf0; --card-edge: #b99d74; --c-black: #2e2214; --c-red: #b3261e; --c-dia: #2a5fa8; --c-club: #3a7a2a;
  --fig-fill: #f3dfbd; --fig-accent: #c4862f;
  --back-bg: #5a3a1e; --back-ink: #f0c070; --back-line: #a8774a; --back-edge: #2e1c0c;
}
:root[data-theme="neon"], [data-swatch="neon"] {
  --night: #0a0618; --night-2: #160d2e; --night-3: #3a1d6e; --ink: #f4f1ff; --ink-2: #d6ccff; --dim: #a596d8;
  --accent: #2af5d2; --on-accent: #04201b; --accent-shadow: #0f8f7a; --bad: #ff4f8b;
  --deep: #07041a; --panel: #120a28; --raised: #2a1460; --shade: #000; --big-bot: #110a26; --resume-top: #26135a; --banner-bg: rgba(10, 6, 24, .95);
  --sky: radial-gradient(50% 35% at 15% 0%, rgba(255, 63, 212, .32) 0%, transparent 70%), radial-gradient(50% 35% at 90% 100%, rgba(42, 245, 210, .22) 0%, transparent 70%), linear-gradient(#0d0722, #06030f);
  --felt: radial-gradient(70% 50% at 20% 0%, rgba(255, 63, 212, .25) 0%, transparent 70%), radial-gradient(60% 45% at 90% 100%, rgba(42, 245, 210, .18) 0%, transparent 70%), #0f0824;
  --slot: rgba(42, 245, 210, .4);
  --card-face: #f7f5ff; --card-edge: #ff3fd4; --c-black: #1a0638; --c-red: #e8247c; --c-dia: #1b6fe0; --c-club: #0c9a7e;
  --fig-fill: #e9e4ff; --fig-accent: #ff3fd4;
  --back-bg: #1a0638; --back-ink: #2af5d2; --back-line: #ff3fd4; --back-edge: #000;
}
:root[data-theme="ocean"], [data-swatch="ocean"] {
  --night: #0b2236; --night-2: #12324d; --night-3: #24557a; --ink: #eef7ff; --ink-2: #cfe4f5; --dim: #9dbdd4;
  --accent: #ffb86b; --on-accent: #2b1a08; --accent-shadow: #b0753a; --bad: #ff8a8a;
  --deep: #081a2a; --panel: #0f2b43; --raised: #1f4a6e; --shade: #04121e; --big-bot: #0f2c45; --resume-top: #1d4668; --banner-bg: rgba(11, 34, 54, .96);
  --sky: radial-gradient(60% 40% at 50% 0%, #1f5580 0%, transparent 70%), linear-gradient(#0f2c45, #071724);
  --felt: radial-gradient(120% 70% at 50% 0%, #1f5580 0%, #143a5c 50%, #0b2236 100%); --slot: rgba(207, 228, 245, .3);
  --card-face: #fbfdff; --card-edge: #9fb7c9; --c-black: #0b2236; --c-red: #d2404f; --c-dia: #2a70c8; --c-club: #2a8a6a;
  --fig-fill: #e2eef8; --fig-accent: #f0963c;
  --back-bg: #12324d; --back-ink: #ffb86b; --back-line: #4f86ad; --back-edge: #04121e;
}
:root[data-theme="pastel"], [data-swatch="pastel"] {
  color-scheme: light;
  --night: #f7f1fb; --night-2: #ffffff; --night-3: #dccdf0; --ink: #3a2b52; --ink-2: #4f3f6a; --dim: #6a5a86;
  --accent: #f7b6d2; --on-accent: #3a2b52; --accent-shadow: #d98bb0; --bad: #b42848;
  --deep: #ffffff; --panel: #f3ebfa; --raised: #f8dcec; --shade: #d8c8ea; --big-bot: #f6effc; --resume-top: #fde8f2; --banner-bg: rgba(255, 255, 255, .97);
  --sky: radial-gradient(50% 40% at 10% 0%, #ffe3ef 0%, transparent 70%), radial-gradient(50% 40% at 90% 100%, #dff3ee 0%, transparent 70%), linear-gradient(#f9f3fd, #f1eafa);
  --felt: radial-gradient(120% 70% at 50% 0%, #e7dbf7 0%, #d8c8f0 55%, #cbb8e8 100%); --slot: rgba(90, 70, 130, .3); --slot-bg: rgba(255, 255, 255, .25);
  --card-face: #ffffff; --card-edge: #c9b8e6; --c-black: #4a3a68; --c-red: #d6467c; --c-dia: #4a7ad8; --c-club: #3a9a7a;
  --fig-fill: #fdeef5; --fig-accent: #f28cb8;
  --back-bg: #b8a2e0; --back-ink: #fff4fa; --back-line: #f7b6d2; --back-edge: #7d69b0;
}
:root[data-theme="contrast"], [data-swatch="contrast"] {
  --night: #000; --night-2: #000; --night-3: #fff; --ink: #fff; --ink-2: #fff; --dim: #e6e6e6;
  --accent: #ffe500; --on-accent: #000; --accent-shadow: #8a7c00; --bad: #ff6b6b;
  --deep: #000; --panel: #000; --raised: #333; --shade: #000; --big-bot: #000; --resume-top: #1a1a1a; --banner-bg: #000; --sky: linear-gradient(#000, #000);
  --felt: #0a2a14; --slot: #fff; --slot-bg: transparent;
  --card-face: #fff; --card-edge: #000; --c-black: #000; --c-red: #d0001c; --c-dia: #0040d0; --c-club: #00701c;
  --fig-fill: #fff; --fig-accent: #e0a000;
  --back-bg: #1f2fb8; --back-ink: #ffe500; --back-line: #fff; --back-edge: #fff;
}
:root[data-theme="contrast"] .big, :root[data-theme="contrast"] .seg button, :root[data-theme="contrast"] .act { border-color: #fff; }
:root[data-theme="contrast"] .ix { font-size: calc(var(--cw) * .42); }

/* the pickers */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.themes button, .backs button { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 10px; text-align: left;
  border-radius: 14px; border: 2px solid var(--night-3); background: var(--panel); color: var(--ink); }
.themes button[aria-pressed="true"], .backs button[aria-pressed="true"] { border-color: var(--accent); background: var(--raised); }
.themes .sw { flex: none; position: relative; width: 44px; height: 40px; border-radius: 8px; overflow: hidden; background: var(--felt); box-shadow: 0 0 0 2px var(--deep); }
.themes .sw i { position: absolute; top: 6px; width: 18px; height: 26px; border-radius: 3px; }
.themes .sw i.f { left: 5px; background: var(--card-face); border: 1px solid var(--card-edge); }
.themes .sw i.f::after { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px; background: var(--c-red); border-radius: 50% 50% 0 50%; transform: rotate(45deg); }
.themes .sw i.b { left: 21px; top: 9px; background: var(--back-bg); border: 1px solid var(--back-line); }
.backs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.backs button { flex-direction: column; gap: 4px; padding: 8px 4px; font-size: 14px; text-align: center; }
.backs .bk { width: 40px; height: 56px; border-radius: 5px; background-size: 100% 100%; border: 1px solid var(--back-edge); }
