@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-SoftBold.ttf") format("truetype");
  font-weight: 700 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4ede0; --bg2: #ebe1ce; --panel: #faf4e8; --ink: #40362c; --muted: #7a6e5e; --line: #dfd2ba; --rim: #d0bea0;
  --tile: #8cb888; --tile-d: #68996c; --ground: #fcf7ec; --ground-d: #e6dac3;
  --accent: #d37950; --accent-d: #a65430; --accent-ink: #fffaf1; --ok: #3f9a6a; --leafc: #e27e36; --leafrib: #9b4b18;
  --stitch: #7b9a72; --wood: #a67c52; --wood-d: #6d4b2d; --wood-g: #87603b;
  --fur: #c28e5c; --belly: #f2dfc2; --ear: #ebb8a4; --blush: #e59888; --art-ink: #5a402c; --heart: #de6557;
  --c0: #e8bd5c; --c1: #84b5de; --c2: #e59c95; --c3: #7cc4a4; --c4: #b6a1dc;
  --n1: #3b7cb8; --n2: #3a8f5b; --n3: #cc5644; --n4: #6a5db5; --n5: #a9572c; --n6: #2b9494; --n7: #40382f; --n8: #8b7f70;
  --s0: #9a6a00; --s1: #1f62a0;
  --shadow: 0 2px 6px rgba(80, 58, 28, .10), 0 8px 22px rgba(80, 58, 28, .08);
  --linen: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M0 2h8M0 6h8M2 0v8M6 0v8' stroke='%235a402c' stroke-opacity='.045' stroke-width='1'/%3E%3C/svg%3E");
  --floral-top: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='26' viewBox='0 0 140 26'%3E%3Cg fill='%236c9465' fill-opacity='.34' stroke='%23577c52' stroke-opacity='.35' stroke-width='1'%3E%3Cpath d='M8 0c4 8 12 10 18 4-6 0-12-2-18-4zM34 0c-2 9 4 15 11 11-4-3-8-6-11-11zM56 0c6 10 16 12 24 6-8 1-16-1-24-6zM96 0c-4 10 2 18 10 13-5-3-8-7-10-13zM118 0c5 8 13 10 20 3-7 0-14-1-20-3z'/%3E%3Ccircle cx='28' cy='10' r='2'/><circle cx='86' cy='8' r='2.2'/><circle cx='112' cy='11' r='1.8'/>%3C/g%3E%3C/svg%3E");
  --floral-bot: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='26' viewBox='0 0 140 26'%3E%3Cg transform='translate(0 26) scale(1 -1)' fill='%236c9465' fill-opacity='.34' stroke='%23577c52' stroke-opacity='.35' stroke-width='1'%3E%3Cpath d='M16 0c4 8 12 10 18 4-6 0-12-2-18-4zM44 0c-2 9 4 15 11 11-4-3-8-6-11-11zM68 0c6 10 16 12 24 6-8 1-16-1-24-6zM106 0c-4 10 2 18 10 13-5-3-8-7-10-13z'/%3E%3Ccircle cx='36' cy='10' r='2'/><circle cx='96' cy='9' r='2.2'/>%3C/g%3E%3C/svg%3E");
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", "Varela Round", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #1e2124; --bg2: #181a1d; --panel: #292d33; --ink: #ece5d8; --muted: #9e988c; --line: #3c424b; --rim: #464d57;
  --tile: #5b8d6b; --tile-d: #3d6750; --ground: #2e3238; --ground-d: #23262b;
  --accent: #df845c; --accent-d: #b5613e; --accent-ink: #241a14; --ok: #6fd09a; --leafc: #eb9d56; --leafrib: #844519;
  --stitch: #6a8d67; --wood: #5f4733; --wood-d: #37271b; --wood-g: #4c3726;
  --fur: #c99768; --belly: #ecd8ba; --ear: #ebb8a4; --blush: #df8f80; --art-ink: #473222; --heart: #ee7b6d;
  --c0: #c9a046; --c1: #5f93c0; --c2: #c57d78; --c3: #57a487; --c4: #9482c0;
  --n1: #82b8ea; --n2: #7fd09a; --n3: #f28d7b; --n4: #ada0f2; --n5: #e3a473; --n6: #6fd2d2; --n7: #ece5d8; --n8: #9c978c;
  --s0: #f0c765; --s1: #8cc4f2;
  --shadow: 0 2px 6px rgba(0, 0, 0, .28), 0 8px 20px rgba(0, 0, 0, .22);
  --linen: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M0 2h8M0 6h8M2 0v8M6 0v8' stroke='%23ffffff' stroke-opacity='.035' stroke-width='1'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--bg); color: var(--ink); font: 500 16px/1.45 var(--font);
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  background-image:
    radial-gradient(ellipse at 50% 45%, transparent 52%, rgba(124, 92, 48, .12) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  background-attachment: fixed;
}
[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse at 50% 45%, transparent 50%, rgba(0, 0, 0, .35) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
}
#app { min-height: 100%; position: relative; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.ic { width: 1.25em; height: 1.25em; flex: none; overflow: visible; }
.out { stroke: var(--art-ink); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.ic .fur, .mouse .fur { fill: var(--fur); } .ic .ear, .mouse .ear { fill: var(--ear); }
.ic .belly, .mouse .belly { fill: var(--belly); } .ic .blush, .mouse .blush { fill: var(--blush); opacity: .65; }
.ic .paw, .mouse .paw { fill: var(--belly); }
.ic .tail, .mouse .tail { fill: none; stroke: var(--ear); stroke-width: 5.5; stroke-linecap: round; }
.ic .eye, .mouse .eye { fill: none; stroke: var(--art-ink); stroke-width: 3.2; stroke-linecap: round; }
.ic .nose, .mouse .nose, .pupil { fill: var(--art-ink); }
.ic .shine, .mouse .shine { fill: #fffaf1; }
.ic .brow, .mouse .brow { fill: none; stroke: var(--art-ink); stroke-width: 3; stroke-linecap: round; }
.ic .sadmouth, .mouse .sadmouth, .ic .smile, .mouse .smile { fill: none; stroke: var(--art-ink); stroke-width: 2.8; stroke-linecap: round; }
.ic .whisker, .mouse .whisker { fill: none; stroke: var(--art-ink); stroke-width: 1.9; stroke-linecap: round; opacity: .7; }
.ic .blanket, .mouse .blanket { fill: var(--tile); }
.ic .blanket-rib, .mouse .blanket-rib { fill: none; stroke: var(--tile-d); stroke-width: 2.6; stroke-linecap: round; }
.spark { fill: none; stroke: var(--accent); stroke-width: 3.4; stroke-linecap: round; }
.sparkdot { fill: var(--accent); }
.blade { fill: var(--leafc); } .rib { fill: none; stroke: var(--leafrib); stroke-width: 3.2; stroke-linecap: round; }
.vein { fill: none; stroke: var(--leafrib); stroke-width: 2; stroke-linecap: round; opacity: .75; }
.heart { fill: var(--heart); }
.heart-hi { fill: none; stroke: #fffaf1; stroke-width: 4.5; stroke-linecap: round; opacity: .6; }
.heart-empty { fill: none; stroke: var(--heart); stroke-width: 3.4; stroke-dasharray: 6 6; stroke-linecap: round; opacity: .45; }
.puffs circle { fill: var(--c0); opacity: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Botanical corner flourishes on menus and pressed-leaf watermarks on the game stage. */
.sprigs { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.stage .sprigs { position: absolute; }
.sprig { position: absolute; width: clamp(8.5rem, 23vw, 15.5rem); opacity: .76; }
.sprig.tl { top: -.4rem; left: -.4rem; }
.sprig.tr { top: -.4rem; right: -.4rem; }
.sprig.bl { bottom: -.4rem; left: -.4rem; }
.sprig.br { bottom: -.4rem; right: -.4rem; }
.sp-stem { fill: none; stroke: var(--tile-d); stroke-width: 2.2; stroke-linecap: round; opacity: .75; }
.sp-leaf { fill: color-mix(in srgb, var(--tile) 85%, #fff); stroke: var(--tile-d); stroke-width: 2.2; stroke-linejoin: round; }
.sp-vein { fill: none; stroke: var(--tile-d); stroke-width: 1.5; stroke-linecap: round; opacity: .7; }
.sp-clover { fill: color-mix(in srgb, var(--tile) 82%, #fff); stroke: var(--tile-d); stroke-width: 1.4; }
.sp-berry { fill: var(--accent); stroke: var(--accent-d); stroke-width: 1.2; }
[data-theme="dark"] .sprig { opacity: .34; }
.sprigs.pressed .sprig { width: clamp(7rem, 18vw, 13rem); opacity: .16; }
.sprigs.pressed .sp-leaf { fill: var(--wood); stroke: var(--wood-d); }
.sprigs.pressed .sp-vein { stroke: var(--wood-d); }
[data-theme="dark"] .sprigs.pressed .sprig { opacity: .12; }

/* ---- home ---- */
.home { position: relative; z-index: 1; max-width: 30rem; margin: 0 auto; padding: max(4vh, env(safe-area-inset-top)) 1.25rem 2rem; display: flex; flex-direction: column; gap: 1.5rem; min-height: 100dvh; justify-content: center; }
.hero { text-align: center; }
.hero .art { width: min(64%, 15.5rem); display: block; margin: 0 auto; padding: 0; border-radius: 1rem; }
.hero .art svg { display: block; width: 100%; overflow: visible; }
/* Tapping the dormouse: it wriggles, flicks its ears and tail, peeks, and the z's scatter. */
.dm, .a-head, .a-earl, .a-earr, .a-tail { transform-box: fill-box; }
.dm { transform-origin: 50% 100%; } .a-head { transform-origin: 70% 80%; }
.a-earl, .a-earr { transform-origin: 50% 90%; } .a-tail { transform-origin: 0% 50%; }
.a-open { fill: var(--art-ink); opacity: 0; } .a-shine { fill: #fffaf1; }
.art.poked .dm { animation: wriggle .9s ease-in-out; }
.art.poked .a-head { animation: nod .9s ease-in-out; }
.art.poked .a-earl { animation: flick .45s ease-in-out 2; } .art.poked .a-earr { animation: flick .45s ease-in-out .1s 2 reverse; }
.art.poked .a-tail { animation: swish .9s ease-in-out; }
.art.poked .a-eye { animation: eye-hide 1.1s steps(1, end) both; } .art.poked .a-open { animation: eye-show 1.1s steps(1, end) both; }
.art.poked .a-z { animation: scatter 1.1s ease-out both, zz 3.6s ease-in-out 1.1s infinite; }
@keyframes wriggle { 15% { transform: scale(1.06, .92); } 35% { transform: scale(.95, 1.07) translateY(-6px); } 55% { transform: rotate(-3deg); } 75% { transform: rotate(2deg); } }
@keyframes nod { 30% { transform: rotate(-9deg); } 65% { transform: rotate(5deg); } }
@keyframes flick { 50% { transform: rotate(-22deg) scale(1.1); } }
@keyframes swish { 25% { transform: rotate(-24deg); } 60% { transform: rotate(16deg); } }
@keyframes eye-hide { 0%, 84% { opacity: 0; } 85%, 100% { opacity: 1; } }
@keyframes eye-show { 0%, 84% { opacity: 1; } 85%, 100% { opacity: 0; } }
@keyframes scatter { 0% { opacity: 1; transform: none; } 40% { opacity: 0; transform: translate(14px, -18px) scale(1.4); } 70% { opacity: 0; transform: translateY(6px); } 100% { opacity: .15; transform: translateY(3px); } }
.hero h1 { font-size: clamp(2.8rem, 9.5vw, 3.6rem); line-height: 1; margin-top: .15rem; color: color-mix(in srgb, var(--accent-d) 42%, var(--ink)); }
.hero p { color: var(--muted); margin-top: .45rem; }
.a-leaf { fill: url(#dm-leaf); stroke: #909457; stroke-width: 1.6; stroke-linejoin: round; }
.a-rib { fill: none; stroke: #8d8052; stroke-width: 2.2; stroke-linecap: round; opacity: .75; }
.a-vein { fill: none; stroke: #8d8052; stroke-width: 1.5; stroke-linecap: round; opacity: .5; }
.a-nest { fill: url(#dm-nest); stroke: #8a5e42; stroke-width: 1.8; stroke-linejoin: round; }
.a-fur { fill: url(#dm-fur); stroke: #7f5438; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.a-ear { fill: #f2cab8; stroke: #b47e63; stroke-width: 1.1; }
.a-blush { fill: #e39582; opacity: .45; }
.a-tuft { fill: none; stroke: #8c5e3c; stroke-width: 1.6; stroke-linecap: round; opacity: .55; }
.a-haunch, .a-fold { fill: none; stroke: #7f5438; stroke-width: 2; stroke-linecap: round; }
.a-tail-fill { fill: #e3b996; stroke: #7f5438; stroke-width: 1.9; stroke-linejoin: round; }
.a-nose { fill: #5a3c28; }
.a-eye { fill: none; stroke: #5a3c28; stroke-width: 2.6; stroke-linecap: round; }
.a-whisker { fill: none; stroke: #7a5238; stroke-width: 1.3; stroke-linecap: round; opacity: .7; }
.a-z { fill: var(--muted); font: 700 18px var(--display); animation: zz 3.6s ease-in-out infinite; }
.a-z.z2 { font-size: 15px; animation-delay: .5s; } .a-z.z3 { font-size: 12px; animation-delay: 1s; }
@keyframes zz { 0%, 100% { opacity: .15; transform: translateY(3px); } 50% { opacity: 1; transform: none; } }
.menu { display: grid; gap: .9rem; }
.card {
  position: relative; display: flex; align-items: center; gap: .9rem; overflow: hidden;
  background-color: var(--panel); background-image: var(--linen);
  border-radius: 1.15rem; padding: 1.05rem 1.35rem;
  box-shadow: 0 2px 0 rgba(105, 80, 48, .18), var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.card::after {
  content: ""; position: absolute; inset: 6px; border-radius: .82rem;
  border: 2px dashed var(--stitch); pointer-events: none; opacity: .78;
}
.card-ic { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; flex: none; color: var(--accent); }
.card-ic .ic { width: 1.7rem; height: 1.7rem; }
.card-txt { min-width: 0; }
.card b { display: block; font-size: 1.15rem; font-weight: 800; line-height: 1.25; }
.card span { color: var(--muted); font-size: .88rem; }
.card.primary { background-color: var(--accent); background-image: var(--linen); color: var(--accent-ink); box-shadow: 0 2px 0 var(--accent-d), var(--shadow); }
.card.primary::after { border-color: color-mix(in srgb, var(--tile-d) 85%, var(--accent)); opacity: .88; }
.card.primary .card-ic { color: var(--accent-ink); }
.card.primary span { color: inherit; opacity: .92; }
.card.today {
  background-color: var(--panel);
  background-image: var(--floral-top), var(--floral-bot), var(--linen);
  background-repeat: repeat-x, repeat-x, repeat;
  background-position: top center, bottom center, 0 0;
}
.card.free {
  background-color: color-mix(in srgb, var(--tile) 30%, var(--panel));
  background-image: var(--floral-top), var(--linen);
  background-repeat: repeat-x, repeat;
  background-position: top center, 0 0;
}
.card.free .card-ic { color: var(--ink); }
.card:hover { transform: translateY(-2px); }
.card:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(105, 80, 48, .18), var(--shadow); }
.home footer { display: flex; flex-wrap: wrap; justify-content: center; gap: .2rem 1.25rem; white-space: nowrap; }
.link { color: color-mix(in srgb, var(--accent-d) 78%, var(--ink)); font-weight: 800; padding: .4rem; border-radius: .5rem; }
[data-theme="dark"] .link { color: var(--accent); }
.link:hover { color: var(--ink); }

/* ---- pages ---- */
.page { position: relative; z-index: 1; max-width: 44rem; margin: 0 auto; padding: 0 1rem 3rem; }
.bar { display: flex; align-items: center; gap: .6rem; padding: max(.6rem, env(safe-area-inset-top)) .2rem .6rem; }
.bar h1 { font-size: 1.4rem; } .spacer { flex: 1; }
.iconbtn { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--panel); border: 1.5px solid var(--rim); box-shadow: 0 2px 0 var(--rim), var(--shadow); flex: none; }
.iconbtn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--rim); }
.iconbtn.small { width: 1.9rem; height: 1.9rem; border: 0; box-shadow: none; background: transparent; font-size: 1.3rem; line-height: 1; }
.chapters { display: grid; gap: .95rem; }
.chapter {
  position: relative; background-color: var(--panel); background-image: var(--linen);
  border-radius: 1.15rem; padding: 1.1rem 1.3rem 1.2rem;
  box-shadow: 0 2px 0 rgba(105, 80, 48, .15), var(--shadow);
}
.chapter::after {
  content: ""; position: absolute; inset: 5px; border-radius: .85rem;
  border: 1.5px dashed color-mix(in srgb, var(--stitch) 55%, transparent); pointer-events: none;
}
.chapter h2 { font-size: 1.15rem; display: flex; align-items: center; gap: .55rem; }
.chapter h2 small { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--tile); color: #fff; font-size: .8rem; }
.chapter p { color: var(--muted); font-size: .92rem; margin: .15rem 0 .8rem; }
.chapter.locked { opacity: .55; }
.rec p:last-child { margin-bottom: 0; }
.rec ol { margin: 0; padding: 0; list-style: none; counter-reset: rank; display: grid; gap: .1rem; }
.rec li { counter-increment: rank; display: grid; grid-template-columns: 1.6rem minmax(3.2rem, auto) auto 1fr; align-items: center; gap: .7rem; padding: .3rem 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rec li::before { content: counter(rank); color: var(--muted); font-weight: 800; font-size: .85rem; }
.rec li .muted { text-align: right; font-size: .88rem; }
.rec ol.plain li { grid-template-columns: minmax(3.2rem, auto) auto 1fr; } .rec ol.plain li::before { content: none; }
.rec ol.days li { display: block; padding: 0; }
.rec ol.days button { width: 100%; display: grid; grid-template-columns: minmax(3.2rem, auto) auto 1fr auto; align-items: center; gap: .7rem; padding: .35rem .2rem; border-radius: .6rem; text-align: left; font-variant-numeric: tabular-nums; }
.rec ol.days button .ic { color: var(--muted); } .rec ol.days button .muted { text-align: right; font-size: .88rem; }
.rec ol.days button:hover { background: var(--bg); } .rec ol.days button:hover .ic { color: var(--accent); }
.levels { display: flex; flex-wrap: wrap; gap: .55rem; }
.lv { width: 4.1rem; padding: .5rem 0 .4rem; border-radius: .9rem; background: var(--bg); display: grid; justify-items: center; gap: .1rem; transition: transform .12s; }
.lv b { font-size: 1.2rem; font-weight: 800; }
.lv:not(:disabled):hover { transform: translateY(-2px); }
.lv:disabled { cursor: default; opacity: .45; }
.lv.done { background: color-mix(in srgb, var(--tile) 26%, var(--panel)); }
.stars { letter-spacing: .05em; font-size: .8rem; } .stars i { font-style: normal; color: var(--line); } .stars i.on { color: #e3a52c; }

.form { display: grid; gap: 1rem; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 800; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .4rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { padding: .5rem .95rem; border-radius: 999px; background: var(--panel); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 700; }
.chip.tall { border-radius: .9rem; display: grid; text-align: left; } .chip small { font-weight: 500; color: var(--muted); }
.chip.on { background: var(--ink); color: var(--bg); box-shadow: none; } .chip.on small { color: inherit; opacity: .75; }
.chip:disabled { opacity: .4; cursor: default; }
.chip.rand { display: inline-flex; align-items: center; gap: .35rem; border: 1.5px dashed var(--line); box-shadow: none; }
.chip.rand.on { border-color: transparent; }
.go { display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: sticky; bottom: 0; padding: .8rem 0 max(.8rem, env(safe-area-inset-bottom)); }
.btn { padding: .7rem 1.3rem; border-radius: 999px; font-weight: 800; background: var(--panel); border: 1.5px solid var(--rim); box-shadow: 0 2px 0 var(--rim); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-d); box-shadow: 0 2px 0 var(--accent-d); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.big { padding: .85rem 2.4rem; font-size: 1.1rem; }
.btn:active { transform: translateY(1px); }

/* ---- game ---- */
.game { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg2); background-image: inherit; }
.game .bar { position: relative; z-index: 2; padding-left: max(.7rem, env(safe-area-inset-left)); padding-right: max(.7rem, env(safe-area-inset-right)); }
.title { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.title b { font-family: var(--display); font-size: 1.08rem; }
.title b, .title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title span { color: var(--muted); font-size: .82rem; }
.stat { display: flex; align-items: center; gap: .3rem; background: var(--panel); border-radius: 999px; padding: .32rem .72rem; font-weight: 800; font-variant-numeric: tabular-nums; border: 1.5px solid var(--rim); box-shadow: 0 2px 0 var(--rim), var(--shadow); }
.stat.hearts { gap: .15rem; } .stat.hearts:empty { display: none; }
.stat.hearts > span { display: grid; position: relative; }
.stat.hearts .split { position: absolute; inset: 0; display: grid; pointer-events: none; }
.stat.hearts .split .heart-l, .stat.hearts .split .heart-r { transform-box: fill-box; transform-origin: center; }
.stat.hearts .burst .heart-l { animation: crack-l .65s cubic-bezier(.2, .7, .4, 1) both; }
.stat.hearts .burst .heart-r { animation: crack-r .65s cubic-bezier(.2, .7, .4, 1) both; }
@keyframes crack-l { 0% { transform: scale(1.18); opacity: 1; } 25% { transform: translate(-4px, -3px) rotate(-14deg) scale(1.08); opacity: 1; } 100% { transform: translate(-11px, 16px) rotate(-36deg) scale(.75); opacity: 0; } }
@keyframes crack-r { 0% { transform: scale(1.18); opacity: 1; } 25% { transform: translate(4px, -3px) rotate(14deg) scale(1.08); opacity: 1; } 100% { transform: translate(11px, 16px) rotate(36deg) scale(.75); opacity: 0; } }
.bit { position: absolute; left: 50%; top: 50%; width: .3rem; height: .3rem; margin: -.15rem; border-radius: 50%; background: var(--heart); pointer-events: none; animation: bit .6s ease-out .08s both; }
.bit:nth-child(odd) { width: .22rem; height: .22rem; margin: -.11rem; }
@keyframes bit { 0% { transform: rotate(var(--a)) translateY(0) scale(1.2); opacity: 1; } 100% { transform: rotate(var(--a)) translateY(-1.4rem) scale(.2); opacity: 0; } }
.stat.time { min-width: 3.6rem; justify-content: center; }
.hint-src-ui { outline: 3px solid var(--ink); outline-offset: 2px; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem .6rem; padding: 0 .7rem .5rem; font-size: .88rem; font-weight: 700; }
.lg { display: flex; align-items: center; gap: .35rem; background: var(--panel); border-radius: 999px; padding: .2rem .7rem .2rem .3rem; }
.lg i { width: 1.15rem; height: 1.15rem; border-radius: .35rem; background: var(--c); }
.lg.zero { opacity: .5; }
.lg.tw i { background: var(--c4); position: relative; }
.lg.tw i::after { content: "••"; position: absolute; inset: 0; font: 800 .6rem/1.15rem var(--font); text-align: center; color: #40382f; font-style: normal; }
.k0 { --c: var(--c0); } .k1 { --c: var(--c1); } .k2 { --c: var(--c2); } .k3 { --c: var(--c3); } .k4 { --c: var(--c4); }

.stage { flex: 1; min-height: 0; position: relative; display: flex; }
.boardwrap { flex: 1; min-width: 0; min-height: 0; position: relative; overflow: hidden; touch-action: none; outline: none; }
.boardwrap.pannable { cursor: grab; }
.boardwrap.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }
.board { position: absolute; left: 0; top: 0; display: block; overflow: visible; transform-origin: 0 0; will-change: transform; }
.board.entering .enter { animation-play-state: paused; }
.board text { font-family: var(--font); font-weight: 800; text-anchor: middle; pointer-events: none; }
.garden-frame { pointer-events: none; }
.bed-soil { fill: var(--ground-d); }
.wood { fill: var(--wood); stroke: var(--wood-d); stroke-width: 3.5; stroke-linejoin: round; }
.wood-grain { fill: none; stroke: var(--wood-g); stroke-width: 2.2; stroke-linecap: round; opacity: .55; }
.wood-peg { fill: var(--wood-d); opacity: .75; }

.cell { --t: var(--tile); --d: var(--tile-d); cursor: pointer; }
.cell.v1:not(.kc):not(.twin) { --t: color-mix(in srgb, var(--tile) 94%, #fff); }
.cell.v2:not(.kc):not(.twin) { --t: color-mix(in srgb, var(--tile) 94%, var(--tile-d)); }
.cell.kc { --t: var(--c); --d: color-mix(in srgb, var(--c) 72%, #2c2116); }
.cell.twin { --t: var(--c4); --d: color-mix(in srgb, var(--c4) 72%, #2c2116); }
.cell polygon { stroke-width: 20; stroke-linejoin: round; }
.cell .base { fill: var(--d); stroke: var(--d); transform: translateY(7px); }
.cell .top { fill: var(--t); stroke: var(--t); transform: translateY(-3px); transition: fill .18s, stroke .18s; }
.cell .ct { transform-box: fill-box; }
.cell:not(.open) .ct { translate: 0 -3px; }
@media (hover: hover) { .cell:not(.open):hover { --t: color-mix(in srgb, var(--tile) 80%, #fff); } .cell.kc:not(.open):hover, .cell.twin:not(.open):hover { --t: color-mix(in srgb, var(--c, var(--c4)) 78%, #fff); } }
.cell.open { cursor: default; }
.cell.open .base { display: none; }
.cell.open .top { transform: none; opacity: 0; }
.cell.open:not(.pop) .top { stroke: none; }
.floor { --f: var(--ground); fill: var(--f); stroke: color-mix(in srgb, var(--ink) 9%, var(--f)); stroke-width: 2.5; stroke-linejoin: round; pointer-events: none; visibility: hidden; }
.floor.on { visibility: visible; }
.floor.kc { --f: color-mix(in srgb, var(--c) 24%, var(--ground)); }
.floor.twin { --f: color-mix(in srgb, var(--c4) 20%, var(--ground)); }
.cell.woken { --t: color-mix(in srgb, var(--heart) 38%, var(--ground)); --d: color-mix(in srgb, var(--heart) 56%, #2c2116); }
.cell.shown { --t: color-mix(in srgb, var(--tile) 42%, var(--ground)); }
.cell.wrong .leafmark { opacity: .45; }
.cross { stroke: var(--heart); stroke-width: 9; stroke-linecap: round; fill: none; }
[data-motion="on"] .cell.pop.open .top { animation: peel .26s ease-out both; animation-delay: inherit; }
[data-motion="on"] .cell.pop .ct { animation: fadein .24s both; animation-delay: inherit; }
[data-motion="on"] .cell.pop.leaf .leafmark { animation: leafdrop .28s cubic-bezier(.2, .85, .35, 1.08) both; }
[data-motion="on"] .cell.pop.leaf .puffs circle { animation: puff .36s ease-out both; }
[data-motion="on"] .cell.pop.woken .mouse { animation: startle .45s cubic-bezier(.2, 1.35, .4, 1) both; }
[data-motion="on"] .cell.pop.woken .sparks { animation: sparks .5s ease-out both; }
@keyframes peel { 0% { opacity: 1; transform: translateY(-3px); } 100% { opacity: 0; transform: translateY(-11px); } }
@keyframes leafdrop { 0% { opacity: 0; transform: translate(-7px, -22px) rotate(-18deg) scale(1.16); } 65% { opacity: 1; transform: translate(3px, 2px) rotate(5deg) scale(.96); } 100% { opacity: 1; transform: none; } }
@keyframes puff { 0% { opacity: .85; transform: scale(.5); } 100% { opacity: 0; transform: scale(1.7); } }
@keyframes startle { 0% { transform: scale(.6) translateY(10px); } 45% { transform: scale(1.14, .92) translateY(-7px); } 75% { transform: scale(.96, 1.05) translateY(0); } 100% { transform: none; } }
@keyframes sparks { 0% { opacity: 0; transform: scale(.5); } 35% { opacity: 1; transform: scale(1.12); } 100% { opacity: .9; transform: scale(1); } }
/* A new board: its tiles fly in from beyond the edges (delays, origins and directions are set per tile). */
.cell.enter { animation: flyin .46s cubic-bezier(.2, .9, .3, 1.12) both; }
.floor.enter, .lbl.enter { animation: fadein .42s ease-out both; }
.lbl.enter { animation-delay: .3s; }
@keyframes flyin { from { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.4); } 60% { opacity: 1; } }
.cell .ct.poked .mouse { transform-box: fill-box; transform-origin: 50% 80%; animation: wriggle .7s ease-in-out; }
@keyframes fadein { from { opacity: 0; } }

.n { font-size: 54px; fill: var(--ink); }
.n1 { fill: var(--n1); } .n2 { fill: var(--n2); } .n3 { fill: var(--n3); } .n4 { fill: var(--n4); }
.n5 { fill: var(--n5); } .n6 { fill: var(--n6); } .n7 { fill: var(--n7); } .n8, .n9 { fill: var(--n8); }
.kc .n, .twin .n { fill: var(--ink); }
.n.wide { font-size: 42px; } .n.owl { font-size: 44px; } .n.owl.wide { font-size: 34px; }
.grid-tri .n { font-size: 46px; } .grid-tri .n.wide { font-size: 36px; }
.ring { fill: none; stroke: var(--ink); stroke-width: 4.5; stroke-dasharray: 2 9; stroke-linecap: round; opacity: .75; }
.n.sp { font-size: 42px; } .grid-tri .n.sp { font-size: 34px; }
.n.s0, .spm.s0 { fill: var(--s0); } .n.s1, .spm.s1 { fill: var(--s1); }
.n.zero { opacity: .35; }
.twindots { fill: #40382f; opacity: .75; }
.mark { fill: #40382f; opacity: .5; display: none; } [data-markers="on"] .mark { display: inline; }
.leaf .mark, .woken .mark, .shown .mark { display: none !important; }
.lbl circle { fill: var(--panel); stroke: var(--line); stroke-width: 3; }
.lbl text { font-size: 34px; fill: var(--ink); }
.lbl { cursor: pointer; transition: opacity .2s; } .lbl.done { opacity: .35; }

.cell .edge { fill: none; stroke: none; stroke-width: 0; stroke-linejoin: round; transform: translateY(-3px); pointer-events: none; }
.cell.open .edge { transform: none; }
.cell.hl:not(.open) .edge { stroke: var(--ink); stroke-width: 7; stroke-opacity: .4; }
.cell.hint-src .edge { stroke: var(--ink); stroke-width: 7; }
.cell.cursor .edge { stroke: var(--accent); stroke-width: 7; stroke-dasharray: 14 8; }
.cell.hint-safe .edge { stroke: var(--ok); stroke-width: 10; animation: pulse 1s ease-in-out 3; }
.cell.hint-mine .edge { stroke: var(--accent); stroke-width: 10; animation: pulse 1s ease-in-out 3; }
.cell.hint-wrong .edge { stroke: var(--heart); stroke-width: 10; animation: pulse 1s ease-in-out 3; }
.cell.hint-safe .top { fill: color-mix(in srgb, var(--t) 70%, #fff); }
.lbl.hint-src circle { stroke: var(--ink); stroke-width: 7; }
@keyframes pulse { 50% { stroke-opacity: .35; } }

.hintbar { position: absolute; z-index: 2; left: .7rem; right: .7rem; bottom: .5rem; margin: 0 auto; max-width: 40rem; background: var(--panel); border-radius: 1rem; padding: .6rem .5rem .6rem 1rem; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: .4rem; border-left: 5px solid var(--muted); -webkit-user-select: text; user-select: text; }
.hintbar[hidden] { display: none; }
.hintbar p { margin: 0; flex: 1; font-size: .95rem; }
.hintbar.safe { border-color: var(--ok); } .hintbar.mine { border-color: var(--accent); } .hintbar.wrong, .hintbar.toast { border-color: var(--heart); }
.hintbar.top { bottom: auto; top: .5rem; }
.hintbar.toast { pointer-events: none; } .hintbar.toast button { display: none; }
.tools { position: relative; z-index: 2; display: flex; justify-content: center; align-items: stretch; gap: .5rem; padding: 0 .7rem max(.7rem, env(safe-area-inset-bottom)); }
.tool, .mode button { display: flex; align-items: center; gap: .4rem; padding: .5rem .95rem; border-radius: 999px; font-weight: 800; }
.tool { background: var(--panel); border: 1.5px solid var(--rim); box-shadow: 0 2px 0 var(--rim), var(--shadow); }
.tool:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--rim); }
.mode { display: flex; background: var(--panel); border-radius: 999px; border: 1.5px solid var(--rim); box-shadow: 0 2px 0 var(--rim), var(--shadow); padding: .2rem; }
.mode button { padding: .32rem .85rem; } .mode button.on { background: var(--ink); color: var(--bg); }
/* Narrow phones: the side buttons show only their icons, and the Turn / Leaf switch keeps its words (they say what a tap does) but drops its icons, which leaves room for longer words in other languages. */
@media (max-width: 30rem) { .tool span { display: none; } .tool { padding: .65rem .8rem; } .tools { gap: .4rem; } .mode button { padding: .35rem .75rem; } .mode button .ic { display: none; } .stat { padding: .3rem .55rem; } .title span { display: none; } }
@media (max-width: 22rem) { .tools { gap: .3rem; padding-left: .4rem; padding-right: .4rem; } .tool { padding: .6rem .6rem; } .mode button { padding: .35rem .55rem; } }
/* Short screens (a phone on its side): the controls get their own column on the right, so they never cover the board. */
@media (max-height: 30rem) {
  .game { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "bar bar" "legend legend" "stage tools"; }
  .game > .bar { grid-area: bar; padding-top: .3rem; padding-bottom: .3rem; } .game > .legend { grid-area: legend; } .game > .stage { grid-area: stage; }
  .tools { grid-area: tools; flex-direction: column; justify-content: center; align-items: center; padding: .3rem max(.6rem, env(safe-area-inset-right)) max(.4rem, env(safe-area-inset-bottom)) .5rem; }
  .mode { flex-direction: column; }
  .tool span, .mode span { display: none; }
}

/* ---- dialogs ---- */
dialog { border: 0; padding: 0; background: transparent; color: inherit; max-width: min(32rem, calc(100vw - 1.6rem)); max-height: calc(100dvh - 1.6rem); }
dialog::backdrop { background: rgba(40, 30, 20, .52); }
dialog:focus-visible, .sheet:focus-visible { outline: none; }
dialog[open] { animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.sheet { position: relative; background-color: var(--panel); background-image: var(--linen); border-radius: 1.3rem; padding: 1.5rem 1.5rem 1.2rem; border: 1.5px solid var(--rim); box-shadow: 0 3px 0 var(--rim), var(--shadow); overflow: auto; max-height: calc(100dvh - 1.6rem); -webkit-user-select: text; user-select: text; }
.sheet h2 { font-size: 1.3rem; margin-bottom: .5rem; }
.sheet section + section { margin-top: 1.1rem; padding-top: 1rem; border-top: 1.5px solid var(--line); }
.sheet .how { background: var(--bg); border-radius: .8rem; padding: .7rem .9rem; }
.sheet label { display: block; font-weight: 800; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .9rem 0 .35rem; }
.row { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--bg); border-radius: 1.2rem; padding: .2rem; }
.seg button { white-space: nowrap; }
.seg button { padding: .35rem .95rem; border-radius: 999px; font-weight: 700; } .seg button.on { background: var(--ink); color: var(--bg); }
.result { text-align: center; min-width: min(20rem, 80vw); }
.result .big { display: inline-block; padding: 0; border-radius: 50%; }
.result .big .ic { width: 4.5rem; height: 4.5rem; transform-origin: 50% 80%; }
.result .big.poked .ic { animation: wriggle .8s ease-in-out; }
.result .big.awake .ic { animation: shake .5s 2; }
.result .stars { font-size: 1.7rem; display: block; margin-bottom: .4rem; }
.result .row { justify-content: center; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -5vh; width: .8rem; height: 1.15rem; border-radius: 80% 10% 80% 10%; background: color-mix(in srgb, var(--tile) calc(var(--k) * 25%), var(--leafc)); animation: fall linear both; will-change: transform; }
@keyframes fall { from { transform: translate3d(0, 0, 0) rotate(var(--r)); } to { transform: translate3d(0, 112vh, 0) rotate(calc(var(--r) + 540deg)); } }
[data-motion="off"] *, [data-motion="off"] *::before { animation-duration: .01s !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; } }
.rec h2 + ol { margin-top: .6rem; }
.record { display: grid; gap: .1rem; margin: .2rem auto .7rem; padding: .55rem 1rem; width: fit-content; border-radius: .9rem; background: color-mix(in srgb, #e3a52c 22%, var(--panel)); border: 2px solid #e3a52c; }
.record b { font-size: 1.15rem; font-weight: 800; letter-spacing: .02em; }
.record span { font-size: .9rem; }
[data-motion="on"] .record { animation: cheer .7s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes cheer { from { opacity: 0; transform: scale(.6) rotate(-4deg); } }
.about { text-align: center; min-width: min(20rem, 80vw); }
.about .big .ic { width: 4rem; height: 4rem; }
.about .links { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.about .links a { background: var(--bg); border-radius: 999px; padding: .4rem .9rem; font-weight: 800; color: var(--accent); }
.about .row { justify-content: center; }
