:root {
  --bg: #fff4e8;
  --bg-2: #ffe7d1;
  --card: #ffffff;
  --ink: #4a3226;
  --ink-soft: #8b6b59;
  --line: #3b2a20;
  --thin: rgba(74, 50, 38, 0.16);
  --soft-line: rgba(74, 50, 38, 0.22);
  --glow: none;
  --accent: #ff8a65;
  --accent-ink: #ffffff;
  --accent-2: #ffc15e;
  --daily: #8fd3b6;
  --good: #3fae84;
  --bad: #e2546d;
  --bone: #fff3dc;
  --shadow: 0 3px 0 rgba(74, 50, 38, 0.14), 0 8px 24px rgba(74, 50, 38, 0.1);
  --radius: 18px;
  --paw-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='12' cy='16' rx='5.2' ry='4.4'/%3E%3Cellipse cx='5.6' cy='10' rx='2.1' ry='2.7'/%3E%3Cellipse cx='9.6' cy='5.8' rx='2.1' ry='2.8'/%3E%3Cellipse cx='14.4' cy='5.8' rx='2.1' ry='2.8'/%3E%3Cellipse cx='18.4' cy='10' rx='2.1' ry='2.7'/%3E%3C/svg%3E");
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Varela Round', 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #211814;
    --bg-2: #2c211c;
    --card: #33271f;
    --ink: #f8e9dc;
    --ink-soft: #c9ab97;
    --line: #120c09;
    --thin: rgba(30, 20, 14, 0.28);
    --bone: #fff0d4;
    --soft-line: rgba(248, 233, 220, 0.22);
    --glow: drop-shadow(0 0 1.2px rgba(255, 236, 220, 0.75)) drop-shadow(0 0 8px rgba(255, 236, 220, 0.12));
    --shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #211814;
  --bg-2: #2c211c;
  --card: #33271f;
  --ink: #f8e9dc;
  --ink-soft: #c9ab97;
  --line: #120c09;
  --thin: rgba(30, 20, 14, 0.28);
  --bone: #fff0d4;
  --soft-line: rgba(248, 233, 220, 0.22);
  --glow: drop-shadow(0 0 1.2px rgba(255, 236, 220, 0.75)) drop-shadow(0 0 8px rgba(255, 236, 220, 0.12));
  --shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, var(--bg-2), transparent 60%);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { display: block; }

#app { max-width: 620px; margin: 0 auto; min-height: 100%; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 6px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 12px) max(16px, env(safe-area-inset-left));
}

/* ---------- shared bits ---------- */

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.topbar-title { margin: 0; font-size: 1.35rem; font-weight: 600; }
.topbar-spacer { width: 44px; height: 44px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: var(--card); box-shadow: var(--shadow); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
  transition: transform 0.12s;
}
.icon-btn:active { transform: translateY(2px) scale(0.96); }
.icon-btn svg { width: 22px; height: 22px; }

.btn {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 0;
  width: 100%; min-height: 56px; padding: 10px 18px;
  border: 0; border-radius: var(--radius); cursor: pointer;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow);
  font-size: 1.2rem; font-weight: 600; letter-spacing: 0.01em;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn small { font-size: 0.82rem; font-weight: 500; opacity: 0.85; }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0, 0, 0, 0); }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-size: 1.45rem; min-height: 68px; }
.btn-daily { background: var(--daily); color: #1f4a3a; }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 2.5px var(--soft-line); font-size: 1.05rem; min-height: 50px; }
.btn-row { display: flex; gap: 12px; }

[data-icon] svg { width: 100%; height: 100%; }
.paw-inline { display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; color: var(--accent); }

/* ---------- home ---------- */

.home { justify-content: space-between; }
.hero { text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.logo {
  margin: 0; font-size: clamp(3.2rem, 15vw, 4.6rem); font-weight: 700; line-height: 1;
  letter-spacing: -0.01em;
}
.logo-dog { color: var(--accent); text-shadow: 0 4px 0 rgba(74, 50, 38, 0.15); }
.logo-doku { color: var(--ink); }
.tagline { margin: 6px 0 4px; font-size: 1.15rem; color: var(--ink-soft); font-weight: 500; }

.parade { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; justify-items: center; align-items: end; margin: 22px 0 6px; }
.parade-dog { width: 100%; max-width: 210px; text-align: center; }
.parade-dog:nth-child(3) { grid-column: 1 / -1; width: 50%; }
.dog-body, .bubble-face .dog-face, .face .dog-face, .pup-slot .dog-face { filter: var(--glow); }
.parade-dog .dog-body { width: 100%; height: auto; overflow: visible; }
.parade-dog:nth-child(1) { animation: trot 1.1s ease-in-out infinite; }
.parade-dog:nth-child(2) { animation: trot 1.1s ease-in-out -0.37s infinite; }
.parade-dog:nth-child(3) { animation: trot 1.1s ease-in-out -0.74s infinite; }
.name-tag {
  display: inline-block; margin-top: 2px; padding: 2px 10px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 0.95rem;
}
.dog-body .tail { transform-box: fill-box; transform-origin: 100% 100%; animation: wag 0.5s ease-in-out infinite alternate; }

.home-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.footnote { text-align: center; color: var(--ink-soft); margin: 14px 0 0; font-size: 0.95rem; }

/* ---------- difficulty ---------- */

.diff-0 { --diff: #4cbf86; }
.diff-1 { --diff: #f0b93a; }
.diff-2 { --diff: #f2804a; }
.diff-3 { --diff: #d9547f; }

/* ---------- levels ---------- */

.level-list { display: flex; flex-direction: column; gap: 22px; padding: 8px 0 24px; }
.tier h3 { margin: 0 0 10px; font-size: 1.15rem; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tier h3 .range { display: block; font-size: 0.85rem; margin-top: 1px; }
.tier h3 small { color: var(--ink-soft); font-weight: 500; font-size: 0.9rem; }
.tier-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.lvl {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 1.1rem;
  display: grid; place-items: center;
}
.lvl:active { transform: translateY(2px); }
.lvl::before {
  content: ''; position: absolute; left: 7px; bottom: 7px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--diff, transparent);
}
.lvl.current::before { box-shadow: 0 0 0 1.5px #fff; }
.lvl.done { background: #c9efd9; color: #1f5a40; }
.lvl.done::after {
  content: ''; position: absolute; right: 5px; bottom: 5px; width: 13px; height: 13px;
  background: currentColor; opacity: 0.55;
  -webkit-mask: var(--paw-mask) center / contain no-repeat; mask: var(--paw-mask) center / contain no-repeat;
}
.lvl.current { background: var(--accent); color: #fff; animation: nudge 1.6s ease-in-out infinite; }
.lvl.locked { opacity: 0.4; cursor: default; box-shadow: none; background: var(--bg-2); }
.lvl.locked:active { transform: none; }

/* ---------- free play ---------- */

.free-body { display: flex; flex-direction: column; gap: 10px; padding: 8px 0 16px; margin: auto 0; }
.free-body h3 { margin: 10px 0 0; font-size: 1.1rem; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
#free-diffs { grid-template-columns: repeat(4, 1fr); }
.chip {
  border: 0; border-radius: 14px; min-height: 46px; padding: 6px 8px; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 1rem; color: var(--ink);
}
.chip:active { transform: translateY(2px); }
.chip.on { background: var(--accent); color: #fff; }
.diff-chip { box-shadow: inset 0 -4px 0 var(--diff), var(--shadow); }
.diff-chip.on { background: var(--diff); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.chip:disabled { opacity: 0.35; cursor: default; }
.free-preview {
  margin: 10px 0 4px; padding: 14px; border-radius: var(--radius); background: var(--bg-2);
  text-align: center; line-height: 1.5; min-height: 70px;
}
.free-preview small { color: var(--ink-soft); }
.free-intro { margin: 0; text-align: center; color: var(--ink-soft); }
.free-body .face-row { margin: 0; }
.free-body .face-row .face { width: 64px; height: 64px; }

/* ---------- leaderboards ---------- */

.topbar-group { display: flex; gap: 8px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin: 8px 0 12px; background: var(--bg-2); border-radius: 16px; }
.tabs button { border: 0; border-radius: 12px; padding: 9px 4px; background: transparent; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.lb-panel { flex: 1; }
.lb-title { margin: 0 0 8px; font-size: 1rem; color: var(--ink-soft); font-weight: 500; text-align: center; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center;
  background: var(--card); border-radius: 14px; padding: 9px 12px; box-shadow: var(--shadow);
}
.lb-row.me { background: #ffe1d2; box-shadow: inset 0 0 0 2.5px var(--accent), var(--shadow); }
:root[data-theme='dark'] .lb-row.me { background: #4a2e22; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .lb-row.me { background: #4a2e22; } }
.lb-rank { font-weight: 700; text-align: center; font-size: 1.05rem; }
.lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name small { display: block; font-weight: 500; color: var(--ink-soft); font-size: 0.78rem; }
.lb-time { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
.lb-gap { text-align: center; color: var(--ink-soft); line-height: 1; }
.lb-empty, .lb-status { text-align: center; color: var(--ink-soft); padding: 18px 8px; margin: 0; }
.lb-me { margin: 14px 0 6px; text-align: center; color: var(--ink-soft); }
.lb-me b { color: var(--ink); }
.lb-me .link { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px; text-decoration: underline; }
.lb-note { font-size: 0.8rem; color: var(--ink-soft); text-align: center; margin: 6px 0 0; }
.lb-rounds { display: flex; flex-direction: column; gap: 6px; }
.lb-round { display: flex; justify-content: space-between; align-items: center; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 14px; padding: 12px 14px; cursor: pointer; font-weight: 600; text-align: left; }
.lb-round small { color: var(--ink-soft); font-weight: 500; }
.modal .lb { margin-top: 12px; }
.lb-result { background: var(--bg-2); border-radius: 14px; padding: 10px; margin-bottom: 8px; }
.lb-result b { font-size: 1.4rem; }
.lb-result span { color: var(--ink-soft); }
.name-input {
  width: 100%; font: inherit; font-size: 1.2rem; padding: 12px 14px; border-radius: 14px; margin-top: 10px;
  border: 2.5px solid var(--soft-line); background: var(--bg); color: var(--ink); text-align: center;
}
.name-input:focus { outline: none; border-color: var(--accent); }
.form-error { color: var(--bad) !important; font-weight: 600; }
.modal .lb-list { text-align: left; margin-top: 8px; max-height: 50vh; overflow: auto; padding: 2px; }

/* ---------- sign in ---------- */

.account {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--bg-2); border-radius: 14px; padding: 10px 12px; margin: 8px 0 4px; color: var(--ink-soft); font-size: 0.95rem;
}
.account b { color: var(--ink); }
.account .btn { width: auto; min-height: 40px; padding: 6px 16px; font-size: 1rem; }
.account .link, .lb-me .link { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px; text-decoration: underline; }
.btn-google { flex-direction: row; gap: 10px; background: #fff; color: #3c4043; box-shadow: inset 0 0 0 1.5px #dadce0, var(--shadow); font-size: 1.05rem; }
.g-logo { width: 22px; height: 22px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); margin: 12px 0 0; font-size: 0.9rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1.5px; background: var(--soft-line); }
.code-input { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; }

/* ---------- the pack ---------- */

.pack-intro { margin: 0 0 6px; color: var(--ink-soft); text-align: center; }
.pack-list { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }
.pack-section h3 { margin: 0 0 8px; font-size: 1.1rem; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pack-section h3 small { color: var(--ink-soft); font-weight: 500; font-size: 0.85rem; }
.pup-card {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border-radius: 16px; padding: 8px 12px 8px 8px; box-shadow: var(--shadow); margin-bottom: 8px;
}
.pup-card .face { width: 56px; height: 56px; }
.pup-card .face svg { width: 100%; height: 100%; }
.pup-info b { display: block; font-size: 1.05rem; }
.pup-info small { color: var(--ink-soft); }
.pup-info .link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0 0 0 6px; cursor: pointer; text-decoration: underline; }
.pup-card.locked { opacity: 0.55; }
.pup-card.locked .face { filter: grayscale(1) brightness(0.7) blur(1px); }
.add-pup {
  width: 100%; border: 2.5px dashed var(--soft-line); border-radius: 16px; background: transparent; color: var(--ink);
  padding: 14px; font-weight: 600; font-size: 1.05rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.add-pup span { font-size: 1.6rem; line-height: 1; color: var(--accent); }
.add-pup small { color: var(--ink-soft); font-weight: 500; }
.unlock { background: linear-gradient(135deg, #fff1c9, #ffe0d1); border-radius: 18px; padding: 12px; margin-bottom: 12px; color: #4a3226; }
.unlock b { font-size: 1.1rem; }
.unlock span { font-size: 0.92rem; }
.unlock .face-row .face { width: 64px; height: 64px; }
.unlock .btn { margin-top: 8px; min-height: 44px; font-size: 1rem; }

/* ---------- the pup builder ---------- */

.builder-preview {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--bg); padding: 6px 0 8px; margin: 0 -16px; box-shadow: 0 8px 12px -10px rgba(0, 0, 0, 0.2);
}
.bp-face { width: 112px; height: 112px; flex: none; }
.bp-body { width: 190px; flex: none; }
.bp-face svg, .bp-body svg { width: 100%; height: 100%; }
.builder-body { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 28px; }
.builder-body h3 { margin: 10px 0 0; font-size: 1.05rem; }
.photo-btn { flex-direction: row; gap: 8px; cursor: pointer; }
.photo-wrap { text-align: center; }
#photo-canvas { max-width: 100%; max-height: 300px; border-radius: 16px; touch-action: manipulation; cursor: crosshair; box-shadow: var(--shadow); }
.photo-tip { margin: 6px 0; color: var(--ink-soft); font-size: 0.9rem; }
.swatches { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--card); box-shadow: var(--shadow); cursor: pointer; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot {
  display: flex; align-items: center; gap: 8px; border: 0; border-radius: 14px; padding: 8px 10px; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 0.88rem; color: var(--ink); text-align: left;
}
.slot i { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15); }
.slot.on { box-shadow: inset 0 0 0 3px var(--accent), var(--shadow); }
.picker-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--ink-soft); font-size: 0.9rem; }
.picker-row input { width: 44px; height: 32px; border: 0; background: none; padding: 0; cursor: pointer; }
.builder .chips { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }

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

.game-title { text-align: center; min-width: 0; }
.game-title h2 { margin: 0; font-size: 1.3rem; font-weight: 600; line-height: 1.1; }
.game-title span { color: var(--ink-soft); font-size: 0.9rem; }

.status { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; min-height: 30px; }
.lives { display: flex; gap: 3px; }
.bone { width: 30px; height: 20px; transition: transform 0.3s, opacity 0.3s; }
.bone.lost { opacity: 0.22; filter: grayscale(1); }
.bone.breaking { animation: bone-break 0.7s ease-in forwards; }
.pups { display: flex; gap: 2px; flex: 1; justify-content: center; min-width: 0; }
.pup-slot { width: 18px; height: 18px; flex: 0 1 18px; min-width: 0; color: var(--soft-line); }
.pup-slot svg { width: 100%; height: 100%; }
.pup-slot.filled { color: inherit; animation: pop 0.45s ease-out; }
.pup-count { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-soft); }
.pup-count b { color: var(--ink); font-size: 1.1rem; }
.pup-count .pup-slot { width: 22px; height: 22px; flex: none; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.05rem; min-width: 52px; text-align: right; color: var(--ink-soft); }

.board-wrap { display: flex; justify-content: center; }
.board-frame {
  --size: min(calc(100vw - 28px), calc(100vh - 300px), 560px);
  --size: min(calc(100vw - 28px), calc(100dvh - 300px), 560px);
  position: relative;
  width: max(var(--size), 260px);
  aspect-ratio: 1;
  border: 3px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--line);
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.board-frame:has(.board:focus-visible) { box-shadow: 0 0 0 4px var(--accent), var(--shadow); }
.board {
  --n: 5;
  --thick: 3px;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  transform-origin: 0 0;
  outline: none;
}

.cell {
  position: relative;
  background: var(--patch);
  border-top: 1px solid var(--thin);
  border-left: 1px solid var(--thin);
  display: grid; place-items: center;
  cursor: pointer;
  overflow: visible;
}
.cell.r0 { border-top: 0; }
.cell.c0 { border-left: 0; }
.cell.bt { border-top: var(--thick) solid var(--line); }
.cell.bl { border-left: var(--thick) solid var(--line); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .cell { filter: saturate(0.92) brightness(0.93); }
}
:root[data-theme='dark'] .cell { filter: saturate(0.92) brightness(0.93); }

.cell .x { width: 42%; height: 42%; color: #6b4e3e; opacity: 0.75; animation: x-in 0.14s ease-out; }
.cell .x path { stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; fill: none; }
.cell .wrong { width: 58%; height: 58%; animation: x-in 0.18s ease-out; }
.cell .wrong path { stroke: var(--bad); stroke-width: 2; stroke-linecap: round; fill: none; }
.cell .pup { width: 94%; height: 94%; pointer-events: none; }
.cell.fresh .pup { animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.cell .pup svg { width: 100%; height: 100%; overflow: visible; }
.cell.wiggle .pup { animation: wiggle 0.5s ease-in-out; }
.cell.shake { animation: shake 0.4s ease-in-out; }
.cell.flash-bad::before {
  content: ''; position: absolute; inset: 0; background: var(--bad); opacity: 0;
  animation: flash 0.6s ease-out;
}
.cell.blocker .pup { animation: wiggle 0.5s ease-in-out 2; }
.cell.cursor { box-shadow: inset 0 0 0 3px var(--accent); }
.cell.helper::after {
  content: "\2605"; position: absolute; top: 2%; right: 4%; line-height: 1;
  font-size: clamp(8px, 1.6vw, 13px); color: #f2b134; text-shadow: 0 0 2px #fff, 0 0 2px #fff; pointer-events: none;
}

.cell.hint-unit::after {
  content: ''; position: absolute; inset: 0; background: #fff; opacity: 0.35; pointer-events: none;
}
.cell.hint-x::after, .cell.hint-dog::after {
  content: ''; position: absolute; inset: 2px; border-radius: 6px; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--accent); animation: pulse 1s ease-in-out infinite;
}
.cell.hint-dog::after { box-shadow: inset 0 0 0 3px var(--good); background: rgba(63, 174, 132, 0.25); }
.cell.hint-oops::after {
  content: ''; position: absolute; inset: 2px; border-radius: 6px; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--bad); animation: pulse 1s ease-in-out infinite;
}

.can-blink .eye { transform-box: fill-box; transform-origin: center; animation: blink 5.5s infinite; animation-delay: var(--blink, 0s); }

.bubble {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; padding: 8px 12px 8px 8px;
  min-height: 60px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative;
}
.bubble::before {
  content: ''; position: absolute; top: -7px; left: 26px; width: 14px; height: 14px;
  background: var(--card); transform: rotate(45deg); border-radius: 3px;
}
.bubble-face { width: 44px; height: 44px; flex: 0 0 44px; position: relative; z-index: 1; }
.bubble-face svg { width: 100%; height: 100%; }
.bubble p { margin: 0; flex: 1; font-size: 1rem; line-height: 1.25; position: relative; z-index: 1; }
.bubble.pop-in p, .bubble.pop-in .bubble-face { animation: bubble-in 0.25s ease-out; }
.bubble-action {
  flex: 0 0 auto; border: 0; border-radius: 12px; padding: 8px 12px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; position: relative; z-index: 1;
}

.play { margin: auto 0; display: flex; flex-direction: column; }
.toolbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.tool .label { font-weight: inherit; }
.tool {
  border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  padding: 8px 4px 7px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; color: var(--ink);
}
.tool span { width: 24px; height: 24px; }
.tool:active { transform: translateY(2px); }
.tool:disabled { opacity: 0.4; }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(40, 24, 16, 0.45); animation: fade-in 0.2s ease-out;
}
.modal {
  position: relative; z-index: 1;
  width: min(100%, 420px); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--card); border-radius: 26px; padding: 22px 20px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center; animation: modal-in 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.modal h2 { margin: 0 0 6px; font-size: 1.7rem; font-weight: 700; }
.modal p { margin: 6px 0; color: var(--ink-soft); line-height: 1.35; }
.modal .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.modal .stats { display: flex; justify-content: center; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.stat { background: var(--bg-2); border-radius: 14px; padding: 8px 12px; min-width: 76px; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: 0.8rem; color: var(--ink-soft); }
.modal .parade { margin: 8px 0 4px; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.modal .parade-dog:nth-child(3) { grid-column: auto; width: 100%; }
.modal .name-tag { font-size: 0.8rem; padding: 1px 8px; }
.modal .parade-dog { animation: hop 0.7s ease-in-out infinite; }
.modal .parade-dog:nth-child(2) { animation-delay: -0.23s; }
.modal .parade-dog:nth-child(3) { animation-delay: -0.46s; }
.face-row { display: flex; justify-content: center; gap: 10px; margin: 10px 0; }
.face-row .face { width: 74px; height: 74px; }
.face-row.sad .face { animation: droop 2s ease-in-out infinite; }

.howto { text-align: left; }
.howto h2 { text-align: center; }
.howto ol { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.howto li { display: flex; gap: 12px; align-items: center; }
.howto .demo { flex: 0 0 76px; height: 76px; }
.howto .demo svg { width: 100%; height: 100%; }
.howto p { margin: 0; color: var(--ink); }
.pack { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; text-align: center; }
.pack .face { width: 64px; height: 64px; margin: 0 auto; }
.pack b { display: block; }
.pack small { color: var(--ink-soft); font-size: 0.78rem; line-height: 1.2; display: block; }

.settings { text-align: left; }
.settings h2 { text-align: center; }
.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px; border-bottom: 1.5px solid var(--thin); cursor: pointer; font-size: 1.05rem;
}
.toggle small { display: block; color: var(--ink-soft); font-size: 0.82rem; }
.switch { position: relative; width: 52px; height: 30px; flex: 0 0 52px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--thin); transition: background 0.2s; pointer-events: none; }
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent); }
.danger { color: var(--bad) !important; box-shadow: inset 0 0 0 2.5px currentColor !important; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  z-index: 60; animation: toast 1.8s ease-out forwards; pointer-events: none;
}

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.confetti span { position: absolute; top: -40px; font-size: 22px; animation: fall linear forwards; }

/* ---------- animation ---------- */

@keyframes pop { 0% { transform: scale(0) rotate(-25deg); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes x-in { from { transform: scale(0.4); opacity: 0; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.08); } 75% { transform: rotate(12deg) scale(1.08); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@keyframes flash { 0% { opacity: 0.55; } 100% { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
@keyframes trot { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-5px) rotate(-1.5deg); } 50% { transform: translateY(0) rotate(0); } 75% { transform: translateY(-3px) rotate(1deg); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px) rotate(-3deg); } 60% { transform: translateY(-10px) rotate(2deg); } }
@keyframes wag { from { transform: rotate(-14deg); } to { transform: rotate(16deg); } }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes bone-break { 0% { transform: scale(1); } 30% { transform: scale(1.3) rotate(-10deg); } 100% { transform: translateY(8px) rotate(30deg) scale(0.9); opacity: 0.22; filter: grayscale(1); } }
@keyframes bubble-in { from { transform: translateY(5px); opacity: 0.4; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { transform: scale(0.85) translateY(20px); opacity: 0; } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes fall { to { transform: translateY(calc(100vh + 80px)) rotate(var(--spin, 360deg)); } }
@keyframes droop { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg) translateY(2px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

@media (max-height: 700px) {
  .parade { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .parade-dog:nth-child(3) { grid-column: auto; width: 100%; }
}
@media (max-height: 640px) {
  .parade { margin-top: 8px; }
  .logo { font-size: 3rem; }
  .btn-primary { min-height: 58px; }
}
