/* Meowdoku — phone first. Everything is sized off the viewport so the board
   and the toolbar both fit without scrolling on a handset. */

:root {
  color-scheme: light;

  --bg: #fff6ec;
  --bg-tint-a: #ffd9e8;
  --bg-tint-b: #d6ecff;
  --bg-tint-c: #fff0c2;
  --bg-2: #ffffff;
  --ink: #3b2f4d;
  --ink-soft: #7a6b8c;
  --line: #f0dcc8;
  --accent: #ff5fa2;
  --accent-2: #7c4dff;
  --accent-ink: #ffffff;
  --danger: #ef4b6b;
  --wrong-bg: #ffe0e6;
  --wrong-ink: #e8214e;
  --grid-line: rgba(36, 31, 43, .16);
  --region-edge: #3c3050;
  --cell-ink: #3b2f4d;
  --sunny: #ffb52e;

  /* Region colours — sweet-shop bright, but still light enough that a cat with
     a dark outline reads cleanly on top. The thick region outlines carry the
     real information; colour is the fast lookup. */
  --r0: #ffb3a7;
  --r1: #9fd0ff;
  --r2: #b6e88a;
  --r3: #ffdf7e;
  --r4: #d3b6ff;
  --r5: #ffaedd;
  --r6: #86e6d4;
  --r7: #f6cf9c;
  --r8: #c3cdf7;
  --r9: #ff9fc0;
  --r10: #d6c39b;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e1730;
  --bg-tint-a: #4a2350;
  --bg-tint-b: #1d3a5c;
  --bg-tint-c: #4a3a1c;
  --bg-2: #2b2340;
  --ink: #f7eefc;
  --ink-soft: #b4a6c8;
  --line: #453763;
  --accent: #ff77b3;
  --accent-2: #b79bff;
  --accent-ink: #24143a;
  --danger: #ff6b88;
  --wrong-bg: #5a1f33;
  --wrong-ink: #ff7d9c;
  --grid-line: rgba(0, 0, 0, .35);
  --region-edge: #150f22;
  --cell-ink: #2a2038;
  --sunny: #ffc857;

  /* Deeper but still candied — the cats keep their pale outline, so they
  stay legible without washing the board out. */
  --r0: #d9705f;
  --r1: #5d8ecb;
  --r2: #74a95c;
  --r3: #cba14a;
  --r4: #9575d1;
  --r5: #cc6ba5;
  --r6: #4fa898;
  --r7: #b08a5c;
  --r8: #7c88b8;
  --r9: #c96b95;
  --r10: #99805f;
}

/* Moonsweeper. The same board in a colder sky: page tints go nebula rather than
   sweet shop, and the accents pull violet and cyan.
   These blocks have to restate every variable rather than patch a few, because
   [data-skin] and [data-theme] have equal specificity — whichever is written
   last would otherwise win outright. The dark one carries an extra attribute
   so it beats the light one regardless of order. */
:root[data-skin="moonsweeper"] {
  color-scheme: light;

  --bg: #eef2ff;
  --bg-tint-a: #dcd9ff;
  --bg-tint-b: #cfe8ff;
  --bg-tint-c: #f0dcff;
  --bg-2: #ffffff;
  --ink: #241a3d;
  --ink-soft: #6b6288;
  --line: #d8dbf0;
  --accent: #6c5ce7;
  --accent-2: #00b4d8;
  --accent-ink: #ffffff;
  --danger: #ef4b6b;
  --wrong-bg: #ffe0e6;
  --wrong-ink: #e8214e;
  --grid-line: rgba(36, 26, 61, .16);
  --region-edge: #241a3d;
  --cell-ink: #241a3d;
  --sunny: #ffb52e;

  /* Pale enough that a saturated planet with a dark outline still reads on
     top, and far enough apart to tell at a glance. */
  --r0: #ffb8a3;
  --r1: #a8d3ff;
  --r2: #b4e6b0;
  --r3: #ffe08a;
  --r4: #cbbaff;
  --r5: #ffb0d8;
  --r6: #93e6de;
  --r7: #e8cfa8;
  --r8: #b9c6f5;
  --r9: #f0a9c8;
  --r10: #cfc2a4;
}

:root[data-skin="moonsweeper"][data-theme="dark"] {
  color-scheme: dark;

  --bg: #120e22;
  --bg-tint-a: #2a1c52;
  --bg-tint-b: #10304f;
  --bg-tint-c: #3a1f45;
  --bg-2: #1d1836;
  --ink: #eae6ff;
  --ink-soft: #a49dc4;
  --line: #352f57;
  --accent: #8b7dff;
  --accent-2: #38d0e8;
  --accent-ink: #120e22;
  --danger: #ff6b88;
  --wrong-bg: #4d1730;
  --wrong-ink: #ff7d9c;
  --grid-line: rgba(0, 0, 0, .4);
  --region-edge: #0a0716;
  --cell-ink: #241a3d;
  --sunny: #ffc857;

  --r0: #b8543f;
  --r1: #3f6fa8;
  --r2: #4d8a5a;
  --r3: #a8813a;
  --r4: #6f56b8;
  --r5: #a4507f;
  --r6: #2f8a86;
  --r7: #8a6b45;
  --r8: #5a68a0;
  --r9: #a35577;
  --r10: #7a6a4d;
}

* { box-sizing: border-box; }

/* Several elements here set display:grid/flex, which otherwise beats the
   [hidden] attribute and leaves an invisible layer eating taps. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* Soft pools of colour behind everything, so the page never reads as a grey
   form. Fixed and non-interactive, so it can't affect the board's layout. */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(38vw 38vw at 12% 8%, var(--bg-tint-a), transparent 65%),
    radial-gradient(42vw 42vw at 88% 22%, var(--bg-tint-b), transparent 62%),
    radial-gradient(46vw 46vw at 50% 96%, var(--bg-tint-c), transparent 60%);
  opacity: .75;
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(2%, -2%, 0) scale(1.08); }
}

/* Paw prints, or stars, wandering slowly up the page. */
.drift {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.drift span {
  position: absolute;
  bottom: -8vh;
  font-size: 1.4rem;
  opacity: .16;
  animation: wander linear infinite;
}

@keyframes wander {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(-118vh) rotate(320deg); }
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.topbar {
  width: 100%;
  max-width: 560px;
  padding: 10px 14px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); flex: none; }

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -.02em;
  font-weight: 900;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-mark { animation: bob 3.4s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes bob {
  0%, 100% { transform: rotate(-7deg) translateY(0); }
  50% { transform: rotate(7deg) translateY(-2px); }
}

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: .95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- mode tabs ---------- */

.modes {
  width: 100%;
  max-width: 560px;
  padding: 4px 14px 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.mode {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 4px;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.mode.active {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 4px 0 0 color-mix(in srgb, var(--accent-2) 55%, #000);
  transform: translateY(-1px);
}

.mode:active { transform: translateY(1px); }

main {
  width: 100%;
  max-width: 560px;
  padding: 0 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 1;
}

/* ---------- status line ---------- */

.status {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
}

.status-label { font-weight: 700; margin-right: auto; }

.status-chip {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--ink-soft);
  font-weight: 600;
}

.mono { font-variant-numeric: tabular-nums; }

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

/* ---------- score row ---------- */

.score-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.score {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(100deg, var(--sunny), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.score.bump { animation: score-bump .34s cubic-bezier(.34, 1.7, .5, 1); }
@keyframes score-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

.combo {
  font-weight: 900;
  font-size: .95rem;
  padding: 3px 12px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(120deg, #ff7a18, #ff2d78);
  box-shadow: 0 0 0 0 rgba(255, 45, 120, .6);
  animation: combo-pop .4s cubic-bezier(.34, 1.7, .5, 1), combo-glow 1.4s ease-out infinite;
}

@keyframes combo-pop {
  0% { transform: scale(.4) rotate(-12deg); }
  60% { transform: scale(1.22) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes combo-glow {
  from { box-shadow: 0 0 0 0 rgba(255, 45, 120, .55); }
  to { box-shadow: 0 0 0 12px rgba(255, 45, 120, 0); }
}

.board-wrap { position: relative; width: 100%; display: flex; justify-content: center; }

/* Effects layer. Sits over the board, ignores pointers, and is outside the
   board's overflow clip so a payout can float up past the top row. */
.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

.pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 1.15rem;
  color: #fff;
  text-shadow: 0 2px 0 #c2410c, 0 0 12px rgba(255, 180, 60, .9);
  animation: pop-up .95s cubic-bezier(.2, .8, .3, 1) forwards;
  white-space: nowrap;
}

@keyframes pop-up {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.5); }
  22% { opacity: 1; transform: translate(-50%, -75%) scale(1.25); }
  40% { transform: translate(-50%, -85%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.ring {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid var(--sunny);
  animation: ring-out .6s ease-out forwards;
}

@keyframes ring-out {
  from { width: 10%; height: 10%; opacity: .9; }
  to { width: 190%; height: 190%; opacity: 0; }
}

.board {
  position: relative; /* anchors the jackpot sweep */
  width: min(100%, 62dvh, 460px);
  aspect-ratio: 1;
  display: grid;
  /* The 1px gap, showing the board's own dark background, is the thin grid. */
  gap: 1px;
  background: var(--region-edge);
  border: 4px solid var(--region-edge);
  border-radius: 20px;
  box-shadow: 0 10px 0 0 color-mix(in srgb, var(--region-edge) 70%, transparent),
              0 18px 34px rgba(60, 20, 80, .18);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  /* Without this, a long press on iOS raises the selection callout instead of
     placing a cat. */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.cell {
  position: relative;
  /* Region outlines are borders rather than box-shadows so that a cell on two
     boundaries at once draws both, instead of the second rule replacing the
     first. Both neighbours draw their own half, so a boundary reads as one
     solid line. */
  border: 0 solid var(--region-edge);
  padding: 0;
  margin: 0;
  background: var(--cellbg);
  color: var(--cell-ink);
  display: block;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}

/* The reels landing. Each column drops in a beat after the one before it, so a
   new board arrives like a slot machine settling rather than just appearing. */
/* No input while the reels are still moving: the cells are visually displaced
   mid-drop, so a tap would land on a square the player did not aim at — and
   could cost them a life for it. */
.board.spin { pointer-events: none; }

.board.spin .cell {
  animation: reel-drop .46s cubic-bezier(.22, .9, .3, 1.5) backwards;
  animation-delay: calc(var(--col, 0) * 55ms);
}

@keyframes reel-drop {
  from { opacity: 0; transform: translateY(-165%); }
  70% { opacity: 1; }
  to { opacity: 1; transform: translateY(0); }
}

/* One cat from home — the board holds its breath. */
.board.anticipation {
  animation: anticipate 1s ease-in-out infinite;
}

@keyframes anticipate {
  0%, 100% { box-shadow: 0 10px 0 0 color-mix(in srgb, var(--region-edge) 70%, transparent), 0 0 0 0 rgba(255, 181, 46, .0); }
  50% { box-shadow: 0 10px 0 0 color-mix(in srgb, var(--region-edge) 70%, transparent), 0 0 34px 6px rgba(255, 181, 46, .65); }
}

/* Jackpot: a band of light sweeps the board on a win. */
.board.jackpot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .85) 50%, transparent 65%);
  background-size: 300% 100%;
  animation: sweep .85s ease-out 2;
}

@keyframes sweep {
  from { background-position: 160% 0; }
  to { background-position: -60% 0; }
}

.cell.et { border-top-width: 2px; }
.cell.er { border-right-width: 2px; }
.cell.eb { border-bottom-width: 2px; }
.cell.el { border-left-width: 2px; }

/* Cell contents are positioned out of flow. If they took part in layout, the
   grid tracks would resize the instant a token or mark appeared and the whole
   board would jump under the player's finger. */
.cell svg {
  position: absolute;
  display: block;
  left: 13%;
  top: 13%;
  width: 74%;
  height: 74%;
}

.cell .mark {
  left: 28%;
  top: 28%;
  width: 44%;
  height: 44%;
  opacity: .5;
}

.cell .mark.auto { opacity: .22; }

.cell.token-cell svg { animation: pounce .42s cubic-bezier(.34, 1.7, .5, 1); }
@keyframes pounce {
  0% { transform: scale(.2) rotate(-16deg); }
  55% { transform: scale(1.14) rotate(6deg); }
  75% { transform: scale(.96) rotate(-3deg); }
  100% { transform: scale(1) rotate(0); }
}

/* They blink on their own schedule, which is most of what makes them read as
   alive rather than as counters. Kept to the eyes: swaying a whole boardful on
   a logic puzzle is distracting rather than charming. */
.token .eyes {
  transform-origin: center 17px;
  animation: blink 7s var(--blink-delay, 0s) infinite;
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%, 97% { transform: scaleY(.12); }
}
.cell[data-want="mark"] .mark { animation: plop .26s cubic-bezier(.34, 1.7, .5, 1); }
@keyframes plop {
  from { transform: scale(.3) rotate(-20deg); }
  to { transform: scale(1) rotate(0); }
}

/* "Moonsweeper" is half again as long as "Meowdoku", and at 1.5rem it pushes
   the last icon button off a narrow handset. Scoped to the skin so the cat
   header stays pixel-identical to what is already live. */
:root[data-skin="moonsweeper"] .topbar h1 { font-size: clamp(1.05rem, 4.6vw, 1.5rem); }
:root[data-skin="moonsweeper"] .brand { min-width: 0; }

/* Planets carry a ring and sometimes a moon, so their artwork sits further
   inside its own viewBox than a cat's does. A few percent back makes the two
   skins read at the same weight on the board. */
:root[data-skin="moonsweeper"] .cell .token { left: 10%; top: 10%; width: 80%; height: 80%; }

/* The squish under a finger. Transform only, so nothing re-flows. */
.cell:active { transform: scale(.93); }

.cell.conflict { background: var(--danger); }
.cell.conflict svg { color: #fff; animation: shake .3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-9%); }
  75% { transform: translateX(9%); }
}

/* A wrong square: it never actually lands, it just gets crossed out. The X is
   deliberately near cell-sized — you should not be able to miss having lost a
   life. */
.cell.wrong { background: var(--wrong-bg); }
.cell.wrong .token { opacity: .35; }

.cell .bigx {
  left: 3%;
  top: 3%;
  width: 94%;
  height: 94%;
  color: var(--wrong-ink);
  animation: stamp .32s cubic-bezier(.3, 1.6, .5, 1);
}

@keyframes stamp {
  0% { transform: scale(2.1) rotate(-16deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Lives, as three paws that get crossed off. */
.lives { display: inline-flex; gap: 4px; align-items: center; padding: 3px 8px; }
.lives i { font-style: normal; font-size: .8rem; line-height: 1; }
.lives i.lost { color: var(--danger); font-weight: 800; }

.fail-mark {
  width: 62px;
  height: 62px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--wrong-bg);
  color: var(--wrong-ink);
  display: grid;
  place-items: center;
  animation: stamp .35s cubic-bezier(.3, 1.6, .5, 1);
}

.fail-mark svg { width: 60%; height: 60%; }

/* Hint highlighting: focus squares are the evidence, target squares are the
   move being suggested. */
.cell.focus::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 6px;
  background: rgba(124, 77, 255, .3);
  animation: glow 1.2s ease-in-out infinite alternate;
}
.cell.target::after {
  content: "";
  position: absolute;
  inset: 6%;
  border-radius: 6px;
  border: 3px dashed var(--accent);
  animation: glow 1.2s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .35; } to { opacity: 1; } }

.cell.revealed svg { opacity: .85; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-radius: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------- hint bar ---------- */

.hintbar {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise .18s ease-out;
}

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hint-text { font-size: .88rem; line-height: 1.35; }
.hint-text strong { display: block; margin-bottom: 2px; }
.hint-text span { color: var(--ink-soft); }
.hint-actions { display: flex; gap: 8px; justify-content: flex-end; }

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

.toolbar {
  width: 100%;
  display: flex;
  gap: 8px;
}

.toolbar-secondary { align-items: center; }

/* Chunky, slightly cartoonish buttons: a solid drop edge that squashes when
   pressed, rather than a flat rectangle. */
.btn {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 16px;
  padding: 12px 6px;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 48px;
  box-shadow: 0 4px 0 0 var(--line);
  transition: transform .08s ease, box-shadow .08s ease;
}

.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 0 var(--line); }

.btn-primary {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 4px 0 0 color-mix(in srgb, var(--accent-2) 55%, #000);
}

.btn-primary:active:not(:disabled) { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 55%, #000); }

#btn-hint:not(:disabled) span, .hint-bulb { display: inline-block; animation: wiggle 2.6s ease-in-out infinite; }
@keyframes wiggle {
  0%, 88%, 100% { transform: rotate(0); }
  92% { transform: rotate(-16deg) scale(1.15); }
  96% { transform: rotate(16deg) scale(1.15); }
}
.btn-small { flex: 0 0 auto; padding: 8px 14px; min-height: 0; font-size: .85rem; }
.btn-wide { width: 100%; }
.btn-ghost {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-weight: 700;
  box-shadow: none;
}

.btn-ghost:active:not(:disabled) { box-shadow: none; transform: translateY(2px); }

.toolbar-options { margin-top: -2px; }

/* ---------- share sheet ---------- */

.code-box {
  margin: 0 0 14px;
  padding: 14px 10px;
  border-radius: 16px;
  background: linear-gradient(150deg, #2b1f3d, #4a2a5e);
  border: 3px dashed var(--sunny);
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: .16em;
  color: #ffe9a8;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase;
  word-break: break-all;
}

.code-entry { margin: 4px 0 10px; text-align: left; }

.code-entry label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.code-entry-row { display: flex; gap: 8px; }

.code-entry-row input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
  font-size: .9rem;
  background: var(--bg);
  color: var(--ink);
}

.code-entry-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-entry-row .btn { flex: 0 0 auto; padding: 10px 18px; min-height: 0; }

.code-error {
  display: block;
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--danger);
}

.switch {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  color: var(--ink-soft);
  font-weight: 600;
  justify-content: flex-end;
}

.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 17, .55);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.overlay[hidden] { display: none; }

.sheet {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-2);
  border-radius: 28px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  animation: bounce-in .42s cubic-bezier(.34, 1.65, .5, 1);
  overflow: hidden;
}

@keyframes bounce-in {
  0% { opacity: 0; transform: scale(.72) translateY(24px); }
  60% { opacity: 1; transform: scale(1.04) translateY(-4px); }
  100% { transform: scale(1) translateY(0); }
}

.sheet h2 {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 900;
}

.party-token {
  width: 108px;
  height: 84px;
  display: block;
  margin: 0 auto 4px;
  animation: hop 1.4s ease-in-out infinite;
}

@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-9px) rotate(2deg); }
}

.wave-hand { transform-origin: 30px 22px; animation: wave .7s ease-in-out infinite; }
/* The space skin waves a moon rather than a paw, so it swings about the planet
   it belongs to and reads as an orbit. */
:root[data-skin="moonsweeper"] .wave-hand { transform-origin: 22px 20px; }
@keyframes wave {
  0%, 100% { transform: rotate(-18deg); }
  50% { transform: rotate(18deg); }
}

.sheet-scroll { text-align: left; max-height: 84dvh; overflow-y: auto; }
.sheet h2 { margin: 0 0 10px; font-size: 1.4rem; }
.sheet p { margin: 0 0 10px; line-height: 1.45; font-size: .92rem; color: var(--ink-soft); }
.sheet p strong { color: var(--ink); }

.help-list { margin: 0 0 12px; padding-left: 18px; font-size: .9rem; color: var(--ink-soft); line-height: 1.6; }
.help-tap { color: var(--ink); font-weight: 700; }
.help-note { font-size: .85rem; }

.win-sub { margin-bottom: 14px; }

/* ---------- payout ---------- */

.payout {
  position: relative;
  margin: 0 0 14px;
  padding: 12px 10px 10px;
  border-radius: 18px;
  background: linear-gradient(150deg, #2b1f3d, #4a2a5e);
  border: 3px solid var(--sunny);
  box-shadow: inset 0 0 22px rgba(255, 181, 46, .35);
}

.payout-label {
  display: block;
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--sunny);
  font-weight: 800;
}

.payout-score {
  display: block;
  font-size: 2.3rem;
  font-weight: 900;
  line-height: 1.1;
  color: #ffe9a8;
  text-shadow: 0 0 16px rgba(255, 200, 87, .8);
  font-variant-numeric: tabular-nums;
}

.payout-best {
  display: inline-block;
  margin-top: 2px;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .1em;
  color: #2b1f3d;
  background: var(--sunny);
  padding: 2px 10px;
  border-radius: 999px;
  animation: blink-badge .7s steps(1) infinite;
}

@keyframes blink-badge {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: .25; }
}

/* ---------- leaderboard ---------- */

.ladder { list-style: none; margin: 0 0 10px; padding: 0; }

.ladder li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  background: var(--bg);
  margin-bottom: 6px;
  border: 2px solid transparent;
}

.ladder li.you {
  background: linear-gradient(120deg, color-mix(in srgb, var(--sunny) 35%, var(--bg-2)), color-mix(in srgb, var(--accent) 25%, var(--bg-2)));
  border-color: var(--sunny);
  box-shadow: 0 4px 0 0 color-mix(in srgb, var(--sunny) 45%, transparent);
  animation: you-glow 2.2s ease-in-out infinite;
}

@keyframes you-glow {
  0%, 100% { box-shadow: 0 4px 0 0 color-mix(in srgb, var(--sunny) 45%, transparent); }
  50% { box-shadow: 0 4px 0 0 color-mix(in srgb, var(--sunny) 45%, transparent), 0 0 20px 2px rgba(255, 181, 46, .5); }
}

.ladder .rank {
  width: 26px;
  flex: none;
  font-weight: 900;
  font-size: .9rem;
  color: var(--ink-soft);
  text-align: center;
}

.ladder li.you .rank { color: var(--ink); font-size: 1.1rem; }
.ladder .who { flex: 1; text-align: left; min-width: 0; }
.ladder .who b { display: block; font-size: .92rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ladder .who small { color: var(--ink-soft); font-size: .72rem; }
.ladder .pts { font-weight: 900; font-variant-numeric: tabular-nums; font-size: .98rem; }

.ladder-empty { font-size: .9rem; text-align: center; }

.ladder li.bot { opacity: .82; }
.ladder .bot-tag {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: 1px;
}

.ladder-compact { margin-top: 10px; max-height: 190px; overflow-y: auto; }
.ladder-compact li { padding: 6px 8px; margin-bottom: 4px; }
.ladder-compact .who b { font-size: .85rem; }

/* ---------- tabs ---------- */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 4px;
  font-size: .85rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.tab.active {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
}

/* ---------- account ---------- */

.account {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.account b { color: var(--ink); }

.btn-google {
  background: var(--bg-2);
  border: 2px solid var(--line);
  color: var(--ink);
  margin-bottom: 10px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 800;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.ladder-note {
  font-size: .72rem;
  line-height: 1.45;
  color: var(--ink-soft);
  opacity: .85;
  margin-bottom: 14px;
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 16px;
}

.stats-grid { grid-template-columns: repeat(2, 1fr); }

.win-stats div {
  background: var(--bg);
  border-radius: 16px;
  padding: 10px 4px;
  border: 2px solid var(--line);
}

.win-stats div:nth-child(1) { background: color-mix(in srgb, var(--r3) 40%, var(--bg-2)); }
.win-stats div:nth-child(2) { background: color-mix(in srgb, var(--r1) 40%, var(--bg-2)); }
.win-stats div:nth-child(3) { background: color-mix(in srgb, var(--r5) 40%, var(--bg-2)); }
.win-stats div:nth-child(4) { background: color-mix(in srgb, var(--r2) 40%, var(--bg-2)); }
.win-stats div:nth-child(5) { background: color-mix(in srgb, var(--r4) 40%, var(--bg-2)); }
.win-stats div:nth-child(6) { background: color-mix(in srgb, var(--r6) 40%, var(--bg-2)); }

.win-stats dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.win-stats dd { margin: 3px 0 0; font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.sheet-actions { display: flex; gap: 8px; margin-bottom: 6px; }

/* Falling paws, or stars, on a win. Purely decorative, kept behind the text. */
.rain { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.sheet > *:not(.rain) { position: relative; z-index: 1; }
.rain span {
  position: absolute;
  top: -30px;
  font-size: 1.1rem;
  opacity: .55;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(420px) rotate(320deg); opacity: 0; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  z-index: 30;
  animation: rise .16s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; }
}

/* Landscape phones: keep the board on screen by shrinking it, not by scrolling. */
@media (max-height: 560px) and (orientation: landscape) {
  .board { width: min(100%, 56dvh, 380px); }
  .modes { padding-bottom: 4px; }
}
