[hidden] { display: none !important; }
:root {
  --bg: #f7f3ea; --fg: #23261f; --muted: #5f6557; --card: #fffdf8; --line: #3a3f34; --thin: rgba(58,63,52,.2);
  --accent: #3f7d4c; --accent-fg: #fff; --bad: #b3261e; --hl: #f0b429; --gold: #e8b931;
  --r0: #f3d9a4; --r1: #bfd8b0; --r2: #b7d3ee; --r3: #f2c4c9; --r4: #e3b9a0; --r5: #d3c4ec; --r6: #abddd3; --r7: #f6e58f; --r8: #c9d3dd; --r9: #e6c9e9;
  --stone: #8d8a82; --stone-fg: #fff; --x: rgba(35,38,31,.55);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d201c; --fg: #f1f0ea; --muted: #b9bdb0; --card: #2a2e28; --line: #0d0e0c; --thin: rgba(0,0,0,.35);
  --accent: #7cc48a; --accent-fg: #102313; --bad: #ff8a80; --hl: #ffd166;
  --r0: #9a8550; --r1: #66885a; --r2: #5a7ea6; --r3: #a86d78; --r4: #9c6e57; --r5: #7b6cab; --r6: #458f81; --r7: #a09445; --r8: #6b7a8c; --r9: #94699a;
  --stone: #3e3c38; --stone-fg: #ffffff; --x: rgba(255,255,255,.8);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d201c; --fg: #f1f0ea; --muted: #b9bdb0; --card: #2a2e28; --line: #0d0e0c; --thin: rgba(0,0,0,.35);
    --accent: #7cc48a; --accent-fg: #102313; --bad: #ff8a80; --hl: #ffd166;
    --r0: #9a8550; --r1: #66885a; --r2: #5a7ea6; --r3: #a86d78; --r4: #9c6e57; --r5: #7b6cab; --r6: #458f81; --r7: #a09445; --r8: #6b7a8c; --r9: #94699a;
    --stone: #3e3c38; --stone-fg: #ffffff; --x: rgba(255,255,255,.8);
    color-scheme: dark;
  }
}
/* Boss gardens: a frosty palette */
body.boss {
  --r0: #dcefff; --r1: #c4e3f7; --r2: #e6e1fb; --r3: #cfeaf0; --r4: #b7d4ef; --r5: #f0f7ff; --r6: #d3dcf5; --r7: #bfe9e4; --r8: #e1edf7; --r9: #cad5ea;
  --line: #2d4d6b; --accent: #2f7fb5; --bg: #eaf3fa;
  background-image: radial-gradient(circle at 15% 10%, rgba(255,255,255,.9) 0 2px, transparent 3px), radial-gradient(circle at 70% 30%, rgba(255,255,255,.8) 0 1.5px, transparent 2.5px), radial-gradient(circle at 40% 80%, rgba(255,255,255,.8) 0 2px, transparent 3px);
  background-size: 120px 120px, 90px 90px, 150px 150px;
}
:root[data-theme="dark"] body.boss { --bg: #14202b; --r0: #2b4a63; --r1: #24445a; --r2: #3a3f6a; --r3: #22505a; --r4: #2f4f73; --r5: #3c4f66; --r6: #33406b; --r7: #245a55; --r8: #34495c; --r9: #3d4766; --line: #08121b; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; -webkit-appearance: none; appearance: none; }
.top { width: 100%; max-width: 560px; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 6px; }
.top-right { display: flex; gap: 5px; }
.brand { margin: 0; font-size: 1.5rem; font-weight: 750; }
.brand-btn { background: none; border: 0; padding: 0; display: flex; align-items: center; gap: 6px; font-weight: 750; cursor: pointer; letter-spacing: .3px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--thin); background: var(--card); font-size: 1.05rem; cursor: pointer; padding: 0; }
main { width: 100%; max-width: 560px; padding: 0 12px; flex: 1; }
.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .92rem; margin: 2px 0 10px; flex-wrap: wrap; }
.pill { background: var(--card); border: 1px solid var(--thin); border-radius: 99px; padding: 1px 10px; color: var(--fg); font-size: .82rem; }
.chances { display: inline-flex; gap: 2px; font-size: .95rem; }
.chances .lost { opacity: .22; filter: grayscale(1); }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; }
.banner { background: var(--card); border: 1px dashed var(--muted); border-radius: 10px; padding: 6px 10px; font-size: .85rem; color: var(--muted); margin: 0 0 10px; }

/* ---- Board: uniform square cells from first paint ---- */
.board-wrap { width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board { --n: 6; display: grid; width: 100%; aspect-ratio: 1 / 1;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  border: 3px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--line); container-type: inline-size; position: relative; }
.cell { position: relative; display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0;
  overflow: hidden; cursor: pointer; line-height: 1; font-size: 0; }
.cell > * { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.cell .mark-x { font-size: calc(46cqw / var(--n)); color: var(--x); }
.cell .sprout { width: 62%; height: 62%; }
.cell.stone .stone-shape { width: 74%; height: 74%; border-radius: 42% 50% 46% 54%; background: var(--stone); color: var(--stone-fg);
  display: grid; place-items: center; font-weight: 750; font-size: calc(48cqw / var(--n)); box-shadow: inset -3px -4px 0 rgba(0,0,0,.18); }
.cell.stone.frost .stone-shape { background: linear-gradient(160deg, #ffffff, #b9def5 60%, #8fc6ea); color: #2a6a96; box-shadow: inset -2px -3px 0 rgba(42,106,150,.25), 0 0 6px rgba(255,255,255,.9); }
.cell.stone.thawed .stone-shape { animation: thaw .9s ease-out both; }
@keyframes thaw { 0% { background: #e8f6ff; transform: translate(-50%,-50%) scale(1.25); filter: brightness(1.4); } 100% { transform: translate(-50%,-50%) scale(1); } }
.cell:focus-visible { outline: 3px solid var(--hl); outline-offset: -3px; z-index: 2; }
.cell.bad::after, .cell.badclue::after { content: ""; position: absolute; inset: 3px; border: 3px solid var(--bad); border-radius: 8px; transform: none; left: auto; top: auto; }
.cell.focus::before { content: ""; position: absolute; inset: 0; transform: none; left: 0; top: 0; box-shadow: inset 0 0 0 3px var(--hl); background: rgba(255,255,255,.18); }
.cell.target::after { content: ""; position: absolute; inset: 3px; transform: none; left: auto; top: auto; border: 3px dashed var(--hl); border-radius: 8px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.cell.shake > * { animation: shake .35s; }
@keyframes shake { 25% { transform: translate(-60%, -50%); } 75% { transform: translate(-40%, -50%); } }
.board.won .cell { cursor: default; }
.sprout { display: inline-block; width: 1em; height: 1em; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 56V30' stroke='%232f5d3a' stroke-width='6' stroke-linecap='round'/%3E%3Cpath d='M32 33C32 21 23 14 10 14c0 12 9 19 22 19z' fill='%233f7d4c'/%3E%3Cpath d='M32 29c0-11 8-17 20-17 0 11-8 17-20 17z' fill='%235fa865'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] .cell .sprout { filter: drop-shadow(0 0 1.5px rgba(255,255,255,.75)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cell .sprout { filter: drop-shadow(0 0 1.5px rgba(255,255,255,.75)); } }

/* ---- Win cascade ---- */
.cell.bloom .sprout { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 60V36' stroke='%232f5d3a' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M32 50c-2-7-9-10-16-9 2 7 9 10 16 9z' fill='%235fa865'/%3E%3Cg fill='%23f49ab3'%3E%3Ccircle cx='32' cy='14' r='9'/%3E%3Ccircle cx='45' cy='23' r='9'/%3E%3Ccircle cx='40' cy='37' r='9'/%3E%3Ccircle cx='24' cy='37' r='9'/%3E%3Ccircle cx='19' cy='23' r='9'/%3E%3C/g%3E%3Ccircle cx='32' cy='26' r='7' fill='%23f6c453'/%3E%3C/svg%3E");
  width: 78%; height: 78%; animation: bloom .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.cell.bloom::before { content: ""; position: absolute; inset: 0; left: 0; top: 0; transform: none; background: radial-gradient(circle, rgba(255,236,150,.85), transparent 70%); animation: glow 1.4s ease-out both; }
@keyframes bloom { 0% { transform: translate(-50%,-50%) scale(.5) rotate(-25deg); } 60% { transform: translate(-50%,-50%) scale(1.3) rotate(8deg); } 100% { transform: translate(-50%,-50%) scale(1); } }
@keyframes glow { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: .35; } }
.board.harvest { animation: harvest 1.2s ease-out both; }
@keyframes harvest { 0% { box-shadow: 0 0 0 0 rgba(246,196,83,.0); } 40% { box-shadow: 0 0 0 10px rgba(246,196,83,.55), 0 0 40px 10px rgba(246,196,83,.5); } 100% { box-shadow: 0 0 0 3px rgba(246,196,83,.5), 0 0 24px 4px rgba(246,196,83,.25); } }
canvas.fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
@media (prefers-reduced-motion: reduce) {
  .cell.target::after, .cell.bloom .sprout, .cell.bloom::before, .board.harvest, .cell.thawed .stone-shape, .cell.shake > * { animation: none !important; }
}

.toolbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.tool, .primary { min-height: 44px; border-radius: 12px; border: 1px solid var(--thin); background: var(--card); font-size: .9rem; cursor: pointer; padding: 6px 10px; }
.tool small { color: var(--muted); }
.tool:disabled { opacity: .55; cursor: not-allowed; }
.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 650; }
.primary.big { min-height: 54px; font-size: 1.1rem; border-radius: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.linkish { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 4px; font-size: .9rem; }
.reward-btn { border-style: dashed; }
.msg { min-height: 3em; margin: 12px 2px 6px; color: var(--muted); font-size: .95rem; }
.msg.warn { color: var(--bad); } .msg.good { color: var(--accent); }
.offer { margin: 0 0 10px; } .offer .tool { width: 100%; }
.slot { border: 2px dashed var(--muted); border-radius: 12px; padding: 10px 12px; margin: 10px 0; color: var(--muted); font-size: .82rem; background: repeating-linear-gradient(45deg, transparent 0 10px, var(--thin) 10px 11px); }
.slot p { margin: 4px 0 8px; }
.foot { color: var(--muted); font-size: .85rem; padding: 16px; text-align: center; }
.foot a { color: inherit; }
dialog { border: 0; border-radius: 20px; padding: 0; background: var(--card); color: var(--fg); width: min(92vw, 430px); max-height: 92dvh; }
dialog::backdrop { background: rgba(20,24,18,.5); }
.dlg { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.dlg h2 { margin: 0 0 4px; }
.rules { padding-left: 1.2em; margin: 0; } .rules li { margin: 4px 0; }
.small { font-size: .85rem; color: var(--muted); margin: 4px 0; } .center { text-align: center; }
.howto-demo { display: grid; grid-template-columns: 34px 1fr 34px 1fr; gap: 8px 10px; align-items: center; font-size: .85rem; margin: 6px 0; }
.demo-cell { width: 34px; height: 34px; border-radius: 6px; background: var(--r1); display: grid; place-items: center; border: 1.5px solid var(--line); }
.demo-cell.x { color: var(--x); font-size: 20px; } .demo-cell.seed .sprout { width: 24px; height: 24px; }
.demo-cell.stone { background: var(--stone); color: var(--stone-fg); font-weight: 750; border-radius: 45%; }

/* ---- Win card ---- */
dialog[open].done-dlg { animation: rise .55s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes rise { from { transform: translateY(40px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog[open].done-dlg { animation: none; } }
.done-hero { text-align: center; padding: 6px 0 2px; background: radial-gradient(circle at 50% 30%, rgba(246,196,83,.35), transparent 65%); border-radius: 16px; }
.done-emoji { font-size: 3.2rem; line-height: 1.1; }
.done-hero h2 { font-size: 2rem; margin: 2px 0; letter-spacing: .3px; }
.done-hero p { margin: 0; color: var(--muted); }
.chips { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--bg); border-radius: 99px; padding: 4px 12px; font-size: .92rem; font-variant-numeric: tabular-nums; }
.share-preview { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 2px 0; font: 1rem/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; text-align: center; }
.verse { margin: 4px 0; padding: 8px 12px; border-left: 4px solid var(--accent); font-style: italic; font-size: .92rem; }
.verse cite { display: block; font-style: normal; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.tomorrow { text-align: center; background: var(--bg); border-radius: 12px; padding: 8px; font-size: .95rem; }
details.slots { margin-top: 6px; font-size: .82rem; color: var(--muted); }
details.slots summary { cursor: pointer; }
.badge-award { text-align: center; }
.medal { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-size: 30px;
  background: radial-gradient(circle at 35% 30%, #fff, #bfe6ff 45%, #5aa6d6); border: 3px solid var(--gold); box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.medal.locked { background: var(--bg); border: 2px dashed var(--muted); filter: grayscale(1); opacity: .5; }
.medal.small { width: 42px; height: 42px; font-size: 20px; }

/* ---- Boss intro ---- */
.boss-dlg { background: linear-gradient(180deg, #f2f9ff, #d9ecfa); color: #183a55; text-align: center; }
.boss-dlg .boss-flake { font-size: 3.6rem; line-height: 1; color: #5aa6d6; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boss-dlg .boss-flake { animation: none; } }
.boss-kicker { margin: 0; text-transform: uppercase; letter-spacing: 2px; font-size: .78rem; color: #2f7fb5; font-weight: 700; }
.boss-dlg h2 { font-size: 1.8rem; }
.boss-rule { display: flex; gap: 10px; align-items: center; text-align: left; background: rgba(255,255,255,.7); border-radius: 12px; padding: 10px; font-size: .9rem; }
.frost-demo { flex: none; width: 40px; height: 40px; border-radius: 45%; display: grid; place-items: center; background: linear-gradient(160deg, #fff, #b9def5); color: #2a6a96; font-size: 20px; }
.boss-dlg .primary { background: #2f7fb5; color: #fff; }

/* ---- Practice path ---- */
.path-title { margin: 4px 0; }
.badges { display: flex; justify-content: center; gap: 12px; margin: 10px 0 4px; }
.badges figure { margin: 0; text-align: center; font-size: .72rem; color: var(--muted); width: 72px; }
.path { list-style: none; padding: 0; margin: 10px 0 20px; display: flex; flex-direction: column; gap: 10px; }
.path li { display: flex; }
.band { justify-content: center; font-weight: 700; color: var(--muted); font-size: .85rem; margin-top: 8px; letter-spacing: 1px; text-transform: uppercase; }
.node { width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--accent); background: var(--card); font-weight: 750; font-size: 1.05rem; cursor: pointer; position: relative; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.node.cleared { background: var(--accent); color: var(--accent-fg); }
.node.locked { border-color: var(--thin); color: var(--muted); cursor: not-allowed; background: var(--bg); box-shadow: none; }
.node.current { animation: pulse 1.6s ease-in-out infinite; }
.node.challenge { width: 62px; height: 62px; border-color: var(--gold); }
.node.boss { width: 80px; height: 80px; border-color: #2f7fb5; background: linear-gradient(160deg, #fff, #cfe8f8); color: #183a55; font-size: .8rem; }
.node.boss.cleared { background: radial-gradient(circle at 35% 30%, #fff, #bfe6ff 45%, #5aa6d6); border-color: var(--gold); }
.node.tutorial { width: auto; padding: 0 16px; border-radius: 99px; height: 44px; }
.node .tag { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .68rem; font-weight: 600; color: var(--muted); }
.ad-sim { width: min(92vw, 380px); text-align: center; }
.ad-sim-box { padding: 20px; display: flex; flex-direction: column; gap: 10px; align-items: center; background: repeating-linear-gradient(45deg, var(--card) 0 14px, var(--bg) 14px 28px); border-radius: 20px; }
.ad-sim-tag { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; border: 2px dashed var(--muted); border-radius: 8px; padding: 4px 10px; }
.ad-sim-big { font-size: 1.05rem; margin: 0; } .ad-sim-reward { margin: 0; color: var(--accent); font-weight: 650; }
.ad-sim-count span { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; border: 4px solid var(--accent); font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; } .stat span { font-size: .78rem; color: var(--muted); }
.r0{background:var(--r0)}.r1{background:var(--r1)}.r2{background:var(--r2)}.r3{background:var(--r3)}.r4{background:var(--r4)}.r5{background:var(--r5)}.r6{background:var(--r6)}.r7{background:var(--r7)}.r8{background:var(--r8)}.r9{background:var(--r9)}

.next-under { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 12px; }
.next-under[hidden] { display: none; }
.next-under .primary, .done-dlg .next-btn { width: 100%; }
.share-btn { min-height: 50px; font-weight: 650; border: 2px solid var(--accent); color: var(--accent); font-size: 1.02rem; border-radius: 14px; }
.finale { text-align: center; background: var(--bg); border-radius: 12px; padding: 10px; margin: 2px 0; }
.theme-btn { font-size: 1.15rem; }
:root[data-theme="dark"] .cell.stone .stone-shape { box-shadow: inset -3px -4px 0 rgba(0,0,0,.35), 0 0 0 1.5px rgba(255,255,255,.35); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cell.stone .stone-shape { box-shadow: inset -3px -4px 0 rgba(0,0,0,.35), 0 0 0 1.5px rgba(255,255,255,.35); } }

/* anonymous comparisons */
.compare { margin: 6px 0 2px; text-align: center; color: var(--fg); }
.compare p { margin: 2px 0; font-size: .95rem; line-height: 1.35; }
.compare p:first-child::before { content: "\1F331 "; }
