:root {
  --paper-top: #f7e6c8;
  --paper-low: #e9c79b;
  --ink: #3b2316;
  --ink-soft: #7a5a44;
  --walnut: #6d3f22;
  --walnut-hi: #a56a3d;
  --walnut-lo: #432213;
  --slot: #5f3520;
  --slot-lo: #4a2815;
  --gold: #ffd34d;
  --sheet: #fff8ec;
  --bw: min(calc(100vw - 32px), calc(100dvh - 372px), 500px);
  --cs: calc((var(--bw) - 16px - 6px - 18px) / 10); /* one cell: frame, board padding and gaps taken off */
  --ts: calc(var(--cs) * 0.62); /* a cell of a piece sitting in the tray */
  --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:
    radial-gradient(circle at 80% 8%, rgba(255, 244, 220, 0.9), transparent 42%),
    repeating-linear-gradient(0deg, rgba(120, 80, 40, 0.035) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, var(--paper-top), var(--paper-low));
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding-bottom: 7vh; }
.app {
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--sg-corner-top) - 6px) 16px calc(var(--safe-bottom) + 12px);
}
.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- Block look (board cells, tray pieces, burst copies) ---------- */
.blk, .cell.blk {
  --w1: #ecc994;
  --w2: #d9a768;
  background:
    repeating-linear-gradient(92deg, rgba(110, 66, 28, 0.13) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(88deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 11px),
    linear-gradient(155deg, var(--w1), var(--w2));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 2px 0 0 rgba(255, 255, 255, 0.25),
    inset 0 -3px 0 rgba(120, 70, 28, 0.38),
    inset -2px 0 0 rgba(120, 70, 28, 0.2),
    0 1px 2px rgba(30, 12, 0, 0.55);
}
.blk.t0 { --w1: #efcf9c; --w2: #dcab6c; }
.blk.t1 { --w1: #e7bd82; --w2: #d09a58; }
.blk.t2 { --w1: #f3d9ab; --w2: #e0b87c; }
.blk.t3 { --w1: #e2b077; --w2: #c98d4c; }
.blk.fish::after {
  content: "";
  position: absolute;
  inset: 12%;
  background: var(--fish) center / contain no-repeat;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.5));
}

/* ---------- Title screen: the shared layout (shared/mainmenu.js); Catnap's wood is only these colors ---------- */
#home {
  --sg-bg: linear-gradient(180deg, var(--paper-top), var(--paper-low));
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: #fff3d8; --sg-title-shadow: 0 3px 0 var(--walnut), 0 5px 0 var(--walnut-lo), 0 9px 14px rgba(70, 30, 5, 0.35);
  --sg-accent: #7a4526; --sg-accent-ink: #fff6e3;
  --sg-card: rgba(255, 248, 236, 0.9); --sg-card-ink: var(--ink); --sg-line: rgba(109, 63, 34, 0.25);
}
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--ink); --sg-accent: #7a4526; --sg-accent-ink: #fff6e3; --sg-ink-soft: var(--ink-soft); }
.logo-cats { height: 108px; display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.logo-cats .lc { height: 100%; width: 118px; filter: drop-shadow(0 4px 3px rgba(80, 40, 10, 0.25)); animation: bob 4.2s ease-in-out infinite; }
.logo-cats .lc:nth-child(2) { animation-delay: -1.4s; }
.logo-cats .lc:nth-child(3) { animation-delay: -2.8s; }
.logo-cats svg { width: 100%; height: 100%; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.icon-btn:focus-visible, .primary:focus-visible, .secondary:focus-visible, .lvl:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.note { margin: 0; font-size: 14px; color: var(--ink-soft); text-align: center; }

/* ---------- Play: header and status ---------- */
.top { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; min-height: 56px; }
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 14px; cursor: pointer;
  background: linear-gradient(160deg, #a76d3f, #7a4526); color: #fff3d8;
  box-shadow: inset 0 2px 0 rgba(255, 220, 170, 0.4), 0 3px 0 var(--walnut-lo);
}
.icon-btn:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 220, 170, 0.4), 0 1px 0 var(--walnut-lo); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hud { display: flex; justify-content: center; align-items: flex-end; gap: 22px; min-width: 0; }
.hud small { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1; }
.hud b { display: block; font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-best b { font-size: 22px; color: var(--ink-soft); }
.hud-score { text-align: center; }
.hud-best { text-align: center; padding-bottom: 2px; }
.hud-adv { flex-direction: column; align-items: center; gap: 2px; }
.hud-level { font-size: 14px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1; }
.goal { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; line-height: 1.1; white-space: nowrap; }
.goal-count { white-space: nowrap; padding: 1px 10px; border-radius: 999px; background: var(--walnut); color: #fff3d8; font-size: 18px; font-variant-numeric: tabular-nums; }
.goal.done .goal-count { background: #3c9a6c; }

.status { min-height: 30px; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 2px 0 6px; }
.budget { display: flex; align-items: center; gap: 10px; flex: 1; max-width: var(--bw); }
.budget-bar { position: relative; flex: 1; height: 12px; border-radius: 999px; background: rgba(90, 50, 20, 0.22); box-shadow: inset 0 1px 3px rgba(60, 30, 10, 0.45); }
.budget-bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 999px; background: linear-gradient(180deg, #8fd48e, #3c9a6c); transition: width 0.3s, background 0.3s; }
.budget-bar i.low { background: linear-gradient(180deg, #f3b46a, #d9822b); }
.budget-bar i.crit { background: linear-gradient(180deg, #ef8a80, #c64a40); }
.tick { position: absolute; top: -3px; bottom: -3px; width: 3px; border-radius: 2px; background: var(--walnut); text-decoration: none; }
.tick.t2 { left: 20%; }
.tick.t3 { left: 40%; }
.tick::after { content: ""; position: absolute; top: -9px; left: 50%; width: 10px; height: 10px; transform: translateX(-50%); background: var(--gold); clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.tick.t3::after { filter: drop-shadow(8px 0 0 var(--gold)); transform: translateX(-100%); }
.budget-text { font-size: 15px; font-weight: 700; color: var(--ink-soft); min-width: 74px; text-align: right; white-space: nowrap; }
.streak { min-height: 28px; display: flex; align-items: center; }
.streak.on {
  padding: 0 14px; border-radius: 999px; font-weight: 800; font-size: 18px; color: #5a2d00;
  background: linear-gradient(180deg, #ffe58a, #ffc531); box-shadow: 0 2px 0 #b97c0f;
  animation: streak-in 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes streak-in { from { transform: scale(0.6); opacity: 0; } }

/* ---------- The board ---------- */
.frame {
  position: relative;
  width: var(--bw);
  margin: 0 auto;
  padding: 8px;
  border-radius: 20px;
  background:
    repeating-linear-gradient(97deg, rgba(0, 0, 0, 0.07) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(83deg, rgba(255, 220, 170, 0.07) 0 1px, transparent 1px 13px),
    linear-gradient(145deg, var(--fr1, #ad6d3d), var(--fr2, #7c4627) 55%, var(--fr3, #5c3019));
  box-shadow: inset 0 3px 0 rgba(255, 224, 180, 0.5), inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 8px 0 var(--fr-lo, var(--walnut-lo)), 0 16px 26px rgba(60, 28, 6, 0.38);
  touch-action: none;
}
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--slot-lo), var(--slot-deep, #3a1e10));
  box-shadow: inset 0 4px 9px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 220, 170, 0.3);
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 5px;
  background:
    repeating-linear-gradient(92deg, rgba(0, 0, 0, 0.1) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, var(--slot-hi, #67391f), var(--slot));
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 200, 150, 0.1);
}
.cell.blk { border-radius: 5px; }
.cell.land { animation: land 0.22s ease-out; }
@keyframes land { 0% { transform: scale(1.2); } 55% { transform: scale(0.93); } 100% { transform: scale(1); } }
/* The ghost: where the lifted piece will land */
.cell.ghost { background: linear-gradient(155deg, rgba(255, 240, 205, 0.78), rgba(238, 198, 132, 0.68)); box-shadow: inset 0 0 0 2px rgba(255, 248, 228, 0.95), 0 0 8px rgba(255, 230, 170, 0.7); }
/* Cells in a row or column the ghost would complete */
.cell.will {
  animation: will 0.55s ease-in-out infinite alternate;
  box-shadow: inset 0 0 0 2px #fff0a8, 0 0 10px 1px rgba(255, 211, 77, 0.9);
}
.cell.ghost.will { background: linear-gradient(155deg, rgba(255, 244, 190, 0.95), rgba(255, 211, 77, 0.8)); }
@keyframes will { from { filter: brightness(1); } to { filter: brightness(1.22); } }

.cats, .fx { position: absolute; inset: 8px; pointer-events: none; }
.chips { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* A napping cat: a cushion over its cells, the cat curled up on it. --r --c (top-left cell) --w --h (cells) */
.cat {
  position: absolute;
  left: calc(3px + var(--c) * (var(--cs) + 2px));
  top: calc(3px + var(--r) * (var(--cs) + 2px));
  width: calc(var(--w) * var(--cs) + (var(--w) - 1) * 2px);
  height: calc(var(--h) * var(--cs) + (var(--h) - 1) * 2px);
  transition: opacity 0.3s;
}
.cat-bed {
  position: absolute;
  inset: 3px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--bed-hi), var(--bed));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -4px 0 rgba(0, 0, 0, 0.16), 0 2px 4px rgba(20, 8, 0, 0.55);
}
.cat-in { position: absolute; inset: 0; }
.cat-in svg { position: absolute; left: 50%; bottom: 1px; height: calc(106% + var(--len) * 9%); width: auto; aspect-ratio: 206 / 142; transform: translateX(-50%); overflow: visible; }
.cat.v .cat-in { inset: auto; left: 50%; top: 50%; width: calc(var(--len) * var(--cs) + (var(--len) - 1) * 2px); height: var(--cs); transform: translate(-50%, -50%) rotate(90deg); }
.cat.mac { --bed: #93a6cc; --bed-hi: #b9c8e6; }
.cat.kento { --bed: #efba85; --bed-hi: #f9d8b2; }
.cat.honey { --bed: #dba0b2; --bed-hi: #f0c4d0; }
.cat.in { animation: cat-in 0.5s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes cat-in { from { transform: scale(0.4); opacity: 0; } }
.cat.out { opacity: 0; }
.cat .zzz { position: absolute; right: 6%; top: -22%; font-weight: 800; font-size: calc(var(--cs) * 0.55); color: #fff8ec; text-shadow: 0 1px 2px rgba(40, 20, 5, 0.8); animation: zzz 2.6s ease-in-out infinite; }
.cat .zzz:nth-of-type(2) { animation-delay: -1.3s; right: 22%; font-size: calc(var(--cs) * 0.4); }
@keyframes zzz { 0% { transform: translate(0, 6px); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(8px, -14px); opacity: 0; } }
.cat.v .zzz { right: -14%; top: -4%; }
.cat.wakeup .cat-bed { animation: bed-flash 0.5s ease-out forwards; }
@keyframes bed-flash { 0% { filter: brightness(1.4); } 100% { opacity: 0; } }
.cat.wakeup .cat-in, .cat.wakeup .zzz { display: none; }
.cat.will .cat-bed { box-shadow: inset 0 0 0 2px #fff0a8, 0 0 12px 2px rgba(255, 211, 77, 0.95); }
.cat.will .cat-in svg { animation: nudge 0.5s ease-in-out infinite alternate; }
@keyframes nudge { from { transform: translateY(0); } to { transform: translateY(-3px) rotate(-2deg); } }
/* The wake-up: the cat sits up, stretches, yawns and trots off */
.awake { position: absolute; display: grid; place-items: end center; pointer-events: none; animation: awake 1.5s ease-out forwards; transform-origin: 50% 100%; }
.awake svg { width: 100%; height: 100%; overflow: visible; }
.awake .say {
  position: absolute; left: 62%; top: -6%; padding: 1px 10px; border-radius: 12px; background: #fffaf0; color: var(--ink);
  font-weight: 800; font-size: calc(var(--cs) * 0.5); white-space: nowrap; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); animation: say 1.5s ease-out forwards;
}
@keyframes awake {
  0% { transform: translateY(8%) scale(0.9, 0.7); opacity: 0; }
  14% { transform: translateY(0) scale(0.95, 1.22); opacity: 1; }
  30% { transform: scale(1.05, 0.92); }
  44% { transform: scale(1, 1.08) rotate(-3deg); }
  62% { transform: scale(1) rotate(3deg); opacity: 1; }
  100% { transform: translateX(14%) scale(1); opacity: 0; }
}
@keyframes say { 0%, 20% { transform: scale(0); } 34% { transform: scale(1.15); } 46%, 80% { transform: scale(1); opacity: 1; } 100% { opacity: 0; } }

/* Clearing: the blocks puff out in a wave from where the piece landed */
.burst { position: absolute; border-radius: 5px; animation: burst 0.5s ease-in forwards; animation-delay: var(--d, 0ms); }
.burst::before { content: ""; position: absolute; inset: 0; border-radius: 5px; background: #fff7d6; opacity: 0; animation: flash 0.5s ease-in forwards; animation-delay: var(--d, 0ms); }
@keyframes burst {
  0% { transform: scale(1); }
  35% { transform: scale(1.22) rotate(var(--r, 3deg)); filter: brightness(1.25); }
  100% { transform: scale(0.1) rotate(calc(var(--r, 3deg) * 3)); opacity: 0; }
}
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 0.85; } 100% { opacity: 0; } }
.pop {
  position: absolute; z-index: 5; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-weight: 800; font-size: 26px; color: #fff3b0; -webkit-text-stroke: 1px rgba(90, 40, 0, 0.55);
  text-shadow: 0 2px 0 #8a4a10, 0 4px 8px rgba(60, 20, 0, 0.5); animation: pop 1.05s ease-out forwards;
}
.pop.big { font-size: 36px; color: #ffe27a; }
.pop.catpop { color: #ffd0dc; }
.pop.label { font-size: 26px; color: #fff; }
@keyframes pop { 0% { transform: translate(-50%, -30%) scale(0.5); opacity: 0; } 18% { transform: translate(-50%, -60%) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }
.frame.shake { animation: shake 0.32s linear; }
/* a big clear: the board gives a little under it and settles (calm; never a shake) */
.frame.settle { animation: settle 0.38s cubic-bezier(0.3, 0.7, 0.4, 1); }
@keyframes settle { 0%, 100% { transform: none; } 35% { transform: translateY(3px) scale(0.994); } 70% { transform: translateY(-1px); } }
@keyframes shake { 0%, 100% { transform: translate(0); } 20% { transform: translate(-3px, 2px); } 40% { transform: translate(3px, -2px); } 60% { transform: translate(-2px, -1px); } 80% { transform: translate(2px, 1px); } }

/* ---------- The tray ---------- */
.tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: var(--bw);
  margin: 22px auto 0;
}
.slot {
  position: relative;
  height: calc(var(--ts) * 5 + 22px);
  min-height: 88px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(90, 50, 20, 0.2), rgba(90, 50, 20, 0.1));
  box-shadow: inset 0 2px 5px rgba(70, 35, 10, 0.3), 0 1px 0 rgba(255, 245, 225, 0.6);
  touch-action: none;
  cursor: grab;
}
.piece { display: grid; gap: 1px; pointer-events: none; transition: opacity 0.12s; }
.piece i { display: block; position: relative; border-radius: 3px; }
.piece i.off { visibility: hidden; }
.slot.empty { cursor: default; }
.slot.lifted .piece { opacity: 0.22; }
.slot.deal .piece { animation: deal 0.34s cubic-bezier(0.3, 1.4, 0.5, 1) backwards; animation-delay: var(--d, 0ms); }
@keyframes deal { from { transform: translateY(40px) scale(0.5); opacity: 0; } }
.slot.nofit .piece { filter: grayscale(0.5) brightness(0.9); }

.drag { position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none; will-change: transform; }
.drag.settle { transition: transform 0.09s ease-out; }
.drag.back { transition: transform 0.18s ease-in; }
.drag-in { transform-origin: 50% 100%; transform: scale(var(--from, 0.56)); transition: transform 0.12s ease-out; filter: drop-shadow(0 8px 5px rgba(40, 15, 0, 0.35)); }
.drag.up .drag-in { transform: scale(1.04); }
.drag.back .drag-in { transform: scale(var(--from, 0.56)); transition: transform 0.18s; filter: none; }
.drag .piece { gap: 2px; }
.drag .piece i { border-radius: 5px; }

/* ---------- Sheets ---------- */
.sheet {
  width: min(calc(100vw - 32px), 380px);
  max-height: calc(100dvh - 40px);
  padding: 22px 20px 20px;
  border: 0;
  border-radius: 26px;
  background: var(--sheet);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 0 0 4px var(--walnut), 0 0 0 7px rgba(255, 233, 198, 0.9), 0 24px 50px rgba(40, 15, 0, 0.5);
  overflow-y: auto;
}
.sheet.wide { width: min(calc(100vw - 24px), 440px); }
.sheet::backdrop { background: rgba(48, 24, 8, 0.5); }
.sheet[open] { animation: sheet-in 0.28s cubic-bezier(0.3, 1.3, 0.5, 1); }
@keyframes sheet-in { from { transform: translateY(24px) scale(0.94); opacity: 0; } }
.sheet h2 { margin: 0; font-size: 32px; font-weight: 800; line-height: 1.1; }
.sheet p { margin: 6px 0 14px; font-size: 17px; color: var(--ink-soft); line-height: 1.3; }
.kicker { margin: 0 0 2px !important; font-size: 14px !important; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.over-score { font-size: 54px !important; font-weight: 800; color: var(--ink) !important; margin: 0 !important; line-height: 1.1; font-variant-numeric: tabular-nums; }
.over-cat { height: 96px; margin: -6px auto 4px; display: flex; justify-content: center; }
.over-cat svg { height: 100%; width: auto; }
.stack { display: grid; gap: 10px; margin-top: 14px; }
.primary, .secondary {
  min-height: 54px; padding: 0 20px; border-radius: 16px; font-size: 20px; font-weight: 800; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.primary { border: 0; color: #fff6e3; background: linear-gradient(160deg, #b27544, #7a4526); box-shadow: inset 0 2px 0 rgba(255, 220, 170, 0.45), 0 4px 0 var(--walnut-lo); }
.primary:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 220, 170, 0.45), 0 2px 0 var(--walnut-lo); }
.secondary { border: 2px solid rgba(90, 50, 20, 0.25); background: transparent; color: var(--ink); }

.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; height: 84px; }
.star {
  width: 56px; height: 56px; background: rgba(90, 50, 20, 0.2); transform: scale(0.9);
  clip-path: polygon(50% 2%, 62% 36%, 98% 38%, 69% 60%, 80% 96%, 50% 75%, 20% 96%, 31% 60%, 2% 38%, 38% 36%);
}
.star.big { width: 72px; height: 72px; }
.star.on { background: linear-gradient(160deg, #ffe58a, #ffb81f); animation: star-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) backwards; animation-delay: var(--d, 0ms); transform: scale(1); }
@keyframes star-pop { from { transform: scale(0); } }

.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0 4px; }
.lvl {
  position: relative; min-height: 64px; padding: 4px 0 6px; display: grid; justify-items: center; align-content: center; gap: 0;
  border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; font-size: 22px; line-height: 1.05; color: #fff6e3;
  background: linear-gradient(160deg, #b27544, #7a4526); box-shadow: inset 0 2px 0 rgba(255, 220, 170, 0.4), 0 3px 0 var(--walnut-lo);
}
.lvl small { display: block; font-size: 13px; letter-spacing: 1px; color: #ffd34d; min-height: 15px; }
.lvl.todo { background: linear-gradient(160deg, #f3d9ab, #dfb378); color: var(--ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 3px 0 #b98a52; }
.lvl.todo small { color: var(--ink-soft); }
.lvl.locked { background: rgba(90, 50, 20, 0.16); color: rgba(60, 35, 20, 0.45); box-shadow: none; cursor: default; }
.lvl .kind { position: absolute; top: 3px; right: 4px; width: 14px; height: 14px; background-size: contain; background-repeat: no-repeat; opacity: 0.8; }
.lvl .kind.fish { background-image: var(--fish); }
.lvl .kind.cats { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M3 17V6l4 3h6l4-3v11Z' fill='%23fff3d8' stroke='%233b2316' stroke-width='1.4' stroke-linejoin='round'/></svg>"); }
.lvl .resume { position: absolute; left: 4px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: #ffd34d; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2); }

.ach-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.ach { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(90, 50, 20, 0.08); }
.ach .medal { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(90, 50, 20, 0.2); }
.ach .medal::after { content: ""; width: 22px; height: 22px; background: rgba(90, 50, 20, 0.45); clip-path: polygon(50% 2%, 62% 36%, 98% 38%, 69% 60%, 80% 96%, 50% 75%, 20% 96%, 31% 60%, 2% 38%, 38% 36%); }
.ach.got { background: rgba(255, 211, 77, 0.25); }
.ach.got .medal { background: linear-gradient(160deg, #ffe58a, #ffb81f); box-shadow: 0 2px 0 #b97c0f; }
.ach.got .medal::after { background: #fff8e0; }
.ach b { display: block; font-size: 18px; line-height: 1.1; }
.ach span { display: block; font-size: 15px; color: var(--ink-soft); line-height: 1.25; }
.ach em { font-style: normal; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.ach-text { flex: 1; min-width: 0; }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 14px); z-index: 60; transform: translate(-50%, -20px); max-width: calc(100vw - 32px);
  padding: 10px 18px; border-radius: 16px; background: var(--ink); color: #fff3d8; font-weight: 700; font-size: 17px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--gold); }

@media (max-height: 700px) {
  .logo-cats { height: 80px; }
  .home { gap: 10px; }
  .mode { min-height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo-cats .lc, .cell.will, .cat .zzz, .cat.will .cat-in svg { animation: none; }
  .cell.land, .sheet[open], .slot.deal .piece, .cat.in, .frame.shake, .frame.settle, .streak.on { animation: none; }
  .drag.settle, .drag.back, .drag-in, .budget-bar i, .toast, .mode { transition: none; }
  .pop { animation-duration: 1.4s; }
  .awake { animation: awake-calm 1.4s linear forwards; }
}
@keyframes awake-calm { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

.hint { margin: 14px auto 0; max-width: var(--bw); text-align: center; font-size: 16px; font-weight: 700; color: var(--ink-soft); }
#mute-btn .cross { display: none; }
#mute-btn[aria-pressed="true"] .cross { display: block; }
#mute-btn[aria-pressed="true"] .wave { display: none; }

/* 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; }

/* ---------- Cozy Corners: the board's woods (progress.js WOODS; walnut is the board as it always was) ---------- */
body.wood-oak { --fr1: #e3b071; --fr2: #c08447; --fr3: #9a6431; --fr-lo: #6e4320; --slot: #8a5a2e; --slot-lo: #6f4522; --slot-hi: #9c6a3a; --slot-deep: #5a361a; }
body.wood-cherry { --fr1: #c96f4e; --fr2: #9c4630; --fr3: #74301f; --fr-lo: #4f1d12; --slot: #6a2e20; --slot-lo: #552418; --slot-hi: #7a3a29; --slot-deep: #3f1a11; }
body.wood-birch { --fr1: #f2deb8; --fr2: #d9bd8c; --fr3: #b89a68; --fr-lo: #8a7048; --slot: #a88a5c; --slot-lo: #8d7249; --slot-hi: #b89a6c; --slot-deep: #6f5836; }
body.wood-driftwood { --fr1: #cfc8bb; --fr2: #a59c8f; --fr3: #7e766b; --fr-lo: #575048; --slot: #6b655c; --slot-lo: #59534b; --slot-hi: #7a746a; --slot-deep: #44403a; }
body.wood-midnight { --fr1: #57537a; --fr2: #39365a; --fr3: #25233d; --fr-lo: #16152a; --slot: #2b2946; --slot-lo: #221f3a; --slot-hi: #35325a; --slot-deep: #17152a; }

/* ---------- Cozy Corners: the title room and the sheet ---------- */
.room-art { width: 100%; aspect-ratio: 420 / 150; height: auto; max-height: 150px; border-radius: 18px; overflow: hidden; box-shadow: 0 6px 14px -8px rgba(60, 28, 6, 0.5), inset 0 0 0 2px rgba(255, 240, 210, 0.6); }
.room-art svg { width: 100%; height: 100%; display: block; }
.cozy { text-align: left; }
.room-sheet { margin: -2px 0 8px; }
.cozy-sum { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: #fff1cf; }
.cozy-total { margin: 0 !important; display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.cozy-total small { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }
.cozy-total b { font-size: 26px; line-height: 1; color: var(--ink); }
.cozy-parts { margin: 0 !important; font-size: 14px !important; line-height: 1.35; color: var(--ink-soft); }
.cozy-next { margin-top: 8px; padding: 10px 12px 12px; border-radius: 16px; background: #fff1cf; }
.cozy-next p { margin: 0 0 8px !important; display: flex; flex-direction: column; line-height: 1.2; }
.cozy-next small { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); }
.cozy-next b { font-size: 19px; color: var(--ink); }
.cozy-next em { font-style: normal; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.cozy-pb { --pb-track: rgba(109, 63, 34, 0.18); --pb-fill: linear-gradient(180deg, #ffd56e, #e9a325); }
.cozy-pb .pb-track { height: 12px; }
.cozy h3 { margin: 16px 0 8px; font-size: 17px; font-weight: 800; color: var(--ink); }
.cozy-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-bottom: 8px; }
.cozy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.cozy-woods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.cozy-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 84px; padding: 4px 3px 7px;
  border: 2px solid rgba(74, 42, 26, 0.12); border-radius: 13px; background: #fff8ec; color: var(--ink); font: inherit; cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(74, 42, 26, 0.07);
}
.cozy-tile:active:not(:disabled) { transform: scale(0.96); }
.cozy-tile[aria-pressed="true"] { border-color: #3c9a6c; background: #eef8f2; }
.cozy-tile:disabled { background: rgba(255, 248, 236, 0.5); cursor: default; box-shadow: none; }
.cozy-tile .tile-pic { width: 100%; max-width: 96px; aspect-ratio: 152 / 126; }
.cozy-tile .tile-pic svg { width: 100%; height: 100%; display: block; }
.cozy-tile .tile-name { font-size: 13px; font-weight: 700; line-height: 1.1; text-align: center; }
.cozy-tile .tile-sub { font-size: 12px; font-weight: 600; line-height: 1.1; color: var(--ink-soft); text-align: center; }
.cozy-tile .tile-sub:empty { display: none; }
.cozy-tile:disabled .tile-name { color: var(--ink-soft); }
.wood-tile { min-height: 70px; }
.wood-tile .tile-pic { aspect-ratio: auto; height: 36px; }
.wood-tile .sw { display: block; width: 100%; height: 100%; border-radius: 8px; box-shadow: inset 0 2px 0 rgba(255, 230, 190, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.25);
  background: repeating-linear-gradient(97deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 9px), linear-gradient(145deg, var(--a), var(--b) 55%, var(--c)); }
.wood-tile:disabled .sw { opacity: 0.4; filter: grayscale(0.6); }
.wood-swatch-walnut { --a: #ad6d3d; --b: #7c4627; --c: #5c3019; }
.wood-swatch-oak { --a: #e3b071; --b: #c08447; --c: #9a6431; }
.wood-swatch-cherry { --a: #c96f4e; --b: #9c4630; --c: #74301f; }
.wood-swatch-birch { --a: #f2deb8; --b: #d9bd8c; --c: #b89a68; }
.wood-swatch-driftwood { --a: #cfc8bb; --b: #a59c8f; --c: #7e766b; }
.wood-swatch-midnight { --a: #57537a; --b: #39365a; --c: #25233d; }
.cozy-note { margin: 10px 2px 0 !important; font-size: 14px !important; line-height: 1.35; color: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) { .cozy-tile:active:not(:disabled) { transform: none; } }

/* title screen over the painted scene: the room is just the floor and the napping cats */
.room-art:not(.room-sheet) { border-radius: 0; overflow: visible; box-shadow: none; -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
