@font-face {
  font-family: 'Fredoka One';
  src: url('/fonts/FredokaOne-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --pink: #F5B5B4;
  --pink-light: #FBD3D1;
  --pink-deep: #E8888A;
  --red: #D7141A;
  --ink: #1A1A2E;
  --ink-soft: #5B4A55;
  --tile-shadow: #A8E3E6;
  --white: #fff;
  --green: #4CAF50;
  --green-dark: #388E3C;
  --purple: #6B2FA0;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(160, 70, 80, .18);
  --font-display: 'Fredoka One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: #F9BEC4;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); margin: .2rem 0 0; }

/* Background: daisies on pink (landscape and portrait versions). A fixed layer works on iOS, unlike background-attachment: fixed. */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: #F9BEC4 url('/img/bg-desktop.jpg') center / cover no-repeat;
  background-image: image-set(url('/img/bg-desktop.webp') type('image/webp'), url('/img/bg-desktop.jpg') type('image/jpeg'));
}
@media (max-aspect-ratio: 4/5) {
  body::before {
    background-image: url('/img/bg-phone.jpg');
    background-image: image-set(url('/img/bg-phone.webp') type('image/webp'), url('/img/bg-phone.jpg') type('image/jpeg'));
  }
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(0,0,0,.05);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-size: 1.15rem; }
.brand img { border-radius: 10px; }
.heart { color: var(--red); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 0; font-size: 1.25rem; cursor: pointer; padding: 6px; border-radius: 10px; }
.icon-btn:hover { background: rgba(0,0,0,.05); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; cursor: pointer; text-decoration: none;
  font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .3px;
  padding: 14px 26px; border-radius: 999px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(2px); }
.btn-play { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-dark); }
.btn-play:active { box-shadow: 0 2px 0 var(--green-dark); }
.btn-secondary { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #E3C3C4; }
.btn-secondary:active { box-shadow: 0 2px 0 #E3C3C4; }
.btn-app { background: #111; color: #fff; box-shadow: 0 4px 0 #000; }
.btn-app.small, .btn.small { font-size: .9rem; padding: 9px 16px; box-shadow: none; }
.btn-small { font-size: .95rem; padding: 10px 16px; background: #fff; box-shadow: 0 3px 0 #E3C3C4; }
.btn-small:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .cat-card:focus-visible, .sub-card:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }

.view { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; }

/* Hero */
.hero { text-align: center; padding: 24px 0 8px; }
.logo { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: normal; }
.logo-i {
  font-family: var(--font-display); color: #fff; font-size: clamp(3rem, 9vw, 4.5rem); line-height: .9;
  text-shadow: 0 3px 0 rgba(0,0,0,.08);
}
.logo-heart { font-size: clamp(3.4rem, 10vw, 5rem); line-height: 1; filter: drop-shadow(0 4px 6px rgba(150, 0, 0, .25)); }
.tiles { display: flex; gap: clamp(4px, 1vw, 8px); }
.tiles b {
  display: grid; place-items: center;
  width: clamp(38px, 8vw, 58px); height: clamp(38px, 8vw, 58px);
  background: #fff; border-radius: 10px;
  font-family: var(--font-display); font-weight: normal; font-size: clamp(1.4rem, 4.6vw, 2.2rem);
  box-shadow: 0 4px 0 var(--tile-shadow);
}
.tagline { max-width: 520px; margin: 18px auto 20px; font-size: 1.08rem; color: var(--ink-soft); }
.hero-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.streak { font-family: var(--font-display); color: var(--purple); margin-top: 16px; }

/* Panels */
.panel {
  background: rgba(255,255,255,.88); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-top: 28px;
}
.panel h2 { font-family: var(--font-display); font-weight: normal; margin: 0; font-size: 1.5rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search input {
  width: min(320px, 80vw); padding: 11px 16px; border-radius: 999px; border: 2px solid #F0D2D3;
  font-size: 1rem; background: #fff; outline: none;
}
.search input:focus { border-color: var(--pink-deep); }

.groups { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 6px; scrollbar-width: thin; }
.groups button {
  flex: none; border: 0; cursor: pointer; padding: 8px 14px; border-radius: 999px;
  background: #FBEAEA; font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.groups button[aria-selected="true"] { background: var(--ink); color: #fff; }

.cat-grid, .sub-grid { display: grid; gap: 10px; margin-top: 12px; }
.cat-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.sub-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 16px; }
.cat-card, .sub-card {
  display: flex; align-items: center; gap: 10px; text-align: left; text-decoration: none;
  background: #fff; border: 2px solid #F6E0E0; border-radius: 14px; padding: 12px 14px; cursor: pointer;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.cat-card:hover, .sub-card:hover { transform: translateY(-2px); border-color: var(--pink-deep); box-shadow: 0 4px 10px rgba(200,100,110,.15); }
.cat-card .emoji { font-size: 1.6rem; flex: none; }
.cat-card .name { font-family: var(--font-display); font-size: .95rem; line-height: 1.15; }
.cat-card .count { display: block; font-family: var(--font-body); font-size: .78rem; color: var(--ink-soft); margin-top: 2px; }
.sub-card { font-weight: 600; justify-content: space-between; }
.sub-card .done { color: var(--green); font-size: .9rem; }
.empty { color: var(--ink-soft); padding: 20px 4px; }

.app-promo { display: flex; gap: 22px; align-items: flex-start; }
.promo-icon { border-radius: 22px; box-shadow: 0 6px 14px rgba(0,0,0,.15); flex: none; }
.features { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; }
@media (max-width: 600px) { .app-promo { flex-direction: column; align-items: center; text-align: center; } .features { text-align: left; } }

.back { display: inline-block; text-decoration: none; font-weight: 700; color: var(--ink); padding: 6px 2px; }
.back:hover { text-decoration: underline; }

/* Game */
.game-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.game-title { text-align: center; min-width: 0; }
.game-title h2 { font-family: var(--font-display); font-weight: normal; margin: 0; font-size: clamp(1.1rem, 3.5vw, 1.6rem); overflow-wrap: anywhere; }
.timer { font-family: var(--font-display); font-size: 1.3rem; background: #fff; padding: 6px 14px; border-radius: 999px; font-variant-numeric: tabular-nums; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; margin-top: 14px; align-items: start; }
@media (max-width: 860px) { .game-layout { grid-template-columns: 1fr; } }

.board-wrap { display: flex; flex-direction: column; align-items: center; }
.board {
  --n: 10;
  position: relative;
  width: min(100%, 620px, calc(100vh - 220px));
  min-width: 260px;
  aspect-ratio: 1;
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  padding: 2.2%;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.marks, .cells { position: absolute; inset: 2.2%; width: 95.6%; height: 95.6%; }
.cells { display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); }
.cell {
  display: grid; place-items: center;
  font-family: var(--font-display); color: var(--ink);
  font-size: calc(var(--board-px, 500px) / var(--n) * .5);
  cursor: pointer; line-height: 1;
}
.cell.hint { animation: hintPulse 1.2s ease-in-out 3; color: var(--red); }
@keyframes hintPulse { 50% { transform: scale(1.35); } }
.marks line { stroke-linecap: round; }
.marks .sel { stroke: rgba(107, 47, 160, .32); }
.marks .bad { stroke: rgba(215, 20, 26, .3); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.difficulty { display: inline-flex; background: #fff; border-radius: 999px; padding: 4px; box-shadow: 0 3px 0 #E3C3C4; }
.difficulty button { border: 0; background: none; cursor: pointer; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.difficulty button[aria-checked="true"] { background: var(--ink); color: #fff; }

.words-panel { background: rgba(255,255,255,.88); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.words-panel h3 { margin: 0 0 12px; font-family: var(--font-display); font-weight: normal; color: var(--purple); }
.words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.words li {
  padding: 6px 12px; border-radius: 999px; background: #F7F2F7; border: 2px solid #E8DDEA;
  font-weight: 700; font-size: .9rem; letter-spacing: .3px; transition: background .3s;
}
.words li.found { text-decoration: line-through; text-decoration-thickness: 2px; border-color: transparent; color: rgba(26,26,46,.75); }
.words li.pop { animation: pop .4s ease; }
@keyframes pop { 50% { transform: scale(1.18); } }
.mini-promo { margin-top: 18px; padding-top: 14px; border-top: 2px dashed #F0D2D3; font-size: .9rem; color: var(--ink-soft); }
.mini-promo p { margin: 0 0 10px; }
@media (max-width: 860px) { .words li { font-size: .82rem; padding: 5px 10px; } }

/* Win dialog */
.win {
  border: 0; border-radius: 24px; padding: 28px 24px 20px; width: min(440px, 92vw);
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden;
}
.win::backdrop { background: rgba(80, 20, 40, .45); }
.win h2 { font-family: var(--font-display); font-weight: normal; margin: 0; font-size: 1.8rem; }
.win-time { font-family: var(--font-display); font-size: 2.4rem; margin: 10px 0 0; color: var(--purple); }
.win-buttons { display: flex; flex-direction: column; gap: 12px; margin: 22px 0; }
.win-promo { display: flex; align-items: center; gap: 12px; text-align: left; background: #FBEAEA; border-radius: 16px; padding: 12px; }
.win-promo img { border-radius: 12px; }
.win-promo div { flex: 1; font-size: .85rem; display: flex; flex-direction: column; gap: 2px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(560px) rotate(540deg); opacity: 0; } }

.footer { position: relative; z-index: 1; text-align: center; font-size: .85rem; color: var(--ink-soft); padding: 10px 16px 30px; }
.footer p { margin: 4px 0; }
.version { opacity: .7; font-size: .78rem; }

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

/* Phone layout */
.brand, .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .brand span { display: none; }
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
  .view { padding: 10px 12px 32px; }
  .game-head { grid-template-columns: auto 1fr auto; gap: 6px; }
  .game-title h2 { font-size: 1.05rem; }
  .game-title p { font-size: .8rem; }
  .timer { font-size: 1.05rem; padding: 4px 10px; }
  .back { font-size: .9rem; }
}
@media (max-width: 860px) {
  .board-wrap { display: contents; }
  .game-layout { gap: 12px; }
  .board { width: min(100%, 560px); justify-self: center; order: 1; }
  .words-panel { order: 2; padding: 12px; }
  .words-panel h3 { font-size: 1rem; margin-bottom: 8px; }
  .words { gap: 6px; }
  .controls { order: 3; margin-top: 0; }
  .mini-promo { display: none; }
}
.mobile-promo { display: none; }
@media (max-width: 860px) {
  .mobile-promo { order: 4; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: rgba(255,255,255,.88); border-radius: 14px; padding: 10px 12px; font-size: .88rem; color: var(--ink-soft); }
}

/* ---------- App Store badge (official artwork; keep ≥40px tall, no edits) ---------- */
.store-badge { display: inline-block; line-height: 0; border-radius: 8px; flex: none; }
.store-badge img { height: 40px; width: auto; display: block; }
.store-badge:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.topbar .store-badge img { height: 40px; }
.promo-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.text-link { font-weight: 700; color: var(--purple); text-decoration: none; }
.text-link:hover { text-decoration: underline; }
@media (max-width: 600px) { .promo-actions { justify-content: center; } }

/* ---------- Icon buttons ---------- */
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; }
.icon-btn svg { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#soundBtn .spk { fill: var(--ink); }
#soundBtn .mute { display: none; stroke: var(--red); stroke-width: 2.2; }
#soundBtn[aria-pressed="false"] .wave { display: none; }
#soundBtn[aria-pressed="false"] .mute { display: inline; }
#soundBtn[aria-pressed="false"] .spk { fill: #8A7A84; }

/* ---------- Dialog basics ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(80, 20, 40, .45); }
.close { position: absolute; top: 10px; right: 10px; font-size: 1.1rem; }
.small { font-size: .85rem; }

/* ---------- Settings ---------- */
.sheet { border: 0; border-radius: 24px; padding: 22px; width: min(480px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-family: var(--font-display); font-weight: normal; margin: 0; }
.sheet-head .close { position: static; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid #F3E3E4; }
.setting-row div, .setting-block { display: flex; flex-direction: column; gap: 2px; }
.setting-block { padding: 14px 0; border-bottom: 1px solid #F3E3E4; }
.setting-block .mt { margin-top: 14px; }
.sheet-foot { margin: 14px 0 0; }

.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #C9BFC4; border-radius: 999px; transition: background .2s; }
.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,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--purple); outline-offset: 2px; }

.style-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.style-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: 14px; border: 2px solid #F0DDE0; background: #fff; cursor: pointer; font-size: .78rem; font-weight: 700; }
.style-opt[aria-checked="true"] { border-color: var(--ink); background: #FBF3F4; }
.style-opt svg { width: 100%; max-width: 76px; height: auto; }
@media (max-width: 420px) { .style-options { grid-template-columns: repeat(3, 1fr); } }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--ink); }
.segmented { display: inline-flex; background: #F6EEF0; border-radius: 999px; padding: 4px; margin-top: 8px; align-self: flex-start; }
.segmented button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: .9rem; }
.segmented button[aria-checked="true"] { background: var(--ink); color: #fff; }

/* Coloured style: tinted letter tiles */
.cell.tinted { border-radius: 22%; margin: 4%; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.18); transition: background .25s; }

/* Word list for line-style marking */
.words li.found.plain { background: #EFE6EA; color: rgba(26,26,46,.55); }

/* ---------- Surprise me ---------- */
.surprise { border: 0; border-radius: 24px; padding: 26px 22px 22px; width: min(420px, 92vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.surprise h2 { font-family: var(--font-display); font-weight: normal; margin: 0 0 16px; }
.reel {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 170px; padding: 18px 12px; border-radius: 20px;
  background: linear-gradient(180deg, #FFF 0%, #FBEAEA 100%); box-shadow: inset 0 2px 8px rgba(160,70,80,.12);
  overflow: hidden;
}
.reel-emoji { font-size: 3rem; line-height: 1.1; }
.reel-sub { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.2; }
.reel-cat { font-size: .85rem; color: var(--ink-soft); font-weight: 600; letter-spacing: .3px; }
.reel.spinning .reel-emoji, .reel.spinning .reel-sub { animation: tick .09s ease-out; }
.reel.landed { animation: land .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes tick { from { transform: translateY(-14px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes land { 0% { transform: scale(.94); } 60% { transform: scale(1.04); } 100% { transform: none; } }
.surprise-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.surprise-buttons .btn:disabled { opacity: .5; cursor: default; transform: none; }

/* ---------- Hint effect ---------- */
.board { overflow: visible; }
.cell.hint { position: relative; z-index: 3; color: var(--red); animation: hintPulse 1.15s ease-in-out 3; text-shadow: 0 0 10px rgba(255, 193, 7, .9); }
@keyframes hintPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.4); } }
.hint-fx { position: absolute; width: 0; height: 0; z-index: 2; pointer-events: none; }
.hint-fx .ring {
  position: absolute; left: calc(var(--cell) * -.5); top: calc(var(--cell) * -.5);
  width: var(--cell); height: var(--cell); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 64, .55) 0%, rgba(255, 215, 64, .25) 45%, transparent 70%);
  box-shadow: 0 0 0 3px rgba(255, 179, 0, .85), 0 0 18px 6px rgba(255, 193, 7, .55);
  animation: ringPulse 1.15s ease-out 3;
}
.hint-fx .ring.r2 { background: none; box-shadow: 0 0 0 2px rgba(255, 107, 107, .8); animation: ringWave 1.15s ease-out 3; }
@keyframes ringPulse { 0% { transform: scale(.6); opacity: 0; } 25% { opacity: 1; } 60% { transform: scale(1.15); } 100% { transform: scale(1.05); opacity: .2; } }
@keyframes ringWave { 0% { transform: scale(.8); opacity: .9; } 100% { transform: scale(2.4); opacity: 0; } }
.hint-fx i {
  position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
  opacity: 0; box-shadow: 0 0 10px 2px rgba(255, 213, 79, .95);
  animation: spark .95s cubic-bezier(.15, .7, .3, 1) both;
}
.hint-fx i.star { width: 18px; height: 18px; left: -9px; top: -9px; border-radius: 1px; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
@keyframes spark {
  0% { opacity: 0; transform: rotate(var(--a)) translateX(calc(var(--cell) * .2)) scale(.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(calc(var(--cell) * var(--d) * 1.25)) scale(1.1) rotate(180deg); }
}

/* ---------- Leave puzzle? ---------- */
.confirm { border: 0; border-radius: 22px; padding: 24px; width: min(380px, 92vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.confirm h2 { font-family: var(--font-display); font-weight: normal; margin: 0 0 8px; }
.confirm-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* ---------- Favourites ---------- */
.cat-wrap { position: relative; }
.cat-wrap .cat-card { height: 100%; padding-right: 44px; }
.fav-btn {
  border: 0; background: none; cursor: pointer; font-size: 1.15rem; line-height: 1;
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center;
  color: #C48A93; transition: transform .15s, background .15s;
}
.cat-wrap .fav-btn { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); }
.fav-btn:hover { background: #FBEAEA; }
.fav-btn.on { animation: favPop .35s ease; }
.fav-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 1px; }
@keyframes favPop { 50% { scale: 1.35; } }
#catTitle .fav-btn { vertical-align: middle; font-size: 1.3rem; }

/* ---------- Stats ---------- */
a.icon-btn { text-decoration: none; }
#stats h2 { margin-bottom: 14px; }
#stats h3 { font-family: var(--font-display); font-weight: normal; margin: 0 0 12px; font-size: 1.2rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 2px solid #F6E0E0; border-radius: 16px; padding: 14px 16px; }
.stat-value { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; color: var(--purple); font-variant-numeric: tabular-nums; }
.stat-label { font-weight: 700; }
.stat-sub { font-size: .8rem; color: var(--ink-soft); }
.stats-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 760px) { .stats-cols { grid-template-columns: 1fr; } .stat-grid { grid-template-columns: 1fr 1fr; } .stat-value { font-size: 1.6rem; } }
.stat-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td { text-align: right; padding: 9px 6px; border-bottom: 1px solid #F3E3E4; }
.stat-table th:first-child, .stat-table tbody th { text-align: left; }
.stat-table thead th { font-size: .8rem; color: var(--ink-soft); font-weight: 700; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 170px; align-items: end; }
.week .day { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.bar-track { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; }
.bar { width: 100%; background: linear-gradient(180deg, #FF8A8A, #E85A6A); border-radius: 8px 8px 3px 3px; transition: height .4s ease; }
.day.today .bar { background: linear-gradient(180deg, #A06BD6, var(--purple)); }
.bar-val { font-size: .75rem; font-weight: 700; min-height: 1em; }
.bar-label { font-size: .75rem; color: var(--ink-soft); }
.day.today .bar-label { color: var(--purple); font-weight: 700; }
.top-cats { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; }
.top-cats li { padding: 4px 0; }
.top-cats li a { font-weight: 700; text-decoration: none; }
.top-cats li a:hover { text-decoration: underline; }
.top-cats li span { float: right; color: var(--ink-soft); font-size: .9rem; }
.app-promo.slim { align-items: center; }
.app-promo.slim p { margin: 4px 0 12px; }
.reset-row { text-align: center; margin-top: 22px; }
.btn.danger { background: #D7141A; box-shadow: 0 5px 0 #9E0F13; }
#winStats { margin-top: 2px; }

/* Keep the title fixed while the timer ticks: equal side columns, fixed-width timer */
.game-head { grid-template-columns: 6.5rem minmax(0, 1fr) 6.5rem; }
.game-stats { justify-self: end; }
.timer { display: inline-block; min-width: 4.4ch; box-sizing: content-box; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .game-head { grid-template-columns: 4.6rem minmax(0, 1fr) 4.6rem; } }

/* ---------- Beating heart with heart particles ---------- */
.logo-heart-wrap { position: relative; display: inline-block; }
.logo-heart { display: inline-block; transform-origin: 50% 60%; animation: heartbeat 1.4s ease-in-out infinite; }
@keyframes heartbeat {
  0%   { transform: scale(1); }
  12%  { transform: scale(1.18); }   /* lub */
  24%  { transform: scale(.98); }
  36%  { transform: scale(1.12); }   /* dub */
  52%  { transform: scale(1); }
  100% { transform: scale(1); }
}
.heart-particle {
  position: absolute; left: 50%; top: 45%; pointer-events: none; z-index: 1;
  font-size: var(--s, 1rem); line-height: 1; color: var(--c, #E8394B);
  animation: heartFloat var(--t, 1.6s) cubic-bezier(.2, .7, .4, 1) forwards;
  text-shadow: 0 1px 2px rgba(150, 0, 30, .15);
}
@keyframes heartFloat {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(0deg); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--r)); }
}
@media (prefers-reduced-motion: reduce) { .logo-heart { animation: none; } .heart-particle { display: none; } }

/* Stats shown as a pop-up over a puzzle */
.stats-close { display: none; }
.stats-dialog {
  border: 0; padding: 0; width: min(1000px, 96vw); max-height: 92vh; border-radius: 24px;
  background: #FCE7EA; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: auto;
}
.stats-dialog .view { padding: 8px 18px 22px; }
.stats-dialog .stats-back { display: none; }
.stats-dialog .stats-close { display: inline-grid; position: sticky; top: 10px; float: right; z-index: 2; background: #fff; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,.15); margin: 10px -4px 0 0; }
.stats-dialog .reset-row { margin-bottom: 0; }

/* Settings groups */
.setting-group { font-family: var(--font-display); font-weight: normal; font-size: 1.05rem; color: var(--purple); margin: 18px 0 0; }
.setting-group + .setting-row { border-top: 0; }
.sheet .setting-block:first-of-type { border-top: 0; }
.dir-note { color: var(--green-dark); margin: 6px 0 0; font-weight: 700; }
.hidden-note { margin: 0 0 10px; }
.sheet { overflow-y: auto; }

/* Particles come out from behind the big heart */
.logo-heart-wrap { isolation: isolate; }
.logo-heart { position: relative; z-index: 2; }
.heart-particle { z-index: 1; }

/* New puzzle: old grid is cleared first, the new one fades in */
.cells, .marks { transition: opacity .18s ease; }
.board.loading .cells, .board.loading .marks { opacity: 0; transition: none; }
