/* Stone Road — paper and stone.
   Warm cream paper, a honey-oak board, matte pebbles; gold for what matters.
   Light and dark follow the system unless the player picks one (data-theme on
   <html>); reduced motion follows the system unless picked (data-motion). */

:root {
  color-scheme: light;
  --paper: #f4ede0;
  --paper-2: #ebe1cf;
  --card: #fffaf1;
  --card-2: #f7efe1;
  --ink: #2c2219;
  --ink-2: #5b4b3c;
  --ink-3: #85725f;
  --line: rgba(80, 55, 30, 0.14);
  --line-2: rgba(80, 55, 30, 0.24);
  --gold: #f2b84b;
  --gold-ink: #8a5a0e;
  --gold-deep: #a86b12;
  --light-stone: #efe6d6;
  --dark-stone: #4a5d73;
  --p0: #efe6d6;
  --p1: #4a5d73;
  --p0-ink: #6b5a43;
  --p1-ink: #3c4e63;
  --good: #3f7d52;
  --bad: #b8483a;
  --ca-accent: #96670f;
  --shadow: 0 1px 2px rgba(60, 35, 10, 0.08), 0 8px 24px -12px rgba(60, 35, 10, 0.28);
  --shadow-lg: 0 2px 6px rgba(60, 35, 10, 0.1), 0 24px 60px -24px rgba(60, 35, 10, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI Variable Display", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --num: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --backdrop: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1e1915;
    --paper-2: #26201a;
    --card: #2b231d;
    --card-2: #332a22;
    --ink: #f3e9dc;
    --ink-2: #cdbba6;
    --ink-3: #a08c77;
    --line: rgba(255, 235, 210, 0.1);
    --line-2: rgba(255, 235, 210, 0.2);
    --gold-ink: #f2b84b;
    --p0: #e8ecf2;
    --p1: #e06a5a;
    --p0-ink: #dfe4ec;
    --p1-ink: #f0907f;
    --good: #7cc495;
    --bad: #f08a7a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1e1915;
  --paper-2: #26201a;
  --card: #2b231d;
  --card-2: #332a22;
  --ink: #f3e9dc;
  --ink-2: #cdbba6;
  --ink-3: #a08c77;
  --line: rgba(255, 235, 210, 0.1);
  --line-2: rgba(255, 235, 210, 0.2);
  --gold-ink: #f2b84b;
  --p0: #e8ecf2;
  --p1: #e06a5a;
  --p0-ink: #dfe4ec;
  --p1-ink: #f0907f;
  --good: #7cc495;
  --bad: #f08a7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 60px -24px rgba(0, 0, 0, 0.8);
}

/* ---- the board ------------------------------------------------------------------------- */

.board {
  position: relative;
  width: var(--board, 300px);
  height: var(--board, 300px);
  flex: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.board-canvas {
  position: absolute;
  left: calc(var(--mx) * -1);
  top: calc(var(--mt) * -1);
  width: calc(var(--board) + var(--mx) * 2);
  height: calc(var(--board) + var(--mt) + var(--mb));
  pointer-events: none;
}
.board::before {
  /* the board's shadow on the paper */
  content: "";
  position: absolute;
  inset: 2% 1% -3%;
  border-radius: 4%;
  background: rgba(60, 30, 5, 0.35);
  filter: blur(18px);
  transform: translateY(10px);
  z-index: -1;
}
.cells {
  position: absolute;
  inset: var(--frame);
  display: grid;
  grid-template-columns: repeat(var(--n, 5), 1fr);
  grid-template-rows: repeat(var(--n, 5), 1fr);
  touch-action: none;
}
.cell {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  border-radius: 12%;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.cell:focus-visible {
  box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.board.locked .cell {
  cursor: default;
}

/* ---- base -------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.45 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
img, svg, canvas { display: block; }
.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; }
[hidden] { display: none !important; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.lead { color: var(--ink-2); font-size: 16px; }
.big-num { font-family: var(--num); font-weight: 800; font-variant-numeric: tabular-nums; }

/* the paper (and the unlockable backgrounds) behind everything */
.paper {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(170, 120, 60, 0.12), transparent 60%),
    var(--paper);
}
.paper::after {
  content: ""; position: absolute; inset: 0; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .18 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .paper, :root:not([data-theme="light"]) .paper { }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .paper { background: radial-gradient(120% 80% at 20% 0%, rgba(255, 220, 170, 0.06), transparent 60%), var(--paper); } }
:root[data-theme="dark"] .paper { background: radial-gradient(120% 80% at 20% 0%, rgba(255, 220, 170, 0.06), transparent 60%), var(--paper); }
body[data-bg="rice"] .paper::after { opacity: 0.9; background-image: 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='.012 .25' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .4 0 0 0 0 .25 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E"); }
body[data-bg="map"] .paper::after { opacity: 0.55; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300' fill='none' stroke='%238a6a40' stroke-opacity='.28'%3E%3Cpath d='M20 150c40-60 120-80 160-40s70 90 120 60M0 200c60-30 90 20 150 0s80-70 150-40M40 60c50 10 70-40 120-30s60 50 120 20M60 260c30-40 90-30 120 0s70 20 120-10'/%3E%3Cellipse cx='210' cy='90' rx='30' ry='18'/%3E%3Cellipse cx='210' cy='90' rx='16' ry='9'/%3E%3C/svg%3E"); }
body[data-bg="moss"] .paper { background: radial-gradient(60% 50% at 10% 90%, rgba(80, 130, 60, 0.22), transparent 70%), radial-gradient(50% 40% at 95% 10%, rgba(90, 140, 70, 0.18), transparent 70%), var(--paper); }
body[data-bg="stars"] .paper { background: radial-gradient(130% 90% at 50% -10%, #2b3a5c, #141a2b 70%); }
body[data-bg="stars"] .paper::after { opacity: 1; background-image: radial-gradient(1.2px 1.2px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 120px 80px, #ffe9b0, transparent), radial-gradient(1.4px 1.4px at 60px 150px, #fff, transparent), radial-gradient(1px 1px at 170px 120px, #cfe0ff, transparent), radial-gradient(1px 1px at 90px 60px, #fff, transparent); background-size: 200px 180px; }
body[data-bg="peak"] .paper { background: linear-gradient(180deg, transparent 55%, rgba(90, 100, 120, 0.18)), var(--paper); }
body[data-bg="peak"] .paper::after { opacity: 1; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 120' preserveAspectRatio='none'%3E%3Cpath d='M0 120 60 60l30 25 60-70 50 50 40-30 70 65 40-25 50 45z' fill='%237a8aa3' fill-opacity='.35'/%3E%3Cpath d='M150 15l18 18-10-4-8 9-8-8-10 4z' fill='%23fff' fill-opacity='.6'/%3E%3C/svg%3E") bottom / 100% 34% no-repeat; }
body[data-bg="stars"] { --ink: #f3e9dc; --ink-2: #d6c7b3; --ink-3: #aa9a86; }

/* ---- buttons --------------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border: 0; border-radius: 14px;
  background: var(--card); color: var(--ink); font-weight: 650; font-size: 15.5px;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px rgba(60, 35, 10, 0.06);
  cursor: pointer; text-decoration: none; white-space: normal; text-align: center;
  transition: transform 0.12s var(--ease), background 0.15s, box-shadow 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--card-2); }
.btn:active, .icon-btn:active, .round:active, .way:active, .card:active, .act:active, .type:active, .seg:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(180deg, #b47a1c, var(--ca-accent)); color: #fff; box-shadow: 0 8px 22px -12px rgba(143, 90, 12, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.danger { background: var(--bad); color: #fff; box-shadow: none; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 11px; }
.btn.big { min-height: 54px; font-size: 17px; padding: 0 26px; border-radius: 16px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled], .icon-btn[disabled], .round[disabled], .act[disabled] { opacity: 0.45; cursor: default; transform: none; }
.btn .i { width: 20px; height: 20px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 13px;
  background: transparent; color: var(--ink-2); cursor: pointer; position: relative;
  transition: background 0.15s, color 0.15s, transform 0.12s var(--ease);
}
.icon-btn:hover { background: var(--line); color: var(--ink); }
.round {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow); cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.15s;
}
.round.big { width: 54px; height: 54px; }
.round.yes { background: var(--good); color: #fff; box-shadow: var(--shadow); }
.round.no { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 650; background: var(--line); color: var(--ink-2); white-space: nowrap; }
.pill .i { width: 14px; height: 14px; }
.pill.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill.gold { background: color-mix(in srgb, var(--gold) 28%, transparent); color: var(--gold-ink); }
.pill.warn { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }

/* ---- the shell --------------------------------------------------------------------------------- */

.app { min-height: 100dvh; display: flex; flex-direction: column; width: 100%; min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--safe-t) + 6px) calc(var(--safe-r) + 10px) 6px calc(var(--safe-l) + 10px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; cursor: pointer; overflow: hidden; }
.brand b { overflow: hidden; text-overflow: ellipsis; }
.brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 2px 6px rgba(60, 35, 10, 0.25); flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand b { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.brand small { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 2px; flex: none; }
.account-slot { margin-left: 4px; display: inline-flex; }
@media (max-width: 400px) { .brand small { display: none; } .tools .icon-btn { width: 40px; } }
@media (max-width: 340px) { .brand b { font-size: 16px; } }
body[data-screen="game"] .brand small { display: none; }
@media (max-width: 420px) { body:not([data-screen="menu"]) .brand-text { display: none; } }

.screens { flex: 1; position: relative; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.screen { grid-area: 1 / 1; min-width: 0; padding: 14px calc(var(--safe-r) + 14px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 14px); }
.screen.entering { animation: screen-in 0.24s var(--ease) both; }
.screen.leaving { animation: screen-out 0.24s var(--ease) both; pointer-events: none; }
@keyframes screen-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes screen-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-18px); } }
.screen-title { font-size: 24px; font-weight: 800; margin: 2px 0 12px; }

/* ---- the menu ----------------------------------------------------------------------------------- */

.menu-inner, .list-inner { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.card {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; border: 0; border-radius: var(--radius);
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); text-align: left; cursor: pointer;
  transition: transform 0.14s var(--ease), box-shadow 0.2s;
}
.card:hover { box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-lg); }
.card .mini { width: 76px; height: 76px; border-radius: 10px; box-shadow: 0 3px 8px rgba(60, 35, 10, 0.25); flex: none; }
.card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.card-text small { color: var(--gold-ink); font-weight: 750; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; }
.card-text b { font-size: 16.5px; line-height: 1.25; }
.card-go { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--gold); color: #3b2a10; flex: none; }
.card-go .i { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.card.daily { background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card) 60%); }
.daily-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.streak { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; color: #d2691e; font-variant-numeric: tabular-nums; }
.streak .i { width: 18px; height: 18px; fill: #f2994a; stroke: #d2691e; }
.shield .i { width: 18px; height: 18px; color: var(--ink-3); }
.shield.ready .i { color: var(--good); fill: color-mix(in srgb, var(--good) 22%, transparent); }

.strip { display: flex; flex-direction: column; gap: 8px; }
.strip-title { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.strip-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; }
.fcard {
  flex: none; width: 156px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border: 0; border-radius: 16px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); text-align: left; cursor: pointer; scroll-snap-align: start;
}
.fcard b { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard small { color: var(--ink-3); font-size: 12.5px; }
.fcard.invite { width: 200px; background: linear-gradient(160deg, color-mix(in srgb, var(--gold) 20%, var(--card)), var(--card)); }
.fbtns { display: flex; gap: 6px; flex-wrap: wrap; }

.ways { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.way {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 14px; border: 0; border-radius: 16px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); font-weight: 700; font-size: 15px; text-align: left; cursor: pointer;
  transition: transform 0.12s var(--ease), box-shadow 0.2s;
}
.way:hover { box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-lg); }
.way.main { grid-column: 1 / -1; min-height: 64px; font-size: 17px; background: linear-gradient(180deg, #b47a1c, var(--ca-accent)); color: #fff; box-shadow: 0 12px 26px -14px rgba(143, 90, 12, 0.9); }
.way-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold-ink); flex: none; }
.way.main .way-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }
.way:last-child:nth-child(even) { grid-column: 1 / -1; }

.career { display: flex; align-items: center; gap: 12px; margin-top: 6px; padding: 10px 6px 0; border-top: 1px dashed var(--line-2); }
.lvl { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.level-badge {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe6a8, var(--gold) 55%, #c98a22); color: #3b2a10;
  font: 800 18px/1 var(--num); box-shadow: 0 3px 8px rgba(160, 100, 20, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.level-badge.pop { animation: pop 0.5s var(--spring) both; }
@keyframes pop { 0% { transform: scale(0.6); } 55% { transform: scale(1.25); } 100% { transform: scale(1); } }
.lvl-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.lvl-text b { font-size: 15px; }
.lvl-text small { color: var(--ink-3); font-size: 12.5px; }
.xpbar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: var(--p); border-radius: inherit; background: linear-gradient(90deg, #e9a93a, var(--gold)); transition: width 0.8s var(--ease); }
.moss { position: relative; width: 70px; height: 70px; border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.moss .fig { width: 70px; height: 70px; }
.bell { position: relative; }
.bell .dot { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font: 700 11px/18px var(--num); font-style: normal; }

/* ---- sheets ------------------------------------------------------------------------------------------ */

dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; padding: 0; border: 0; width: min(100%, 560px); max-height: min(92dvh, 860px);
  background: transparent; color: var(--ink); overflow: visible;
}
dialog.sheet::backdrop { background: rgba(30, 18, 8, 0.38); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade 0.2s both; }
dialog.sheet.closing::backdrop { animation: fade 0.18s reverse both; }
.sheet-card {
  display: flex; flex-direction: column; max-height: min(92dvh, 860px); background: var(--card); border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg); padding-bottom: var(--safe-b); animation: rise 0.3s var(--ease) both;
}
dialog.sheet.closing .sheet-card { animation: sink 0.18s ease-in both; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sink { to { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 640px) and (min-height: 560px) {
  dialog.sheet { inset: 0; margin: auto; height: fit-content; }
  .sheet-card { border-radius: 24px; padding-bottom: 0; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 12px 6px 20px; }
.sheet-head h2 { font-size: 20px; font-weight: 800; }
.sheet-body { padding: 6px 20px 16px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px; }
.sheet-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin-top: 6px; }
.sheet-actions { display: flex; gap: 10px; padding: 10px 20px 16px; border-top: 1px solid var(--line); }
.sheet-actions .btn { flex: 1; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list .btn { justify-content: flex-start; }

.level-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 12px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); text-align: center; transition: box-shadow 0.15s, transform 0.12s;
}
.level-card[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--gold), 0 6px 16px -8px rgba(160, 100, 20, 0.6); background: color-mix(in srgb, var(--gold) 12%, var(--card)); }
.lc-fig .fig { width: 64px; height: 64px; }
.level-card b { font-size: 15px; }
.level-card small { color: var(--gold-ink); font-weight: 700; font-size: 12.5px; }
.lc-desc { color: var(--ink-3); font-size: 12.5px; line-height: 1.3; margin-top: 2px; }
.segs { display: flex; gap: 8px; flex-wrap: wrap; }
.seg {
  flex: 1 1 0; min-width: 90px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 6px 10px;
  border: 0; border-radius: 14px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-weight: 650;
}
.seg[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--card)); }
.seg.tall { flex-direction: column; padding: 12px 10px; text-align: center; }
.seg.tall small { color: var(--ink-3); font-weight: 500; font-size: 12.5px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.2); }
.sw-light { background: radial-gradient(circle at 35% 30%, #fff, var(--p0)); }
.sw-dark { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--p1) 70%, #fff), var(--p1)); }
.sw-random { background: linear-gradient(90deg, var(--p0) 50%, var(--p1) 50%); }
.layout-pic { width: 54px; height: 40px; border-radius: 8px; background: var(--line-2); position: relative; }
.lp-face::before, .lp-face::after, .lp-pass::before { content: ""; position: absolute; left: 50%; width: 22px; height: 6px; margin-left: -11px; border-radius: 3px; background: var(--gold); }
.lp-face::before { top: 3px; } .lp-face::after { bottom: 3px; }
.lp-pass::before { bottom: 3px; } .lp-pass::after { content: "↻"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-2); font-weight: 800; }
.names { display: flex; flex-direction: column; gap: 8px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.text { width: 100%; min-height: 46px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 16px; }

/* ---- the game ------------------------------------------------------------------------------------------ */

.screen.game {
  display: grid; padding: 8px calc(var(--safe-r) + 10px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 10px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "plates" "task" "stage" "tray" "actions";
  height: calc(100dvh - 57px - var(--safe-t)); gap: 6px; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.g-plates { grid-area: plates; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.task { grid-area: task; }
.g-stage { grid-area: stage; position: relative; display: grid; place-items: center; min-height: 0; padding-top: 18px; }
.g-tray { grid-area: tray; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 64px; position: relative; }
.g-actions { grid-area: actions; display: flex; justify-content: center; gap: 8px; }
.board-host { display: grid; place-items: center; }

.plate {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; border-radius: 16px; min-width: 0;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); transition: box-shadow 0.25s, transform 0.25s var(--ease);
}
.plate.side1 { align-items: flex-end; }
.plate.active { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 4px color-mix(in srgb, var(--gold) 22%, transparent), var(--shadow); }
.plate-main { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "av who" "av stock"; align-items: center; column-gap: 8px; row-gap: 2px; min-width: 0; width: 100%; }
.plate.side1 .plate-main { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who av" "stock av"; text-align: right; }
.plate-main .av { grid-area: av; } .plate-main .who { grid-area: who; } .plate-main .stock { grid-area: stock; }
.plate.side1 .stock { justify-content: flex-end; }
.av { position: relative; width: 44px; height: 44px; flex: none; }
.av .fig { width: 44px; height: 44px; }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pname { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstatus { color: var(--gold-ink); font-size: 12px; font-weight: 700; min-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock { display: flex; align-items: center; gap: 3px; font: 800 14px/1 var(--num); font-variant-numeric: tabular-nums; }
.pstatus { display: none; }
.chip-stone, .chip-cap { width: 13px; height: 9px; border-radius: 50%; background: var(--pc); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.18); margin-left: 4px; }
.chip-cap { width: 10px; height: 11px; border-radius: 40% 40% 30% 30%; }
.plate.side0 { --pc: var(--p0); } .plate.side1 { --pc: var(--p1); }
.plate .types, .plate .own-undo { display: none; }
.turn-pill { font-size: 12.5px; font-weight: 700; color: var(--ink-3); text-align: center; max-width: 84px; line-height: 1.2; }
.plate[data-say]::after { content: attr(data-say); position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); padding: 4px 10px; border-radius: 99px; background: var(--gold); color: #3b2a10; font-weight: 800; font-size: 13px; white-space: nowrap; opacity: 0; pointer-events: none; z-index: 5; }
.plate.yours::after { animation: say 1.2s var(--ease) both; }
@keyframes say { 0% { opacity: 0; transform: translate(-50%, 0); } 15%, 80% { opacity: 1; transform: translate(-50%, 6px); } 100% { opacity: 0; } }

.task { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; border-radius: 14px; background: color-mix(in srgb, var(--gold) 14%, var(--card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 40%, transparent); }
.task-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-meta { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold-ink); }
.task-text { font-weight: 650; font-size: 15px; }
.task.done .task-text { color: var(--good); animation: pop 0.45s var(--spring); }

.types { display: flex; gap: 6px; }
.type {
  display: flex; align-items: center; gap: 7px; min-height: 48px; padding: 4px 12px 4px 8px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow); font-weight: 700; font-size: 14px; transition: box-shadow 0.15s, transform 0.12s var(--ease), opacity 0.15s;
}
.type.on { box-shadow: inset 0 0 0 2px var(--gold), 0 6px 14px -8px rgba(160, 100, 20, 0.7); }
.type[disabled] { opacity: 0.45; cursor: default; }
.type.out .tcount { color: var(--bad); font-size: 11.5px; }
.types.inactive { opacity: 0.55; }
.tlabel { white-space: nowrap; }
.tcount { font: 800 13px/1 var(--num); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ticon { width: 24px; height: 24px; position: relative; flex: none; --c: var(--p0); }
.types[data-colour="1"] .ticon { --c: var(--p1); }
.ti-flat::before { content: ""; position: absolute; left: 1px; right: 1px; top: 8px; height: 11px; border-radius: 50%; background: radial-gradient(ellipse at 35% 35%, color-mix(in srgb, var(--c) 60%, #fff), var(--c)); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 70%, #000), 0 0 0 1px rgba(0, 0, 0, 0.18); }
.ti-wall::before { content: ""; position: absolute; left: 8px; width: 9px; top: 1px; bottom: 2px; border-radius: 45% 45% 35% 35%; background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, #fff), var(--c)); box-shadow: 2px 0 0 color-mix(in srgb, var(--c) 65%, #000), 0 0 0 1px rgba(0, 0, 0, 0.18); }
.ti-cap::before { content: ""; position: absolute; left: 4px; right: 4px; top: 4px; bottom: 3px; border-radius: 50% 50% 40% 40%; background: radial-gradient(circle at 40% 30%, color-mix(in srgb, var(--c) 55%, #fff), var(--c)); box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 70%, #000), 0 0 0 1px rgba(0, 0, 0, 0.18); }
.ti-cap::after { content: ""; position: absolute; left: 9px; top: 7px; width: 6px; height: 4px; border-radius: 50%; background: rgba(0, 0, 0, 0.2); }
.g-note { color: var(--ink-2); font-size: 13.5px; font-weight: 600; min-height: 18px; text-align: center; }

.act {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 76px; min-height: 52px; padding: 4px 10px;
  border: 0; border-radius: 14px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 12px; font-weight: 700; position: relative;
  transition: background 0.15s, transform 0.12s var(--ease);
}
.act:hover { background: var(--line); color: var(--ink); }
.act .badge { position: absolute; top: 2px; right: 14px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--gold); color: #3b2a10; font: 800 11px/18px var(--num); font-style: normal; }
.danger-text { color: var(--bad); }

.carry {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 99px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-lg); animation: rise 0.2s var(--ease) both; white-space: nowrap;
}
.carry-n, .carry-q { font-weight: 800; font-size: 14px; padding: 0 4px; font-variant-numeric: tabular-nums; }
.g-banner {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); z-index: 4; pointer-events: none;
  padding: 12px; text-align: center; font-weight: 800; font-size: 18px; opacity: 0; color: #3b2a10;
  background: linear-gradient(90deg, transparent, var(--bc, var(--gold)) 20%, var(--bc, var(--gold)) 80%, transparent);
}
.g-banner[data-colour="0"] { --bc: color-mix(in srgb, var(--p0) 92%, transparent); }
.g-banner[data-colour="1"] { --bc: color-mix(in srgb, var(--p1) 92%, transparent); color: #fff; }
.g-banner.show { animation: band 1s var(--ease) both; }
@keyframes band { 0% { opacity: 0; transform: translateY(-50%) scaleY(0.4); } 15%, 75% { opacity: 1; transform: translateY(-50%); } 100% { opacity: 0; } }
.inspector {
  position: absolute; right: 4px; top: 4px; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px;
  border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-lg); animation: rise 0.18s var(--ease) both;
}
.inspector b { font-size: 13px; }
.inspector small { color: var(--ink-3); font-size: 11.5px; }
.layers { display: flex; flex-direction: column-reverse; gap: 1px; }
.layer { display: block; width: 34px; height: 8px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.15); }
.layer.c0 { background: var(--p0); } .layer.c1 { background: var(--p1); }
.layer.wall { width: 10px; height: 18px; margin: 0 auto; border-radius: 40%; }
.layer.cap { width: 24px; height: 14px; margin: 0 auto; border-radius: 45% 45% 35% 35%; }
.side-menu { display: none; }
.board.locked { cursor: progress; }
.g-stage .board-host .board { margin-top: 6px; }

/* pass and play: a gentle tilt towards whoever moves */
.screen.game.pass .board-host { perspective: 1400px; }
.screen.game.pass .board { transform: rotateX(9deg); transform-origin: 50% 70%; }
:root[data-motion="reduced"] .screen.game.pass .board { transform: none; }

/* wide screens and landscape: the board between two player panels */
.screen.game.wide {
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) minmax(180px, 260px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "left task right" "left stage right" "left tray right";
  column-gap: 16px;
}
.screen.game.wide .g-plates { display: contents; }
.screen.game.wide .plate.side0 { grid-area: left; align-self: center; }
.screen.game.wide .plate.side1 { grid-area: right; align-self: center; margin-bottom: 70px; }
.screen.game.wide .plate { align-items: stretch; padding: 14px; gap: 12px; }
.screen.game.wide .plate-main { flex-direction: column; text-align: center; }
.screen.game.wide .plate.side1 .plate-main { flex-direction: column; text-align: center; }
.screen.game.wide .av, .screen.game.wide .av .fig { width: 72px; height: 72px; }
.screen.game.wide .stock { justify-content: center; font-size: 16px; }
.screen.game.wide .plate-main, .screen.game.wide .plate.side1 .plate-main { grid-template-columns: 1fr; grid-template-areas: "av" "who" "stock"; justify-items: center; text-align: center; }
.screen.game.wide .pstatus { display: block; }
.screen.game.wide .turn-pill { display: none; }
.screen.game.wide .g-actions { grid-area: right; align-self: end; flex-wrap: wrap; }
.screen.game.wide .g-tray { align-self: start; }

/* face to face: the device lies between two players; the far one reads upside down */
.screen.game[data-layout="face"] {
  position: fixed; inset: 0; z-index: 30; height: 100dvh; background: var(--paper);
  padding: calc(var(--safe-t) + 6px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 8px);
  grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "far" "stage" "near";
}
.screen.game[data-layout="face"] .g-plates { display: contents; }
.screen.game[data-layout="face"] .plate { padding: 10px 12px; gap: 8px; flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.screen.game[data-layout="face"] .plate.side0 { grid-area: near; }
.screen.game[data-layout="face"] .plate.side1 { grid-area: far; transform: rotate(180deg); }
.screen.game[data-layout="face"] .plate.side1 .plate-main { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "av who" "av stock"; text-align: left; }
.screen.game[data-layout="face"] .plate.side1 .stock { justify-content: flex-start; }
.screen.game[data-layout="face"] .plate-main { width: auto; flex: 1 1 160px; }
.screen.game[data-layout="face"] .plate .types { display: flex; }
.screen.game[data-layout="face"] .plate .own-undo { display: inline-grid; }
.screen.game[data-layout="face"] .plate::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px; border-radius: 0 0 16px 16px; background: transparent; transition: background 0.3s; }
.screen.game[data-layout="face"] .plate.active::before { background: var(--pc); box-shadow: 0 0 14px var(--pc); }
.screen.game[data-layout="face"] .turn-pill, .screen.game[data-layout="face"] .g-tray .types, .screen.game[data-layout="face"] .g-actions, .screen.game[data-layout="face"] .task { display: none; }
.screen.game[data-layout="face"] .g-tray { position: absolute; left: 0; right: 0; bottom: 50%; min-height: 0; pointer-events: none; }
.screen.game[data-layout="face"] .g-tray > * { pointer-events: auto; }
.screen.game[data-layout="face"] .g-note { display: none; }
.screen.game[data-layout="face"] .side-menu { display: inline-grid; position: absolute; left: calc(var(--safe-l) + 4px); top: 50%; transform: translateY(-50%) rotate(90deg); z-index: 8; background: var(--card); box-shadow: var(--shadow); }
.screen.game[data-layout="face"] .plate:not(.active) .types { opacity: 0.4; pointer-events: none; }
.screen.game.compact[data-layout="face"] .plate { padding: 6px 8px; }
.screen.game.compact[data-layout="face"] .av, .screen.game.compact[data-layout="face"] .av .fig { width: 34px; height: 34px; }
.screen.game.compact[data-layout="face"] .type { min-height: 44px; padding: 2px 8px 2px 6px; }
.screen.game.compact[data-layout="face"] .tlabel { display: none; }
body:has(.screen.game[data-layout="face"]:not([hidden])) .top { visibility: hidden; }

/* ---- the result ------------------------------------------------------------------------------------------- */

.result { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; padding: 12px; background: rgba(30, 18, 8, 0); transition: background 0.4s; pointer-events: none; }
.result.show { background: rgba(30, 18, 8, 0.32); pointer-events: auto; }
.screen.game { position: relative; }
.result-card {
  width: min(100%, 420px); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 18px 18px;
  border-radius: 24px; background: var(--card); box-shadow: var(--shadow-lg); text-align: center; transform: translateY(60px); opacity: 0;
}
.result.show .result-card { animation: card-in 0.5s var(--ease) forwards; }
@keyframes card-in { to { transform: none; opacity: 1; } }
.res-figs { display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.res-fig .fig { width: 112px; height: 112px; }
.res-fig.small .fig { width: 60px; height: 60px; opacity: 0.9; }
.result-card h2 { font-size: 26px; font-weight: 850; }
.res-how { color: var(--gold-ink); font-weight: 800; font-size: 17px; }
.res-row { display: flex; justify-content: space-between; width: 100%; padding: 8px 12px; border-radius: 12px; background: var(--card-2); font-weight: 650; }
.res-val { font-weight: 800; }
.res-val .big-num { font-size: 20px; }
.res-note { color: var(--ink-3); font-size: 13.5px; }
.res-explain { color: var(--ink-2); font-size: 14.5px; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--gold) 12%, transparent); }
.unlock { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--gold) 18%, var(--card)); text-align: left; animation: pop 0.5s var(--spring) both; animation-delay: 0.9s; }
.unlock-stone { width: 30px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--p0)); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
.unlock-bg { width: 30px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--gold), var(--paper-2)); }
.res-extra { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; margin-top: 4px; }
.res-actions .btn { flex: 1 1 120px; }
.reactions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.react { width: 48px; height: 48px; border: 0; padding: 4px; border-radius: 14px; background: var(--card-2); cursor: pointer; transition: transform 0.15s var(--spring); }
.react:hover { transform: scale(1.08); }
.react.sent, .react[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--gold); }
.react .rx, .their-react .rx { width: 40px; height: 40px; }
.their-react { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); }
.result.split { padding: 0; place-items: stretch; grid-template-rows: 1fr 1fr; }
.result.split .half { display: grid; place-items: center; padding: 8px; min-height: 0; }
.result.split .half.far { transform: rotate(180deg); }
.result.split .result-card { max-height: 100%; padding: 10px 14px; gap: 6px; }
.result.split .res-fig .fig { width: 72px; height: 72px; }

/* ---- bubbles and toasts ------------------------------------------------------------------------------------- */

.bubble {
  position: absolute; left: 50%; z-index: 9; width: max-content; max-width: 220px; padding: 8px 12px; border-radius: 14px;
  background: #fffdf8; color: #2c2219; font-size: 14px; font-weight: 650; line-height: 1.3; text-align: center;
  box-shadow: 0 8px 22px -8px rgba(60, 35, 10, 0.45), 0 0 0 1px rgba(80, 55, 30, 0.12); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s var(--spring);
}
.bubble.below { top: calc(100% + 8px); transform: translate(-50%, -6px) scale(0.9); }
.bubble.above { bottom: calc(100% + 8px); transform: translate(-50%, 6px) scale(0.9); }
.bubble.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.bubble::before { content: ""; position: absolute; left: 50%; width: 12px; height: 12px; margin-left: -6px; background: inherit; transform: rotate(45deg); }
.bubble.below::before { top: -5px; } .bubble.above::before { bottom: -5px; }
.plate.side1 .bubble.below { left: auto; right: 0; transform: translate(0, -6px) scale(0.9); }
.plate.side1 .bubble.below.show { transform: none; }
.plate.side1 .bubble::before { left: auto; right: 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 18px); z-index: 2147482000; max-width: min(92vw, 440px); padding: 12px 18px; border-radius: 14px;
  background: #2c2219; color: #fff6e6; font-weight: 650; font-size: 14.5px; text-align: center; box-shadow: var(--shadow-lg);
  transform: translate(-50%, 24px); opacity: 0; transition: opacity 0.2s, transform 0.25s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- lists ------------------------------------------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--line); }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 42px; padding: 0 8px; border: 0; border-radius: 11px; background: transparent; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tab .i { width: 16px; height: 16px; }
.tab small { color: var(--ink-3); font-weight: 600; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.ptile { position: relative; display: grid; place-items: center; padding: 6px; border: 0; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); cursor: pointer; transition: transform 0.12s var(--ease); }
.ptile .mini { width: 100%; height: auto; aspect-ratio: 1; border-radius: 9px; }
.pnum { position: absolute; left: 4px; top: 4px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: rgba(30, 18, 8, 0.7); color: #fff; font: 800 12.5px/24px var(--num); }
.ptile.done { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--good) 70%, transparent), var(--shadow); }
.pstars { position: absolute; bottom: 4px; display: flex; gap: 1px; padding: 2px 5px; border-radius: 9px; background: rgba(30, 18, 8, 0.65); }
.pstars .i { width: 13px; height: 13px; stroke: #6b5a43; }
.pstars .on .i { fill: var(--gold); stroke: var(--gold); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 14px; text-align: center; color: var(--ink-2); }
.empty > .i { width: 34px; height: 34px; color: var(--ink-3); }
.empty .fig { width: 90px; height: 90px; }
.empty.soft { padding: 14px; }
.empty-board { position: relative; }
.empty-board .fig { position: absolute; right: -40px; bottom: -14px; }
.empty-board .mini { border-radius: 12px; box-shadow: var(--shadow); }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--ink-3); font-size: 12.5px; }
.row-av { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: #3b2a10; font-weight: 800; flex: none; }
.row-open { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border: 0; background: none; padding: 2px 0; text-align: left; cursor: pointer; }
.res-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink-3); }
.res-dot.win { background: var(--good); } .res-dot.loss { background: var(--bad); } .res-dot.local { background: var(--gold); }
.res-word { font-weight: 750; font-size: 13.5px; white-space: nowrap; }
.res-word.win { color: var(--good); } .res-word.loss { color: var(--bad); }
.notes .row.unread { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--gold) 60%, transparent); }
.notes .rx { width: 32px; height: 32px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.tile .big-num { font-size: 24px; }
.tile small { color: var(--ink-3); font-size: 12.5px; }
.stat-table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.stat-table th { text-align: left; font-weight: 700; padding: 8px 10px; background: var(--card); border-radius: 12px 0 0 12px; }
.stat-table td { padding: 8px 10px; background: var(--card); }
.stat-table td:last-child { border-radius: 0 12px 12px 0; font-size: 13px; }
.stat-table .num { font: 800 16px var(--num); }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.set-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px 12px; border: 0; border-radius: 16px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); cursor: pointer; text-align: center; }
.set-tile.on { box-shadow: inset 0 0 0 2px var(--gold), var(--shadow); }
.set-tile small { color: var(--ink-3); font-size: 12px; line-height: 1.25; }
.set-tile.locked b { color: var(--ink-3); }
.stone-preview { width: 76px; height: 76px; }
.bar { display: grid; place-items: center; position: relative; width: 100%; height: 16px; border-radius: 8px; background: var(--line); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: var(--p); background: color-mix(in srgb, var(--gold) 70%, transparent); }
.bar em { position: relative; font: 800 10.5px/16px var(--num); font-style: normal; color: var(--ink-2); }
.bg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bg-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border: 0; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-size: 13px; }
.bg-tile.on { box-shadow: inset 0 0 0 2px var(--gold); }
.bg-tile.locked { opacity: 0.55; }
.bg-tile small { color: var(--ink-3); font-size: 11.5px; }
.bg-swatch { width: 100%; aspect-ratio: 1.4; border-radius: 9px; box-shadow: inset 0 0 0 1px var(--line-2); background: #f4ede0; }
.bg-rice .bg-swatch { background: repeating-linear-gradient(8deg, #f6f1e6 0 3px, #ece3d2 3px 4px); }
.bg-map .bg-swatch { background: radial-gradient(circle at 70% 40%, transparent 8px, rgba(138, 106, 64, 0.35) 9px, transparent 10px, transparent 15px, rgba(138, 106, 64, 0.35) 16px, transparent 17px), #f1e8d6; }
.bg-moss .bg-swatch { background: radial-gradient(circle at 20% 80%, rgba(80, 130, 60, 0.5), transparent 60%), #eef0dd; }
.bg-stars .bg-swatch { background: radial-gradient(1px 1px at 20% 30%, #fff, transparent), radial-gradient(1.5px 1.5px at 70% 60%, #fff, transparent), linear-gradient(#2b3a5c, #141a2b); }
.bg-peak .bg-swatch { background: linear-gradient(160deg, transparent 55%, #8a99b0 56%), #eef1f6; }
.wood-swatch { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.wood-oak .wood-swatch { background: linear-gradient(135deg, #e2b373, #a8733c); }
.wood-walnut .wood-swatch { background: linear-gradient(135deg, #a77852, #6a4329); }
.wood-maple .wood-swatch { background: linear-gradient(135deg, #f0d5a6, #c99f66); }
.me-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: color-mix(in srgb, var(--gold) 16%, var(--card)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 40%, transparent); }
.me-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.me-text small { color: var(--ink-3); }
.me-score { font: 800 20px var(--num); }
.board-list { min-height: 120px; }
.net-note { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.net-note .fig { width: 52px; height: 52px; flex: none; }
.net-note p { flex: 1; font-size: 14px; }
.link-sheet { display: flex; flex-direction: column; gap: 10px; }

/* ---- replay ---------------------------------------------------------------------------------------------- */

.replay-inner { max-width: 760px; margin: 0 auto; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.r-stage { display: grid; place-items: center; padding-top: 30px; }
.r-controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.r-count { min-width: 64px; text-align: center; font: 800 15px var(--num); color: var(--ink-2); }
.slider { width: 100%; accent-color: var(--gold-deep); height: 32px; }
.r-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.r-list { max-height: 30dvh; overflow-y: auto; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.moves { list-style: none; margin: 0; padding: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 2px; }
.moves button { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 36px; padding: 0 8px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-variant-numeric: tabular-nums; text-align: left; }
.moves li.on button { background: color-mix(in srgb, var(--gold) 30%, transparent); font-weight: 800; }
.mn { color: var(--ink-3); width: 24px; font-size: 12.5px; }
.mt { white-space: nowrap; }
.key-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 6px var(--gold); margin-left: auto; }
@media (min-width: 900px) {
  .replay-inner { grid-template-columns: minmax(0, 1fr) 260px; grid-template-areas: "head head" "stage list" "ctrl list" "slider list" "act list"; }
  .r-head { grid-area: head; } .r-stage { grid-area: stage; } .r-controls { grid-area: ctrl; } .slider { grid-area: slider; } .r-actions { grid-area: act; }
  .r-list { grid-area: list; max-height: 70dvh; }
  .moves { grid-template-columns: 1fr 1fr; }
}

/* ---- rules, settings, about ---------------------------------------------------------------------------------- */

.rule-nav { display: block; }
.rule-ctl { display: flex; align-items: center; justify-content: center; gap: 14px; }
.rule-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-height: 420px; }
.screen.game, .screen.replay { overflow-x: clip; }
.rule-card h3 { font-size: 18px; color: var(--ink); text-transform: none; letter-spacing: 0; margin: 0; }
.rule-body { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: 14.5px; text-align: left; align-self: stretch; }
.rule-board { padding-top: 44px; display: grid; place-items: center; }
.rule-try { display: flex; align-items: center; gap: 10px; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dot { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 50%; background: var(--line-2); cursor: pointer; position: relative; }
.dot::after { content: ""; position: absolute; inset: -12px; }
.dot.on { background: var(--gold); width: 22px; border-radius: 5px; }
.faq details, .keys { border-radius: 12px; background: var(--card-2); padding: 0 12px; }
.faq { display: flex; flex-direction: column; gap: 6px; }
.faq summary, .keys summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; list-style: none; }
.faq summary::after, .keys summary::after { content: "+"; margin-left: auto; color: var(--gold-ink); font-weight: 800; }
details[open] > summary::after { content: "−"; }
.faq p, .keys ul { padding: 0 0 12px; color: var(--ink-2); font-size: 14.5px; margin: 0; }
.keys ul { padding-left: 18px; }
.settings { gap: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.set-label { display: flex; flex-direction: column; min-width: 0; }
.set-label small { color: var(--ink-3); font-size: 12.5px; }
.set-row select { min-height: 42px; max-width: 54%; padding: 0 10px; border: 0; border-radius: 11px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s var(--ease); }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.vol-wrap { display: flex; align-items: center; gap: 8px; }
.vol { width: 140px; accent-color: var(--gold-deep); }
.vol-wrap output { width: 40px; text-align: right; font: 700 13px var(--num); color: var(--ink-2); }
.set-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.about { align-items: center; text-align: center; }
.about img { border-radius: 18px; box-shadow: var(--shadow); margin: 0 auto; }

/* ---- the landing page ------------------------------------------------------------------------------------- */

.landing { min-height: 100dvh; display: flex; flex-direction: column; }
.lp-top { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 14px) 6px calc(var(--safe-l) + 14px); }
.lp-tools { display: flex; align-items: center; gap: 4px; }
.lp-lang { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line-2); min-height: 44px; }
.lp-lang select { border: 0; background: transparent; min-height: 40px; font-weight: 650; }
.lp-main { overflow-x: clip; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 0 16px calc(var(--safe-b) + 24px); }
.lp-hero { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 980px; padding-top: 40px; }
.lp-board { display: grid; place-items: center; padding-top: 30px; }
.lp-moss { pointer-events: none; position: absolute; right: max(8px, calc(50% - 260px)); top: 40px; width: 74px; height: 74px; z-index: 3; }
.lp-moss .fig { width: 74px; height: 74px; }
.lp-title { text-align: center; margin-top: 18px; }
.lp-title h1 { font-size: clamp(34px, 7vw, 52px); font-weight: 900; letter-spacing: -0.03em; }
.lp-sub { font-size: clamp(17px, 3.4vw, 21px); color: var(--ink-2); margin-top: 4px; }
.lp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; width: 100%; max-width: 860px; }
.lp-card { padding: 16px; border-radius: 20px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.lp-card h2 { font-size: 18px; font-weight: 800; }
.lp-card p { color: var(--ink-2); font-size: 14.5px; }
.lp-anim { position: relative; height: 70px; border-radius: 14px; background: linear-gradient(135deg, #e2b373, #b47e44); overflow: hidden; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2); }
.lp-anim i { position: absolute; width: 36px; height: 20px; border-radius: 50%; background: radial-gradient(ellipse at 35% 30%, #fff, #e9dcc5 55%, #c8b89c); box-shadow: 0 4px 0 #b9a582, 0 6px 8px rgba(0, 0, 0, 0.3); }
.a-place i { left: calc(50% - 18px); top: 26px; animation: lp-drop 2.4s var(--ease) infinite; }
@keyframes lp-drop { 0% { transform: translateY(-50px); opacity: 0; } 25% { transform: translateY(2px); opacity: 1; } 32% { transform: translateY(-2px); } 38%, 85% { transform: none; opacity: 1; } 100% { opacity: 0; } }
.a-spread i { top: 26px; left: 14%; }
.a-spread i:nth-child(1) { animation: lp-s1 3s var(--ease) infinite; }
.a-spread i:nth-child(2) { animation: lp-s2 3s var(--ease) infinite; }
.a-spread i:nth-child(3) { animation: lp-s3 3s var(--ease) infinite; }
@keyframes lp-s1 { 0%, 20% { transform: translate(0, 0); } 45%, 90% { transform: translate(28%, 0); } 100% { transform: translate(0, 0); } }
@keyframes lp-s2 { 0%, 20% { transform: translate(0, -7px); } 55%, 90% { transform: translate(250%, 0); } 100% { transform: translate(0, -7px); } }
@keyframes lp-s3 { 0%, 20% { transform: translate(0, -14px); } 65%, 90% { transform: translate(470%, 0); } 100% { transform: translate(0, -14px); } }
.a-connect i { top: 26px; }
.a-connect i:nth-child(1) { left: 6%; } .a-connect i:nth-child(2) { left: 30%; } .a-connect i:nth-child(3) { left: 54%; } .a-connect i:nth-child(4) { left: 78%; }
.a-connect b { position: absolute; left: 10%; right: 10%; top: 35px; height: 4px; border-radius: 2px; background: var(--gold); box-shadow: 0 0 10px var(--gold); transform-origin: left; animation: lp-road 2.6s var(--ease) infinite; }
@keyframes lp-road { 0%, 15% { transform: scaleX(0); opacity: 0; } 55%, 85% { transform: scaleX(1); opacity: 1; } 100% { opacity: 0; } }
.lp-cta { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 520px; }
.lp-note { color: var(--ink-2); font-size: 15px; }
.lp-offline { color: var(--bad); font-weight: 650; }
.lp-tiny { color: var(--ink-3); font-size: 13px; }

/* ---- motion off --------------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *, :root:not([data-motion="full"]) *::before, :root:not([data-motion="full"]) *::after { animation-duration: 0.12s !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
}
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation-duration: 0.12s !important; animation-iteration-count: 1 !important; transition-duration: 0.12s !important; }
:root[data-motion="reduced"] .screen.entering, :root[data-motion="reduced"] .screen.leaving { animation-name: fade !important; }
/* ───────── Stone Road – stone spirits (.fig) and reaction stones (.rx) ─────────
   Markup: public/js/figures.js. Every rule is scoped to .fig or .rx.
   Moods via data-mood on the <svg>: idle | happy | cheer | think | sad | sigh | surprised.
   .fig.breathing = the active player's avatar (3 s, ±3 %). Transform/opacity only. */

.fig, .rx { overflow: visible; }

/* palette per spirit (light) – figures.js carries the same values as attributes */
.fig {
  --fg-sh: #2B1D12;
  --fg-rim-o: .28;
  --fg-dot: #FFFCF6; --fg-dot-ol: #9A8670;
  --fg-puff: #FFFFFF; --fg-puff-ol: #A8977E;
}
.fig-moss   { --fg-hi: #FFFCF5; --fg-base: #EFE6D6; --fg-mid: #DCCCB2; --fg-lo: #C2AD8E; --fg-ol: #7D6A52; }
.fig-ember  { --fg-hi: #8598AE; --fg-base: #4A5D73; --fg-mid: #3B4C60; --fg-lo: #2A3749; --fg-ol: #1C2531; --fg-socket: #151C26; --fg-rim-o: .14; }
.fig-pebble { --fg-hi: #FFF5EE; --fg-base: #ECD2C4; --fg-mid: #DDB8A6; --fg-lo: #C29684; --fg-ol: #7E5A4C; }
.fig-flint  { --fg-hi: #DCD6CE; --fg-base: #A69E95; --fg-mid: #8D857C; --fg-lo: #6C645D; --fg-ol: #3A3430; --fg-rim-o: .22; }
.fig-basalt { --fg-hi: #7C7678; --fg-base: #5D585A; --fg-mid: #494547; --fg-lo: #312E30; --fg-ol: #171516; --fg-rim-o: .12; }

.fig .fg-st-hi   { stop-color: var(--fg-hi); }
.fig .fg-st-base { stop-color: var(--fg-base); }
.fig .fg-st-mid  { stop-color: var(--fg-mid); }
.fig .fg-st-lo   { stop-color: var(--fg-lo); }
.fig .fg-st-sh   { stop-color: var(--fg-sh); }
.fig .fg-ol      { stroke: var(--fg-ol); }
.fig .fg-fill-hi   { fill: var(--fg-hi); }
.fig .fg-fill-base { fill: var(--fg-base); }
.fig .fg-fill-mid  { fill: var(--fg-mid); }
.fig .fg-fill-lo   { fill: var(--fg-lo); }
.fig .fg-stroke-base { stroke: var(--fg-base); }
.fig .fg-socket  { fill: var(--fg-socket); }
.fig .fg-rim     { opacity: var(--fg-rim-o); }
.fig .fg-dot     { fill: var(--fg-dot); stroke: var(--fg-dot-ol); }
.fig .fg-sigh-fill { fill: var(--fg-puff); }
.fig .fg-sigh-ol   { fill: var(--fg-puff-ol); stroke: var(--fg-puff-ol); }

/* ───────── dark theme: system dark unless forced light, or forced dark ───────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fig { --fg-sh: #000; --fg-rim-o: .5; --fg-dot: #E8ECF2; --fg-dot-ol: #5E6878; --fg-puff: #E8ECF2; --fg-puff-ol: #6B7486; }
  :root:not([data-theme="light"]) .fig-moss   { --fg-hi: #FFFFFF; --fg-base: #E8ECF2; --fg-mid: #C9D0DB; --fg-lo: #A3ADBD; --fg-ol: #59647A; }
  :root:not([data-theme="light"]) .fig-ember  { --fg-hi: #F7A898; --fg-base: #E06A5A; --fg-mid: #C55444; --fg-lo: #9E3D33; --fg-ol: #4E1A15; --fg-socket: #3A1210; --fg-rim-o: .4; }
  :root:not([data-theme="light"]) .fig-basalt { --fg-hi: #8E888A; --fg-base: #6E696B; --fg-mid: #585355; --fg-lo: #3F3B3D; --fg-ol: #0F0D0E; --fg-rim-o: .45; }
  :root:not([data-theme="light"]) .rx { --rx-sh: #000; }
}
:root[data-theme="dark"] .fig { --fg-sh: #000; --fg-rim-o: .5; --fg-dot: #E8ECF2; --fg-dot-ol: #5E6878; --fg-puff: #E8ECF2; --fg-puff-ol: #6B7486; }
:root[data-theme="dark"] .fig-moss   { --fg-hi: #FFFFFF; --fg-base: #E8ECF2; --fg-mid: #C9D0DB; --fg-lo: #A3ADBD; --fg-ol: #59647A; }
:root[data-theme="dark"] .fig-ember  { --fg-hi: #F7A898; --fg-base: #E06A5A; --fg-mid: #C55444; --fg-lo: #9E3D33; --fg-ol: #4E1A15; --fg-socket: #3A1210; --fg-rim-o: .4; }
:root[data-theme="dark"] .fig-basalt { --fg-hi: #8E888A; --fg-base: #6E696B; --fg-mid: #585355; --fg-lo: #3F3B3D; --fg-ol: #0F0D0E; --fg-rim-o: .45; }
:root[data-theme="dark"] .rx { --rx-sh: #000; }
.rx .rx-st-sh { stop-color: var(--rx-sh, #2B1D12); }

/* ───────── pivots ───────── */
.fig .fg-breath { transform-box: view-box; transform-origin: 60px 108px; }
.fig .fg-rig    { transform-box: view-box; transform-origin: 60px 106px; }
.fig .fg-shadow, .fig .fg-eyes, .fig .fg-dot, .fig .fg-spark, .fig .fg-tear,
.fig .fg-brow-l, .fig .fg-brow-r { transform-box: fill-box; transform-origin: 50% 50%; }
.fig .fg-leaf   { transform-box: fill-box; transform-origin: 45% 100%; }
.fig .fg-lid    { transform-box: fill-box; transform-origin: 50% 100%; }
.fig .fg-arm-l  { transform-box: fill-box; transform-origin: 100% 0%; }
.fig .fg-arm-r  { transform-box: fill-box; transform-origin: 0% 0%; }
.fig .fg-hand-scratch { transform-box: fill-box; transform-origin: 0% 100%; }
.fig .fg-sigh   { transform-box: fill-box; transform-origin: 0% 100%; }

.fig .fg-arm-l, .fig .fg-arm-r, .fig .fg-lid, .fig .fg-brow-l, .fig .fg-brow-r, .fig .fg-look, .fig .fg-leaf {
  transition: transform .28s cubic-bezier(.34, 1.4, .5, 1), opacity .16s;
}

/* ───────── what each mood shows ───────── */
.fig .fg-mouth-idle, .fig .fg-mouth-happy, .fig .fg-mouth-sad, .fig .fg-mouth-o, .fig .fg-mouth-hmm,
.fig .fg-eyes, .fig .fg-eyes-joy, .fig .fg-brows, .fig .fg-cheeks, .fig .fg-hand-scratch,
.fig .fg-dot, .fig .fg-tear, .fig .fg-sigh { transition: opacity .16s; }

.fig .fg-mouth-happy, .fig .fg-mouth-sad, .fig .fg-mouth-o, .fig .fg-mouth-hmm,
.fig .fg-eyes-joy, .fig .fg-lid, .fig .fg-brows, .fig .fg-hand-scratch,
.fig .fg-dot, .fig .fg-tear, .fig .fg-sigh { opacity: 0; }
.fig-flint .fg-brows, .fig-basalt .fg-brows, .fig-basalt .fg-lid { opacity: 1; }
.fig .fg-cheeks { opacity: .8; }

.fig:is([data-mood="happy"], [data-mood="cheer"], [data-mood="think"], [data-mood="sad"], [data-mood="sigh"], [data-mood="surprised"]) .fg-mouth-idle { opacity: 0; }
.fig:is([data-mood="happy"], [data-mood="cheer"]) .fg-mouth-happy { opacity: 1; }
.fig:is([data-mood="happy"], [data-mood="cheer"]) .fg-cheeks { opacity: 1; }
.fig[data-mood="think"] .fg-mouth-hmm { opacity: 1; }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-mouth-sad { opacity: 1; }
.fig[data-mood="surprised"] .fg-mouth-o { opacity: 1; }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-cheeks { opacity: .45; }

/* eyes: blink in every open-eyed mood; joy arcs when cheering */
@keyframes fg-blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.08); } }
.fig .fg-eyes { animation: fg-blink 4.2s ease-in-out infinite; }
.fig-ember  .fg-eyes { animation-delay: -1.7s; }
.fig-pebble .fg-eyes { animation-duration: 3.4s; animation-delay: -.6s; }
.fig-flint  .fg-eyes { animation-delay: -2.9s; }
.fig-basalt .fg-eyes { animation-duration: 6s; animation-delay: -3.4s; }
.fig[data-mood="cheer"] .fg-eyes { opacity: 0; }
.fig[data-mood="cheer"] .fg-eyes-joy { opacity: 1; }
.fig[data-mood="cheer"] .fg-lid { opacity: 0; }
.fig[data-mood="surprised"] .fg-eyes { animation: none; transform: scale(1.16); }
.fig-basalt[data-mood="surprised"] .fg-lid { opacity: 0; }
.fig[data-mood="think"] .fg-look { transform: translate(1.6px, -1.8px); }
.fig[data-mood="sad"] .fg-look { transform: translateY(1.2px); }

/* lids and brows */
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-lid { opacity: 1; }
.fig[data-mood="sad"] .fg-lid-l { transform: rotate(-12deg); }
.fig[data-mood="sad"] .fg-lid-r { transform: rotate(12deg); }
.fig[data-mood="sigh"] .fg-lid { transform: translateY(1.4px); }
.fig:is([data-mood="sad"], [data-mood="sigh"], [data-mood="think"], [data-mood="surprised"]) .fg-brows { opacity: 1; }
.fig[data-mood="sad"] .fg-brow-l { transform: translateY(.6px) rotate(-16deg); }
.fig[data-mood="sad"] .fg-brow-r { transform: translateY(.6px) rotate(16deg); }
.fig[data-mood="sigh"] .fg-brow-l { transform: translateY(1px) rotate(-9deg); }
.fig[data-mood="sigh"] .fg-brow-r { transform: translateY(1px) rotate(9deg); }
.fig[data-mood="surprised"] .fg-brow-l, .fig[data-mood="surprised"] .fg-brow-r { transform: translateY(-2.6px); }
.fig[data-mood="think"] .fg-brow-l { transform: translateY(-2.2px) rotate(-6deg); }
.fig[data-mood="think"] .fg-brow-r { transform: translateY(.6px) rotate(4deg); }
.fig:is([data-mood="happy"], [data-mood="cheer"]) .fg-brow-l,
.fig:is([data-mood="happy"], [data-mood="cheer"]) .fg-brow-r { transform: translateY(-1.2px); }

/* arms */
.fig[data-mood="happy"] .fg-arm-l { transform: rotate(22deg); }
.fig[data-mood="happy"] .fg-arm-r { transform: rotate(-22deg); }
.fig[data-mood="cheer"] .fg-arm-l { transform: rotate(80deg); animation: fg-wave-l .48s ease-in-out infinite alternate; }
.fig[data-mood="cheer"] .fg-arm-r { transform: rotate(-80deg); animation: fg-wave-r .48s ease-in-out infinite alternate; }
.fig[data-mood="surprised"] .fg-arm-l { transform: rotate(46deg); }
.fig[data-mood="surprised"] .fg-arm-r { transform: rotate(-46deg); }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-arm-l { transform: rotate(-12deg); }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-arm-r { transform: rotate(12deg); }
.fig[data-mood="think"] .fg-arm-r { opacity: 0; }
.fig[data-mood="think"] .fg-hand-scratch { opacity: 1; animation: fg-scratch .42s ease-in-out infinite alternate; }
@keyframes fg-wave-l { from { transform: rotate(68deg); } to { transform: rotate(92deg); } }
@keyframes fg-wave-r { from { transform: rotate(-68deg); } to { transform: rotate(-92deg); } }
@keyframes fg-scratch { from { transform: rotate(-6deg); } to { transform: rotate(7deg); } }

/* thinking dots, tear, sigh puff (static poses are visible; animation adds the motion) */
.fig[data-mood="think"] .fg-dot { opacity: 1; animation: fg-dot 1.5s ease-in-out infinite; }
.fig[data-mood="think"] .fg-dot:nth-child(2) { animation-delay: .22s; }
.fig[data-mood="think"] .fg-dot:nth-child(3) { animation-delay: .44s; }
@keyframes fg-dot { 0%, 64%, 100% { transform: translateY(0) scale(1); opacity: .5; } 30% { transform: translateY(-2.6px) scale(1.12); opacity: 1; } }
.fig[data-mood="sad"] .fg-tear { opacity: 1; animation: fg-tear 2.6s ease-in infinite; }
@keyframes fg-tear {
  0% { transform: translateY(-2px) scale(.5); opacity: 0; }
  18% { transform: translateY(0) scale(1); opacity: 1; }
  72% { transform: translateY(5px) scale(1); opacity: 1; }
  100% { transform: translateY(8px) scale(.9); opacity: 0; }
}
.fig[data-mood="sigh"] .fg-sigh { opacity: .95; transform: translate(20px, -6px); animation: fg-puff 4.4s ease-out infinite; }
@keyframes fg-puff {
  0%, 30% { transform: translate(0, 0) scale(.3); opacity: 0; }
  38% { transform: translate(6px, -1px) scale(.7); opacity: .95; }
  72% { transform: translate(20px, -6px) scale(1); opacity: .8; }
  90%, 100% { transform: translate(27px, -11px) scale(1.15); opacity: 0; }
}

/* ───────── body motion per mood ───────── */
@keyframes fg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.8px); } }
@keyframes fg-bob-sh { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.95); opacity: .85; } }
.fig:is([data-mood="idle"], :not([data-mood])) .fg-rig { animation: fg-bob 3.6s ease-in-out infinite; }
.fig:is([data-mood="idle"], :not([data-mood])) .fg-shadow { animation: fg-bob-sh 3.6s ease-in-out infinite; }
.fig-basalt:is([data-mood="idle"], :not([data-mood])) :is(.fg-rig, .fg-shadow) { animation-duration: 5.2s; }
.fig-pebble:is([data-mood="idle"], :not([data-mood])) :is(.fg-rig, .fg-shadow) { animation-duration: 2.8s; }

@keyframes fg-happy {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  28% { transform: translateY(0) scale(1.03, .97); }
  55% { transform: translateY(-3.5px) scale(.99, 1.02); }
  80% { transform: translateY(0) scale(1.01, .99); }
}
.fig[data-mood="happy"] .fg-rig { animation: fg-happy 1.1s ease-in-out infinite; }

@keyframes fg-jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  14% { transform: translateY(0) scale(1.07, .9); }
  34% { transform: translateY(-13px) scale(.95, 1.06); }
  52% { transform: translateY(-14px) scale(1, 1); }
  72% { transform: translateY(0) scale(1.06, .92); }
  86% { transform: translateY(0) scale(.98, 1.02); }
}
@keyframes fg-jump-sh { 0%, 14%, 72%, 100% { transform: scale(1); opacity: 1; } 34%, 52% { transform: scale(.68); opacity: .45; } }
.fig[data-mood="cheer"] .fg-rig { animation: fg-jump .95s cubic-bezier(.3, 0, .4, 1) infinite; }
.fig[data-mood="cheer"] .fg-shadow { animation: fg-jump-sh .95s cubic-bezier(.3, 0, .4, 1) infinite; }

@keyframes fg-ponder { 0%, 100% { transform: rotate(-1.6deg); } 50% { transform: rotate(1.6deg); } }
.fig[data-mood="think"] .fg-rig { animation: fg-ponder 3.2s ease-in-out infinite; }

@keyframes fg-sad { 0%, 100% { transform: translateY(1.5px) scale(1.02, .97); } 50% { transform: translateY(2.2px) scale(1.03, .96); } }
.fig[data-mood="sad"] .fg-rig { transform: translateY(1.5px) scale(1.02, .97); animation: fg-sad 4s ease-in-out infinite; }

@keyframes fg-sigh {
  0%, 100% { transform: translateY(2.4px) scale(1.03, .95); }
  18% { transform: translateY(-1.2px) scale(.99, 1.035); }
  44% { transform: translateY(2.4px) scale(1.03, .95); }
}
.fig[data-mood="sigh"] .fg-rig { transform: translateY(2.4px) scale(1.03, .95); animation: fg-sigh 4.4s ease-in-out infinite; }

@keyframes fg-hop {
  0% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-6px) scale(.97, 1.04); }
  62% { transform: translateY(0) scale(1.03, .97); }
  100% { transform: translateY(0) scale(1, 1); }
}
.fig[data-mood="surprised"] .fg-rig { animation: fg-hop .45s ease-out 1; }

/* little living details */
@keyframes fg-sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.fig .fg-leaf { animation: fg-sway 3.4s ease-in-out infinite; }
.fig[data-mood="cheer"] .fg-leaf { animation-duration: .95s; }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-tuft { animation: none; transform: rotate(14deg); }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-sprout { animation: none; transform: rotate(16deg); }

@keyframes fg-glow { 0%, 100% { opacity: .5; } 50% { opacity: .95; } }
@keyframes fg-glow-dim { 0%, 100% { opacity: .15; } 50% { opacity: .35; } }
.fig .fg-glow { animation: fg-glow 2.6s ease-in-out infinite; }
.fig .fg-crack { animation: fg-glow 2.6s ease-in-out -1.3s infinite; }
.fig:is([data-mood="sad"], [data-mood="sigh"]) :is(.fg-glow, .fg-crack) { animation-name: fg-glow-dim; animation-duration: 4.4s; }
.fig:is([data-mood="happy"], [data-mood="cheer"], [data-mood="surprised"]) .fg-glow { animation-duration: 1.2s; }

@keyframes fg-spark {
  0% { transform: translateY(4px) scale(.4); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-12px) scale(.9); opacity: 0; }
}
.fig .fg-spark { opacity: 0; animation: fg-spark 3s ease-out infinite; }
.fig .fg-spark:nth-child(2) { animation-delay: 1.1s; }
.fig .fg-spark:nth-child(3) { animation-delay: 2s; }
.fig:is([data-mood="sad"], [data-mood="sigh"]) .fg-spark { animation-play-state: paused; opacity: 0; }

@keyframes fg-glint { 0%, 84%, 100% { opacity: .7; } 90% { opacity: 1; } 92% { opacity: .35; } }
.fig .fg-glint { animation: fg-glint 5s linear infinite; }

/* the active player's avatar breathes */
@keyframes fg-breathe { 0%, 100% { transform: scale(.97); } 50% { transform: scale(1.03); } }
.fig.breathing .fg-breath { animation: fg-breathe 3s ease-in-out infinite; }

/* ───────── reduced motion: static poses, simple fades ───────── */
@media (prefers-reduced-motion: reduce) {
  .fig, .fig *, .rx, .rx * { animation: none !important; transition-property: opacity !important; transition-duration: .12s !important; }
}
:root[data-motion="reduced"] .fig, :root[data-motion="reduced"] .fig *,
:root[data-motion="reduced"] .rx, :root[data-motion="reduced"] .rx * {
  animation: none !important; transition-property: opacity !important; transition-duration: .12s !important;
}
