:root {
  --felt-hi: #2f8a68;
  --felt: #1d6b52;
  --felt-lo: #12503c;
  --ink: #1f2a44;
  --ink-soft: #4a5672;
  --card: #fffdf7;
  --card-edge: #e6dccb;
  --sheet: #fffaf4;
  --gold: #f2c13c;
  --cw: 70px;
  --ch: 96px;
  --back: #2d2d38;
  --back-art: none; /* a card back from the Card table (table.js); none: the dealer's tux color, as always */
  --felt-pat: linear-gradient(transparent, transparent); /* the felt's woven pattern (table.js feltVars) */
  --felt-pat-size: 8px 8px;
  --move-ms: 260ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background:
    var(--felt-pat) 0 0 / var(--felt-pat-size) repeat,
    radial-gradient(ellipse 90% 60% at 50% 30%, var(--felt-hi), transparent 70%),
    radial-gradient(circle at 50% 50%, var(--felt) 40%, var(--felt-lo) 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; }

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sg-corner-top) - 4px) 12px calc(var(--safe-bottom) + 12px);
  max-width: 560px;
  margin: 0 auto;
}

/* Header */
.top {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 52px;
}
.top h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn svg, .ctl svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn svg { stroke: #fff; }
.icon-btn:focus-visible, .ctl:focus-visible, .primary:focus-visible, .secondary:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* The dealer, the moves counter and what the dealer says */
.dealer-row {
  display: grid;
  grid-template-columns: 84px auto 1fr;
  align-items: end;
  gap: 8px;
  height: 96px;
  margin-bottom: 6px;
}
.moves {
  align-self: center;
  display: grid;
  justify-items: center;
  padding: 6px 4px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  line-height: 1;
}
.moves b { font-size: 30px; font-weight: 800; }
.moves span { font-size: 13px; font-weight: 700; opacity: 0.9; margin-top: 2px; }
.moves .goal { font-size: 12px; font-weight: 700; color: var(--gold); margin-top: 4px; white-space: nowrap; }
.moves.low { background: #c2410c; animation: pulse 1s ease-in-out infinite alternate; }
.moves.out { background: #9f1239; }
@keyframes pulse { to { transform: scale(1.06); } }
/* Hearts (logic.js HEARTS): full ones red, lost ones an empty outline; a lost one breaks in two. */
.moves .hearts { display: flex; gap: 2px; margin-top: 4px; }
.heart { display: block; width: 16px; height: 16px; overflow: visible; }
.heart path { fill: #ff4d6d; stroke: #fff; stroke-width: 1.3; stroke-linejoin: round; transform-origin: 12px 21px; }
.heart.gone path { fill: rgba(255, 255, 255, 0.14); stroke: rgba(255, 255, 255, 0.5); }
.heart .h-l, .heart .h-r, .heart.break .h-w { display: none; }
.heart.break .h-l, .heart.break .h-r { display: inline; }
.heart.break { animation: heart-pop 0.6s ease-out; }
.heart.break .h-l { animation: heart-l 0.6s ease-in forwards; }
.heart.break .h-r { animation: heart-r 0.6s ease-in forwards; }
@keyframes heart-pop { 0% { transform: scale(1); } 25% { transform: scale(1.45); } 100% { transform: scale(1); } }
@keyframes heart-l { 0%, 25% { transform: none; opacity: 1; } 100% { transform: translate(-5px, 7px) rotate(-40deg); opacity: 0; } }
@keyframes heart-r { 0%, 25% { transform: none; opacity: 1; } 100% { transform: translate(5px, 7px) rotate(40deg); opacity: 0; } }
.moves.hurt { animation: hurt 0.4s; }
@keyframes hurt { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.dealer {
  width: 86px;
  height: 96px;
  transform-origin: 50% 100%;
}
.dealer svg { display: block; width: 86px; height: 96px; }
.dealer.dealing svg { animation: deal-bob 0.32s ease-in-out infinite alternate; }
.dealer.dealing .dl-paw-r { animation: deal-paw 0.32s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 50%; }
.dealer.cheer svg { animation: cheer 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
.dealer.cheer .dl-hat { animation: hat-tip 0.8s ease-in-out; transform-box: fill-box; transform-origin: 30% 100%; }
.dealer.party svg { animation: party 0.5s ease-in-out 3 alternate; }
.dealer.sad svg { transform: rotate(-4deg) translateY(4px); transition: transform 0.4s; }
.dl-smoke { animation: smoke 2.4s ease-in-out infinite; }
@keyframes deal-bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes deal-paw { from { transform: translate(0, 0); } to { transform: translate(-6px, -8px); } }
@keyframes cheer { 0% { transform: none; } 40% { transform: translateY(-12px) rotate(-3deg); } 100% { transform: none; } }
@keyframes hat-tip { 0%, 100% { transform: none; } 40%, 60% { transform: translateY(-14px) rotate(-14deg); } }
@keyframes party { from { transform: rotate(-6deg) translateY(0); } to { transform: rotate(6deg) translateY(-10px); } }
@keyframes smoke { 0%, 100% { opacity: 0.25; transform: translateY(2px); } 50% { opacity: 0.75; transform: translateY(-3px); } }

.bubble {
  position: relative;
  align-self: center;
  margin: 0;
  padding: 8px 12px;
  border-radius: 16px;
  background: #fffaf0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.5);
  min-height: 0;
  max-height: 88px;
  overflow: hidden;
}
.bubble:empty { visibility: hidden; }
.bubble::before {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 18px;
  border: 8px solid transparent;
  border-right-color: #fffaf0;
  border-left: 0;
}
.bubble.say { animation: say 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes say { from { transform: scale(0.85); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* The table */
.table {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: none;
}
.layer { position: absolute; inset: 0; }
#cards { z-index: 2; }

.spot {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.13);
  border: 2px dashed rgba(255, 255, 255, 0.3);
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: calc(var(--cw) * 0.15);
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
}
.spot.col { border-style: solid; border-color: rgba(0, 0, 0, 0.12); background: rgba(0, 0, 0, 0.06); color: transparent; }
.spot.slot { background: rgba(0, 0, 0, 0.12); }
.spot.stock { border-style: solid; background: rgba(0, 0, 0, 0.12); cursor: pointer; }
.spot.stock svg { width: 46%; height: 46%; fill: none; stroke: rgba(255, 255, 255, 0.7); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.spot.waste { border-color: rgba(255, 255, 255, 0.16); }
.spot.target { border-color: #fff; border-style: solid; background: rgba(255, 255, 255, 0.18); }

.badge {
  position: absolute;
  z-index: 3;
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.badge.bump { animation: bump 0.35s cubic-bezier(0.3, 1.8, 0.5, 1); }
@keyframes bump { from { transform: scale(1.5); } to { transform: none; } }

/* Cards */
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.13);
  transition: transform var(--move-ms) cubic-bezier(0.3, 0.75, 0.35, 1), opacity 0.3s;
  will-change: transform;
  cursor: pointer;
  -webkit-touch-callout: none;
}
.card.dragging, .card.instant { transition: none; }
.card.gone { opacity: 0; pointer-events: none; }
.card .face, .card .back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
}
.card .face {
  background: var(--card);
  border: 1px solid var(--card-edge);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 2px 5px -1px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--ch) * 0.06) 3px 0;
  overflow: hidden;
}
.card .word {
  font-weight: 800;
  font-size: var(--fs, 15px);
  line-height: 1.15;
  white-space: nowrap;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.card .paw {
  margin-top: auto;
  margin-bottom: calc(var(--ch) * 0.1);
  width: 42%;
  aspect-ratio: 1;
  opacity: 0.13;
  fill: var(--ink);
}
.card.cat .face {
  background: var(--cc, #2f6fd6);
  border-color: rgba(0, 0, 0, 0.15);
  color: #fff;
  padding-left: 4px;
  padding-right: 4px;
}
.card.cat .word {
  color: #fff;
  white-space: normal;
  text-align: center;
  font-size: var(--fs, 13px);
  line-height: 1.05;
}
.card.cat .count {
  margin-top: auto;
  margin-bottom: calc(var(--ch) * 0.1);
  font-size: calc(var(--cw) * 0.17);
  font-weight: 800;
  opacity: 0.9;
}
.card .back {
  background:
    var(--back-art) center / cover no-repeat,
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.16) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 4px, transparent 4px 9px),
    var(--back);
  border: 3px solid #f6efe0;
  box-shadow: 0 2px 5px -1px rgba(0, 0, 0, 0.4);
  display: none;
}
.card.down .back { display: block; }
.card.down .face { display: none; }
.card.hint .face, .card.lift .face { box-shadow: 0 0 0 3px #fff, 0 0 16px 4px rgba(255, 230, 140, 0.9); }
.card.shake { animation: shake 0.32s; }
@keyframes shake {
  0%, 100% { translate: 0 0; }
  25% { translate: -5px 0; }
  75% { translate: 5px 0; }
}
.card.flip .face { animation: flip 0.34s cubic-bezier(0.3, 0.7, 0.4, 1); }
/* turning over: the card swings round on its long edge, past flat, and settles */
@keyframes flip {
  from { transform: perspective(500px) rotateY(-90deg); filter: brightness(0.8); }
  65% { transform: perspective(500px) rotateY(10deg); filter: brightness(1.06); }
  to { transform: none; filter: none; }
}

.ctl {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 4;
  width: 76px;
  min-height: 60px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 252, 248, 0.92);
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.ctl:active:not(:disabled) { transform: scale(0.95); }
.ctl:disabled { opacity: 0.45; cursor: default; }

.toast {
  position: fixed;
  left: 50%;
  top: 44%;
  transform: translate(-50%, 12px);
  width: max-content;
  max-width: calc(100vw - 48px);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(31, 42, 68, 0.95);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}

/* Dialogs */
.sheet {
  width: min(340px, calc(100vw - 32px));
  border: 0;
  border-radius: 26px;
  padding: 22px 22px 20px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.sheet::backdrop { background: rgba(10, 30, 24, 0.5); }
.sheet[open] { animation: sheet-in 0.28s cubic-bezier(0.3, 1.3, 0.5, 1); }
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.sheet h2 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.1; }
.sheet p { margin: 6px 0 16px; font-size: 17px; color: var(--ink-soft); }
.sheet .primary + .secondary { margin-top: 10px; }

.primary, .secondary {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.primary { border: 0; background: var(--felt); color: #fff; }
.secondary { border: 2px solid rgba(31, 42, 68, 0.18); background: transparent; color: var(--ink); }
.primary:focus-visible, .secondary:focus-visible { outline-color: var(--ink); }
.primary[hidden], .secondary[hidden] { display: none; } /* (the lose sheet's Undo, out of hearts) */

.win-dealer { display: grid; place-items: center; height: 120px; margin: -6px 0 2px; }
.win-dealer svg { width: 108px; height: 120px; }
.win-dealer.party svg { animation: party 0.5s ease-in-out 4 alternate; }
.win-stars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  height: 58px;
  margin-bottom: 8px;
}
.star {
  width: 42px;
  height: 42px;
  background: #d9dee8;
  clip-path: polygon(50% 0%, 61.8% 35%, 98% 35%, 68.5% 57%, 79.4% 91%, 50% 70%, 20.6% 91%, 31.5% 57%, 2% 35%, 38.2% 35%);
}
.star.big { width: 54px; height: 54px; margin-bottom: 4px; }
.star.earned.pop {
  background: linear-gradient(160deg, #ffe58a 0%, #f7c948 45%, #e09a1b 100%);
  animation: star-pop 0.42s cubic-bezier(0.3, 1.8, 0.5, 1) both;
}
@keyframes star-pop {
  from { transform: scale(0.2) rotate(-25deg); }
  to { transform: none; }
}
.win-ach {
  list-style: none;
  margin: -6px 0 14px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #fff3d6;
  text-align: left;
  font-size: 15px;
}
.win-ach li { display: flex; gap: 8px; align-items: baseline; }
.win-ach li + li { margin-top: 4px; }
.win-ach b { color: var(--ink); }
.win-ach .ach-star { color: #d98a12; font-weight: 800; }

/* Title screen: the shared layout (shared/mainmenu.js); these are only CATegories' colors. */
#mm {
  --sg-bg: var(--felt-pat) 0 0 / var(--felt-pat-size) repeat, radial-gradient(ellipse 90% 60% at 50% 30%, var(--felt-hi), transparent 70%), radial-gradient(circle at 50% 50%, var(--felt) 40%, var(--felt-lo) 100%);
  --sg-ink: #fff; --sg-ink-soft: rgba(255, 255, 255, 0.82);
  --sg-title: #fff; --sg-title-shadow: 0 3px 0 var(--felt-lo), 0 8px 14px rgba(0, 0, 0, 0.35);
  --sg-accent: var(--gold); --sg-accent-ink: #3a2a05;
  --sg-card: var(--sheet); --sg-card-ink: var(--ink); --sg-line: rgba(255, 255, 255, 0.4);
}
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--ink); --sg-accent: var(--felt); --sg-accent-ink: #fff; --sg-ink-soft: var(--ink-soft); }
.star-total {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px !important;
  font-weight: 700;
  color: var(--ink) !important;
}
.star-icon {
  width: 22px;
  height: 22px;
  background: linear-gradient(160deg, #ffe58a, #f7c948 45%, #e09a1b);
  clip-path: polygon(50% 0%, 61.8% 35%, 98% 35%, 68.5% 57%, 79.4% 91%, 50% 70%, 20.6% 91%, 31.5% 57%, 2% 35%, 38.2% 35%);
}
#ach-box > .note { font-size: 15px; margin: 0 0 8px; line-height: 1.35; color: var(--ink-soft); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

.menu-section { margin-top: 0; }
.level-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.level-btn {
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: #eef1f5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.level-btn small { font-size: 11px; letter-spacing: -1px; color: #d3a21f; }
.level-btn.done { background: #e2f3ea; }
.level-btn.here { outline: 3px solid var(--felt); outline-offset: -3px; }
.level-btn:disabled { opacity: 0.4; cursor: default; }
.level-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }

.ach-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.ach {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 14px;
  background: #f1f3f6;
}
.ach.earned { background: #fff1cc; }
.ach-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d7dce5;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}
.ach.earned .ach-icon { background: linear-gradient(160deg, #ffe58a, #f2b632 55%, #d98a12); }
.ach b { display: block; font-size: 16px; line-height: 1.15; }
.ach span { display: block; font-size: 14px; line-height: 1.25; color: var(--ink-soft); }
.ach .bar { height: 6px; margin-top: 5px; border-radius: 3px; background: #dde2ea; overflow: hidden; }
.ach .bar i { display: block; height: 100%; background: #3c9a6c; border-radius: 3px; }
.ach .prog { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.how { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.35; color: var(--ink-soft); }
.how li + li { margin-top: 4px; }

@media (max-height: 700px) {
  .dealer-row { height: 80px; grid-template-columns: 76px auto 1fr; }
  .dealer, .dealer svg { width: 72px; height: 80px; }
  .moves b { font-size: 26px; }
  .moves { padding: 4px; }
  .moves .goal { margin-top: 2px; }
  .moves .hearts { margin-top: 3px; }
  .heart { width: 13px; height: 13px; }
  .bubble { font-size: 14px; max-height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .ctl, .toast, .badge { transition: none; }
  .sheet[open], .star.earned.pop, .bubble.say, .badge.bump, .card.flip .face, .card.shake,
  .dealer svg, .dealer .dl-hat, .dealer .dl-paw-r, .dl-smoke, .moves.low, .win-dealer.party svg,
  .heart.break, .heart.break path, .moves.hurt { animation: none !important; }
}

/* iPhone: no double-tap zoom anywhere. touch-action isn't inherited, so it goes on every element
   (anything with its own touch-action keeps it). Text fields stay selectable. */
* { touch-action: manipulation; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* ---------- The title's hand of cards (the backs in the picked look) ---------- */
.fan { position: relative; width: 210px; height: 140px; --back: #2d2d38; }
.fan-card {
  position: absolute; left: 50%; bottom: 6px; width: 74px; height: 102px; margin-left: -37px; border-radius: 9px;
  transform-origin: 50% 165%; box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.55);
}
.fan-card:nth-child(1) { transform: translateX(-6px) rotate(-27deg); }
.fan-card:nth-child(2) { transform: translateX(-2px) rotate(-12deg); }
.fan-card:nth-child(3) { transform: rotate(3deg); }
.fan-card:nth-child(4) { transform: translateX(4px) rotate(18deg); }
.fc-back {
  background:
    var(--back-art) center / cover no-repeat,
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.16) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 4px, transparent 4px 9px),
    var(--back);
  border: 3px solid #f6efe0;
}
.fc-word, .fc-cat { display: flex; flex-direction: column; align-items: center; padding-top: 8px; border: 1px solid var(--card-edge); }
.fc-word { background: var(--card); }
.fc-word { align-items: flex-start; padding-left: 8px; }
.fc-word b { font: 800 15px/1.15 "Baloo 2", system-ui, sans-serif; color: var(--ink); }
.fc-word .paw { margin-top: auto; margin-bottom: 10px; width: 42%; aspect-ratio: 1; opacity: 0.13; fill: var(--ink); }
.fc-cat { background: #d64045; border-color: rgba(0, 0, 0, 0.15); color: #fff; }
.fc-cat b { font: 800 15px/1.1 "Baloo 2", system-ui, sans-serif; }
.fc-cat small { margin-top: auto; margin-bottom: 10px; font: 800 13px/1 "Baloo 2", system-ui, sans-serif; opacity: 0.9; }

/* ---------- What a win opened (the win sheet) ---------- */
.win-new {
  list-style: none; margin: -6px 0 12px; padding: 8px 10px; border-radius: 16px; background: #eaf4ee; text-align: left;
  font-size: 15px; line-height: 1.3; color: var(--ink-soft);
}
.win-new li { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.win-new li + li { margin-top: 6px; }
.win-new b { color: var(--ink); }
.wn-ico { flex: none; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; background: center / cover no-repeat; }
.wn-ico svg { display: block; width: 100%; height: 100%; }
.wn-stamp .wn-ico, .wn-gold .wn-ico { width: 40px; height: 32px; border-radius: 2px; border: 3px solid #fffdf8; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.wn-gold .wn-ico { border-color: #f4c44e; }
.wn-felt .wn-ico { border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }
.wn-back .wn-ico { width: 26px; height: 36px; border-radius: 4px; border: 2px solid #f6efe0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.wn-use {
  flex: none; margin-left: auto; min-width: 72px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px;
  background: var(--felt); color: #fff; font: 800 15px/1 "Baloo 2", system-ui, sans-serif; cursor: pointer;
}
.wn-use:disabled { background: #cfd8d2; color: var(--ink-soft); }

/* ---------- The Sorting Book ---------- */
.book, .tbl { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.book-head { display: flex; flex-direction: column; gap: 6px; }
.book-count { margin: 0; font: 700 16px/1.2 var(--sg-font); color: var(--ink-soft); }
.book-count b { color: var(--ink); font-weight: 800; }
.book-bar { position: relative; height: 10px; border-radius: 5px; background: #e6ddd0; overflow: hidden; }
.book-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: linear-gradient(90deg, #2f8a68, #3c9a6c); }
.book-bar i.gold { background: linear-gradient(90deg, #f4c44e, #e09a1b); }
.book-note { margin: 0; font: 600 15px/1.35 var(--sg-font); color: var(--ink-soft); }
.book-index { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ch-tile, .stamp, .book-back, .book-arrow, .tbl-tile {
  appearance: none; -webkit-appearance: none; font: inherit; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ch-tile {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 44px; padding: 6px 6px 7px;
  border: 0; border-radius: 14px; background: #f3eadb; box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgba(90, 60, 30, 0.12);
}
.ch-tile.full { background: #e4f1e8; }
.ch-tile.allgold { background: linear-gradient(160deg, #fff4c4, #f7d36a); }
.bt-pic { display: block; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1); }
.bt-pic svg { display: block; width: 100%; height: auto; }
.bt-pic .ghost, .st-pic .ghost { opacity: 0.2; } /* (no CSS filter: Safari ignores it on SVG parts) */
.bt-name { font: 800 13.5px/1.1 var(--sg-font); text-align: center; min-height: 2.2em; display: grid; place-items: center; }
.bt-sub { font: 700 13px/1 var(--sg-font); color: var(--ink-soft); text-align: center; }
.book-nav { display: flex; gap: 8px; align-items: center; }
.book-back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px 0 8px; margin-right: auto;
  border: 0; border-radius: 999px; background: #efe6d7; font: 800 16px/1 var(--sg-font);
}
.book-arrow { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #efe6d7; }
.book-back svg, .book-arrow svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.book-page {
  padding: 12px 10px 10px; border-radius: 16px;
  background: linear-gradient(90deg, rgba(120, 80, 40, 0.1), transparent 14px), #f2e6d2;
  box-shadow: inset 0 0 0 1px rgba(120, 80, 40, 0.15);
}
.book-page h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 10px; font: 800 20px/1.1 var(--sg-font); }
.book-page h3 small { font: 700 14px/1 var(--sg-font); color: var(--ink-soft); white-space: nowrap; }
.book-stamps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
/* A stamp: paper with perforated edges (a dotted border in the page's color reads as the holes), a picture, a name. */
.stamp {
  display: flex; flex-direction: column; gap: 3px; min-height: 44px; padding: 3px 3px 2px;
  border: 4px dotted #f2e6d2; border-radius: 2px; background: #fffdf8; box-shadow: 0 1px 0 4px rgba(120, 80, 40, 0.06);
}
.stamp:nth-child(3n + 1) { transform: rotate(-1.2deg); }
.stamp:nth-child(3n + 2) { transform: rotate(0.8deg); }
.stamp.sel { outline: 3px solid var(--felt); outline-offset: 1px; }
.st-pic { display: block; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18); }
.st-pic svg { display: block; width: 100%; height: auto; }
.st-name { display: grid; place-items: center; min-height: 2.25em; font: 800 13px/1.1 var(--sg-font); text-align: center; overflow-wrap: anywhere; }
.stamp.gold { background: linear-gradient(150deg, #fff6c8, #f4c44e 55%, #d99a2b); }
.stamp.gold .st-name { color: #4a3208; }
.stamp.blank { border: 2px dashed rgba(90, 60, 30, 0.28); background: rgba(255, 255, 255, 0.25); padding: 5px 5px 4px; box-shadow: none; }
.stamp.blank .st-pic { box-shadow: none; }
.stamp.blank .st-name { color: rgba(74, 86, 114, 0.6); }
.book-cap { min-height: 2.7em; margin: 10px 2px 0; font: 700 15px/1.35 var(--sg-font); color: var(--ink-soft); }

/* ---------- The card table sheet ---------- */
.tbl-preview {
  display: grid; place-items: center; height: 156px; border-radius: 18px; overflow: hidden;
  background:
    var(--felt-pat) 0 0 / var(--felt-pat-size) repeat,
    radial-gradient(ellipse 90% 70% at 50% 30%, var(--felt-hi), transparent 70%),
    radial-gradient(circle at 50% 50%, var(--felt) 40%, var(--felt-lo) 100%);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.12), inset 0 -10px 24px rgba(0, 0, 0, 0.25);
}
.tbl h3 { margin: 6px 0 0; font: 800 19px/1.1 var(--sg-font); }
.tbl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tbl-tile {
  display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 44px; padding: 8px 4px 7px;
  border: 0; border-radius: 14px; background: #f3eadb; box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgba(90, 60, 30, 0.12);
}
.tbl-tile[aria-pressed="true"] { background: #e4f1e8; box-shadow: inset 0 0 0 3px var(--felt); }
.tbl-tile.locked { cursor: default; }
.tbl-tile.locked .tt-pic { filter: grayscale(0.85); opacity: 0.4; }
.tt-name { font: 800 13px/1.1 var(--sg-font); text-align: center; min-height: 2.2em; display: grid; place-items: center; }
.tbl-tile.locked .tt-name { color: var(--ink-soft); }
.tbl-felt .tt-pic { width: 48px; height: 48px; border-radius: 50%; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 2px 5px rgba(0, 0, 0, 0.3); }
.tbl-back .tt-pic {
  width: 38px; height: 54px; border-radius: 5px; border: 2px solid #f6efe0; background: center / cover no-repeat;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}
.tbl-back .tt-pic.tt-dealer {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.16) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 4px, transparent 4px 9px),
    var(--back);
}
@media (max-width: 370px) {
  .tbl-grid { gap: 6px; }
  .book-stamps { gap: 9px 6px; }
}
