{
  "slug": "nine-pentacles-garden",
  "version": 2,
  "format": "html",
  "html": "<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Nine Pentacles Garden</title>\n<meta name=\"claude:viewport-fit-sides\" content=\"cover\">\n<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=IM+Fell+English+SC&family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;0,800;1,400&display=swap\">\n<style>\n/* Layout: a terminal session. The garden is one big ASCII plate drawn on a character grid;\n   under it, two framed panes (focus ledger, reading) like a text-mode dashboard. Single committed black look. */\n:root{\n  color-scheme: dark;\n  --bg:#050f0a;\n  --pane:#0a1a11;\n  --rule:#24503a;        /* dim teal frame */\n  --teal:#e2b23c;        /* frames, chrome */\n  --ink:#f1e6c4;\n  --dim:#8f9a7c;\n  --green:#4fb06a;       /* growth */\n  --bone:#ecd48a;        /* roots */\n  --red:#e0303f;         /* flux */\n  --gold:#ffd24a;        /* pentacles */\n  --mono:\"JetBrains Mono\",Consolas,\"SF Mono\",Menlo,\"DejaVu Sans Mono\",monospace;\n}\nhtml,body{background:var(--bg)}\nbody{color:var(--ink);font-family:var(--mono);font-size:13px;line-height:1.55}\n.wrap{max-width:1180px;margin:0 auto;padding-block:20px 40px;\n  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));\n  display:flex;flex-direction:column;gap:14px}\nheader{display:flex;flex-wrap:wrap;align-items:center;gap:16px 28px}\nheader .txt{flex:1 1 320px;min-width:0}\n.plate{flex:0 0 auto;width:clamp(170px,24vw,240px);aspect-ratio:124/184;max-width:100%;display:block;background:#050505}\n.eyebrow{display:flex;justify-content:space-between;gap:12px;color:var(--teal);font-size:11px;letter-spacing:.22em;text-transform:uppercase}\n.eyebrow span:first-child{color:var(--red)}\n.eyebrow span:last-child{color:var(--dim)}\nh1{font-weight:800;font-size:clamp(24px,5.2vw,44px);line-height:1.05;margin:6px 0 8px;letter-spacing:.01em;text-transform:uppercase;text-wrap:balance}\nheader p{margin:0;max-width:68ch;color:var(--dim)}\n.zz{color:var(--teal);white-space:nowrap;overflow:hidden;line-height:1;font-size:13px;letter-spacing:.05em;user-select:none}\nh2{font-weight:500;font-size:11px;margin:0;letter-spacing:.22em;text-transform:uppercase;color:var(--teal)}\nh2::before{content:\"// \"}\n\n.bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px}\n.clock{margin-right:auto;min-width:0;color:var(--dim);font-variant-numeric:tabular-nums}\n.clock::before{content:\"$ \";color:var(--green)}\n.clock b{color:var(--ink);font-weight:500}\nbutton{font:inherit;color:var(--teal);background:transparent;border:0;padding:4px 2px;cursor:pointer;text-transform:lowercase;white-space:nowrap}\nbutton::before{content:\"[ \";color:var(--dim)}\nbutton::after{content:\" ]\";color:var(--dim)}\nbutton:hover{color:var(--ink)}\nbutton:focus-visible,input:focus-visible{outline:1px solid var(--gold);outline-offset:2px}\nbutton[aria-pressed=\"true\"],button.primary{background:var(--teal);color:#000;font-weight:700}\nbutton[aria-pressed=\"true\"]::before,button[aria-pressed=\"true\"]::after,button.primary::before,button.primary::after{color:#000}\n.seg{display:flex;gap:4px}\n.skyline{color:var(--dim);min-height:1.55em}\n.skyline b{color:var(--gold);font-weight:500}\n.skyline .rx{color:var(--red)}\n.almanac{display:flex;flex-direction:column;gap:3px;min-height:9.6em;font-size:12px}\n.almanac div{display:flex;gap:12px}\n.almanac time{color:var(--dim);white-space:nowrap;flex:0 0 11ch}\n.almanac .storm{color:var(--red)}\n.almanac .boon{color:var(--green)}\n.almanac .moon,.almanac .sun{color:var(--gold)}\nlabel.check{display:flex;align-items:center;gap:6px;color:var(--dim);cursor:pointer}\ninput[type=checkbox],input[type=range]{accent-color:var(--teal)}\n\n.stage{border:1px solid var(--rule);background:#050f0a;overflow:hidden}\n.stage canvas{display:block;width:100%;cursor:crosshair}\n\n.cols{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:14px}\n@media (max-width:820px){.cols{grid-template-columns:minmax(0,1fr)}}\n.pane{border:1px solid var(--rule);background:var(--pane);padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0}\n.head{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 12px}\n.head span{color:var(--dim);font-size:12px;font-variant-numeric:tabular-nums}\n\n.energy{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;color:var(--dim)}\n.energy input{flex:1 1 140px;min-width:0}\n.energy output{color:var(--gold);font-variant-numeric:tabular-nums}\n\n.beds{display:flex;flex-direction:column;border-top:1px dashed var(--rule)}\n.rowb{display:grid;grid-template-columns:34px minmax(0,1fr) auto auto;grid-template-areas:\"num name pips meters\";\n  align-items:center;gap:4px 12px;padding:5px 6px;border-bottom:1px dashed var(--rule);cursor:pointer}\n.rowb.sel{background:#12281a;box-shadow:inset 2px 0 0 var(--teal)}\n.rowb .num{grid-area:num;color:var(--gold)}\n.rowb .nm{grid-area:name;display:flex;align-items:center;gap:8px;min-width:0}\n.rowb input.name{font:inherit;text-transform:uppercase;letter-spacing:.06em;color:var(--ink);background:transparent;border:0;border-bottom:1px solid transparent;padding:2px 0;width:100%;min-width:0;max-width:150px}\n.rowb input.name:hover,.rowb input.name:focus{border-bottom-color:var(--rule)}\n.rowb .tag{color:var(--gold);font-size:11px;white-space:nowrap}\n.pips{grid-area:pips;display:flex}\n.pips button{width:22px;height:26px;padding:0;font-size:19px;line-height:26px;color:var(--dim)}\n.pips button::before,.pips button::after{content:none}\n.pips button.on{color:var(--gold);background:transparent}\n.meters{grid-area:meters;display:flex;flex-direction:column;font-size:9px;line-height:1.05;letter-spacing:0;white-space:pre}\n.meters span i{font-style:normal;color:#1a2c20}\n.m-g b{color:var(--green)}.m-r b{color:var(--bone)}.m-f b{color:var(--red)}\n.meters b{font-weight:400}\n@media (max-width:520px){\n  .rowb{grid-template-columns:30px minmax(0,1fr) auto;grid-template-areas:\"num name pips\" \"meters meters meters\"}\n  .meters{flex-direction:row;gap:8px;overflow:hidden}\n}\n.key{display:flex;flex-wrap:wrap;gap:2px 16px;color:var(--dim);font-size:12px}\n.key span::before{content:\"██ \";color:var(--c);font-size:9px}\n\n.reading{margin:0;min-height:7.5em;display:flex;flex-direction:column;gap:6px}\n.reading span{display:block;padding-left:2ch;text-indent:-2ch}\n.reading span::before{content:\"> \";color:var(--green)}\n.reading span + span{color:var(--dim)}\n.reading span:last-child::after{content:\"█\";color:var(--teal);margin-left:4px;animation:blink 1.1s steps(1) infinite}\n@keyframes blink{50%{opacity:0}}\n@media (prefers-reduced-motion:reduce){.reading span:last-child::after{animation:none}}\n.presets{display:flex;flex-wrap:wrap;gap:4px 14px}\n.spark{white-space:pre;overflow:hidden;line-height:1.25;font-size:13px}\n.spark .lab{color:var(--dim)}\n.spark .axis{color:var(--dim)}\ndl{margin:0;display:grid;grid-template-columns:auto minmax(0,1fr);gap:6px 14px}\ndt{white-space:pre}\ndd{margin:0;color:var(--dim)}\n.sep{border:0;border-top:1px dashed var(--rule);margin:2px 0;width:100%}\n</style>\n\n<div class=\"wrap\">\n  <header>\n    <canvas class=\"plate\" id=\"plate\" role=\"img\" aria-label=\"Gold line drawing of the Nine of Pentacles: a robed woman in a vineyard with a falcon on her glove and nine pentacles around her\"></canvas>\n    <div class=\"txt\">\n      <div class=\"eyebrow\"><span>// IX of pentacles</span><span>garden.sim</span></div>\n      <h1>Nine Pentacles Garden</h1>\n      <p>Nine areas of a life, grown as vines against the hedge. Give each one focus, let the seasons run, and watch what climbs, what roots, and what a storm can take.</p>\n    </div>\n  </header>\n  <div class=\"zz\" id=\"zz\" aria-hidden=\"true\"></div>\n\n  <div class=\"bar\">\n    <div class=\"clock\" id=\"clock\" aria-live=\"off\"></div>\n    <button class=\"primary\" id=\"play\" type=\"button\">pause</button>\n    <div class=\"seg\" role=\"group\" aria-label=\"Speed\">\n      <button type=\"button\" data-speed=\"3\" aria-pressed=\"false\">slow</button>\n      <button type=\"button\" data-speed=\"10\" aria-pressed=\"true\">steady</button>\n      <button type=\"button\" data-speed=\"40\" aria-pressed=\"false\">swift</button>\n    </div>\n    <button type=\"button\" id=\"storm\">send a storm</button>\n    <label class=\"check\"><input type=\"checkbox\" id=\"weather\" checked> the sky moves the garden</label>\n    <button type=\"button\" id=\"clear\">clear the garden</button>\n  </div>\n\n  <div class=\"skyline\" id=\"skyline\" aria-live=\"off\"></div>\n\n  <div class=\"stage\"><canvas id=\"garden\" aria-label=\"The garden drawn in text characters: the zodiac and planets in the sky, nine vines above the soil, their roots below\"></canvas></div>\n\n  <div class=\"cols\">\n    <section class=\"pane\">\n      <div class=\"head\"><h2>Where your focus goes</h2><span id=\"spent\"></span></div>\n      <div class=\"energy\">\n        <label for=\"energy\">energy you have</label>\n        <input type=\"range\" id=\"energy\" min=\"6\" max=\"24\" step=\"1\" value=\"16\">\n        <output id=\"energyOut\" for=\"energy\">16</output>\n      </div>\n      <div class=\"key\">\n        <span style=\"--c:var(--green)\">growth</span>\n        <span style=\"--c:var(--bone)\">roots</span>\n        <span style=\"--c:var(--red)\">flux</span>\n      </div>\n      <div class=\"beds\" id=\"beds\"></div>\n      <div class=\"presets\">\n        <button type=\"button\" data-preset=\"even\">tend all nine evenly</button>\n        <button type=\"button\" data-preset=\"few\">devote to the strongest</button>\n        <button type=\"button\" data-preset=\"one\">pour into the selected one</button>\n        <button type=\"button\" data-preset=\"chase\" id=\"chase\" aria-pressed=\"false\">chase what's new</button>\n      </div>\n    </section>\n\n    <aside class=\"pane\">\n      <div class=\"head\"><h2>The reading</h2><span id=\"setCount\"></span></div>\n      <p class=\"reading\" id=\"reading\"></p>\n      <hr class=\"sep\">\n      <div class=\"head\"><h2>Almanac</h2><span>what the sky just did</span></div>\n      <div class=\"almanac\" id=\"almanac\"></div>\n      <hr class=\"sep\">\n      <div class=\"head\"><h2 id=\"chartTitle\"></h2><span>last two years</span></div>\n      <div class=\"spark\" id=\"spark\" role=\"img\" aria-label=\"Growth, roots and flux of the selected area over the last two years\"></div>\n      <hr class=\"sep\">\n      <h2>How to read the garden</h2>\n      <dl>\n        <dt style=\"color:var(--green)\">{|}</dt><dd>Growth: the vine and its coin. Comes quickly with focus, slows in winter.</dd>\n        <dt style=\"color:var(--bone)\">/|\\</dt><dd>Roots: stability. They only deepen under focus that stays put for seasons, and keep working through winter.</dd>\n        <dt style=\"color:var(--red)\">~^'</dt><dd>Flux: static around the coin. Shows when growth has outrun its roots, or your focus keeps changing.</dd>\n        <dt style=\"color:var(--gold)\">(*)</dt><dd>A vine that stays tall and rooted for a full season engraves its star. A set pentacle holds on very little focus.</dd>\n        <dt style=\"color:var(--gold)\">O )</dt><dd>The sky shows where the Sun, Moon and planets really are on the date shown. Full moons favour growth and new moons favour roots. Mercury retrograde stirs up flux. A square or opposition to Saturn brings a storm; Jupiter with the Sun brings a generous week.</dd>\n        <dt><svg width=\"30\" height=\"20\" viewBox=\"0 0 30 20\" aria-hidden=\"true\"><path d=\"M1 19 Q9 15 18 16 Q21 16 22 10 Q26 6 28 11 Q29 18 25 19 Z\" fill=\"#ecd48a\"/><circle cx=\"12\" cy=\"10\" r=\"7\" fill=\"#b3202f\" stroke=\"#ffd24a\" stroke-width=\"1.4\"/><path d=\"M12 6.5 a3.5 3.5 0 1 1 -3.5 3.5\" fill=\"none\" stroke=\"#ffd24a\" stroke-width=\"1.2\"/><path d=\"M24 9 L23 3 M26 9 L28 3.5\" stroke=\"#ecd48a\" stroke-width=\"1.4\" stroke-linecap=\"round\"/></svg></dt><dd>The snail walks the wall once a year.</dd>\n      </dl>\n    </aside>\n  </div>\n</div>\n\n<script>\n(() => {\n'use strict';\nconst ROMAN = ['I','II','III','IV','V','VI','VII','VIII','IX'];\nconst DEFAULT_NAMES = ['Body','Home','Craft','Coin','Love','Kin','Study','Spirit','Rest'];\nconst SEASONS = ['spring','summer','autumn','winter'];\nconst SEASON_GROWTH = [1.2, 1.0, 0.8, 0.4];\nconst SKYC = ['#3f7a5a','#a8842c','#a8602c','#8a8a78'];\nconst reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst clamp = (v, a = 0, b = 1) => Math.max(a, Math.min(b, v));\nconst lerp = (a, b, t) => a + (b - a) * t;\nconst mix = (a, b, t) => `rgb(${a.map((v, i) => Math.round(lerp(v, b[i], t))).join(',')})`;\nfunction rng(a){return () => {a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296;};}\n\n/* ---------- the real sky ----------\n   Low-precision orbital elements (after Paul Schlyter); geocentric ecliptic longitudes of date,\n   good to about a degree, which is plenty for signs, phases, retrogrades and aspects. */\nconst RAD = Math.PI / 180, n360 = x => ((x % 360) + 360) % 360, adiff = (a, b) => ((a - b + 540) % 360) - 180;\nconst EL = [ // N, N', i, i', w, w', a, e, e', M, M'\n  [0, 0, 0, 0, 282.9404, 4.70935e-5, 1, 0.016709, -1.151e-9, 356.0470, 0.9856002585],\n  [125.1228, -0.0529538083, 5.1454, 0, 318.0634, 0.1643573223, 60.2666, 0.054900, 0, 115.3654, 13.0649929509],\n  [48.3313, 3.24587e-5, 7.0047, 5.00e-8, 29.1241, 1.01444e-5, 0.387098, 0.205635, 5.59e-10, 168.6562, 4.0923344368],\n  [76.6799, 2.46590e-5, 3.3946, 2.75e-8, 54.8910, 1.38374e-5, 0.723330, 0.006773, -1.302e-9, 48.0052, 1.6021302244],\n  [49.5574, 2.11081e-5, 1.8497, -1.78e-8, 286.5016, 2.92961e-5, 1.523688, 0.093405, 2.516e-9, 18.6021, 0.5240207766],\n  [100.4542, 2.76854e-5, 1.3030, -1.557e-7, 273.8777, 1.64505e-5, 5.20256, 0.048498, 4.469e-9, 19.8950, 0.0830853001],\n  [113.6634, 2.38980e-5, 2.4886, -1.081e-7, 339.3939, 2.97661e-5, 9.55475, 0.055546, -9.499e-9, 316.9670, 0.0334442282]];\nconst BODIES = [\n  {name: 'Sun', glyph: 'O', color: '#ffd24a'}, {name: 'Moon', glyph: 'O', color: '#f1e6c4'},\n  {name: 'Mercury', glyph: 'o', color: '#b8c0b0'}, {name: 'Venus', glyph: 'o', color: '#ecd48a'},\n  {name: 'Mars', glyph: 'o', color: '#e0303f'}, {name: 'Jupiter', glyph: 'O', color: '#d8a060'},\n  {name: 'Saturn', glyph: '-o-', color: '#b89a50'}];\nconst SIGNS = ['Aries','Taurus','Gemini','Cancer','Leo','Virgo','Libra','Scorpio','Sagittarius','Capricorn','Aquarius','Pisces'];\nconst SIGN3 = ['ARI','TAU','GEM','CNC','LEO','VIR','LIB','SCO','SGR','CAP','AQR','PSC'];\nconst PHASES = ['new', 'waxing crescent', 'first quarter', 'waxing gibbous', 'full', 'waning gibbous', 'last quarter', 'waning crescent'];\nconst MOONG = ['.', ')', 'D', 'D', 'O', 'C', 'C', '('];\nconst SHOWERS = [[1, 3, 'Quadrantids'], [4, 22, 'Lyrids'], [5, 6, 'Eta Aquariids'], [8, 12, 'Perseids'], [10, 21, 'Orionids'], [11, 17, 'Leonids'], [12, 14, 'Geminids']];\nconst ASPECTS = [[0, 'conjunct'], [90, 'square'], [120, 'trine'], [180, 'opposite']];\nconst MONTHS = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];\nconst signOf = lon => SIGNS[Math.floor(n360(lon) / 30)];\nconst jdDate = jd => new Date((jd - 2440587.5) * 86400000);\nconst fmtDate = jd => { const t = jdDate(jd); return `${t.getUTCDate()} ${MONTHS[t.getUTCMonth()]} ${t.getUTCFullYear()}`; };\n\nfunction orbit(k, d){\n  const q = EL[k], N = (q[0] + q[1] * d) * RAD, inc = (q[2] + q[3] * d) * RAD, w = (q[4] + q[5] * d) * RAD, a = q[6], e = q[7] + q[8] * d, M = n360(q[9] + q[10] * d) * RAD;\n  let E = M + e * Math.sin(M) * (1 + e * Math.cos(M));\n  for (let i = 0; i < 6; i++) E = E - (E - e * Math.sin(E) - M) / (1 - e * Math.cos(E));\n  const xv = a * (Math.cos(E) - e), yv = a * Math.sqrt(1 - e * e) * Math.sin(E), u = Math.atan2(yv, xv) + w, r = Math.hypot(xv, yv);\n  return {x: r * (Math.cos(N) * Math.cos(u) - Math.sin(N) * Math.sin(u) * Math.cos(inc)), y: r * (Math.sin(N) * Math.cos(u) + Math.cos(N) * Math.sin(u) * Math.cos(inc)), M, w, N};\n}\nfunction allLon(d){\n  const s = orbit(0, d), out = [n360(Math.atan2(s.y, s.x) / RAD)], m = orbit(1, d);\n  const Ms = s.M, Mm = m.M, D = (Mm + m.w + m.N) - (Ms + s.w);\n  out.push(n360(Math.atan2(m.y, m.x) / RAD - 1.274 * Math.sin(Mm - 2 * D) + 0.658 * Math.sin(2 * D) - 0.186 * Math.sin(Ms)\n    - 0.059 * Math.sin(2 * Mm - 2 * D) - 0.057 * Math.sin(Mm - 2 * D + Ms) + 0.053 * Math.sin(Mm + 2 * D) + 0.046 * Math.sin(2 * D - Ms)\n    + 0.041 * Math.sin(Mm - Ms) - 0.035 * Math.sin(D) - 0.031 * Math.sin(Mm + Ms)));\n  for (let k = 2; k < 7; k++){ const q = orbit(k, d); out.push(n360(Math.atan2(q.y + s.y, q.x + s.x) / RAD)); }\n  return out;\n}\nfunction computeSky(jd){\n  const d = jd - 2451543.5, lon = allLon(d), a = allLon(d - 0.5), b = allLon(d + 0.5);\n  const retro = lon.map((_, i) => i > 1 && adiff(b[i], a[i]) < 0);\n  const elong = n360(lon[1] - lon[0]), illum = (1 - Math.cos(elong * RAD)) / 2, events = [];\n  // hard aspects to Saturn and gifts from Jupiter first, so they lead the almanac\n  const ids = [0, 2, 3, 4, 5, 6];\n  for (let x = 0; x < ids.length; x++) for (let y = x + 1; y < ids.length; y++){\n    const i = ids[x], j = ids[y], sep = Math.abs(adiff(lon[i], lon[j]));\n    for (const [A, word] of ASPECTS){\n      const boon = i === 0 && j === 5 && (A === 0 || A === 120), hard = j === 6 && (A === 90 || A === 180) && (i === 0 || i === 4 || i === 5);\n      if (Math.abs(sep - A) < (boon ? 3.5 : 1.5))\n        events.push({key: `a${i}${j}${A}`, kind: hard ? 'storm' : boon ? 'boon' : 'aspect', text: `${BODIES[i].name} ${word} ${BODIES[j].name}` + (hard ? ': a storm' : boon ? ': a generous week' : '')});\n    }\n  }\n  if (Math.abs(adiff(elong, 0)) < 6.2) events.push({key: 'new', kind: 'moon', text: `New Moon in ${signOf(lon[1])}`});\n  if (Math.abs(adiff(elong, 180)) < 6.2) events.push({key: 'full', kind: 'moon', text: `Full Moon in ${signOf(lon[1])}`});\n  const sa = Math.floor(a[0] / 30), sb = Math.floor(b[0] / 30);\n  if (sa !== sb) events.push({key: 'in' + sb, kind: 'sun', text: (sb % 3 === 0 ? ['Spring equinox', 'Summer solstice', 'Autumn equinox', 'Winter solstice'][sb / 3] + ': ' : '') + `Sun enters ${SIGNS[sb]}`});\n  for (let i = 2; i < 7; i++) if (retro[i]) events.push({key: 'rx' + i, kind: 'rx', text: `${BODIES[i].name} turns retrograde in ${signOf(lon[i])}`, end: `${BODIES[i].name} turns direct`});\n  const t = jdDate(jd), doy = (Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()) - Date.UTC(t.getUTCFullYear(), 0, 1)) / 86400000;\n  let shower = false;\n  for (const [mo, dy, nm] of SHOWERS){\n    const peak = (Date.UTC(t.getUTCFullYear(), mo - 1, dy) - Date.UTC(t.getUTCFullYear(), 0, 1)) / 86400000;\n    if (Math.abs(doy - peak) <= 1){ shower = true; events.push({key: 'sh' + nm, kind: 'shower', text: `${nm} meteor shower`}); }\n  }\n  return {jd, lon, retro, elong, illum, events, shower, season: Math.floor(lon[0] / 90), phase: Math.floor(n360(elong + 22.5) / 45), boon: events.some(e => e.kind === 'boon')};\n}\nconst _now = new Date(), todayJD = Date.UTC(_now.getFullYear(), _now.getMonth(), _now.getDate()) / 86400000 + 2440587.5 + 0.5;\nlet epochJD = todayJD - 199, sky = computeSky(todayJD), prevEvents = new Map(), almanac = [], almDirty = true, seeding = false;\nfunction noteSky(){\n  const cur = new Map(sky.events.map(e => [e.key, e]));\n  const log = (text, kind) => { almanac.unshift({jd: sky.jd, text, kind}); if (almanac.length > 7) almanac.pop(); almDirty = true; };\n  for (const e of sky.events) if (!prevEvents.has(e.key)){ log(e.text, e.kind); if (e.kind === 'storm' && weather) storm(); }\n  for (const [k, e] of prevEvents) if (e.end && !cur.has(k)) log(e.end, 'rx');\n  prevEvents = cur;\n}\nwindow.__npgSky = computeSky;\n\n/* ---------- model ---------- */\nlet plants = [], day = 0, energy = 16, playing = !reduceMotion, speed = 10, weather = true, chase = false, sel = 2;\nlet stormT = -1e9, uiDirty = true;\n\nfunction genRoots(rand){\n  const segs = [], STEP = 0.05;\n  function grow(x, y, ang, len, w, dist){\n    const steps = Math.ceil(len / STEP);\n    for (let s = 0; s < steps; s++){\n      ang += (rand() - 0.5) * 0.55;\n      ang += (Math.PI / 2 - ang) * 0.07;\n      let nx = x + Math.cos(ang) * STEP * 0.62, ny = y + Math.sin(ang) * STEP;\n      if (Math.abs(nx) > 0.46){ ang = Math.PI - ang; nx = x; }\n      if (ny > 1) break;\n      if (ny < 0.015) ny = 0.015;\n      segs.push({x0: x, y0: y, x1: nx, y1: ny, t0: dist, t1: dist + STEP, w});\n      x = nx; y = ny; dist += STEP;\n      if (w > 0.55 && rand() < 0.3)\n        grow(x, y, ang + (rand() < 0.5 ? -1 : 1) * (0.6 + rand() * 0.6), len * 0.55 * (0.6 + rand() * 0.6), w * 0.6, dist);\n    }\n  }\n  grow(0, 0, Math.PI / 2, 1.05, 3, 0);\n  grow(0, 0.01, 0.42, 0.5, 1.8, 0.05);\n  grow(0, 0.01, Math.PI - 0.42, 0.5, 1.8, 0.05);\n  const max = Math.max(...segs.map(s => s.t1));\n  segs.forEach(s => { s.t0 /= max; s.t1 /= max; });\n  return segs;\n}\n\nfunction loadNames(){\n  try { const n = JSON.parse(localStorage.getItem('npg-names')); if (Array.isArray(n) && n.length === 9) return n.map((s, i) => String(s || DEFAULT_NAMES[i]).slice(0, 18)); } catch (e) {}\n  return DEFAULT_NAMES.slice();\n}\nfunction saveNames(){ try { localStorage.setItem('npg-names', JSON.stringify(plants.map(p => p.name))); } catch (e) {} }\n\nfunction fresh(){\n  if (plants.length) epochJD += day;\n  const names = plants.length ? plants.map(p => p.name) : loadNames();\n  plants = names.map((name, i) => ({name, pips: 0, g: 0, r: 0, ema: 0, flux: 0, p: 0, set: false, hit: 0, hitT: -1e9,\n    hist: [], seed: i * 7.3 + 1, roots: genRoots(rng(1000 + i * 77))}));\n  day = 0;\n}\n\nfunction step(){\n  sky = computeSky(epochJD + day);\n  const sm = SEASON_GROWTH[sky.season] * (weather ? (0.9 + 0.3 * sky.illum) * (sky.boon ? 1.3 : 1) : 1);\n  const rm = weather ? 0.8 + 0.5 * (1 - sky.illum) : 1, mr = weather && sky.retro[2] ? 0.2 : 0;\n  if (chase && day % 21 === 0) scatter();\n  for (const p of plants){\n    const f = p.pips / 5, eff = Math.pow(f, 0.8);\n    p.ema += (f - p.ema) * 0.03;\n    p.g += 0.02 * sm * eff * (1 - p.g) - 0.010 * (1 - eff) * p.g * (1 - 0.85 * p.r);\n    p.r += 0.006 * rm * Math.pow(Math.min(p.ema, f), 0.8) * p.g * (1 - p.r) - (f === 0 ? 0.0012 * p.r : 0);\n    const target = clamp(0.75 * Math.max(0, p.g - p.r) + 1.5 * Math.abs(f - p.ema) + (p.g > 0.05 ? mr : 0));\n    p.flux += (target - p.flux) * 0.15;\n    p.g = clamp(p.g + (Math.random() - 0.5) * 0.03 * p.flux);\n    p.r = clamp(p.r);\n    if (p.g > 0.8 && p.r > 0.6) p.p = Math.min(1, p.p + 1 / 91); else p.p = Math.max(0, p.p - 2 / 91);\n    if (p.p >= 1) p.set = true;\n    if (p.set && p.g < 0.5) { p.set = false; p.p = 0; }\n    if (day % 4 === 0){ p.hist.push([p.g, p.r, p.flux]); if (p.hist.length > 182) p.hist.shift(); }\n  }\n  noteSky();\n  day++;\n}\n\nfunction storm(){\n  const sev = 0.35 + Math.random() * 0.35, now = seeding ? -1e9 : performance.now();\n  for (const p of plants){\n    const loss = sev * p.g * (1 - 0.9 * p.r);\n    p.g -= loss; p.hit = loss; p.hitT = now;\n    p.flux = Math.min(1, p.flux + 0.35 * (1 - p.r) * Math.min(1, p.g * 4));\n  }\n  stormT = now; uiDirty = true;\n}\n\nconst spent = () => plants.reduce((s, p) => s + p.pips, 0);\nfunction setPips(i, n){\n  const p = plants[i];\n  if (n === p.pips) n--;\n  p.pips = clamp(Math.min(n, p.pips + energy - spent()), 0, 5);\n  setChase(false); uiDirty = true;\n}\nfunction trim(){ while (spent() > energy){ plants.reduce((a, b) => b.pips > a.pips ? b : a).pips--; } }\nfunction fill(order){ let rem = energy; plants.forEach(p => p.pips = 0); for (const i of order){ const n = Math.min(5, rem); plants[i].pips = n; rem -= n; } }\nfunction scatter(){ const o = plants.map((_, i) => i); for (let i = 8; i > 0; i--){ const j = Math.floor(Math.random() * (i + 1)); [o[i], o[j]] = [o[j], o[i]]; } fill(o); uiDirty = true; }\nfunction preset(kind){\n  if (kind === 'chase'){ setChase(!chase); if (chase) scatter(); return; }\n  setChase(false);\n  if (kind === 'even'){ plants.forEach(p => p.pips = 0); let rem = energy, i = 0; while (rem > 0 && i < 45){ plants[i % 9].pips++; rem--; i++; } }\n  if (kind === 'few') fill(plants.map((p, i) => i).sort((a, b) => plants[b].g + plants[b].r - plants[a].g - plants[a].r));\n  if (kind === 'one'){ plants.forEach((p, i) => p.pips = i === sel ? Math.min(5, energy) : 0); }\n  uiDirty = true;\n}\nfunction setChase(v){ chase = v; document.getElementById('chase').setAttribute('aria-pressed', String(v)); }\n\nfunction seedGarden(){\n  seeding = true; fresh(); energy = 16;\n  [2,3,4,2,2,0,0,0,1].forEach((n, i) => plants[i].pips = n);\n  for (let d = 0; d < 180; d++) step();\n  plants[6].pips = 2;\n  for (let d = 0; d < 20; d++) step();\n  seeding = false;\n}\n\n/* ---------- the garden as a character grid ---------- */\nconst cv = document.getElementById('garden'), ctx = cv.getContext('2d');\nconst FONT = '\"JetBrains Mono\", Consolas, \"SF Mono\", Menlo, monospace';\nlet W = 0, H = 0, dpr = 1, fs = 13, cw = 8, chh = 16, cols = 0, ROWS = 44, ox = 0;\nlet chr = [], clr = [], hsh = new Float32Array(0), glow = [];\n\nfunction sizeCanvas(){\n  const w = cv.parentElement.clientWidth; if (!w) return;\n  W = w; fs = w < 560 ? 10 : w < 900 ? 12 : 13;\n  ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.font = `${fs}px ${FONT}`;\n  cw = ctx.measureText('M').width || fs * 0.6; chh = Math.round(fs * 1.3);\n  cols = Math.floor(W / cw); ox = (W - cols * cw) / 2; H = ROWS * chh;\n  dpr = Math.min(2, window.devicePixelRatio || 1);\n  cv.width = Math.round(W * dpr); cv.height = Math.round(H * dpr); cv.style.height = H + 'px';\n  chr = new Array(cols * ROWS); clr = new Array(cols * ROWS);\n  hsh = new Float32Array(cols * ROWS);\n  for (let y = 0; y < ROWS; y++) for (let x = 0; x < cols; x++){ const v = Math.sin(x * 12.9898 + y * 78.233) * 43758.5453; hsh[y * cols + x] = v - Math.floor(v); }\n}\nfunction put(x, y, c, color){ if (x < 0 || y < 0 || x >= cols || y >= ROWS) return; const k = y * cols + x; chr[k] = c; clr[k] = color; }\nfunction puts(x, y, s, color){ for (let i = 0; i < s.length; i++) put(x + i, y, s[i], color); }\nfunction art(cx, bottom, lines, color, starColor, star, glowing){\n  const w = lines[0].length, x0 = cx - (w >> 1);\n  lines.forEach((ln, li) => {\n    const y = bottom - (lines.length - 1 - li), a = ln.search(/\\S/), b = ln.length - 1 - ln.split('').reverse().join('').search(/\\S/);\n    for (let i = a; i <= b; i++){\n      const isStar = ln[i] === 'X', c = isStar ? star : ln[i];\n      put(x0 + i, y, c, isStar ? starColor : color);\n      if (glowing && c !== ' ') glow.push([x0 + i, y, c, isStar ? starColor : color]);\n    }\n  });\n}\nconst COIN_M = [' .-. ', '( X )', \" '-' \"];\nconst COIN_L = [' .---. ', '/  X  \\\\', '\\\\     /', \" '---' \"];\nconst STATIC = \"~^'`\\\",*:\";\n\nfunction drawSnail(x, y, tm){\n  // the same gold line snail as on the card in the header\n  const k = Math.max(3, chh * 0.21), GOLD = '#d8b765';\n  const X = ux => x + (ux - 43) * k, Y = uy => y + (uy - 150.4) * k;\n  ctx.save(); ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.strokeStyle = GOLD;\n  ctx.lineWidth = Math.max(1.2, k * 0.3);\n  ctx.beginPath(); ctx.moveTo(X(40.6), Y(150.4)); ctx.lineTo(X(46.6), Y(150.4)); ctx.lineTo(X(47.6), Y(149.2)); ctx.stroke();\n  ctx.fillStyle = '#050f0a'; ctx.beginPath(); ctx.arc(X(43), Y(148.6), 1.7 * k, 0, Math.PI * 2); ctx.fill(); ctx.stroke();\n  ctx.lineWidth = Math.max(1, k * 0.2);\n  ctx.beginPath(); ctx.arc(X(43), Y(148.6), 0.8 * k, 0, 4.5); ctx.stroke();\n  ctx.beginPath(); ctx.moveTo(X(47.6), Y(149.2)); ctx.lineTo(X(48.3), Y(147.6));\n  ctx.moveTo(X(47.2), Y(149.4)); ctx.lineTo(X(47.2), Y(147.5)); ctx.stroke();\n  ctx.restore();\n}\n\nfunction skyCells(tm){\n  const seg = cols / 12, sunSign = Math.floor(sky.lon[0] / 30);\n  for (let x = 0; x < cols; x++) put(x, 1, '-', '#3a4a30');\n  for (let k = 0; k < 12; k++){\n    const x0 = Math.round(k * seg), name = seg >= 4 ? SIGN3[k] : SIGN3[k].slice(0, 2);\n    put(x0, 1, '+', '#a8842c'); put(x0, 0, '|', '#3a4a30');\n    puts(Math.floor(x0 + (seg - name.length) / 2 + 0.5), 0, name, k === sunSign ? '#ffd24a' : '#8f9a7c');\n  }\n  const long = cols >= 90;\n  BODIES.forEach((b, i) => {\n    const g = i === 1 ? MOONG[sky.phase] : b.glyph, y = 2 + i;\n    const gx = clamp(Math.round(sky.lon[i] / 360 * cols) - (g.length >> 1), 0, cols - g.length);\n    const label = (long ? b.name : b.name.slice(0, 3)).toLowerCase(), full = label.length + (sky.retro[i] ? 3 : 0);\n    const lx = gx + g.length + 1 + full > cols ? gx - 1 - full : gx + g.length + 1;\n    puts(lx, y, label, '#8f9a7c'); if (sky.retro[i]) puts(lx + label.length + 1, y, 'Rx', '#e0303f');\n    puts(gx, y, g, b.color);\n    if (i === 0) glow.push([gx, y, g, b.color]);\n  });\n  if (sky.shower && !reduceMotion) for (let k = 0; k < 2; k++){\n    const ph = tm * 0.8 + k * 0.5, t = ph % 1, r = rng(Math.floor(ph) * 7 + k), sx = Math.floor(r() * (cols - 16)) + 2;\n    const hx = sx + Math.floor(t * 13), hy = 2 + Math.floor(t * 6);\n    put(hx, hy, '*', '#fff8e0'); put(hx - 2, hy - 1, \"'\", '#ecd48a'); put(hx - 4, hy - 2, '.', '#8f9a7c');\n  }\n}\n\nfunction draw(now){\n  if (!W || !cols) return;\n  const tm = reduceMotion ? 0 : now / 1000;\n  const SKY = 9, colW = cols / 9, soil = Math.round(ROWS * 0.66), depth = ROWS - 3 - soil, top = SKY + 6, maxH = soil - top;\n  const season = sky.season;\n  glow.length = 0;\n\n  // ground texture\n  for (let y = 0; y < ROWS; y++) for (let x = 0; x < cols; x++){\n    const k = y * cols + x, h = hsh[k]; let c = ' ', col = null;\n    if (y < SKY){ if (h < 0.028){ c = h < 0.008 ? '*' : h < 0.02 ? '+' : '.'; col = SKYC[season]; } }\n    else if (y === SKY){ c = x % 2 ? '\\\\' : '/'; col = '#a8842c'; }\n    else if (y < soil){ if (h < 0.06){ c = h < 0.02 ? ':' : h < 0.04 ? '.' : \"'\"; col = season === 3 ? '#1a3324' : '#14452a'; } }\n    else if (y === soil){ c = '═'; col = season === 3 ? '#8a7a3a' : '#c79a2e'; }\n    else if (y < ROWS - 1){ if (h < 0.055){ c = h < 0.03 ? '.' : ','; col = '#6a1c22'; } }\n    chr[k] = c; clr[k] = col;\n  }\n\n  skyCells(tm);\n\n  plants.forEach((p, i) => {\n    const cx = Math.floor(colW * (i + 0.5));\n    // stake\n    for (let y = top - 3; y < soil; y++) put(cx, y, ':', '#1f5a38');\n\n    // roots\n    const reveal = p.r * 1.03;\n    for (const s of p.roots){\n      if (s.t0 >= reveal) continue;\n      const fr = Math.min(1, (reveal - s.t0) / (s.t1 - s.t0));\n      const dx = (s.x1 - s.x0) * colW * 0.94, dy = (s.y1 - s.y0) * depth;\n      const gx = cx + Math.round((s.x0 + (s.x1 - s.x0) * fr * 0.5) * colW * 0.94), gy = soil + 1 + Math.floor((s.y0 + (s.y1 - s.y0) * fr * 0.5) * depth);\n      const ratio = Math.abs(dy) < 0.05 ? 99 : dx / dy;\n      const c = Math.abs(ratio) > 3 ? '_' : Math.abs(ratio) < 0.45 ? '|' : ratio > 0 ? '\\\\' : '/';\n      if (gy < ROWS - 1) put(gx, gy, c, s.w >= 3 ? '#ecd48a' : s.w >= 1.5 ? '#b89a50' : '#86703a');\n    }\n\n    // vine\n    const h = Math.max(1, Math.round((0.05 + 0.95 * p.g) * maxH));\n    const vigor = clamp(p.ema * 2.5 + (p.pips ? 0.3 : 0));\n    const stemC = mix([120,100,50], [60,150,85], vigor), leafC = mix([150,120,50], [79,190,106], vigor);\n    let prev = 0, x = cx;\n    const amp = Math.min(1.3, colW * 0.13), sway = colW * 0.22;\n    if (p.g > 0.01) for (let k = 1; k <= h; k++){\n      const t = k / h, row = soil - k;\n      const off = Math.round(Math.sin(t * h / 2.6 + p.seed) * amp * Math.min(1, t * 4)\n        + Math.sin(tm * (1.3 + p.flux * 2.2) + p.seed + t * 3) * p.flux * sway * t * t);\n      x = cx + off;\n      put(x, row, off > prev ? '/' : off < prev ? '\\\\' : '|', stemC);\n      if (k % 2 === 0 && k < h){ const side = (k >> 1) % 2 ? 1 : -1; put(x + side, row, side > 0 ? '}' : '{', leafC); }\n      if (p.g > 0.55 && colW >= 6 && (k === Math.round(h * 0.42) || k === Math.round(h * 0.7))){\n        const sx = k < h * 0.5 ? 2 : -2; put(x + sx, row, '8', '#c2283e'); put(x + sx, row + 1, 'o', '#8a1a2c');\n      }\n      prev = off;\n    }\n\n    // pentacle\n    const bottom = p.g > 0.01 ? soil - h - 1 : soil - 1;\n    const jx = !reduceMotion && p.flux > 0.3 && Math.sin(tm * 9 + p.seed * 3) > 0.7 ? 1 : 0, px = x + jx;\n    const big = colW >= 9 && p.g >= 0.7, med = p.g >= 0.4, lines = big ? COIN_L : COIN_M;\n    const cH = med ? lines.length : 1, cHalf = med ? (lines[0].length >> 1) : 1;\n    // flux static (drawn first so the coin sits on top)\n    const n = Math.round(p.flux * 12);\n    if (n > 0){\n      const r = rng((p.seed * 1000 | 0) + Math.floor(tm * 7));\n      for (let j = 0; j < n; j++){\n        const fx = px + Math.round((r() - 0.5) * 2 * (cHalf + 2)), fy = bottom - Math.round(r() * (cH + 1)) + 1;\n        put(fx, fy, STATIC[Math.floor(r() * STATIC.length)], `rgba(230,45,60,${(0.45 + 0.55 * p.flux).toFixed(2)})`);\n      }\n    }\n    const coinC = p.set ? '#fff0a8' : mix([110,88,30], [255,215,95], clamp(p.g * 1.15));\n    const star = p.set ? '*' : p.p > 0.66 ? '+' : p.p > 0.33 ? ':' : p.p > 0.01 ? '.' : ' ';\n    if (!med){\n      if (p.g < 0.12) put(px, bottom, 'o', coinC); else puts(px - 1, bottom, '(o)', coinC);\n    } else art(px, bottom, lines, coinC, p.set ? '#ffffff' : '#ffb347', star, p.set);\n\n    // what the storm took\n    const age = (now - p.hitT) / 1000;\n    if (age < 2.6 && p.hit > 0.005){\n      const txt = '-' + Math.round(p.hit * 100);\n      puts(px - (txt.length >> 1), bottom - cH - Math.floor(age * 1.2), txt, p.hit > 0.15 ? '#e0303f' : '#f1e6c4');\n    }\n\n    // bed label\n    const full = (ROMAN[i] + ' ' + p.name.toUpperCase()).slice(0, Math.max(1, Math.floor(colW) - 1));\n    const lab = colW >= 11 ? full : ROMAN[i];\n    puts(cx - (lab.length >> 1), ROWS - 1, lab, i === sel ? '#ffd24a' : '#8f9a7c');\n  });\n\n  // the snail walks the year\n  const snailX = ox + cw * 3 + sky.lon[0] / 360 * (cols - 7) * cw, snailY = soil * chh + chh * 0.05;\n\n  // rain\n  const sa = (now - stormT) / 1000;\n  if (sa < 1.6){\n    const fade = 1 - sa / 1.6, r = rng(Math.floor(reduceMotion ? stormT : now / 70)), drops = Math.floor(cols * soil * 0.07 * fade);\n    for (let k = 0; k < drops; k++){ const rx = Math.floor(r() * cols), ry = Math.floor(r() * soil), q = ry * cols + rx; if (chr[q] === ' ' || clr[q] === '#14452a' || clr[q] === '#1a3324'){ chr[q] = '/'; clr[q] = `rgba(236,212,138,${(0.35 + 0.6 * fade).toFixed(2)})`; } }\n  }\n\n  // paint\n  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n  ctx.fillStyle = '#050f0a'; ctx.fillRect(0, 0, W, H);\n  ctx.fillStyle = '#2a090e'; ctx.fillRect(0, soil * chh + chh / 2, W, H);\n  ctx.fillStyle = 'rgba(226,178,60,0.08)';\n  ctx.fillRect(ox + Math.floor(colW * sel) * cw, (SKY + 1) * chh, Math.ceil(colW) * cw, H - (SKY + 1) * chh);\n  ctx.font = `${fs}px ${FONT}`; ctx.textBaseline = 'top'; ctx.textAlign = 'left';\n  const py = Math.round((chh - fs) / 2);\n  let lastC = null;\n  for (let k = 0, nCells = cols * ROWS; k < nCells; k++){\n    const c = chr[k]; if (c === ' ') continue;\n    if (clr[k] !== lastC){ lastC = clr[k]; ctx.fillStyle = lastC; }\n    ctx.fillText(c, ox + (k % cols) * cw, ((k / cols) | 0) * chh + py);\n  }\n  drawSnail(snailX, snailY, tm);\n  if (glow.length){\n    ctx.save(); ctx.shadowColor = 'rgba(255,215,95,0.95)'; ctx.shadowBlur = fs * 0.9;\n    for (const g of glow){ ctx.fillStyle = g[3]; ctx.fillText(g[2], ox + g[0] * cw, g[1] * chh + py); }\n    ctx.restore();\n  }\n}\n\n/* ---------- history as sparklines ---------- */\nconst BLOCKS = '▁▂▃▄▅▆▇█';\nconst sparkEl = document.getElementById('spark');\nfunction drawChart(){\n  const hist = plants[sel].hist, wpx = sparkEl.clientWidth; if (!wpx) return;\n  const n = clamp(Math.floor(wpx / (13 * 0.6)) - 12, 8, 91);\n  sparkEl.textContent = '';\n  [['growth', '#4fb06a', 0], ['roots ', '#ecd48a', 1], ['flux  ', '#e0303f', 2]].forEach(([name, col, idx]) => {\n    let s = '';\n    for (let k = 0; k < n; k++){\n      const j = hist.length - 1 - Math.round((n - 1 - k) * 181 / (n - 1));\n      s += j < 0 ? ' ' : BLOCKS[Math.round(clamp(hist[j][idx]) * 7)];\n    }\n    const line = document.createElement('div');\n    const lab = document.createElement('span'); lab.className = 'lab'; lab.textContent = name + ' ';\n    const bar = document.createElement('span'); bar.style.color = col; bar.textContent = s;\n    const val = document.createElement('span'); val.className = 'lab';\n    val.textContent = ' ' + String(Math.round((hist.length ? hist[hist.length - 1][idx] : 0) * 100)).padStart(3);\n    line.append(lab, bar, val); sparkEl.appendChild(line);\n  });\n  const axis = document.createElement('div'); axis.className = 'axis';\n  axis.textContent = '       ' + (n >= 20 ? '└ 2 yrs ago'.padEnd(n - 5) + 'now ┘' : '');\n  sparkEl.appendChild(axis);\n}\n\n/* ---------- ledger UI ---------- */\nconst beds = document.getElementById('beds'), rows = [];\nfunction buildRows(){\n  beds.textContent = ''; rows.length = 0;\n  plants.forEach((p, i) => {\n    const row = document.createElement('div'); row.className = 'rowb';\n    row.innerHTML = `<span class=\"num\">${ROMAN[i]}</span>\n      <span class=\"nm\"><input class=\"name\" id=\"name-${i}\" maxlength=\"18\" aria-label=\"Name of area ${ROMAN[i]}\"><span class=\"tag\" hidden>[set]</span></span>\n      <span class=\"pips\" role=\"group\"></span>\n      <span class=\"meters\" aria-hidden=\"true\"><span class=\"m-g\"><b></b><i></i></span><span class=\"m-r\"><b></b><i></i></span><span class=\"m-f\"><b></b><i></i></span></span>`;\n    const name = row.querySelector('.name'); name.value = p.name;\n    name.addEventListener('input', () => { p.name = name.value.trim() || DEFAULT_NAMES[i]; saveNames(); uiDirty = true; });\n    name.addEventListener('click', e => e.stopPropagation());\n    const pips = row.querySelector('.pips'), btns = [];\n    for (let n = 1; n <= 5; n++){\n      const b = document.createElement('button'); b.type = 'button';\n      b.addEventListener('click', e => { e.stopPropagation(); sel = i; setPips(i, n); });\n      pips.appendChild(b); btns.push(b);\n    }\n    row.addEventListener('click', () => { sel = i; uiDirty = true; });\n    beds.appendChild(row);\n    rows.push({row, btns, tag: row.querySelector('.tag'), bars: [...row.querySelectorAll('.meters > span')].map(s => [s.children[0], s.children[1]])});\n  });\n}\n\nfunction reading(){\n  const out = [], setN = plants.filter(p => p.set).length, left = energy - spent();\n  if (setN === 9) out.push('All nine pentacles are set. The garden holds itself.');\n  const shallow = plants.filter(p => p.g > 0.5 && p.r < 0.25).sort((a, b) => (b.g - b.r) - (a.g - a.r))[0];\n  if (shallow) out.push(`${shallow.name} has climbed fast on shallow roots. A storm now would take most of it.`);\n  const near = plants.filter(p => !p.set && p.p > 0.05).sort((a, b) => b.p - a.p)[0];\n  if (near) out.push(`${near.name} is tall and rooted. Hold steady and its star finishes in about ${Math.max(1, Math.round((1 - near.p) * 91))} days.`);\n  const idle = plants.filter(p => p.pips === 0 && p.g > 0.25).sort((a, b) => b.r - a.r)[0];\n  if (idle) out.push(idle.r > 0.5 ? `${idle.name} is getting no focus and holding anyway. Its roots are carrying it.` : `${idle.name} is getting no focus and thinning out.`);\n  if (weather && sky.retro[2]) out.push('Mercury is retrograde. Expect static on everything until it turns direct.');\n  if (weather && sky.boon) out.push('Jupiter is with the Sun. Growth comes easier this week.');\n  if (chase) out.push('Your focus moves every three weeks. Plenty of static, very little root.');\n  if (left > 0 && out.length < 3) out.push(`${left} energy is going unspent.`);\n  if (!out.length) out.push(plants.every(p => p.g < 0.05) ? 'The garden is bare. Give an area some focus and let the seasons run.' : 'Steady growth. Roots are slow, so give them seasons.');\n  return out.slice(0, 3);\n}\n\nconst $ = id => document.getElementById(id);\nlet lastReadDay = -99, lastReadKey = '', lastChartKey = '';\nfunction updateUI(){\n  uiDirty = false;\n  $('clock').innerHTML = `<b>${fmtDate(sky.jd)}</b> / ${SEASONS[sky.season]}`;\n  $('skyline').innerHTML = `<b>sun</b> ${signOf(sky.lon[0])} ${Math.floor(sky.lon[0] % 30)}\\u00b0 \\u00b7 <b>moon</b> ${PHASES[sky.phase]}, ${signOf(sky.lon[1])}` + BODIES.map((b, i) => sky.retro[i] ? ` \\u00b7 <span class=\"rx\">${b.name.toLowerCase()} retrograde</span>` : '').join('');\n  if (almDirty){ almDirty = false; const al = $('almanac'); al.textContent = ''; almanac.forEach(e => { const row = document.createElement('div'), tm = document.createElement('time'), tx = document.createElement('span'); tm.textContent = fmtDate(e.jd); tx.textContent = e.text; tx.className = e.kind; row.append(tm, tx); al.appendChild(row); }); }\n  $('spent').textContent = `${spent()}/${energy} energy spent`;\n  $('energyOut').textContent = energy;\n  $('setCount').textContent = `${plants.filter(p => p.set).length}/9 pentacles set`;\n  $('chartTitle').textContent = `${ROMAN[sel]} ${plants[sel].name}`;\n  $('play').textContent = playing ? 'pause' : 'play';\n  plants.forEach((p, i) => {\n    const r = rows[i];\n    r.row.classList.toggle('sel', i === sel);\n    r.tag.hidden = !p.set;\n    r.btns.forEach((b, n) => { const on = n < p.pips; b.classList.toggle('on', on); b.textContent = on ? '■' : '□'; b.setAttribute('aria-label', `Give ${p.name} ${n + 1} of 5 focus`); });\n    [p.g, p.r, p.flux].forEach((v, k) => { const f = Math.round(clamp(v) * 14); r.bars[k][0].textContent = '█'.repeat(f); r.bars[k][1].textContent = '█'.repeat(14 - f); });\n  });\n  const key = plants.map(p => p.pips).join('') + sel + chase + energy + sky.retro[2] + sky.boon + weather;\n  if (Math.abs(day - lastReadDay) >= 10 || key !== lastReadKey){\n    lastReadDay = day; lastReadKey = key;\n    const el = $('reading'); el.textContent = '';\n    reading().forEach(t => { const s = document.createElement('span'); s.textContent = t; el.appendChild(s); });\n  }\n  const ck = sel + ':' + (day >> 2) + ':' + sparkEl.clientWidth + ':' + plants[sel].hist.length;\n  if (ck !== lastChartKey){ lastChartKey = ck; drawChart(); }\n}\n\n/* ---------- the engraved plate ---------- */\nconst plate = document.getElementById('plate');\nfunction drawPlate(){\n  const wpx = plate.clientWidth; if (!wpx) return;\n  const d = Math.min(2, window.devicePixelRatio || 1), c = plate.getContext('2d'), u = wpx / 124;\n  plate.width = Math.round(wpx * d); plate.height = Math.round(wpx * 184 / 124 * d);\n  c.setTransform(d * u, 0, 0, d * u, 0, 0);\n  const GOLD = '#d8b765', BG = '#050505', NIGHT = '#050505', TAU = Math.PI * 2, r = rng(5);\n  const lw = Math.max(0.45, 0.85 / u), thin = lw * 0.6;\n  c.fillStyle = NIGHT; c.fillRect(0, 0, 124, 184);\n  c.strokeStyle = GOLD; c.lineCap = 'round'; c.lineJoin = 'round';\n  const circ = (x, y, rad) => { c.beginPath(); c.arc(x, y, rad, 0, TAU); };\n  const ink = (w) => { c.fillStyle = BG; c.fill(); c.lineWidth = w || lw; c.stroke(); };\n  const line = (pts, w) => { c.lineWidth = w || lw; c.beginPath(); c.moveTo(pts[0], pts[1]); for (let i = 2; i < pts.length; i += 2) c.lineTo(pts[i], pts[i + 1]); c.stroke(); };\n  // night around the card\n  for (let i = 0; i < 80; i++){\n    const x = 4 + r() * 116, y = 4 + r() * 176; if (x > 10 && x < 114 && y > 10 && y < 174) continue;\n    c.fillStyle = `rgba(216,183,101,${(0.35 + r() * 0.6).toFixed(2)})`; circ(x, y, 0.2 + r() * 0.45); c.fill();\n  }\n  c.lineWidth = thin; c.strokeRect(2.5, 2.5, 119, 179);\n  for (const sy of [6.3, 177.7]){\n    c.fillStyle = NIGHT; c.fillRect(57, sy - 4.2, 10, 8.4); c.fillStyle = GOLD; c.beginPath();\n    c.moveTo(62, sy - 3.6); c.quadraticCurveTo(62, sy, 65.6, sy); c.quadraticCurveTo(62, sy, 62, sy + 3.6);\n    c.quadraticCurveTo(62, sy, 58.4, sy); c.quadraticCurveTo(62, sy, 62, sy - 3.6); c.fill();\n  }\n  // the card\n  c.save(); c.translate(12, 12);\n  c.fillStyle = '#000'; c.fillRect(0, 0, 100, 160); c.lineWidth = lw; c.strokeRect(0, 0, 100, 160);\n  c.fillStyle = GOLD; c.textAlign = 'center'; c.textBaseline = 'alphabetic';\n  c.font = '8px \"IM Fell English SC\", Georgia, serif'; c.fillText('IX', 50, 12.5);\n  c.beginPath(); c.rect(0.6, 0.6, 98.8, 158.8); c.clip();\n  // two trees beyond the hedge\n  for (const tx of [15, 85]){\n    line([tx - 0.8, 66, tx - 0.5, 55], lw); line([tx + 0.8, 66, tx + 0.5, 55], lw);\n    [[0, 48, 5.2], [-4, 51.5, 3.6], [4, 51.5, 3.6], [0, 43.5, 3.6]].forEach(o => { circ(tx + o[0], o[1], o[2]); ink(); });\n    c.lineWidth = thin;\n    for (let i = 0; i < 9; i++){ const a = r() * TAU, q = r() * 4; c.beginPath(); c.arc(tx + Math.cos(a) * q, 48 + Math.sin(a) * q, 1.1, 0.3, 2.2); c.stroke(); }\n  }\n  // the vine hedge\n  c.lineWidth = lw; c.beginPath(); for (let x = 0; x < 100; x += 4) c.arc(x + 2, 65.5, 2, Math.PI, 0); c.stroke();\n  for (let i = 0; i < 380; i++){\n    const x = 1 + r() * 98, y = 67 + r() * 71, t = r();\n    if (t < 0.6){ const a = r() * TAU; c.lineWidth = thin; c.beginPath(); c.arc(x, y, 1 + r() * 1.1, a, a + 2.3); c.stroke(); }\n    else { c.fillStyle = GOLD; for (const o of [[0, 0], [0.9, 0.2], [0.45, 0.9]]){ circ(x + o[0], y + o[1], 0.38); c.fill(); } }\n  }\n  line([0, 139.5, 100, 139.5]);\n  for (let i = 0; i < 14; i++){ const x = 4 + r() * 92, y = 143 + r() * 13; line([x, y, x + 2 + r() * 4, y], thin); }\n  // gown\n  c.beginPath(); c.moveTo(44, 47);\n  c.bezierCurveTo(38, 50, 36, 60, 35, 72); c.bezierCurveTo(33, 95, 30, 120, 27, 140);\n  c.lineTo(70, 141.5); c.bezierCurveTo(76, 141.5, 80, 139.5, 83, 136.5);\n  c.bezierCurveTo(74, 130, 68, 110, 64, 86); c.bezierCurveTo(63, 72, 62, 60, 57, 48);\n  c.bezierCurveTo(54, 46, 47, 45, 44, 47); c.closePath(); ink(lw * 1.25);\n  c.lineWidth = thin;\n  [[50, 57, 49, 100, 47, 139], [45, 72, 42, 105, 37, 139.5], [55, 70, 58, 105, 59, 140], [60, 92, 65, 120, 72, 140.5], [40, 96, 38, 118, 33, 139]].forEach(f => {\n    c.beginPath(); c.moveTo(f[0], f[1]); c.quadraticCurveTo(f[2], f[3], f[4], f[5]); c.stroke(); });\n  line([46, 47.5, 50.2, 57, 55, 47.6], lw);\n  [[47, 66], [53, 78], [44, 90], [52, 101], [41, 113], [56, 118], [47, 126], [63, 128], [36, 130], [70, 134], [55, 133]].forEach(f => {\n    c.lineWidth = thin; for (let k = 0; k < 5; k++){ const a = k / 5 * TAU - 1.57; circ(f[0] + Math.cos(a) * 1.25, f[1] + Math.sin(a) * 1.25, 0.62); c.stroke(); }\n    c.fillStyle = GOLD; circ(f[0], f[1], 0.42); c.fill(); });\n  // her right arm, resting down on the coins\n  c.beginPath(); c.moveTo(43.5, 47.5); c.bezierCurveTo(36, 52, 32, 64, 30, 78); c.bezierCurveTo(29, 86, 28, 92, 28.6, 97);\n  c.lineTo(34.6, 99); c.bezierCurveTo(37, 108, 38, 118, 36.5, 127); c.bezierCurveTo(41, 116, 43, 102, 42, 86);\n  c.bezierCurveTo(43, 70, 44.5, 56, 43.5, 47.5); c.closePath(); ink();\n  line([28.6, 97, 34.6, 99], lw); c.beginPath(); c.moveTo(37, 62); c.quadraticCurveTo(34, 78, 33, 96); c.lineWidth = thin; c.stroke();\n  c.beginPath(); c.ellipse(30.8, 100.6, 2.3, 1.7, 0.3, 0, TAU); ink();\n  // her left arm, raised, with a hanging sleeve\n  c.beginPath(); c.moveTo(56, 48); c.bezierCurveTo(63, 49, 69, 56, 72.4, 65); c.bezierCurveTo(73.5, 78, 71.5, 92, 67.5, 105);\n  c.bezierCurveTo(66.5, 92, 64.5, 80, 61.5, 70); c.bezierCurveTo(60, 62, 58, 54, 56, 48); c.closePath(); ink();\n  c.beginPath(); c.moveTo(63, 56); c.quadraticCurveTo(68.5, 72, 67.8, 96); c.lineWidth = thin; c.stroke();\n  c.beginPath(); c.moveTo(65.2, 67.5); c.lineTo(65, 55.6); c.bezierCurveTo(65, 53.4, 70.6, 53, 70.9, 55.6); c.lineTo(72.2, 66.5); c.closePath(); ink();\n  line([65.1, 61.2, 71.5, 60.5], thin); line([65.1, 62.6, 71.7, 61.9], thin);\n  // the hooded falcon\n  c.beginPath(); c.moveTo(68.6, 49.5); c.lineTo(71, 55.4); c.lineTo(67.6, 53.6); c.closePath(); ink();\n  c.beginPath(); c.ellipse(68, 45.6, 2.7, 5.4, 0.25, 0, TAU); ink();\n  c.beginPath(); c.moveTo(67, 42.6); c.bezierCurveTo(69.8, 45, 69.8, 49, 68.6, 51); c.lineWidth = thin; c.stroke();\n  line([66.6, 45.5, 67.6, 46.3], thin); line([66.6, 47.3, 67.7, 48.1], thin);\n  circ(66.6, 39.3, 2.05); ink();\n  c.beginPath(); c.moveTo(64.9, 38.8); c.lineTo(63.5, 39.9); c.lineTo(65.1, 40.4); c.closePath(); c.fillStyle = GOLD; c.fill();\n  line([66.6, 37.3, 66.1, 35.2], thin); line([66.6, 37.3, 67.7, 35.5], thin); line([64.9, 39.9, 68.5, 39.9], thin);\n  // head\n  c.beginPath(); c.moveTo(47.6, 42.5); c.lineTo(47, 48.2); c.lineTo(54.2, 48.2); c.lineTo(53.6, 42.5); c.closePath(); c.fillStyle = BG; c.fill();\n  line([47.6, 43.5, 47.1, 47.6], lw); line([53.7, 43.5, 54.1, 47.6], lw);\n  circ(44.4, 41.4, 2.4); ink();\n  circ(50.6, 38, 5.7); ink();\n  c.beginPath(); c.moveTo(44.9, 39.4); c.bezierCurveTo(43.4, 30.2, 57.8, 30, 56.3, 38.6); c.bezierCurveTo(53.5, 34.2, 48, 34.4, 44.9, 39.4); c.closePath();\n  c.fillStyle = BG; c.fill(); c.lineWidth = lw; c.stroke();\n  c.beginPath(); c.moveTo(45.4, 35.2); c.quadraticCurveTo(50.6, 31.6, 55.9, 35); c.lineWidth = thin; c.stroke();\n  c.fillStyle = GOLD; circ(50.9, 38.6, 0.42); c.fill(); circ(54.1, 38.4, 0.42); c.fill();\n  line([50, 37.5, 51.7, 37.3], thin); line([53.4, 37.2, 54.9, 37.3], thin);\n  line([52.9, 38.8, 53.5, 40.6, 52.7, 40.8], thin); line([51.7, 42.2, 53.5, 42.1], thin);\n  // nine pentacles\n  [[13, 131.5], [26, 132.5], [19.5, 121], [13, 110], [26, 109.5], [19.5, 99], [86, 131.5], [77.5, 122.5], [89.5, 119.5]].forEach(o => {\n    const R = 6.5; circ(o[0], o[1], R); ink(); circ(o[0], o[1], R * 0.8); c.lineWidth = thin; c.stroke();\n    c.beginPath(); for (let k = 0; k <= 5; k++){ const a = -Math.PI / 2 + (k * 2 % 5) * TAU / 5; const x = o[0] + Math.cos(a) * R * 0.72, y = o[1] + Math.sin(a) * R * 0.72; k ? c.lineTo(x, y) : c.moveTo(x, y); }\n    c.lineWidth = lw * 0.8; c.stroke();\n  });\n  // the snail\n  circ(43, 148.6, 1.7); ink(); c.beginPath(); c.arc(43, 148.6, 0.8, 0, 4.5); c.lineWidth = thin; c.stroke();\n  line([40.6, 150.4, 46.6, 150.4, 47.6, 149.2], lw); line([47.6, 149.2, 48.3, 147.6], thin); line([47.2, 149.4, 47.2, 147.5], thin);\n  c.restore();\n}\ndrawPlate();\nnew ResizeObserver(drawPlate).observe(plate);\nif (document.fonts && document.fonts.ready) document.fonts.ready.then(drawPlate);\n\n/* ---------- controls ---------- */\n$('zz').textContent = '\\\\/'.repeat(400);\n$('play').addEventListener('click', () => { playing = !playing; uiDirty = true; });\ndocument.querySelectorAll('[data-speed]').forEach(b => b.addEventListener('click', () => {\n  speed = +b.dataset.speed; document.querySelectorAll('[data-speed]').forEach(o => o.setAttribute('aria-pressed', String(o === b)));\n}));\n$('storm').addEventListener('click', storm);\n$('weather').addEventListener('change', e => { weather = e.target.checked; uiDirty = true; });\n$('clear').addEventListener('click', () => { fresh(); setChase(false); lastReadDay = -99; uiDirty = true; });\n$('energy').addEventListener('input', e => { energy = +e.target.value; trim(); uiDirty = true; });\ndocument.querySelectorAll('[data-preset]').forEach(b => b.addEventListener('click', () => preset(b.dataset.preset)));\ncv.addEventListener('click', e => {\n  const r = cv.getBoundingClientRect(); sel = clamp(Math.floor((e.clientX - r.left) / (r.width / 9)), 0, 8); uiDirty = true;\n});\n\nseedGarden(); buildRows(); sizeCanvas();\nnew ResizeObserver(() => { sizeCanvas(); uiDirty = true; }).observe(cv.parentElement);\nif (document.fonts && document.fonts.ready) document.fonts.ready.then(() => { sizeCanvas(); uiDirty = true; });\nlet last = performance.now(), acc = 0;\nfunction frame(now){\n  const dt = Math.min(0.1, (now - last) / 1000); last = now;\n  if (playing){ acc += dt * speed; let n = 0; while (acc >= 1 && n < 60){ step(); acc -= 1; n++; } if (n) uiDirty = true; }\n  draw(now);\n  if (uiDirty) updateUI();\n  requestAnimationFrame(frame);\n}\nrequestAnimationFrame(frame);\n})();\n</script>\n"
}