* { box-sizing: border-box; }
:root {
  --ink: #2b4136;
  --muted: #5d7a66;
  --paper: #fffdf5;
  --wood: #c98a55;
  --wood-dark: #9a6236;
  --soil: #8c5b3a;
  --grass-a: #cdeaa6;
  --grass-b: #bfe196;
  --focus: #7a3fc4;
  --gold: #ffcf4d;
  font-family: ui-rounded, "Avenir Next", Nunito, system-ui, sans-serif;
  color: var(--ink);
  background: #d7f1fb;
  font-synthesis: none;
}
body { margin: 0; min-height: 100vh; background: linear-gradient(#bfe8fb 0%, #e6f7fb 45%, #eaf7d8 100%); overflow-x: hidden; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, summary:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .45; }
[hidden] { display: none !important; }

/* Sky scenery */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sun { position: absolute; top: 34px; right: 7%; width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle, #fff6b8 0 45%, #ffd95a 46% 70%, #ffd95a00 71%); box-shadow: 0 0 60px 20px #fff2a855; animation: sun-glow 6s ease-in-out infinite; }
.cloud { position: absolute; height: 34px; border-radius: 40px; background: #ffffffd9; filter: drop-shadow(0 6px 0 #d4eef8); animation: drift 38s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; border-radius: 50%; background: inherit; }
.cloud::before { width: 46px; height: 46px; left: 16px; top: -22px; }
.cloud::after { width: 34px; height: 34px; left: 50px; top: -14px; }
.c1 { width: 120px; top: 120px; left: -10%; }
.c2 { width: 94px; top: 60px; left: 30%; animation-duration: 52s; animation-delay: -20s; opacity: .8; }
.c3 { width: 110px; top: 190px; left: 70%; animation-duration: 46s; animation-delay: -34s; opacity: .7; }
.hill { position: absolute; bottom: -180px; border-radius: 50%; }
.h1 { left: -10%; width: 70%; height: 340px; background: #c5e59e; }
.h2 { right: -12%; width: 75%; height: 300px; background: #b3db8c; bottom: -170px; }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(120vw); } }
@keyframes sun-glow { 50% { transform: scale(1.05); } }

.app { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 24px 30px 30px; }
.topbar { margin-bottom: 22px; }
.eyebrow { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; font-weight: 850; margin: 0 0 4px; color: var(--muted); }
h1 { margin: 0; font-size: clamp(26px, 3.2vw, 38px); letter-spacing: -1px; font-weight: 950; }
.top-tools { display: flex; align-items: center; gap: 12px; }
.earned { padding: 11px 16px; background: #ffffffc4; border-radius: 999px; font-size: 14px; font-weight: 850; white-space: nowrap; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 30px; align-items: start; }
.scene { background: #ffffff8c; border: 3px solid #fff; border-radius: 34px; padding: 20px 26px 16px; box-shadow: 0 16px 44px #3e7a4a1f; backdrop-filter: blur(6px); }
.scene-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.scene-heading p { margin: 0 0 3px; font-size: 12px; font-weight: 850; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.scene-heading h2 { margin: 0; font-size: 26px; letter-spacing: -.6px; }
.meter { display: grid; gap: 5px; justify-items: end; min-width: 150px; }
.meter-track { width: 150px; height: 14px; border-radius: 99px; background: #e4efd9; box-shadow: inset 0 2px 0 #cfdfc2; overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #7fd36b, #ffd24d, #ff8fb8); transition: width .35s cubic-bezier(.3, 1.4, .5, 1); }
.meter-text { font-size: 12px; font-weight: 800; color: var(--muted); }

/* Planter and beds */
.planter { position: relative; max-width: min(640px, calc(100vh - 230px)); min-width: min(100%, 420px); margin: 0 auto; padding: 14px; border-radius: 30px; background: linear-gradient(160deg, #d99a63, var(--wood) 50%, #b87843); box-shadow: inset 0 4px 0 #eab686, inset 0 -5px 0 var(--wood-dark), 0 10px 0 #8a5530, 0 22px 30px #5a3a1a33; }
.planter::before { content: ""; position: absolute; inset: 5px; border-radius: 26px; border: 2px dashed #f0c59866; pointer-events: none; }
.board { position: relative; aspect-ratio: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); gap: 10px; padding: 10px; border-radius: 20px; background: radial-gradient(circle at 30% 20%, #9c6a45, var(--soil)); box-shadow: inset 0 5px 10px #0003; }
.bed { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: 6px; padding: 7px; border-radius: 16px; background: var(--grass-a); box-shadow: inset 0 3px 0 #e4f6cb, inset 0 -4px 0 #9fcb77; }
.bed-1, .bed-2, .bed-5 { background: var(--grass-b); }
.bed-flower { position: absolute; width: 20px; height: 20px; z-index: 3; pointer-events: none; filter: drop-shadow(0 2px 0 #0002); }
.bed-flower svg { width: 100%; height: 100%; }
.bed-flower.f1 { top: -9px; left: -7px; transform: rotate(-12deg); }
.bed-flower.f2 { bottom: -8px; right: -6px; width: 16px; height: 16px; transform: rotate(20deg); }
.bed-1 .f1, .bed-4 .f1 { left: auto; right: 22%; }
.bed-2 .f2, .bed-3 .f2 { right: auto; left: 30%; }

.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 14px; background: transparent; transition: transform .15s, background .2s, box-shadow .2s, opacity .2s; }
/* Empty soil is see-through (the old 38% "can't go here" look), so it blends with each bed's grass. */
.cell.empty { background: radial-gradient(circle at 50% 58%, rgb(167 119 82 / .38) 0 34%, rgb(185 138 98 / .38) 35% 52%, #ffffff00 53%); }
.cell.empty::after { content: ""; position: absolute; width: 14%; height: 14%; left: 30%; top: 32%; border-radius: 50%; background: #ffffff15; }
.cell.empty:hover { background: radial-gradient(circle at 50% 58%, rgb(167 119 82 / .38) 0 34%, rgb(185 138 98 / .38) 35% 52%, #ffffff00 53%), #ffffff55; transform: translateY(-2px); }
.cell.given { background: var(--tint); box-shadow: inset 0 0 0 3px #ffffffaa, inset 0 -4px 0 #00000012; }
.cell.placed { background: #fffdf6; box-shadow: inset 0 0 0 3px var(--tint), 0 4px 0 #6d9a4f55; }
.cell.placed:hover { transform: translateY(-2px); }
.cell:focus-visible { outline-offset: -2px; z-index: 4; }
.cell > span { pointer-events: none; }
.digit { font-size: clamp(30px, 5vw, 58px); font-weight: 950; color: var(--num); text-shadow: 0 3px 0 #ffffff, 0 4px 0 color-mix(in srgb, var(--deep) 35%, transparent); line-height: 1; }
.ghost .digit { font-size: .82em; }
.ghost { display: grid; place-items: center; width: 100%; height: 100%; opacity: 0; transition: opacity .15s; }
.cell.empty:hover .ghost, .cell.empty:focus-visible .ghost { opacity: .42; }
.cell.match { box-shadow: inset 0 0 0 3px var(--num), 0 0 0 3px #ffffffcc; }
.cell.match .digit { animation: bob 1.6s ease-in-out infinite; }
.cell.conflict { box-shadow: inset 0 0 0 4px #ff6f61, 0 0 0 3px #ffe0dc; background: #fff0ec; }
.cell.clue { outline: 3px dashed #34498c; outline-offset: -4px; }
.cell.pop .digit { animation: pop .42s cubic-bezier(.3, 1.6, .5, 1); }
.cell.wobble { animation: wobble .55s ease-in-out; }
.cell.sparkle::before { content: "✦"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2em; color: #fff9c4; text-shadow: 0 0 10px #ffd54f, 0 0 20px #fff; animation: twinkle .9s ease-out var(--delay, 0ms) both; z-index: 5; }
.cell.sparkle { animation: glow-cell .9s ease-out var(--delay, 0ms) both; }
.board.party .cell .digit { animation: hop .6s ease-in-out var(--wave) 3; }
@keyframes bob { 50% { transform: translateY(-5%); } }
@keyframes pop { 0% { transform: scale(.2) rotate(-15deg); } 100% { transform: scale(1); } }
@keyframes wobble { 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
@keyframes twinkle { 0% { opacity: 0; transform: scale(.3) rotate(0); } 40% { opacity: 1; transform: scale(1.2) rotate(40deg); } 100% { opacity: 0; transform: scale(.6) rotate(90deg); } }
@keyframes glow-cell { 40% { background-color: #fff7c2; } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22%) rotate(-6deg); } 70% { transform: translateY(0) scale(1.06, .94); } }

.confetti { position: absolute; inset: -20px; pointer-events: none; overflow: hidden; border-radius: 30px; z-index: 6; }
.confetti i { position: absolute; top: -20px; left: var(--x); width: 12px; height: 16px; border-radius: 60% 0 60% 0; background: var(--petal); animation: petal 2.6s ease-in var(--delay) forwards; opacity: 0; }
@keyframes petal { 0% { opacity: 1; transform: translate(0, 0) rotate(var(--spin)); } 100% { opacity: 0; transform: translate(var(--drift), 720px) rotate(calc(var(--spin) + 540deg)); } }

.bloom { position: absolute; left: 50%; top: 50%; z-index: 7; padding: 16px 30px; border-radius: 999px; background: linear-gradient(#fff9d6, #ffe082); border: 4px solid #fff; color: #7a4a00; font-size: clamp(20px, 3vw, 32px); font-weight: 950; white-space: nowrap; box-shadow: 0 8px 0 #d99a1e, 0 18px 40px #7a4a0040; transform: translate(-50%, -50%); animation: bloom-in .7s cubic-bezier(.3, 1.6, .5, 1) 1.2s both; pointer-events: none; }
.bloom span { color: #ff8a3d; }
@keyframes bloom-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.caption { text-align: center; font-size: 14px; font-weight: 650; margin: 24px 0 2px; color: var(--muted); }
.caption strong { color: var(--ink); }

/* Controls */
.controls { text-align: center; background: #ffffff8c; border: 3px solid #fff; border-radius: 34px; padding: 20px 18px 18px; box-shadow: 0 16px 44px #3e7a4a1f; backdrop-filter: blur(6px); }
.friend-note { display: flex; align-items: center; gap: 10px; text-align: left; margin: 0 auto 12px; }
.friend { width: 66px; height: 66px; flex-shrink: 0; animation: bob 2.4s ease-in-out infinite; }
.friend svg { width: 100%; height: 100%; }
.friend-note p { margin: 0; background: #fff; border-radius: 20px 20px 20px 4px; padding: 12px 14px; font-size: 15px; line-height: 1.4; font-weight: 800; box-shadow: 0 3px 0 #e3eed8; }
.controls h2 { font-size: 19px; line-height: 1.3; margin: 0 0 14px; }
.basket { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.brush { position: relative; display: grid; justify-items: center; align-content: center; gap: 6px; padding: 8px 4px 10px; min-height: 92px; border: 3px solid #fff; border-radius: 20px; background: var(--tint, #fff); box-shadow: 0 5px 0 #d7e4ca; transition: transform .15s, box-shadow .15s; }
.brush:hover { transform: translateY(-2px); }
.brush:active { transform: translateY(3px); box-shadow: 0 2px 0 #d7e4ca; }
.brush[aria-pressed="true"] { border-color: var(--deep, #b17a8a); box-shadow: 0 5px 0 var(--deep, #b17a8a), 0 0 0 4px #ffffffcc; transform: translateY(-3px); }
.brush[aria-pressed="true"] .brush-art { animation: bob 1.2s ease-in-out infinite; }
.brush-art { position: relative; width: 52px; height: 52px; display: grid; place-items: center; }
.brush-art .digit { font-size: 44px; }
.brush-art svg { width: 100%; height: 100%; }
.brush-dots { display: flex; gap: 3px; font-size: 11px; font-weight: 850; color: var(--deep); min-height: 9px; align-items: center; }
.brush-dots i { width: 7px; height: 7px; border-radius: 50%; background: #ffffffcc; box-shadow: inset 0 0 0 1.5px var(--num); }
.brush-dots i.on { background: var(--num); }
.brush.all-home { background: color-mix(in srgb, var(--tint) 55%, #fff); }
.brush.eraser { --tint: #fff4f7; --deep: #b3607a; grid-column: 1 / -1; grid-template-columns: 44px auto; justify-content: center; align-items: center; gap: 10px; min-height: 58px; padding: 6px 12px; }
.brush.eraser .brush-art { width: 40px; height: 40px; }
.brush.eraser .brush-dots { color: #b3607a; }

.status { min-height: 48px; margin: 14px 4px 10px; font-size: 15px; line-height: 1.4; font-weight: 700; color: #3f5d49; }
.next { width: 100%; min-height: 56px; margin-bottom: 12px; border: 0; border-radius: 18px; background: linear-gradient(#ff8fb8, #f36b9f); color: #fff; font-size: 19px; font-weight: 950; box-shadow: 0 5px 0 #c24a79; animation: bob 1.4s ease-in-out infinite; }
.helpers { display: flex; gap: 8px; }
.helpers button { flex: 1; min-height: 58px; border: 2px solid #fff; border-radius: 16px; background: #ffffffc9; font-size: 13px; font-weight: 850; box-shadow: 0 4px 0 #d7e4ca; }
.helpers button span { display: block; font-size: 21px; line-height: 1; margin-bottom: 3px; }
.helpers button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #d7e4ca; }
.controls h2, .friend-note p, .status, .caption { text-wrap: balance; }
.footnote { margin: 12px 0 0; font-size: 12px; color: var(--muted); font-weight: 600; }

.map { margin-top: 24px; background: #ffffff8c; border: 3px solid #fff; border-radius: 22px; padding: 4px 18px; }
.map summary { min-height: 46px; display: flex; align-items: center; justify-content: space-between; font-weight: 900; cursor: pointer; }
.map summary span { font-size: 12px; font-weight: 700; color: var(--muted); }
.map nav { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; margin: 6px 0 14px; }
.map nav button { min-height: 52px; border: 3px solid transparent; border-radius: 14px; font-weight: 900; background: #fff; }
.map nav button small { display: block; font-size: 14px; color: #e0a100; }
.map nav .tier-sprout { background: #eaf8dc; }
.map nav .tier-bloom { background: #fff1d6; }
.map nav .tier-blossom { background: #fde5f0; }
.map nav button[aria-current="true"] { border-color: var(--focus); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; text-align: left; }
  .friend-note, .controls h2 { grid-column: 1 / -1; }
  .basket { grid-row: span 4; }
  .status { margin: 0; }
  .map nav { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 640px) {
  .app { padding: 14px; }
  .top-tools { grid-column: 1 / -1; justify-content: space-between; }
  .earned { padding: 10px 12px; font-size: 13px; }
  .scene { padding: 14px 12px 10px; border-radius: 24px; }
  .scene-heading h2 { font-size: 21px; }
  .meter { display: none; }
  .planter { padding: 8px; border-radius: 22px; }
  .board { gap: 6px; padding: 6px; }
  .bed { gap: 3px; padding: 4px; border-radius: 11px; }
  .cell { border-radius: 9px; }
  .controls { display: block; text-align: center; }
  .friend-note { display: none; }
  .brush { min-height: 90px; }
  .map nav { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.pencil-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); width: 87%; height: 83%; align-items: center; color: #374b67; background: #fff9e8ed; border-radius: 9px; font-size: clamp(10px, 1.4vw, 18px); font-weight: 850; line-height: 1; }
.pencil-grid i { font-style: normal; }
.helpers #pencil[aria-pressed="true"] { background: #e8ddff; border-color: #674485; }
