/* Element Alchemy — one stylesheet.
   Concept: a warm alchemist's workshop. Day: parchment table (#f4ebdd), walnut frames,
   deep brown ink, gilded accents. Night: indigo-brown table (#1b1622), candle amber.
   A lamp's light breathes over the table (12 s), dust motes drift; tokens are glazed
   tiles tinted by their category. Serif titles, rounded sans for everything else.
   Motion: springs and ease-outs, transform/opacity only; .reduce turns travel into fades. */

:root {
  color-scheme: light;
  --table: #f4ebdd;
  --table-2: #e9dcc6;
  --panel: #fbf6ec;
  --panel-2: #f1e6d3;
  --raise: #fffaf2;
  --wood: #6b4a2f;
  --ink: #2e2318;
  --muted: #6c5640;
  --gold: #c8902e;
  --gold-ink: #85560f;
  --gold-soft: rgba(200, 144, 46, 0.18);
  --line: rgba(107, 74, 47, 0.18);
  --line-2: rgba(107, 74, 47, 0.3);
  --shadow: 38 22 10;
  --tok-bg1: #fdf8ef;
  --tok-bg2: #f3e7d2;
  --sil: #cdbfa9;
  --mote: #d9a845;
  --lamp: rgba(255, 214, 140, 0.55);
  --scrim: rgba(46, 32, 18, 0.32);
  --dim: rgba(30, 20, 10, 0.3);
  --danger: #b23a2a;
  --ca-accent: #96601a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  --sans: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", Nunito, "Varela Round", Quicksand, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --bar-h: 56px;
  --lib-w: 340px;
  --tok: 72px;
  --sheet-h: 96px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.45, 0.55, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .29 0 0 0 0 .18 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.33'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --table: #1b1622; --table-2: #15111b; --panel: #251e2e; --panel-2: #2e2639; --raise: #312840;
    --wood: #3d2f49; --ink: #f1e6d6; --muted: #bba994; --gold: #f0a848; --gold-ink: #f3b660; --gold-soft: rgba(240, 168, 72, 0.16);
    --line: rgba(241, 230, 214, 0.12); --line-2: rgba(241, 230, 214, 0.22); --shadow: 0 0 0;
    --tok-bg1: #2f2738; --tok-bg2: #231c2b; --sil: #3a3145; --mote: #f0a848; --lamp: rgba(240, 168, 72, 0.16);
    --scrim: rgba(8, 5, 12, 0.5); --dim: rgba(5, 3, 10, 0.4); --danger: #ff7a66;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --table: #1b1622; --table-2: #15111b; --panel: #251e2e; --panel-2: #2e2639; --raise: #312840;
  --wood: #3d2f49; --ink: #f1e6d6; --muted: #bba994; --gold: #f0a848; --gold-ink: #f3b660; --gold-soft: rgba(240, 168, 72, 0.16);
  --line: rgba(241, 230, 214, 0.12); --line-2: rgba(241, 230, 214, 0.22); --shadow: 0 0 0;
  --tok-bg1: #2f2738; --tok-bg2: #231c2b; --sil: #3a3145; --mote: #f0a848; --lamp: rgba(240, 168, 72, 0.16);
  --scrim: rgba(8, 5, 12, 0.5); --dim: rgba(5, 3, 10, 0.4); --danger: #ff7a66;
}

/* category colours: --c for art and tiles, --ci for text (≥ 4.5:1 on the theme) */
.cat-basic { --c: #d4a03a; --ci: #80570f; --cg: #f0c25e; }
.cat-nature { --c: #4aa3df; --ci: #1f638f; --cg: #7cc4f2; }
.cat-mineral { --c: #c58b2e; --ci: #80561a; --cg: #e3ae5a; }
.cat-ocean { --c: #1fa6a0; --ci: #0f6863; --cg: #4fd0c8; }
.cat-plant { --c: #4f9e3c; --ci: #2f6a22; --cg: #86cc6c; }
.cat-animal { --c: #c8643c; --ci: #8f3f1f; --cg: #ec9672; }
.cat-life { --c: #e8956b; --ci: #99502c; --cg: #f4b393; }
.cat-food { --c: #d6452f; --ci: #a2301e; --cg: #f57d68; }
.cat-material { --c: #a39a88; --ci: #5f5848; --cg: #c9c0ad; }
.cat-tool { --c: #5a7fa6; --ci: #355a80; --cg: #8fb2d8; }
.cat-place { --c: #b4513b; --ci: #8e3826; --cg: #e08670; }
.cat-tech { --c: #8a55e0; --ci: #6234b5; --cg: #b592f5; }
.cat-space { --c: #4a5fbf; --ci: #33459a; --cg: #93a4ee; }
.cat-myth { --c: #9b59b6; --ci: #76398f; --cg: #c995dc; }
.cat-culture { --c: #d65a8a; --ci: #a5355f; --cg: #f08fb3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) [class*="cat-"] { --ci: var(--cg); } }
:root[data-theme="dark"] [class*="cat-"] { --ci: var(--cg); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; background: var(--table); }
body {
  margin: 0; min-height: 100dvh; background: var(--table); color: var(--ink);
  font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.booting { visibility: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-ink); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.big { width: 30px; height: 30px; }

/* ---- buttons ------------------------------------------------------------------------------ */
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 14px; border: 0;
  background: transparent; color: var(--ink); transition: background .15s, transform .15s var(--spring);
}
.icon-btn:hover { background: var(--gold-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-btn[aria-pressed="true"] { background: var(--gold-soft); color: var(--gold-ink); }
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--raise);
  color: var(--ink); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: transform .15s var(--spring), background .15s, box-shadow .15s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--ca-accent); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -8px rgb(var(--shadow) / .5); }
.btn.primary:hover { background: #835214; }
.btn.big { min-height: 52px; padding: 0 26px; font-size: 17px; border-radius: 16px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--gold-soft); }
.btn.danger { color: var(--danger); }
.btn.on { color: var(--gold-ink); border-color: var(--gold); }

/* ---- the app frame ---------------------------------------------------------------------------- */
.app { position: fixed; inset: 0; display: grid; grid-template-rows: calc(var(--bar-h) + env(safe-area-inset-top)) 1fr; overflow: hidden; }
.bar {
  position: relative; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--panel) 88%, transparent); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 18px -14px rgb(var(--shadow) / .6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.bar-start { flex: 1 1 0; min-width: 0; display: flex; align-items: center; }
.bar-mid { flex: 0 1 auto; display: flex; align-items: center; gap: 2px; position: relative; }
.bar-end { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 2px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-icon { width: 30px; height: 30px; border-radius: 9px; flex: none; box-shadow: 0 2px 6px -2px rgb(var(--shadow) / .5); }
.brand-title { font: 600 19px/1.1 var(--serif); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-chip { margin-left: 4px; display: grid; place-items: center; min-width: 44px; min-height: 44px; }

.ring-btn { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px 0 4px; border: 0; border-radius: 22px; background: transparent; color: var(--ink); position: relative; }
.ring-btn:hover { background: var(--gold-soft); }
.ring { width: 40px; height: 40px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 4; }
.ring-track { stroke: var(--line-2); }
.ring-fill { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 100 100; stroke-dashoffset: 100; transition: stroke-dashoffset .5s var(--ease); }
.ring-gold { stroke: #f6c453; stroke-dasharray: 100 100; stroke-dashoffset: 100; opacity: 0; }
.ring-btn.milestone .ring-gold { animation: ring-gold 1.2s var(--ease) both; }
@keyframes ring-gold { 0% { stroke-dashoffset: 100; opacity: 1; stroke-width: 4; } 60% { stroke-dashoffset: 0; opacity: 1; stroke-width: 6; } 100% { stroke-dashoffset: 0; opacity: 0; stroke-width: 4; } }
.ring-text { position: absolute; left: 4px; top: 2px; width: 40px; height: 40px; display: grid; place-items: center; font: 700 12px/1 var(--sans); font-variant-numeric: tabular-nums; }
.ring-total { display: none; }
.ring-count.roll { animation: roll .5s var(--ease); }
@keyframes roll { 0% { transform: translateY(5px); opacity: .3; } 100% { transform: none; opacity: 1; } }
.ring-rank { font: 600 14px/1.1 var(--serif); color: var(--gold-ink); white-space: nowrap; }
.bar-note { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 30; margin: 0; padding: 9px 14px; width: max-content; max-width: min(92vw, 460px); border-radius: 14px; background: var(--raise); border: 1px solid var(--line-2); box-shadow: 0 10px 30px -14px rgb(var(--shadow) / .55); font-size: 14px; text-align: center; animation: drop-in .25s var(--ease); }
.bar-note.link { cursor: pointer; }
.bar-note.gold { border-color: var(--gold); color: var(--gold-ink); font: 700 16px/1.2 var(--serif); }
@keyframes drop-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

.chip-btn { height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--raise); color: var(--ink); font-weight: 600; font-size: 14px; max-width: 180px; transition: transform .15s var(--spring); }
.chip-btn:hover { border-color: var(--gold); }
.chip-btn.active { border-color: var(--gold); background: var(--gold-soft); }
.chip-art { width: 26px; height: 26px; margin-left: -6px; }
.chip-btn.active > .ic { display: none; }
.chip-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
#hint-btn.pulse { animation: hint-pulse 2s ease-in-out infinite; }
@keyframes hint-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240, 168, 72, 0); background: transparent; } 50% { box-shadow: 0 0 0 6px rgba(240, 168, 72, .22); background: var(--gold-soft); } }
body.zen .zen-hide { display: none !important; }

/* ---- the workshop ---------------------------------------------------------------------------- */
.workshop { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--lib-w); min-height: 0; transition: grid-template-columns .2s var(--ease); }
body.lib-collapsed .workshop { grid-template-columns: minmax(0, 1fr) 52px; }
.table {
  position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background: var(--table); outline: none; cursor: grab;
}
.table.panning { cursor: grabbing; }
.table-bg { position: absolute; inset: 0; pointer-events: none; background: var(--grain), radial-gradient(120% 90% at 50% 45%, transparent 55%, color-mix(in srgb, var(--table-2) 85%, #000 6%) 100%); }
:root[data-theme="dark"] .table-bg { background-blend-mode: soft-light, normal; }
.lamp { position: absolute; left: 50%; top: 45%; width: 120vmax; height: 120vmax; margin: -60vmax 0 0 -60vmax; background: radial-gradient(circle, var(--lamp) 0%, transparent 42%); animation: lamp 12s ease-in-out infinite; }
@keyframes lamp { 0%, 100% { opacity: .75; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.04); } }
.motes { position: absolute; inset: 0; }
.mote { position: absolute; left: var(--mx); top: var(--my); width: var(--ms); height: var(--ms); border-radius: 50%; background: var(--mote); opacity: 0; box-shadow: 0 0 6px var(--mote); animation: mote var(--md) linear var(--mdl) infinite; }
@keyframes mote { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .55; } 85% { opacity: .4; } 100% { transform: translate(var(--mdx), -120px); opacity: 0; } }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }

.tok { position: absolute; left: 0; top: 0; width: var(--tok); height: var(--tok); cursor: grab; outline: none; }
.tok-body { width: 100%; height: 100%; position: relative; transition: transform .12s var(--ease); }
.tok-card {
  width: 100%; height: 100%; display: grid; place-items: center; border-radius: calc(var(--tok) * .305);
  background: linear-gradient(155deg, color-mix(in srgb, var(--c) 13%, var(--tok-bg1)), color-mix(in srgb, var(--c) 30%, var(--tok-bg2)));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 62%, transparent), inset 0 1px 0 rgba(255, 255, 255, .55), 0 1px 2px rgb(var(--shadow) / .2), 0 6px 12px -6px rgb(var(--shadow) / .45);
  transition: box-shadow .12s var(--ease);
}
.tok-art { width: 78%; height: 78%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.tok-name {
  position: absolute; top: calc(100% + 3px); left: 50%; width: calc(var(--tok) + 30px); transform: translateX(-50%);
  text-align: center; font: 600 13px/1.15 var(--sans); color: var(--ink); pointer-events: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; hyphens: auto;
  text-shadow: 0 0 3px var(--table), 0 0 1px var(--table);
}
@media (max-width: 767px) { .tok-name { font-size: 12px; } }
.names-never .tok-name { opacity: 0; top: auto; bottom: calc(100% + 6px); padding: 4px 9px; border-radius: 9px; background: var(--raise); box-shadow: 0 4px 12px -6px rgb(var(--shadow) / .5); width: max-content; max-width: 180px; text-shadow: none; transition: opacity .12s; }
@media (hover: hover) {
  .tok:hover .tok-body { transform: scale(1.04); }
  .names-never .tok:hover .tok-name { opacity: 1; transition-delay: .4s; }
}
.tok.lifted { z-index: 5; cursor: grabbing; }
.tok.lifted .tok-body { transform: scale(1.08); }
.tok.lifted .tok-card { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 62%, transparent), inset 0 1px 0 rgba(255, 255, 255, .55), 0 16px 26px -10px rgb(var(--shadow) / .55), 0 4px 8px rgb(var(--shadow) / .18); }
.tok.target .tok-card { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 62%, transparent), 0 0 0 4px color-mix(in srgb, var(--ink) 18%, transparent), 0 0 22px 4px rgba(255, 238, 200, .55); }
.tok.selected .tok-card { box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 0 3px var(--gold), 0 0 22px 2px color-mix(in srgb, var(--gold) 60%, transparent); animation: sel-glow 1.6s ease-in-out infinite; }
@keyframes sel-glow { 50% { box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 0 3px var(--gold), 0 0 30px 6px color-mix(in srgb, var(--gold) 45%, transparent); } }
.tok.fresh .tok-card { animation: fresh-glow 3s ease-out; }
@keyframes fresh-glow { 0%, 30% { box-shadow: inset 0 0 0 1.5px var(--c), 0 0 26px 6px color-mix(in srgb, var(--c) 55%, transparent); } }
.tok:focus-visible .tok-card { outline: 2px solid var(--gold); outline-offset: 3px; }
.tok.dying { pointer-events: none; z-index: 4; }
.drag-layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.drag-ghost { position: absolute; width: var(--tok); height: var(--tok); }
.fx { position: fixed; inset: 0; width: 100vw; height: 100dvh; pointer-events: none; z-index: 55; }

.table-tools { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 108px; display: flex; flex-direction: column; gap: 8px; z-index: 6; transition: opacity .15s; }
.tool-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--line-2); background: color-mix(in srgb, var(--raise) 92%, transparent); color: var(--ink); box-shadow: 0 6px 14px -10px rgb(var(--shadow) / .7); transition: transform .15s var(--spring), background .15s; }
.tool-btn:hover { background: var(--panel-2); }
.tool-btn:active { transform: scale(.92); }
.table.dragging .table-tools { opacity: 0; pointer-events: none; }
.trash {
  position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: 110px; width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; z-index: 7; pointer-events: none; color: var(--muted);
  background: color-mix(in srgb, var(--raise) 85%, transparent); border: 2px dashed var(--line-2);
  opacity: 0; transform: scale(.7); transition: opacity .18s, transform .22s var(--spring), background .15s, color .15s, border-color .15s;
}
.trash .ic { width: 30px; height: 30px; transition: transform .2s var(--spring); }
.table.dragging .trash { opacity: 1; transform: scale(1); }
.trash.open { background: rgba(214, 84, 60, .2); color: #c2412b; border-color: #d6543c; transform: scale(1.12) !important; }
.trash.open .ic { transform: rotate(-10deg) translateY(-2px); }
.trash.gulp { opacity: 1; animation: gulp .32s var(--spring); }
@keyframes gulp { 0% { transform: scale(1.12); } 50% { transform: scale(.88); } 100% { transform: scale(.7); opacity: 0; } }
.table.to-library .tok.lifted { opacity: .6; }

.quickbar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; max-width: min(calc(100% - 140px), 900px);
  height: 72px; padding: 8px 12px; display: flex; gap: 8px; align-items: center; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  background: color-mix(in srgb, var(--panel) 86%, transparent); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 14px 30px -18px rgb(var(--shadow) / .7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); touch-action: pan-x;
}
.quickbar::-webkit-scrollbar { display: none; }
.quickbar.empty { height: 48px; }
.qb-empty { margin: 0 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.qb-item { flex: none; width: 56px; }
.qb-item .li-card { width: 52px; height: 52px; }
.qb-item .li-name { display: none; }

/* ---- the library ------------------------------------------------------------------------------ */
.library {
  position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -10px 0 30px -26px rgb(var(--shadow) / .8); z-index: 8;
  padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom);
}
.library.relayout { transition: transform .2s var(--ease), height .2s var(--ease); }
.lib-resize { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 2; }
.lib-grip { display: none; }
.lib-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 8px 12px; }
.search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 14px; background: var(--raise); border: 1px solid var(--line-2); color: var(--muted); }
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; }
.search input::placeholder { color: var(--muted); opacity: .9; }
.lib-cats { display: flex; gap: 6px; padding: 2px 12px 10px; overflow-x: auto; scrollbar-width: none; flex: none; }
.lib-cats::-webkit-scrollbar { display: none; }
.cat-chip { flex: none; height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line-2); background: transparent; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.cat-chip .dot, .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--gold)); flex: none; display: inline-block; }
.cat-chip.on { background: var(--ink); color: var(--table); border-color: var(--ink); }
.lib-recent { display: none; }
.lib-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 24px; overscroll-behavior: contain; touch-action: pan-y; }
.lib-sec { content-visibility: auto; contain-intrinsic-size: auto 300px; }
.lib-sec-title { display: flex; align-items: center; gap: 8px; margin: 14px 4px 8px; font: 600 15px/1.2 var(--serif); color: var(--ci); }
.lib-sec-title small { margin-left: auto; font: 600 12px/1 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px 6px; }
.lib-empty { margin: 30px 10px; text-align: center; color: var(--muted); }
.lib-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px; border-radius: 14px; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; outline: none; }
.lib-recent .lib-item, .quickbar .lib-item { touch-action: pan-x; }
.li-card { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 17px; background: linear-gradient(155deg, color-mix(in srgb, var(--c) 13%, var(--tok-bg1)), color-mix(in srgb, var(--c) 30%, var(--tok-bg2))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 58%, transparent), 0 3px 8px -5px rgb(var(--shadow) / .5); transition: transform .15s var(--spring), box-shadow .2s; }
.li-card img { width: 78%; height: 78%; pointer-events: none; -webkit-user-drag: none; }
.li-name { font-size: 12px; line-height: 1.15; font-weight: 600; text-align: center; max-width: 84px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
@media (hover: hover) { .lib-item:hover .li-card { transform: translateY(-2px) scale(1.04); } }
.lib-item:focus-visible .li-card { outline: 2px solid var(--gold); outline-offset: 2px; }
.li-new { position: absolute; top: 2px; right: calc(50% - 30px); width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--panel); display: none; }
.is-new .li-new { display: block; }
.li-done { position: absolute; top: 40px; right: calc(50% - 32px); width: 18px; height: 18px; border-radius: 50%; background: var(--panel); color: #3f8a3a; display: none; place-items: center; box-shadow: 0 1px 4px rgb(var(--shadow) / .35); }
.li-done .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.is-done .li-done { display: grid; }
.li-star { position: absolute; top: -4px; left: calc(50% - 38px); width: 30px; height: 30px; border: 0; padding: 0; background: transparent; color: var(--muted); display: grid; place-items: center; opacity: 0; transition: opacity .15s, transform .15s var(--spring); }
.li-star .ic { width: 17px; height: 17px; }
.lib-item:hover .li-star, .lib-item:focus-within .li-star, .is-fav .li-star { opacity: 1; }
.is-fav .li-star { color: var(--gold); }
.is-fav .li-star .ic { fill: var(--gold); }
@media (hover: none) { .li-star { opacity: 0; pointer-events: none; } .is-fav .li-star { opacity: 1; } }
.lib-item.glow .li-card { animation: lib-glow 1.4s ease-in-out infinite; }
@keyframes lib-glow { 50% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 4px var(--gold-soft), 0 0 20px 4px color-mix(in srgb, var(--gold) 55%, transparent); } }
.lib-item.fresh { animation: swim-in .3s var(--ease) both; }
.lib-item.fresh .li-card { animation: fresh-glow 3s ease-out; }
@keyframes swim-in { from { opacity: 0; transform: translateY(10px) scale(.85); } to { opacity: 1; transform: none; } }

.library.collapsed > *:not(.lib-head) { display: none; }
.library.collapsed .lib-head { flex-direction: column; padding: 10px 4px; }
.library.collapsed .search { display: none; }
.lib-collapse { flex: none; }

/* tablet: the library takes 40 % on the right */
body[data-layout="tab"] .lib-resize { display: none; }
body[data-layout="tab"] .lib-collapse { display: none; }

/* phones: a bottom sheet with three heights */
@media (max-width: 767px) {
  :root { --bar-h: 48px; }
  .workshop { grid-template-columns: minmax(0, 1fr); }
  .bar-start, .bar-end { flex: none; }
  .bar-mid { flex: 1; justify-content: center; min-width: 0; }
  .chip-btn { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 14px; border: 0; background: transparent; }
  .chip-btn.active { background: var(--gold-soft); }
  .chip-btn .chip-label { display: none; }
  .chip-art { margin: 0; width: 30px; height: 30px; }
  .library {
    position: fixed; left: 0; right: 0; bottom: 0; height: 92dvh; z-index: 30; border-left: 0;
    border-radius: 22px 22px 0 0; border-top: 1px solid var(--line-2); box-shadow: 0 -12px 34px -18px rgb(var(--shadow) / .8);
    transform: translateY(calc(92dvh - var(--sheet, 96px) - env(safe-area-inset-bottom))); transition: transform .28s var(--ease);
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  }
  .library.instant { transition: none; }
  .lib-resize, .lib-collapse { display: none; }
  .lib-grip { display: grid; place-items: center; height: 12px; touch-action: none; cursor: grab; }
  .lib-grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .lib-head { padding: 0 12px 4px; touch-action: none; }
  .search { height: 38px; }
  .library[data-sheet="collapsed"] .lib-cats, .library[data-sheet="collapsed"] .lib-body { display: none; }
  .library[data-sheet="collapsed"] .lib-recent { display: flex; }
  .lib-recent { gap: 4px; padding: 0 12px 4px; overflow-x: auto; scrollbar-width: none; height: 44px; align-items: center; }
  .lib-recent::-webkit-scrollbar { display: none; }
  .lib-recent .lib-item { flex: none; width: 44px; }
  .lib-recent .li-card { width: 40px; height: 40px; border-radius: 13px; }
  .lib-recent .li-name, .lib-recent .li-star, .lib-recent .li-done { display: none; }
  .lib-recent .li-new { right: 2px; }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
  .quickbar { left: 0; right: 0; transform: none; bottom: calc(var(--sheet-h) + env(safe-area-inset-bottom)); max-width: none; height: 64px; border-radius: 0; border-left: 0; border-right: 0; padding: 6px 12px; background: color-mix(in srgb, var(--panel) 80%, transparent); box-shadow: none; }
  .quickbar.empty { height: 40px; justify-content: center; }
  .qb-item .li-card { width: 46px; height: 46px; border-radius: 14px; }
  .table-tools { bottom: calc(var(--sheet-h) + 76px + env(safe-area-inset-bottom)); right: max(8px, env(safe-area-inset-right)); gap: 6px; }
  .tool-btn { width: 44px; height: 44px; border-radius: 13px; }
  .trash { width: 80px; height: 80px; bottom: calc(var(--sheet-h) + 80px + env(safe-area-inset-bottom)); }
  .brand-title { font-size: 17px; }
  .ring-rank { display: none; }
  .wide-only { display: none; }
}
@media (max-width: 767px) and (min-width: 400px) { .ring-btn { padding-right: 4px; } }
@media (max-width: 520px) { .brand-title { display: none; } }
@media (max-width: 359px) {
  .ring-text { display: none; }
  .friend-btn, #challenge-chip { display: none; }
  .bar { gap: 2px; }
}
@media (min-width: 768px) and (max-width: 1023px) { .ring-rank { display: none; } }

/* ---- the ghost hand and the hint bubble ------------------------------------------------------ */
.ghost-hand { position: absolute; left: 0; top: 0; z-index: 9; pointer-events: none; animation: ghost 2s var(--ease) infinite; }
.ghost-hand .hand { width: 54px; height: 54px; fill: rgba(255, 255, 255, .78); stroke: rgba(46, 35, 24, .55); stroke-width: 2; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .25)); transform: translate(-14px, -6px) rotate(-12deg); }
@keyframes ghost {
  0% { transform: translate(var(--ax), var(--ay)) scale(1); opacity: 0; }
  12% { opacity: .95; transform: translate(var(--ax), var(--ay)) scale(1); }
  22% { transform: translate(var(--ax), var(--ay)) scale(.88); }
  70% { transform: translate(var(--bx), var(--by)) scale(.88); opacity: .95; }
  82% { transform: translate(var(--bx), var(--by)) scale(1); opacity: .9; }
  100% { transform: translate(var(--bx), var(--by)) scale(1); opacity: 0; }
}
.ghost-caption { position: absolute; left: 50%; top: var(--cy, 60%); transform: translateX(-50%); z-index: 9; margin: 0; padding: 8px 16px; border-radius: 20px; background: color-mix(in srgb, var(--raise) 92%, transparent); box-shadow: 0 8px 22px -12px rgb(var(--shadow) / .6); font: 600 15px/1.2 var(--sans); white-space: nowrap; pointer-events: none; animation: drop-in2 .4s var(--ease) both; }
@keyframes drop-in2 { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.bubble { position: fixed; left: var(--x); top: var(--y); transform: translateX(-80%); z-index: 70; max-width: 240px; padding: 10px 14px; border-radius: 14px; background: var(--ink); color: var(--table); font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px -10px rgb(var(--shadow) / .6); animation: drop-in2 .3s var(--ease) both; pointer-events: none; }
.bubble::before { content: ''; position: absolute; top: -6px; right: 18%; width: 12px; height: 12px; background: var(--ink); transform: rotate(45deg); border-radius: 2px; }

/* ---- the hint popover ------------------------------------------------------------------------ */
.hint-pop { position: fixed; z-index: 45; top: calc(var(--bar-h) + env(safe-area-inset-top) + 8px); right: calc(var(--lib-w) + 16px); width: min(320px, calc(100vw - 24px)); padding: 12px 14px 10px; border-radius: 18px; background: var(--raise); border: 1px solid var(--line-2); box-shadow: 0 18px 40px -18px rgb(var(--shadow) / .7); animation: drop-in3 .22s var(--ease); }
@keyframes drop-in3 { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.hp-head { display: flex; align-items: center; gap: 8px; color: var(--gold-ink); }
.hp-head strong { flex: 1; font: 600 15px/1.2 var(--serif); }
.hp-x { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 10px; display: grid; place-items: center; color: var(--muted); margin: -6px -6px -6px 0; }
.hp-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; flex-wrap: wrap; }
.hp-label { color: var(--muted); font-size: 13px; min-width: 76px; }
.hp-el { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 14px; background: color-mix(in srgb, var(--c) 14%, var(--panel)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); font-weight: 700; }
.hp-el img { width: 34px; height: 34px; }
.hp-el.sil { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 600; color: var(--muted); }
.hp-foot { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---- toasts and menus ------------------------------------------------------------------------- */
.toasts { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 65; display: flex; flex-direction: column-reverse; gap: 8px; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 24px)); }
body.lib-collapsed .hint-pop { right: 68px; }
@media (max-width: 767px) { .hint-pop { right: max(12px, env(safe-area-inset-right)); } }
@media (max-width: 767px) { .toasts { bottom: calc(var(--sheet-h) + 76px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; min-height: 48px; border-radius: 16px; background: var(--ink); color: var(--table); box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .45); font-size: 14.5px; font-weight: 600; max-width: 100%; }
.toast > span { flex: 1; }
.toast.top { position: fixed; top: calc(var(--bar-h) + env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); }
.toast.gold { background: linear-gradient(135deg, #3b2a12, #59401a); color: #ffe7b8; }
.toast.gold .ic { color: #f6c453; }
.toast-act { flex: none; min-height: 36px; padding: 0 14px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .16); color: inherit; font-weight: 700; }
.toast-act:hover { background: rgba(255, 255, 255, .26); }
.menu-layer { position: fixed; inset: 0; z-index: 66; pointer-events: none; }
.tmenu { pointer-events: auto; position: fixed; }
.tmenu.list { left: var(--x); top: var(--y); min-width: 190px; padding: 6px; border-radius: 16px; background: var(--raise); border: 1px solid var(--line-2); box-shadow: 0 18px 40px -16px rgb(var(--shadow) / .7); transform-origin: top left; }
.tm-item { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 11px; background: transparent; text-align: left; font-weight: 600; }
.tm-item:hover, .tm-item:focus-visible { background: var(--gold-soft); outline: none; }
.tm-item.danger { color: var(--danger); }
.tmenu.radial { left: var(--x); top: var(--y); width: 0; height: 0; }
.rm-name { position: absolute; left: 50%; top: -112px; transform: translateX(-50%); white-space: nowrap; padding: 5px 12px; border-radius: 12px; background: var(--ink); color: var(--table); font-weight: 700; font-size: 13px; }
.rm-btn { position: absolute; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--raise); color: var(--ink); display: grid; place-items: center; box-shadow: 0 10px 22px -10px rgb(var(--shadow) / .8); }
.rm-btn.on { color: var(--gold); } .rm-btn.on .ic { fill: var(--gold); }
.rm-0 { transform: translate(0, -74px); } .rm-1 { transform: translate(74px, 0); } .rm-2 { transform: translate(0, 74px); } .rm-3 { transform: translate(-74px, 0); color: var(--danger); }

/* ---- the discovery card ------------------------------------------------------------------------ */
.card-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.dcard { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.dcard-dim { position: absolute; inset: 0; background: var(--dim); }
.dcard.zen .dcard-dim { background: color-mix(in srgb, var(--dim) 60%, transparent); }
.dcard-box { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 20px; max-width: min(460px, 92vw); }
.dcard-stage { position: relative; width: var(--big); height: var(--big); display: grid; place-items: center; }
.dcard-art { position: relative; width: 100%; height: 100%; display: grid; place-items: center; border-radius: 28%; background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 10%, #fffaf0), color-mix(in srgb, var(--c) 28%, #f1e3cb)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 60%, transparent), 0 24px 50px -20px rgba(0, 0, 0, .55); }
:root[data-theme="dark"] .dcard-art { background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 22%, #3a3046), color-mix(in srgb, var(--c) 14%, #221b2a)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dcard-art { background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 22%, #3a3046), color-mix(in srgb, var(--c) 14%, #221b2a)); } }
.dcard-art .art { width: 80%; height: 80%; }
.dcard-rays { position: absolute; left: 50%; top: 50%; width: 260%; height: 260%; margin: -130% 0 0 -130%; border-radius: 50%; background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--cg) 55%, transparent) 0deg 7deg, transparent 7deg 20deg); -webkit-mask: radial-gradient(circle, #000 18%, transparent 62%); mask: radial-gradient(circle, #000 18%, transparent 62%); animation: rays 14s linear infinite, rays-in 1s var(--ease) both; opacity: .8; }
@keyframes rays { to { transform: rotate(360deg); } }
@keyframes rays-in { from { opacity: 0; scale: .4; } to { opacity: .8; scale: 1; } }
.dcard-halo { position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--cg) 70%, #fff6dc) 0%, transparent 62%); opacity: .85; }
.dcard-ring { position: absolute; inset: -12px; border-radius: 32%; border: 4px solid #f2c14e; box-shadow: 0 0 24px 4px rgba(246, 196, 83, .6), inset 0 0 14px rgba(246, 196, 83, .5); animation: ring-in .6s var(--spring) .3s both; }
@keyframes ring-in { from { opacity: 0; transform: scale(1.25); } to { opacity: 1; transform: none; } }
.dcard-plate { margin-top: 22px; padding: 12px 20px 14px; border-radius: 20px; background: color-mix(in srgb, var(--raise) 95%, transparent); box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6); max-width: 100%; }
.dcard.gold .dcard-plate { box-shadow: inset 0 0 0 2px #f2c14e, 0 18px 40px -18px rgba(0, 0, 0, .6); }
.dcard-kicker { margin: 0; font: 700 12px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); }
.dcard-name { margin: 6px 0 0; font: 600 clamp(28px, 6vw, 40px)/1.1 var(--serif); color: var(--ink); }
.dcard-cat { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: var(--ci); }
.dcard-fact { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--ink); font-size: 15.5px; line-height: 1.45; text-wrap: pretty; }

/* the living illustration: each motion type moves the parts flagged as animated */
.art { overflow: visible; }
.art .a, .art.whole > g { transform-box: fill-box; transform-origin: 50% 50%; }
.m-flicker .a, .m-flicker.whole > g { transform-origin: 50% 100%; animation: m-flicker 1.5s ease-in-out infinite alternate; }
@keyframes m-flicker { 0% { transform: scale(1, 1) skewX(0); } 50% { transform: scale(.96, 1.08) skewX(-3deg); } 100% { transform: scale(1.03, .97) skewX(2.5deg); } }
.m-wave .a, .m-wave.whole > g { animation: m-wave 2.6s ease-in-out infinite; }
@keyframes m-wave { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(2px) rotate(1deg); } 75% { transform: translateX(-2px) rotate(-1deg); } }
.m-float .a, .m-float.whole > g { animation: m-float 3s ease-in-out infinite; }
@keyframes m-float { 50% { transform: translateY(-4px); } }
.m-pulse .a, .m-pulse.whole > g { animation: m-pulse 2s ease-in-out infinite; }
@keyframes m-pulse { 50% { transform: scale(1.07); } }
.m-spin .a, .m-spin.whole > g { animation: m-spin 4s linear infinite; }
@keyframes m-spin { to { transform: rotate(360deg); } }
.m-sparkle .a, .m-sparkle.whole > g { animation: m-sparkle 2s ease-in-out infinite; }
.m-sparkle .a:nth-of-type(2n) { animation-delay: -.7s; } .m-sparkle .a:nth-of-type(3n) { animation-delay: -1.3s; }
@keyframes m-sparkle { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.55); opacity: .45; } }
.m-sway .a, .m-sway.whole > g { transform-origin: 50% 100%; animation: m-sway 3s ease-in-out infinite; }
@keyframes m-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.m-flap .a, .m-flap.whole > g { transform-origin: 50% 100%; animation: m-flap 1.1s ease-in-out infinite; }
@keyframes m-flap { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
.m-steam .a, .m-steam.whole > g { animation: m-steam 2.4s ease-in-out infinite; }
.m-steam .a:nth-of-type(2n) { animation-delay: -1.2s; }
@keyframes m-steam { 0% { transform: translateY(2px); opacity: .9; } 70% { opacity: .5; } 100% { transform: translateY(-7px); opacity: 0; } }
.m-flash .a, .m-flash.whole > g { animation: m-flash 2.4s steps(1) infinite; }
@keyframes m-flash { 0%, 100% { opacity: 1; } 8% { opacity: .35; } 14% { opacity: 1; } 20% { opacity: .5; } 26% { opacity: 1; } }
.m-grow .a, .m-grow.whole > g { transform-origin: 50% 100%; animation: m-grow 3s ease-in-out infinite; }
@keyframes m-grow { 0%, 100% { transform: scale(.94); } 50% { transform: scale(1.04); } }
.m-blink .a, .m-blink.whole > g { animation: m-blink 3.6s ease-in-out infinite; }
@keyframes m-blink { 0%, 44%, 52%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }

/* ---- panels --------------------------------------------------------------------------------- */
.panel-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.panel-wrap { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: auto; }
.panel-scrim { position: absolute; inset: 0; background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.panel {
  position: relative; width: min(600px, 94vw); max-height: min(88dvh, 860px); display: flex; flex-direction: column;
  background: var(--panel); color: var(--ink); border-radius: 24px; border: 1px solid var(--line);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .55); outline: none; overflow: hidden;
}
.panel.wide { width: min(940px, 95vw); height: min(88dvh, 900px); }
.panel.small { width: min(440px, 94vw); }
.panel-grip { display: none; }
.panel-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 6px 18px; border-bottom: 1px solid var(--line); }
.panel-back { margin-left: -10px; }
.panel-title { flex: 1; margin: 0; font: 600 21px/1.2 var(--serif); min-width: 0; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 20px 26px; overscroll-behavior: contain; }
@media (max-width: 767px) {
  .panel-wrap { place-items: end stretch; }
  .panel, .panel.wide, .panel.small { width: 100%; height: calc(100dvh - env(safe-area-inset-top) - 10px); max-height: none; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .panel.small { height: auto; }
  .panel-grip { display: grid; place-items: center; height: 16px; touch-action: none; }
  .panel-grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .panel-head { touch-action: none; padding-top: 2px; }
  .panel-body { padding: 12px 16px 26px; }
}
.sec-title { margin: 22px 0 10px; font: 600 17px/1.25 var(--serif); color: var(--ink); }
.sec-title:first-child { margin-top: 4px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 11px; background: transparent; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--raise); color: var(--ink); box-shadow: 0 2px 6px -3px rgb(var(--shadow) / .5); }
.seg.small button { padding: 0 11px; font-size: 13.5px; }
.bar-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--c, var(--gold)), color-mix(in srgb, var(--c, var(--gold)) 70%, #fff)); transform-origin: left; transform: scaleX(var(--k, 0)); transition: transform .5s var(--ease); }

/* encyclopedia */
.enc-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 4px; position: sticky; top: -14px; z-index: 2; padding: 8px 0; background: var(--panel); }
.enc-sort { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
select { min-height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--raise); color: var(--ink); }
.enc-sec { content-visibility: auto; contain-intrinsic-size: auto 400px; }
.enc-sec-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 6px; font: 600 17px/1.2 var(--serif); color: var(--ci); }
.enc-sec-title small { margin-left: auto; font: 600 13px/1 var(--sans); color: var(--muted); }
.enc-sec .bar-track { margin-bottom: 12px; }
.enc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px 8px; }
.enc-card { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 2px; border: 0; background: transparent; border-radius: 16px; min-height: 44px; }
.enc-card:hover .ec-art { transform: translateY(-2px); }
.ec-art { position: relative; width: 72px; height: 72px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(155deg, color-mix(in srgb, var(--c) 13%, var(--tok-bg1)), color-mix(in srgb, var(--c) 30%, var(--tok-bg2))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 58%, transparent); transition: transform .15s var(--spring); }
.ec-art img { width: 78%; height: 78%; }
.enc-card.sil .ec-art { background: var(--panel-2); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.q { position: absolute; font: 700 22px/1 var(--serif); font-style: normal; color: var(--panel); opacity: .95; }
.ec-name { font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.15; max-width: 96px; min-height: 1.15em; overflow-wrap: anywhere; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.crumbs button { min-height: 32px; padding: 0 10px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.crumbs button + button::before { content: '›'; margin-right: 8px; color: var(--line-2); }
.crumbs button.on { color: var(--ink); }
.bigview { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 640px) { .bigview { grid-template-columns: 1fr; justify-items: center; text-align: center; } .big-stats { justify-content: center; } .big-actions { justify-content: center; } .big-cat { justify-content: center; } }
.big-stage { position: relative; width: min(260px, 70vw); aspect-ratio: 1; border: 0; padding: 0; display: grid; place-items: center; border-radius: 30%; background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 10%, var(--raise)), color-mix(in srgb, var(--c) 28%, var(--panel-2))); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent), 0 20px 40px -24px rgb(var(--shadow) / .8); cursor: pointer; overflow: visible; }
.big-stage.sil { background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--line-2); cursor: default; }
.big-stage .q { font-size: 54px; }
.big-glow { position: absolute; inset: 8%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--cg) 45%, transparent), transparent 70%); opacity: 0; }
.big-art { width: 78%; height: 78%; position: relative; }
.big-stage.flourish .big-glow { animation: fl-glow 1.2s ease-out; }
.big-stage.flourish .big-art { animation: fl-pop 1.2s var(--ease); }
.big-stage.fl-feather.flourish .big-art { animation: fl-hop 1.2s var(--ease); }
.big-stage.fl-drop.flourish::after, .big-stage.fl-bubble.flourish::after { content: ''; position: absolute; inset: 20%; border-radius: 50%; border: 3px solid var(--cg); animation: fl-ripple 1.2s ease-out; }
.big-stage.fl-spark.flourish .big-art { animation: fl-flare 1.2s var(--ease); }
.big-stage.fl-star.flourish .big-art { animation: fl-twirl 1.2s var(--ease); }
@keyframes fl-glow { 30% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fl-pop { 20% { transform: scale(1.12); } 45% { transform: scale(.96); } 70% { transform: scale(1.03); } }
@keyframes fl-hop { 20% { transform: translateY(-18px) scaleY(1.05); } 40% { transform: translateY(0) scaleY(.9); } 55% { transform: translateY(-8px); } 70% { transform: none; } }
@keyframes fl-ripple { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
@keyframes fl-flare { 20% { transform: scale(1.06, 1.18) translateY(-6px); filter: brightness(1.25); } 60% { transform: scale(.98, 1.02); filter: none; } }
@keyframes fl-twirl { 30% { transform: rotate(-12deg) scale(1.1); } 60% { transform: rotate(8deg); } }
.big-info { min-width: 0; }
.big-cat { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 0; color: var(--ci); font-weight: 700; font-size: 13.5px; }
.final { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 2px 9px 2px 6px; border-radius: 10px; background: var(--gold-soft); color: var(--gold-ink); font-size: 12px; }
.final .ic { width: 15px; height: 15px; }
.big-name { margin: 6px 0 8px; font: 600 32px/1.1 var(--serif); }
.big-desc { margin: 0 0 12px; font-size: 16px; line-height: 1.5; text-wrap: pretty; }
.big-fact { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px; border-radius: 16px; background: var(--gold-soft); text-align: left; text-wrap: pretty; }
.big-fact .ic { color: var(--gold-ink); margin-top: 1px; }
.big-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 12px; }
.big-stats div { min-width: 90px; }
.big-stats dt { font-size: 12px; color: var(--muted); }
.big-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.big-left { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.big-left .done { display: inline-flex; align-items: center; gap: 6px; color: #3f8a3a; font-weight: 600; }
:root[data-theme="dark"] .big-left .done { color: #8fd18a; }
.big-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.star-btn.on { color: var(--gold-ink); }
.star-btn.on .ic { fill: var(--gold); stroke: var(--gold); }
.ft { margin-top: 26px; padding-top: 6px; border-top: 1px solid var(--line); text-align: center; }
.ft-title { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 6px; font: 600 18px/1.2 var(--serif); }
.ft-label { margin: 10px 0 8px; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.ft-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 14px; }
.ft-pair { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 18px; background: var(--panel-2); }
.ft-plus { font-weight: 700; color: var(--muted); }
.ft-center { display: flex; justify-content: center; margin: 12px 0; position: relative; }
.ft-center::before, .ft-center::after { content: ''; position: absolute; left: 50%; width: 2px; height: 12px; background: var(--line-2); }
.ft-center::before { top: -12px; } .ft-center::after { bottom: -12px; }
.ft-node { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: transparent; padding: 2px; border-radius: 14px; min-width: 64px; }
.ft-art { position: relative; width: 60px; height: 60px; display: grid; place-items: center; border-radius: 19px; background: linear-gradient(155deg, color-mix(in srgb, var(--c) 13%, var(--tok-bg1)), color-mix(in srgb, var(--c) 30%, var(--tok-bg2))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 58%, transparent); transition: transform .15s var(--spring); }
.ft-art img { width: 78%; height: 78%; }
.ft-node.small .ft-art { width: 48px; height: 48px; border-radius: 15px; }
.ft-center .ft-art { width: 78px; height: 78px; border-radius: 24px; box-shadow: inset 0 0 0 2px var(--c), 0 0 0 4px var(--gold-soft); }
.ft-node:hover .ft-art { transform: translateY(-2px) scale(1.05); }
.ft-node.unknown .ft-art { background: var(--panel-2); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.ft-node.unknown .q { color: var(--muted); font-size: 20px; }
.ft-name { font-size: 12px; font-weight: 600; max-width: 86px; line-height: 1.15; overflow-wrap: anywhere; }
.ft-node.unknown .ft-name { color: var(--muted); }
.ft-kid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ft-with { font-size: 11.5px; color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-empty { color: var(--muted); font-size: 14px; margin: 4px 0; }

/* challenges */
.ch-intro { color: var(--muted); margin: 4px 0 0; }
.ch-active { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; padding: 16px; border-radius: 20px; background: color-mix(in srgb, var(--c) 10%, var(--raise)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 45%, transparent); }
.ch-art { width: 120px; height: 120px; border-radius: 30%; display: grid; place-items: center; background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 10%, var(--raise)), color-mix(in srgb, var(--c) 26%, var(--panel-2))); }
.ch-art .art { width: 80%; height: 80%; }
.ch-kicker { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ci); }
.ch-text h3 { margin: 4px 0; font: 600 26px/1.15 var(--serif); }
.ch-dist { margin: 0; color: var(--muted); }
.ch-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.ch-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ch-level .btn { width: 100%; min-height: 64px; flex-direction: column; gap: 2px; }
.ch-level small { font-weight: 500; color: var(--muted); }
.ch-none { margin: 6px 4px 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.ch-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 12px 6px; border-radius: 16px; background: var(--panel-2); text-align: center; }
.stat strong { display: block; font: 600 24px/1.1 var(--serif); }
.stat span { font-size: 12px; color: var(--muted); }
.ch-all { display: grid; justify-items: center; gap: 10px; padding: 24px; text-align: center; color: var(--gold-ink); font: 600 20px/1.3 var(--serif); }

/* badges */
.rank-box { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 22px; background: linear-gradient(135deg, var(--gold-soft), transparent); border: 1px solid var(--line); }
.rank-crown { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--raise); color: var(--gold-ink); box-shadow: 0 8px 20px -12px rgb(var(--shadow) / .7); flex: none; }
.rank-text { flex: 1; min-width: 0; }
.rank-kicker { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); }
.rank-text h3 { margin: 2px 0; font: 600 28px/1.1 var(--serif); }
.rank-count { margin: 0 0 8px; color: var(--muted); }
.rank-next { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.rank-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; }
.rank-list li { display: flex; gap: 6px; align-items: baseline; padding: 6px 10px; border-radius: 12px; background: var(--panel-2); color: var(--muted); font-size: 13px; font-weight: 600; }
.rank-list li.on { background: var(--gold-soft); color: var(--gold-ink); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.badge { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 18px; background: var(--panel-2); }
.badge:not(.earned) .medal { filter: grayscale(1); opacity: .45; }
.medal { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none; background: radial-gradient(circle at 35% 30%, #fff1c6, #e9b851 55%, #b17c22); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(120, 70, 10, .35), 0 6px 14px -8px rgba(80, 50, 10, .7); color: #6b4410; }
.medal.kind-cat { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 18%, #fff7e6), color-mix(in srgb, var(--c) 55%, #e9b851) 60%, color-mix(in srgb, var(--c) 60%, #8a5a18)); }
.medal img { width: 72%; height: 72%; }
.medal .ic { width: 26px; height: 26px; stroke-width: 2; }
.badge-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.badge-text strong { font: 600 15.5px/1.2 var(--serif); }
.badge-text small { color: var(--muted); font-size: 12.5px; }
.badge-date { color: var(--gold-ink) !important; font-weight: 600; }
.badge-prog { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-top: 3px; }

/* friends */
.board-note { color: var(--muted); font-size: 13.5px; margin: 10px 0; }
.board { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-height: 120px; }
.row { position: relative; display: grid; grid-template-columns: 30px 40px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px 14px; border-radius: 16px; background: var(--panel-2); }
.row.me { position: sticky; top: 0; bottom: 0; z-index: 1; background: color-mix(in srgb, var(--gold) 16%, var(--raise)); box-shadow: inset 0 0 0 1.5px var(--gold), 0 6px 18px -12px rgb(var(--shadow) / .6); }
.pos { font: 700 16px/1 var(--serif); text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: hsl(var(--h) 45% 46%); color: #fff; font-weight: 700; }
.who { min-width: 0; display: flex; flex-direction: column; }
.who strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: 12.5px; }
.heart { color: #d6455e; margin-left: 4px; display: inline-flex; vertical-align: -3px; }
.heart .ic { width: 16px; height: 16px; fill: currentColor; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-bar { position: absolute; left: 12px; right: 12px; bottom: 6px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.board-empty { display: grid; justify-items: center; gap: 12px; padding: 16px; text-align: center; }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 54px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.set-label { display: flex; flex-direction: column; min-width: 0; }
.set-label small { color: var(--muted); }
.switch { width: 52px; height: 32px; border-radius: 16px; border: 0; padding: 3px; background: var(--line-2); flex: none; transition: background .2s; position: relative; }
.switch span { display: block; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: transform .22s var(--spring); }
.switch.on { background: var(--gold); }
.switch.on span { transform: translateX(20px); }
.switch::after { content: ''; position: absolute; inset: -6px; }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input { width: min(180px, 40vw); accent-color: var(--gold); height: 32px; }
.slider output { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.about { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding: 14px; border-radius: 18px; background: var(--panel-2); }
.about img { border-radius: 12px; }
.about div { flex: 1; display: flex; flex-direction: column; }
.about strong { font: 600 16px/1.2 var(--serif); }
.about small { color: var(--muted); }
.reset-text { margin: 0 0 16px; }
.hold { position: relative; overflow: hidden; width: 100%; margin-bottom: 8px; border-color: var(--danger); touch-action: none; user-select: none; -webkit-user-select: none; }
.hold-fill { position: absolute; inset: 0; background: color-mix(in srgb, var(--danger) 22%, transparent); transform-origin: left; transform: scaleX(var(--k, 0)); }
.hold-text { position: relative; }
.p-reset .panel-body .btn.ghost { width: 100%; }

/* help */
.how-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.how { padding: 12px; border-radius: 18px; background: var(--panel-2); }
.how h4 { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font: 600 16px/1.2 var(--serif); }
.how p { margin: 0; color: var(--muted); font-size: 14px; }
.how-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #fff; font: 700 13px/1 var(--sans); }
.how-demo { position: relative; height: 96px; border-radius: 14px; background: var(--table); overflow: hidden; }
.demo-tok { position: absolute; top: 24px; width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(155deg, color-mix(in srgb, var(--c) 13%, var(--tok-bg1)), color-mix(in srgb, var(--c) 30%, var(--tok-bg2))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 58%, transparent), 0 4px 10px -6px rgb(var(--shadow) / .6); }
.demo-tok img { width: 78%; height: 78%; }
.d-a { left: 18%; animation: d-drag 2.4s var(--ease) infinite; }
.d-b { left: 60%; }
@keyframes d-drag { 0%, 15% { transform: none; } 55%, 75% { transform: translate(40px, -10px) scale(1.08); } 100% { transform: none; } }
.c-a { left: 22%; animation: c-a 2.4s var(--ease) infinite; } .c-b { left: 56%; animation: c-b 2.4s var(--ease) infinite; }
@keyframes c-a { 0%, 20% { transform: none; opacity: 1; } 45% { transform: translateX(28px) scale(.85); opacity: 1; } 55%, 100% { transform: translateX(32px) scale(.4); opacity: 0; } }
@keyframes c-b { 0%, 20% { transform: none; opacity: 1; } 45% { transform: translateX(-24px) scale(.85); opacity: 1; } 55%, 100% { transform: translateX(-28px) scale(.4); opacity: 0; } }
.demo-flash { position: absolute; left: 50%; top: 50%; width: 80px; height: 80px; margin: -40px; border-radius: 50%; background: radial-gradient(circle, #fff4cf, transparent 65%); opacity: 0; animation: d-flash 2.4s ease-out infinite; }
@keyframes d-flash { 0%, 48% { opacity: 0; transform: scale(.4); } 58% { opacity: 1; transform: scale(1); } 80%, 100% { opacity: 0; transform: scale(1.3); } }
.demo-rays { position: absolute; left: 50%; top: 50%; width: 160px; height: 160px; margin: -80px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(240, 190, 90, .45) 0deg 8deg, transparent 8deg 22deg); -webkit-mask: radial-gradient(circle, #000 20%, transparent 64%); mask: radial-gradient(circle, #000 20%, transparent 64%); animation: rays 10s linear infinite; }
.r-a { left: calc(50% - 24px); animation: r-pop 2.4s var(--spring) infinite; }
@keyframes r-pop { 0% { transform: scale(.3); opacity: 0; } 20%, 85% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
.help-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.help-cols h4 { margin: 0 0 6px; font: 600 15px/1.2 var(--serif); }
.help-list { margin: 0; padding-left: 18px; display: grid; gap: 5px; font-size: 14px; }
.keys { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.keys div { display: grid; grid-template-columns: 76px 1fr; gap: 8px; align-items: baseline; }
.keys dd { margin: 0; }
kbd { display: inline-block; min-width: 24px; padding: 2px 7px; border-radius: 7px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--raise); font: 600 12.5px/1.4 var(--sans); text-align: center; white-space: nowrap; }
.faq { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.faq p { margin: 0 0 12px; color: var(--muted); }

/* ---- the landing page ---------------------------------------------------------------------------- */
.landing { min-height: 100dvh; background: var(--table); background-image: var(--grain); overflow-x: hidden; }
.lp-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--table) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.landing .brand-title { display: inline; }
.lp-tools { display: flex; align-items: center; gap: 4px; }
.lp-select select { min-height: 40px; }
.lp-main { max-width: 1080px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-left)) calc(40px + env(safe-area-inset-bottom)); }
.lp-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; padding: 24px 0 36px; }
@media (max-width: 760px) { .lp-hero { grid-template-columns: 1fr; text-align: center; padding-top: 8px; } }
.lp-stage { position: relative; aspect-ratio: 5 / 4; border-radius: 28px; overflow: hidden; background: radial-gradient(120% 90% at 50% 40%, color-mix(in srgb, var(--table) 70%, #fff 30%), var(--table-2)); box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -36px rgb(var(--shadow) / .9); }
:root[data-theme="dark"] .lp-stage { background: radial-gradient(120% 90% at 50% 40%, #2c2336, #15111b); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lp-stage { background: radial-gradient(120% 90% at 50% 40%, #2c2336, #15111b); } }
.lp-lamp { position: absolute; inset: -20%; background: radial-gradient(circle at 50% 50%, var(--lamp), transparent 55%); animation: lamp 12s ease-in-out infinite; }
.lp-tok { position: absolute; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: linear-gradient(155deg, color-mix(in srgb, var(--c) 13%, var(--tok-bg1)), color-mix(in srgb, var(--c) 30%, var(--tok-bg2))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 58%, transparent), 0 10px 20px -10px rgb(var(--shadow) / .7); }
.lp-tok img { width: 78%; height: 78%; }
.lp-tok.float { animation: lp-float 6s ease-in-out infinite; }
.lp-tok.f0 { left: 12%; top: 12%; } .lp-tok.f1 { right: 12%; top: 16%; animation-delay: -1.5s; } .lp-tok.f2 { left: 14%; bottom: 14%; animation-delay: -3s; } .lp-tok.f3 { right: 14%; bottom: 12%; animation-delay: -4.5s; }
@keyframes lp-float { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-12px) rotate(3deg); } }
.lp-show { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.lp-show .lp-tok { left: -40px; top: -40px; width: 80px; height: 80px; border-radius: 25px; }
.lp-show .lp-tok.res { box-shadow: inset 0 0 0 2px var(--c), 0 0 34px 6px color-mix(in srgb, var(--cg) 55%, transparent); }
.lp-res-name { position: absolute; left: 0; top: 52px; transform: translateX(-50%); white-space: nowrap; font: 600 20px/1.2 var(--serif); }
.lp-eq { display: flex; align-items: center; gap: 6px; transform: translate(-50%, -50%); position: absolute; white-space: nowrap; font-weight: 700; }
.lp-eq .lp-tok { position: relative; width: 44px; height: 44px; border-radius: 14px; }
.lp-eq:nth-child(1) { top: -60px; } .lp-eq:nth-child(3) { top: 60px; }
.lp-title { margin: 0; font: 600 clamp(38px, 6vw, 58px)/1.02 var(--serif); letter-spacing: -.01em; }
.lp-sub { margin: 12px 0 22px; font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); text-wrap: pretty; }
.lp-note { margin: 16px 0 0; font-size: 14px; color: var(--muted); max-width: 46ch; text-wrap: pretty; }
@media (max-width: 760px) { .lp-note { margin-inline: auto; } }
.lp-offline { margin: 10px 0 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.lp-taster { position: relative; padding: 20px; border-radius: 28px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 24px 60px -40px rgb(var(--shadow) / .9); }
.lp-taster-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lp-taster h2 { margin: 0; font: 600 24px/1.2 var(--serif); }
.lp-count { margin: 0; font-weight: 700; color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.lp-mini { position: relative; height: clamp(260px, 42vw, 360px); margin: 14px 0 12px; border-radius: 20px; background: var(--table); background-image: var(--grain); box-shadow: inset 0 0 0 1px var(--line), inset 0 10px 30px -20px rgb(var(--shadow) / .6); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.lp-mini .tok { --tok: 64px; }
@media (max-width: 600px) { .lp-mini .tok { --tok: 56px; } }
.lp-mini-shelf { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.lp-shelf-item { border: 0; background: transparent; touch-action: none; }
.lp-more { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 14px; padding: 16px; border-radius: 20px; background: var(--gold-soft); text-align: center; font-weight: 600; }
.lp-more p { margin: 0; font: 600 18px/1.3 var(--serif); }
.lp-found { position: absolute; left: 50%; top: 44%; transform: translate(-50%, 0); z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 22px; border-radius: 22px; background: var(--raise); box-shadow: 0 20px 40px -18px rgba(0, 0, 0, .5); pointer-events: none; }
.lp-found img { width: 92px; height: 92px; }
.lp-found strong { font: 600 22px/1.2 var(--serif); }
.lp-found small { color: var(--gold-ink); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 11px; }
.lp-lock { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -100%); padding: 6px 12px; border-radius: 12px; background: var(--ink); color: var(--table); font-size: 13px; font-weight: 600; white-space: nowrap; animation: drop-in2 .25s var(--ease) both; pointer-events: none; z-index: 6; }
.lp-feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 36px 0; }
@media (max-width: 760px) { .lp-feats { grid-template-columns: 1fr; } }
.lp-feat { padding: 20px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); }
.lp-feat .ic { color: var(--gold-ink); }
.lp-feat h3 { margin: 10px 0 4px; font: 600 19px/1.2 var(--serif); }
.lp-feat p { margin: 0; color: var(--muted); }
.lp-gallery { overflow: hidden; margin: 0 calc(-1 * max(16px, env(safe-area-inset-left))); padding: 10px 0; -webkit-mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.lp-strip { display: flex; gap: 18px; width: max-content; animation: strip 60s linear infinite; }
@keyframes strip { to { transform: translateX(-50%); } }
.lp-strip-item { width: 120px; height: 120px; flex: none; display: grid; place-items: center; border-radius: 34px; background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 10%, var(--raise)), color-mix(in srgb, var(--c) 26%, var(--panel-2))); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 50%, transparent); }
.lp-strip-item img { width: 80%; height: 80%; }
.lp-foot { text-align: center; padding: 30px 0 10px; }
.lp-foot p { margin: 4px 0; }

/* the grand finale: 500 of 500 */
body.grand .table-bg { animation: grand 3s ease-in-out; }
@keyframes grand { 30%, 70% { filter: brightness(1.35) saturate(1.3); } }

/* ---- reduced motion: no particles, no overshoot, no loops; fades of 150 ms ------------------------- */
.reduce *, .reduce *::before, .reduce *::after { animation-duration: .15s !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; }
.reduce .lamp, .reduce .motes, .reduce .dcard-rays, .reduce .lp-strip, .reduce .art .a, .reduce .art.whole > g, .reduce .lp-tok.float, .reduce .ghost-hand, .reduce #hint-btn.pulse, .reduce .tok.selected .tok-card { animation: none !important; }
.reduce .ghost-hand { transform: translate(var(--bx), var(--by)); opacity: .9; }
.reduce .lp-strip { flex-wrap: wrap; justify-content: center; width: auto; }
@media print { .table, .library, .bar { display: none; } }

/* every touch target at least 44 × 44: small-looking controls get a larger hit area */
.cat-chip, .crumbs button, .seg button, .hp-x, .toast-act { position: relative; }
.cat-chip::after, .crumbs button::after, .seg button::after, .toast-act::after { content: ''; position: absolute; inset: -6px -2px; }
.li-star::after, .hp-x::after { content: ''; position: absolute; inset: -7px; }
select { min-height: 44px; }

@media (max-width: 440px) {
  .set-row:has(> .seg, > select, > .slider) { flex-wrap: wrap; padding: 8px 0; }
  .set-row > .seg, .set-row > select { width: 100%; }
  .set-row > .seg button { flex: 1; }
  .set-row > .slider { width: 100%; }
  .set-row > .slider input { flex: 1; width: auto; }
}
