@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('quicksand.woff2') format('woff2');
}

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url('fraunces.woff2') format('woff2');
}

:root {
  --bg: #fdf4ee;
  --card: #fffdfb;
  --ink: #6b4f5b;
  --ink-soft: #a08894;
  --accent: #e78fb3;
  --accent-deep: #d5729d;
  --field-bg: #ffffff;
  --field-border: #f0dbe4;
  --shadow: rgba(150, 100, 120, 0.14);
  --glow-a: rgba(247, 201, 216, 0.35);
  --glow-b: rgba(207, 192, 238, 0.3);
  --ring: rgba(213, 114, 157, 0.55);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b4f5b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2b2231;
    --card: #3a2e41;
    --ink: #f1e4eb;
    --ink-soft: #bda6b4;
    --accent: #d97ea6;
    --accent-deep: #f0a7c6;
    --field-bg: #493a51;
    --field-border: #5e4a66;
    --shadow: rgba(20, 10, 20, 0.4);
    --glow-a: rgba(216, 126, 166, 0.12);
    --glow-b: rgba(160, 130, 220, 0.1);
    --ring: rgba(240, 167, 198, 0.55);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23f1e4eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

:root[data-theme="light"] {
  --bg: #fdf4ee;
  --card: #fffdfb;
  --ink: #6b4f5b;
  --ink-soft: #a08894;
  --accent: #e78fb3;
  --accent-deep: #d5729d;
  --field-bg: #ffffff;
  --field-border: #f0dbe4;
  --shadow: rgba(150, 100, 120, 0.14);
  --glow-a: rgba(247, 201, 216, 0.35);
  --glow-b: rgba(207, 192, 238, 0.3);
  --ring: rgba(213, 114, 157, 0.55);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b4f5b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  --bg: #2b2231;
  --card: #3a2e41;
  --ink: #f1e4eb;
  --ink-soft: #bda6b4;
  --accent: #d97ea6;
  --accent-deep: #f0a7c6;
  --field-bg: #493a51;
  --field-border: #5e4a66;
  --shadow: rgba(20, 10, 20, 0.4);
  --glow-a: rgba(216, 126, 166, 0.12);
  --glow-b: rgba(160, 130, 220, 0.1);
  --ring: rgba(240, 167, 198, 0.55);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23f1e4eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(circle at 15% 20%, var(--glow-a), transparent 40%),
    radial-gradient(circle at 85% 75%, var(--glow-b), transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: "Quicksand", ui-rounded, "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  touch-action: manipulation;
  padding: 1.4rem 1rem 2.5rem;
}

.pic {
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1.5px 2px var(--shadow));
}

/* ---------- header ---------- */

header {
  text-align: center;
  margin-bottom: 1rem;
}

.wordmark {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.22em;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 620;
  font-variation-settings: "opsz" 72, "SOFT" 100;
  font-size: clamp(2.3rem, 7vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.wordmark .logo {
  width: 1.12em;
  height: 1.12em;
  object-fit: contain;
  transform: rotate(-7deg);
  filter: drop-shadow(0 2px 3px var(--shadow));
  animation: logo-in 0.6s cubic-bezier(0.22, 1.4, 0.36, 1) backwards;
}

@keyframes logo-in {
  from { opacity: 0; transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.12) rotate(-4deg); }
  to { opacity: 1; transform: scale(1) rotate(-7deg); }
}

.word span {
  display: inline-block;
  animation: letter-in 0.55s cubic-bezier(0.22, 1.2, 0.36, 1) backwards;
  animation-delay: calc(var(--i) * 45ms + 120ms);
}

.word span:nth-child(-n+3) { color: var(--accent-deep); }

@keyframes letter-in {
  from { opacity: 0; transform: translateY(0.45em) rotate(-5deg); }
  to { opacity: 1; transform: none; }
}

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

/* ---------- hud ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  background: var(--card);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  box-shadow: 0 4px 14px var(--shadow);
  margin-bottom: 1rem;
  font-weight: 600;
  animation: fade-up 0.6s ease 0.75s backwards;
}

/* on desktop the groups dissolve into the hud's own flex row */
.hud .stats, .hud .controls { display: contents; }

.lives {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.lives .pic { width: 1.5rem; height: 1.5rem; }

.lives .pic.lost {
  animation: heart-out 0.6s ease forwards;
}

@keyframes heart-out {
  0% { transform: scale(1); }
  35% { transform: scale(1.3) rotate(-10deg); }
  100% { transform: scale(0.85) rotate(8deg); filter: grayscale(1) opacity(0.45); }
}

.hud .count {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.hud .timer {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  /* fixed slot so ticking digits can't reflow the hud */
  min-width: 3.2rem;
  text-align: center;
}

.hud .grade[hidden] { display: none; }

.hud .grade {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--field-border);
  font-size: 0.85rem;
  font-weight: 700;
}

.hud .grade .pic { width: 0.9rem; height: 0.9rem; }

.drop-trigger, button.pill {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--field-bg);
  border: 2px solid var(--field-border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* custom difficulty dropdown */
.dropdown { position: relative; }

.drop-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

.drop-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.drop-label .pic, .drop-list .pic { width: 0.85rem; height: 0.85rem; }

.drop-trigger .chev {
  width: 0.65rem;
  flex-shrink: 0;
  color: var(--ink-soft);
  transition: transform 0.2s ease;
}

.dropdown.open .chev { transform: rotate(180deg); }

.drop-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  translate: -50% 0;
  min-width: max(100%, 12rem);
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--card);
  border: 2px solid var(--field-border);
  border-radius: 16px;
  box-shadow: 0 10px 26px var(--shadow);
  z-index: 30;
  transform-origin: top center;
  animation: drop-in 0.22s cubic-bezier(0.22, 1.3, 0.36, 1);
}

@keyframes drop-in {
  from { opacity: 0; transform: scale(0.92) translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.drop-list[hidden] { display: none; }

.drop-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.drop-list li:hover, .drop-list li:focus-visible {
  background: var(--field-border);
  outline: none;
}

.drop-list li[aria-selected="true"] { color: var(--accent-deep); }

button.pill {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.pill.ghost {
  background: var(--field-bg);
  border-color: var(--field-border);
  color: var(--accent-deep);
}

.ov-actions {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
}

.ov-actions .pill {
  white-space: nowrap;
  padding: 0.42rem 0.85rem;
  font-size: 0.95rem;
}

.ov-actions [hidden] { display: none; }

button.pill:hover { transform: translateY(-1px); box-shadow: 0 4px 10px var(--shadow); }
button.pill:active { transform: translateY(0); }
button.pill:focus-visible, .drop-trigger:focus-visible, .cell:focus-visible {
  outline: 3px solid var(--accent-deep);
  outline-offset: 2px;
}

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

.board-wrap {
  background: var(--card);
  padding: 0.9rem;
  border-radius: 26px;
  box-shadow: 0 10px 30px var(--shadow);
}

#board {
  display: grid;
  grid-auto-rows: 1fr;
  gap: 5px;
  width: min(88vw, 480px);
  aspect-ratio: 1;
  touch-action: none; /* let drag-marking work on touch screens */
}

#board.shake { animation: shake 0.4s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.cell {
  appearance: none;
  border: none;
  border-radius: 12px;
  box-shadow: 0 1.5px 3px var(--shadow);
  padding: 0;
  margin: 0;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease,
    opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  animation: tile-in 0.42s cubic-bezier(0.22, 1.3, 0.36, 1) backwards;
  animation-delay: var(--d, 0ms);
}

@keyframes tile-in {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

.cell:hover:not(.cat):not(.cleared) {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
  filter: brightness(1.04) saturate(1.08);
}

.cell .glyph {
  pointer-events: none;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
}

.cell .glyph .pic { width: 52%; height: 52%; }

.cell.marked {
  opacity: 0.38;
  filter: saturate(0.5);
  box-shadow: none;
}

.cell.marked .glyph {
  opacity: 0.9;
  animation: mark-in 0.3s cubic-bezier(0.22, 1.3, 0.36, 1) backwards;
}
.cell.marked .glyph .pic { width: 42%; height: 42%; }

@keyframes mark-in {
  from { opacity: 0; transform: scale(0.3) rotate(-15deg); }
  to { opacity: 0.9; transform: none; }
}

.cell.cleared {
  filter: saturate(0.55) brightness(1.04);
  cursor: default;
}
.cell.cleared .glyph {
  animation: bloom-in 0.45s ease backwards;
}
.cell.cleared .glyph .pic { width: 56%; height: 56%; }

@keyframes bloom-in {
  from { opacity: 0; transform: scale(0.2) rotate(60deg); }
  to { opacity: 1; transform: none; }
}

.cell.cat { cursor: default; }
.cell.cat .glyph {
  animation: cat-pop 0.5s cubic-bezier(0.22, 1.4, 0.36, 1) backwards;
}
.cell.cat .glyph .pic { width: 82%; height: 82%; }

@keyframes cat-pop {
  0% { opacity: 0; transform: scale(0); }
  55% { transform: scale(1.22, 0.86); }
  75% { transform: scale(0.94, 1.1); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes cheer {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-9deg) translateY(-6%); }
  75% { transform: rotate(9deg) translateY(-6%); }
}

.cell .ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  animation: ring-out 0.65s ease-out forwards;
}

@keyframes ring-out {
  from { box-shadow: 0 0 0 0 var(--ring); }
  to { box-shadow: 0 0 0 18px transparent; }
}

.cell.missed .glyph { filter: grayscale(0.7); opacity: 0.8; }

.cell.hintGlow {
  animation: hint-pulse 1.2s ease infinite;
  z-index: 1;
}

@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-deep), 0 1.5px 3px var(--shadow); }
  50% { box-shadow: 0 0 0 5px var(--accent-deep), 0 0 14px var(--ring); }
}

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

.options {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  animation: fade-up 0.6s ease 0.9s backwards;
}

.options input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--field-border);
  transition: background 0.2s ease;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: transform 0.25s cubic-bezier(0.22, 1.3, 0.36, 1), color 0.2s ease;
}

.switch .knob svg { width: 12px; height: 12px; }

.options input:checked + .switch { background: var(--accent); }
.options input:checked + .switch .knob {
  transform: translateX(20px);
  color: var(--accent-deep);
}

.options input:focus-visible + .switch {
  outline: 3px solid var(--accent-deep);
  outline-offset: 2px;
}

.options:hover .switch .knob { box-shadow: 0 2px 5px var(--shadow); }

#howBtn {
  margin-top: 1.1rem;
  animation: fade-up 0.6s ease 1s backwards;
}

/* ---------- onboarding ---------- */

.overlay .modal.onb-card {
  position: relative;
  width: min(92vw, 470px);
  max-width: 470px;
  padding: 2.1rem 2.2rem 1.7rem;
}

.onb-card h2 { font-size: 1.5rem; }

.onb-card .skip {
  position: absolute;
  top: 0.9rem;
  right: 1.2rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.car-view {
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
}

.car-track {
  display: flex;
  transition: transform 0.5s cubic-bezier(0.22, 1.1, 0.36, 1);
}

.car-track .slide {
  flex: 0 0 100%;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

/* offscreen scenes hold still; the active pane runs its loop */
.slide:not(.active) .demoScene, .slide:not(.active) .demoScene * {
  animation-play-state: paused;
}

.onb-caption {
  min-height: 3.2em;
  line-height: 1.55;
  font-size: 0.98rem;
  margin: 0;
}

.demo {
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.8rem 0 0.4rem;
}

.demoScene { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }

.miniwrap { position: relative; }

.mini {
  display: grid;
  grid-template-columns: repeat(4, 48px);
  gap: 5px;
}

.mc {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  position: relative;
}

.col-a { background: #f9a8b4; }
.col-b { background: #9fd6f7; }
.col-c { background: #c2e598; }
.col-d { background: #f8dd8d; }

/* every icon wrapper fills its cell and centres a fixed-size image */
.mcat, .mcat-st, .dpaw, .dbloom, .dragpaw {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mcat img, .mcat-st img { width: 36px; height: 36px; object-fit: contain; }
.dpaw img, .dragpaw img { width: 24px; height: 24px; object-fit: contain; }
.dbloom img { width: 28px; height: 28px; object-fit: contain; }

/* scene 1 — cats pop into their patches, hold, vanish, loop */
.d1 .mcat {
  animation: d1pop 4s infinite;
  animation-delay: calc(var(--k) * 0.35s);
}

@keyframes d1pop {
  0% { transform: scale(0); }
  6% { transform: scale(1.25); }
  10%, 78% { transform: scale(1); }
  88%, 100% { transform: scale(0); }
}

/* scene 2 — a spotlight frame sweeps the rows, then the columns */
.d2 .rowbar, .d2 .colbar {
  position: absolute;
  border-radius: 14px;
  border: 3px solid var(--accent-deep);
  background: rgba(231, 143, 179, 0.16);
  box-shadow: 0 0 0 4px rgba(231, 143, 179, 0.28), 0 4px 12px var(--shadow);
  pointer-events: none;
}

.d2 .rowbar { left: -5px; right: -5px; top: -5px; height: 58px; animation: d2row 6s infinite; }
.d2 .colbar { top: -5px; bottom: -5px; left: -5px; width: 58px; animation: d2col 6s infinite; opacity: 0; }

@keyframes d2row {
  0% { opacity: 0; transform: translateY(0); }
  4%, 10% { opacity: 1; transform: translateY(0); }
  14%, 20% { transform: translateY(53px); }
  24%, 30% { transform: translateY(106px); }
  34%, 40% { transform: translateY(159px); opacity: 1; }
  46%, 100% { opacity: 0; transform: translateY(159px); }
}

@keyframes d2col {
  0%, 50% { opacity: 0; transform: translateX(0); }
  54%, 58% { opacity: 1; transform: translateX(0); }
  62%, 66% { transform: translateX(53px); }
  70%, 74% { transform: translateX(106px); }
  78%, 84% { transform: translateX(159px); opacity: 1; }
  90%, 100% { opacity: 0; transform: translateX(159px); }
}

/* scenes 3-5 share a one-row lane */
.lane {
  position: relative;
  display: flex;
  gap: 6px;
}

/* scene 3 — the bad try breaks ONLY the touching rule: it sits diagonal to
   the sleeper, in a different row, column and colour. the good landing is one
   cell further along the same green row */
.d3 .ghostcat {
  position: absolute;
  left: 112px;
  top: 59px;
  width: 36px;
  animation: d3ghost 5s infinite;
}

.d3 .ghostcat img { width: 100%; display: block; }

@keyframes d3ghost {
  0% { opacity: 0; transform: translate(0, 0); }
  8%, 14% { opacity: 1; transform: translate(0, 0); }
  18% { transform: translate(-4px, 0); }
  22% { transform: translate(4px, 0); }
  26% { transform: translate(-3px, 0); }
  30% { transform: translate(0, 0); }
  42% { opacity: 1; }
  46% { opacity: 0; transform: translate(0, 0); }
  50% { opacity: 0; transform: translate(53px, 0); }
  56%, 92% { opacity: 1; transform: translate(53px, 0); }
  100% { opacity: 0; transform: translate(53px, 0); }
}

.verdict {
  position: absolute;
  top: -34px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--field-border);
  box-shadow: 0 3px 8px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.verdict svg { width: 12px; height: 12px; display: block; }

.d3 .verdict.no { left: 116px; top: 107px; color: #e0607e; animation: d3no 5s infinite; }
.d3 .verdict.yes { left: 169px; top: 107px; color: #6cae6f; animation: d3yes 5s infinite; }

@keyframes d3no {
  0%, 12% { opacity: 0; transform: translateY(4px); }
  18%, 40% { opacity: 1; transform: translateY(0); }
  46%, 100% { opacity: 0; }
}

@keyframes d3yes {
  0%, 54% { opacity: 0; transform: translateY(4px); }
  60%, 92% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

/* scene 4 — tap ripples: one tap leaves a paw, two taps peek (and cost a heart) */
.ring {
  position: absolute;
  inset: 8px;
  border: 3px solid var(--accent-deep);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.d4 .r1 { animation: dring 5s infinite; animation-delay: 0.2s; }
.d4 .r2 { animation: dring 5s infinite; animation-delay: 2.4s; }
.d4 .r3 { animation: dring 5s infinite; animation-delay: 2.75s; }

@keyframes dring {
  0% { opacity: 0.9; transform: scale(0.4); }
  7% { opacity: 0; transform: scale(1.15); }
  100% { opacity: 0; }
}

.d4 .dpaw { animation: dshow 5s infinite; animation-delay: 0.5s; }
.d4 .dbloom { animation: dshow 5s infinite; animation-delay: 3.1s; }

@keyframes dshow {
  0% { transform: scale(0); }
  5% { transform: scale(1.2); }
  8%, 92% { transform: scale(1); }
  96%, 100% { transform: scale(0); }
}

.dhearts { display: flex; align-items: center; gap: 0.4rem; }
.dhearts img { width: 1.5rem; height: 1.5rem; display: block; }

.d4 .dlost { display: inline-flex; animation: dlose 5s infinite; animation-delay: 3.2s; }

@keyframes dlose {
  0% { transform: scale(1); filter: none; }
  6% { transform: scale(1.3) rotate(-10deg); }
  12%, 88% { transform: scale(0.85) rotate(8deg); filter: grayscale(1) opacity(0.45); }
  94%, 100% { transform: scale(1); filter: none; }
}

/* scene 5 — a pointer sweeps the lane, leaving paw prints behind */
.d5 .dragdot {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-deep);
  box-shadow: 0 0 0 5px rgba(213, 114, 157, 0.25);
  opacity: 0;
  animation: d5dot 3.5s infinite;
}

@keyframes d5dot {
  0%, 5% { opacity: 0; transform: translateX(0); }
  10% { opacity: 1; transform: translateX(0); }
  25% { opacity: 1; transform: translateX(162px); }
  31%, 100% { opacity: 0; transform: translateX(162px); }
}

/* every paw shares the dot's 3.5s timeline (no delay, so loops can't overlap).
   the dot flicks across in ~0.5s (10-25% of the loop) on CSS `ease` =
   cubic-bezier(.25,.1,.25,1); solving that curve for progress 0, 1/3, 2/3, 1
   puts the cell crossings at 10 / 13.3 / 15.8 / 25% of the loop.
   all paws fade together at 85%, before the next sweep */
.d5 .mc:nth-child(1) .dragpaw { animation: d5paw0 3.5s infinite; }
.d5 .mc:nth-child(2) .dragpaw { animation: d5paw1 3.5s infinite; }
.d5 .mc:nth-child(3) .dragpaw { animation: d5paw2 3.5s infinite; }
.d5 .mc:nth-child(4) .dragpaw { animation: d5paw3 3.5s infinite; }

@keyframes d5paw0 {
  0%, 9.5% { transform: scale(0); opacity: 0; }
  12% { transform: scale(1.2); opacity: 0.85; }
  14%, 78% { transform: scale(1); opacity: 0.85; }
  85%, 100% { transform: scale(0); opacity: 0; }
}

@keyframes d5paw1 {
  0%, 12.8% { transform: scale(0); opacity: 0; }
  15.3% { transform: scale(1.2); opacity: 0.85; }
  17.3%, 78% { transform: scale(1); opacity: 0.85; }
  85%, 100% { transform: scale(0); opacity: 0; }
}

@keyframes d5paw2 {
  0%, 15.3% { transform: scale(0); opacity: 0; }
  17.8% { transform: scale(1.2); opacity: 0.85; }
  19.8%, 78% { transform: scale(1); opacity: 0.85; }
  85%, 100% { transform: scale(0); opacity: 0; }
}

@keyframes d5paw3 {
  0%, 24.5% { transform: scale(0); opacity: 0; }
  27% { transform: scale(1.2); opacity: 0.85; }
  29%, 78% { transform: scale(1); opacity: 0.85; }
  85%, 100% { transform: scale(0); opacity: 0; }
}

.onb-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.4rem;
}

.dots { display: inline-flex; gap: 0.4rem; }

.dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--field-border);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.dot.on { background: var(--accent-deep); transform: scale(1.25); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--card);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  box-shadow: 0 8px 24px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 26, 36, 0.4);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.overlay .modal {
  background: var(--card);
  border-radius: 26px;
  padding: 2rem 2.4rem;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 16px 44px var(--shadow);
  transform: translateY(24px) scale(0.9);
  transition: transform 0.4s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.overlay.show .modal { transform: translateY(0) scale(1); }

.modal .big { line-height: 0; display: flex; justify-content: center; }
.modal .big .pic { width: 84px; height: 84px; }
.modal .big.lose .pic { filter: grayscale(0.75) opacity(0.85); }

/* victory dance — a slow, happy sway with soft little bounces */
.modal .big.win .pic {
  transform-origin: 50% 100%;
  animation: cat-dance 2.6s ease-in-out 0.4s infinite;
}

@keyframes cat-dance {
  0%, 100% { transform: none; }
  18% { transform: translateY(-4px) rotate(-5deg); }
  32% { transform: translateY(0) rotate(0) scale(1.03, 0.97); }
  52% { transform: translateY(-4px) rotate(5deg); }
  66% { transform: translateY(0) rotate(0) scale(1.03, 0.97); }
  82% { transform: translateY(-2px) rotate(-2deg); }
}

.modal h2 {
  margin: 0.6rem 0 0.3rem;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-variation-settings: "opsz" 40, "SOFT" 100;
  color: var(--accent-deep);
}

.modal p {
  margin: 0 0 1.1rem;
  color: var(--ink-soft);
  text-wrap: balance;
}

.modal .final-time {
  margin: -0.7rem 0 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.6;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.modal .final-time .best-line { font-weight: 600; }
.modal .final-time.record .best-line { font-weight: 700; }
.modal .final-time.record { color: var(--accent-deep); }

.modal .final-time[hidden] { display: none; }

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  body { padding: 1rem 0.75rem 2rem; }

  header { margin-bottom: 0.7rem; }

  .hud {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
    max-width: 480px;
    border-radius: 22px;
    padding: 0.9rem 1rem;
  }

  .hud .stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
  }

  .hud .count { font-size: 0.95rem; }
  .lives .pic { width: 1.35rem; height: 1.35rem; }

  .hud .controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    border-top: 1px solid var(--field-border);
    padding-top: 0.75rem;
  }

  .hud .controls .dropdown {
    flex: 1 1 100%;
    min-width: 0;
  }

  .hud .controls .pill {
    flex: 1;
    padding: 0.45rem 0.5rem;
    font-size: 0.95rem;
  }

  .board-wrap { padding: 0.6rem; border-radius: 20px; }
  #board { width: min(94vw, 480px); gap: 4px; }
  .cell { border-radius: 10px; }

  .options { font-size: 0.85rem; }

  .toast {
    bottom: 1.2rem;
    max-width: 92vw;
    font-size: 0.85rem;
    text-align: center;
  }

  .overlay .modal { padding: 1.6rem 1.4rem; }
  .overlay .modal.onb-card { padding: 1.6rem 1rem 1.3rem; }
  .onb-card h2 { font-size: 1.3rem; }
  .onb-caption { min-height: 4.8em; font-size: 0.92rem; padding: 0 0.4rem; }
  .onb-nav .pill { padding: 0.4rem 0.8rem; font-size: 0.95rem; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .word span, .wordmark .logo, .hud, .options, #howBtn,
  .cell, .cell .glyph, .cell .ring, .lives .pic.lost,
  #board.shake, .demoScene *, .toast {
    animation: none;
  }
  .lives .pic.lost { filter: grayscale(1) opacity(0.45); transform: scale(0.85); }
  /* onboarding scenes settle on their end states */
  .d3 .ghostcat { opacity: 1; transform: translate(53px, 0); }
  .d3 .verdict.yes { opacity: 1; }
  .d4 .dlost { transform: scale(0.85) rotate(8deg); filter: grayscale(1) opacity(0.45); }
  .d5 .dragpaw { opacity: 0.85; }
  .cell.hintGlow { animation: none; box-shadow: 0 0 0 3px var(--accent-deep); }
  .drop-list { animation: none; }
  .modal .big.win .pic { animation: none; }
  .drop-trigger, button.pill, .cell, .overlay, .overlay .modal, .toast,
  .car-track, .dot, .switch, .switch .knob, .drop-trigger .chev { transition: none; }
}
