{
  "slug": "quakes-today",
  "version": 5,
  "format": "html",
  "html": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<title>Quakes Today</title>\n<style>\n  :root { --bg:#1d1b2e; --fg:#fff4d6; --accent:#ffb347; }\n  * { box-sizing:border-box; }\n  html,body { margin:0; height:100%; background:var(--bg); color:var(--fg);\n    font-family:system-ui,-apple-system,\"Segoe UI\",Roboto,sans-serif; overflow:hidden; }\n  #page { height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2vh; padding:2vh 4vw; text-align:center; }\n  #count { font-weight:900; line-height:1; font-size:clamp(4rem,19vmin,12rem); color:var(--accent);\n    font-variant-numeric:tabular-nums; text-shadow:0 .04em 0 rgba(0,0,0,.35); }\n  #label { font-size:clamp(1rem,3.2vmin,1.8rem); letter-spacing:.12em; text-transform:uppercase; opacity:.9; }\n  #mood { font-size:clamp(1rem,3vmin,1.6rem); min-height:1.6em; font-style:italic; opacity:.85; }\n  #updated { font-size:.85rem; opacity:.55; }\n  #stage { width:min(46vmin,340px); height:min(30vmin,220px); }\n  svg { width:100%; height:100%; overflow:visible; }\n  .shaker { transform-origin:50% 100%; }\n\n  /* ---- bands: set on <body data-band=\"0..4\"> ---- */\n  /* 0 calm: sleeping pudding, gentle breathing */\n  body[data-band=\"0\"] #pud { animation:breathe 4s ease-in-out infinite; }\n  body[data-band=\"0\"] .zzz { display:block; }\n  body[data-band=\"0\"] .eyes-open, body[data-band=\"0\"] .mouth-o, body[data-band=\"0\"] .mouth-scream, body[data-band=\"0\"] .sweat { display:none; }\n  /* 1 tingle: awake, a small wobble */\n  body[data-band=\"1\"] #pud { animation:wobble 1.6s ease-in-out infinite; }\n  body[data-band=\"1\"] .eyes-closed, body[data-band=\"1\"] .mouth-o, body[data-band=\"1\"] .mouth-scream, body[data-band=\"1\"] .sweat { display:none; }\n  /* 2 jiggle: nervous, fast jiggle, sweat */\n  body[data-band=\"2\"] #pud { animation:jiggle .35s ease-in-out infinite; }\n  body[data-band=\"2\"] .eyes-closed, body[data-band=\"2\"] .mouth-smile, body[data-band=\"2\"] .mouth-scream { display:none; }\n  body[data-band=\"2\"] .sweat { display:block; }\n  /* 3 shaking: panic, plate rattles, whole stage shakes */\n  body[data-band=\"3\"] #pud { animation:jiggle .16s linear infinite; }\n  body[data-band=\"3\"] #plate { animation:rattle .12s linear infinite; }\n  body[data-band=\"3\"] #stage { animation:rattle .2s linear infinite; }\n  body[data-band=\"3\"] .eyes-closed, body[data-band=\"3\"] .mouth-smile, body[data-band=\"3\"] .mouth-o { display:none; }\n  body[data-band=\"3\"] .sweat { display:block; }\n  /* 4 chaos: pudding launches, page shakes, debris */\n  body[data-band=\"4\"] #pud { animation:launch 1.1s ease-in-out infinite; }\n  body[data-band=\"4\"] #plate { animation:rattle .08s linear infinite; }\n  body[data-band=\"4\"] #page { animation:pageshake .09s linear infinite; }\n  body[data-band=\"4\"] .eyes-closed, body[data-band=\"4\"] .mouth-smile, body[data-band=\"4\"] .mouth-o { display:none; }\n  body[data-band=\"4\"] .sweat { display:block; }\n  body[data-band=\"4\"] .debris { display:block; }\n  body[data-band=\"4\"] #count { color:#ff6b5e; }\n\n  .zzz, .sweat, .debris { display:none; }\n  .zzz text { animation:float 2.5s ease-in-out infinite; font-weight:800; fill:#cfe3ff; }\n  .zzz text:nth-child(2){ animation-delay:.8s } .zzz text:nth-child(3){ animation-delay:1.6s }\n  .debris rect { animation:fall .7s linear infinite; fill:#8a7f6a; }\n  .debris rect:nth-child(2){ animation-delay:.2s } .debris rect:nth-child(3){ animation-delay:.4s } .debris rect:nth-child(4){ animation-delay:.1s } .debris rect:nth-child(5){ animation-delay:.5s }\n\n  @keyframes breathe { 0%,100%{ transform:scaleY(1) } 50%{ transform:scaleY(1.04) } }\n  @keyframes wobble { 0%,100%{ transform:rotate(-2deg) scaleY(1) } 50%{ transform:rotate(2deg) scaleY(.97) } }\n  @keyframes jiggle { 0%{ transform:translateX(-5px) scaleY(.94) } 50%{ transform:translateX(5px) scaleY(1.05) } 100%{ transform:translateX(-5px) scaleY(.94) } }\n  @keyframes rattle { 0%{ transform:translate(-3px,1px) } 25%{ transform:translate(3px,-2px) } 50%{ transform:translate(-2px,-1px) } 75%{ transform:translate(2px,2px) } 100%{ transform:translate(-3px,1px) } }\n  @keyframes pageshake { 0%{ transform:translate(-6px,3px) } 25%{ transform:translate(5px,-4px) } 50%{ transform:translate(-4px,-3px) } 75%{ transform:translate(6px,4px) } 100%{ transform:translate(-6px,3px) } }\n  @keyframes launch { 0%,100%{ transform:translateY(0) rotate(-6deg) scaleY(.9) } 40%{ transform:translateY(-70px) rotate(8deg) scaleY(1.12) } 70%{ transform:translateY(-20px) rotate(-8deg) } }\n  @keyframes float { 0%{ opacity:0; transform:translate(0,0) } 30%{ opacity:1 } 100%{ opacity:0; transform:translate(14px,-28px) } }\n  @keyframes fall { 0%{ transform:translateY(-40px) rotate(0); opacity:0 } 20%{ opacity:1 } 100%{ transform:translateY(130px) rotate(200deg); opacity:1 } }\n\n  @media (prefers-reduced-motion:reduce) {\n    #page, #stage, #plate, #pud { animation-duration:6s !important; }\n  }\n\n  html,body { overflow-x:hidden; overflow-y:auto; }\n  #page { height:auto; min-height:100%; gap:1.2vh; touch-action:pan-y; user-select:none; -webkit-user-select:none; }\n  #world { font-size:clamp(1.2rem,4vmin,2rem); font-weight:800; letter-spacing:.06em; }\n  #slide { display:flex; flex-direction:column; align-items:center; gap:1.2vh; width:min(100%,42rem); min-width:0; }\n  #slide > * { max-width:100%; overflow-wrap:anywhere; }\n  #row { max-width:100%; }\n  #row { display:flex; align-items:center; gap:2vw; }\n  .nav { background:rgba(255,244,214,.12); color:var(--fg); border:0; border-radius:50%; width:2.8rem; height:2.8rem; font-size:1.8rem; line-height:1; cursor:pointer; }\n  .nav:hover, .nav:focus-visible { background:rgba(255,244,214,.28); outline:2px solid var(--accent); }\n  #fact { font-size:clamp(.85rem,2.3vmin,1.05rem); line-height:1.4; opacity:.85; max-width:34rem; }\n  #updated { min-height:1.2em; }\n  #vote { display:flex; flex-direction:column; align-items:center; gap:.6rem; width:min(92vw,26rem); }\n  #vote[hidden] { display:none; }\n  #voteBtn { background:var(--accent); color:#2a1b00; border:0; border-radius:2rem; padding:.7rem 1.4rem; font-size:1rem; font-weight:800; cursor:pointer; }\n  #voteBtn[disabled] { opacity:.6; cursor:default; }\n  #voteBtn:focus-visible { outline:3px solid #fff; }\n  #gauge { width:100%; height:.9rem; border-radius:1rem; background:rgba(255,244,214,.15); overflow:hidden; }\n  #fuel { height:100%; width:0; background:linear-gradient(90deg,#ffb347,#ff6b5e); transition:width .6s; }\n  #tally { font-size:.9rem; opacity:.85; min-height:1.3em; }\n  #dots { display:flex; gap:.6rem; margin-top:.5rem; }\n  .dot { width:.8rem; height:.8rem; padding:0; border-radius:50%; border:0; background:rgba(255,244,214,.3); cursor:pointer; }\n  .dot[aria-current=\"true\"] { background:var(--accent); transform:scale(1.3); }\n  .dot:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }\n  #all { font-size:.8rem; opacity:.55; min-height:1.2em; }\n\n  .pud-body { fill:var(--pud,#f4b04a); } .pud-top { fill:var(--pudtop,#7a3e12); }\n  body[data-world=\"moon\"]   { --pud:#c9ced8; --pudtop:#6b7280; }\n  body[data-world=\"mars\"]   { --pud:#e0765a; --pudtop:#7a2e1a; }\n  body[data-world=\"venus\"]  { --pud:#f2d36b; --pudtop:#a8651e; }\n  body[data-world=\"europa\"] { --pud:#bfe6f2; --pudtop:#4f86a8; }\n  body[data-kind=\"unknown\"] #count { color:#9fb4ff; }\n  body[data-kind=\"archive\"] #count { color:#9ad1a0; }\n\n  /* look: wide awake, looking around (worlds nobody has measured) */\n  body[data-band=\"look\"] #pud { animation:lookaround 3.4s ease-in-out infinite; }\n  body[data-band=\"look\"] .eyes-closed, body[data-band=\"look\"] .mouth-o, body[data-band=\"look\"] .mouth-scream, body[data-band=\"look\"] .sweat { display:none; }\n  @keyframes lookaround { 0%,100%{ transform:translateX(-7px) rotate(-3deg) } 50%{ transform:translateX(7px) rotate(3deg) } }\n</style>\n</head>\n<body data-band=\"0\" data-world=\"earth\" data-kind=\"live\">\n<div id=\"page\">\n  <div id=\"world\"></div>\n  <div id=\"slide\">\n    <div id=\"row\">\n      <button class=\"nav\" id=\"prev\" aria-label=\"Previous world\">&lsaquo;</button>\n      <div id=\"stage\" aria-hidden=\"true\">\n    <svg viewBox=\"0 0 300 200\">\n      <g class=\"debris\">\n        <rect x=\"30\" y=\"0\" width=\"10\" height=\"10\"/><rect x=\"95\" y=\"0\" width=\"8\" height=\"8\"/>\n        <rect x=\"170\" y=\"0\" width=\"12\" height=\"12\"/><rect x=\"225\" y=\"0\" width=\"9\" height=\"9\"/><rect x=\"265\" y=\"0\" width=\"7\" height=\"7\"/>\n      </g>\n      <g id=\"plate\">\n        <ellipse cx=\"150\" cy=\"178\" rx=\"120\" ry=\"16\" fill=\"#e8e1d0\"/>\n        <ellipse cx=\"150\" cy=\"172\" rx=\"100\" ry=\"12\" fill=\"#fffaf0\"/>\n      </g>\n      <g class=\"shaker\" id=\"pudwrap\" style=\"transform-origin:150px 172px\">\n        <g id=\"pud\" style=\"transform-origin:150px 172px; transform-box:view-box\">\n          <path class=\"pud-body\" d=\"M88 172 C84 120 108 62 150 62 C192 62 216 120 212 172 Z\"/>\n          <path class=\"pud-top\" d=\"M96 100 C100 78 120 62 150 62 C180 62 200 78 204 100 C185 88 115 88 96 100 Z\"/>\n          <ellipse cx=\"150\" cy=\"60\" rx=\"7\" ry=\"6\" fill=\"#c0392b\"/>\n          <g class=\"eyes-open\"><circle cx=\"128\" cy=\"124\" r=\"7\" fill=\"#222\"/><circle cx=\"172\" cy=\"124\" r=\"7\" fill=\"#222\"/>\n            <circle cx=\"130\" cy=\"122\" r=\"2.5\" fill=\"#fff\"/><circle cx=\"174\" cy=\"122\" r=\"2.5\" fill=\"#fff\"/></g>\n          <g class=\"eyes-closed\" stroke=\"#222\" stroke-width=\"3.5\" fill=\"none\" stroke-linecap=\"round\">\n            <path d=\"M120 126 q8 7 16 0\"/><path d=\"M164 126 q8 7 16 0\"/></g>\n          <path class=\"mouth-smile\" d=\"M136 146 q14 12 28 0\" stroke=\"#222\" stroke-width=\"3.5\" fill=\"none\" stroke-linecap=\"round\"/>\n          <ellipse class=\"mouth-o\" cx=\"150\" cy=\"150\" rx=\"6\" ry=\"8\" fill=\"#222\"/>\n          <path class=\"mouth-scream\" d=\"M132 142 Q150 175 168 142 Z\" fill=\"#222\"/>\n          <g class=\"sweat\" fill=\"#6ec6ff\"><path d=\"M108 108 q-5 10 0 14 q5 -4 0 -14z\"/><path d=\"M194 104 q-5 10 0 14 q5 -4 0 -14z\"/></g>\n        </g>\n      </g>\n      <g class=\"zzz\"><text x=\"196\" y=\"80\" font-size=\"22\">z</text><text x=\"212\" y=\"62\" font-size=\"28\">z</text><text x=\"230\" y=\"40\" font-size=\"34\">Z</text></g>\n    </svg>\n  </div>\n      <button class=\"nav\" id=\"next\" aria-label=\"Next world\">&rsaquo;</button>\n    </div>\n    <div id=\"count\" role=\"status\" aria-live=\"polite\">&ndash;</div>\n    <div id=\"label\"></div>\n    <div id=\"mood\">Shaking out the numbers&hellip;</div>\n    <div id=\"fact\"></div>\n    <div id=\"updated\"></div>\n  </div>\n  <div id=\"vote\" hidden>\n    <button id=\"voteBtn\">&#128640; Send a seismometer</button>\n    <div id=\"gauge\" role=\"progressbar\" aria-label=\"Rocket fuel\" aria-valuemin=\"0\" aria-valuemax=\"100\" aria-valuenow=\"0\"><div id=\"fuel\"></div></div>\n    <div id=\"tally\"></div>\n  </div>\n  <div id=\"dots\" role=\"tablist\" aria-label=\"Worlds\"></div>\n  <div id=\"all\"></div>\n</div>\n\n<script>\n(function () {\n  var REFRESH_MS = 60 * 1000, POLL_MS = 30 * 1000, ROTATE_MS = 12 * 1000, GOAL = 100, SHARDS = 8;\n  var BANDS = [\n    { min: 0,   mood: \"Quiet day. The pudding is napping.\" },\n    { min: 150, mood: \"A little tingle. The pudding stirs.\" },\n    { min: 250, mood: \"Busy! The pudding is jiggling nervously.\" },\n    { min: 350, mood: \"Whoa! The pudding and the plate are rattling!\" },\n    { min: 500, mood: \"EVERYTHING IS SHAKING. THE PUDDING HAS LEFT THE PLATE.\" }\n  ];\n  // Facts below come from NASA / mission sources. Moon and Mars are finished records, not today's count.\n  var WORLDS = [\n    { id: \"earth\", name: \"Earth\", emoji: \"\\uD83C\\uDF0D\", kind: \"live\",\n      label: \"earthquakes today (UTC)\",\n      fact: \"Live from USGS: every quake it records worldwide since 00:00 UTC, of any size.\" },\n    { id: \"moon\", name: \"The Moon\", emoji: \"\\uD83C\\uDF11\", kind: \"archive\", band: \"0\", count: 12558,\n      label: \"seismic events on record\", stamp: \"last measured 1977 \\u00B7 Apollo seismometers\",\n      mood: \"The seismometers were switched off in 1977. The pudding is retired.\",\n      fact: \"Apollo's seismometers catalogued 12,558 events from 1969 to 1977, a mix of moonquakes and meteoroid impacts. A finished record, not today's count.\" },\n    { id: \"mars\", name: \"Mars\", emoji: \"\\uD83D\\uDD34\", kind: \"archive\", band: \"0\", count: 1319,\n      label: \"seismic events on record\", stamp: \"last measured 2022 \\u00B7 NASA InSight\",\n      mood: \"InSight went quiet in 2022. The pudding is dozing.\",\n      fact: \"NASA's InSight detected 1,319 quakes on Mars, a few from meteoroid impacts. A finished record, not today's count.\" },\n    { id: \"venus\", name: \"Venus\", emoji: \"\\uD83D\\uDFE1\", kind: \"unknown\", band: \"look\",\n      label: \"quakes today: nobody knows\", mood: \"Wide awake. Looking around. No idea how shaky it is.\",\n      fact: \"Venus's surface is about 467\\u00B0C (872\\u00B0F), hot enough to melt lead. The Soviet Venera landers of 1982 listened for ground motion, but no lander has lasted more than about two hours. Nobody has a count.\" },\n    { id: \"europa\", name: \"Europa\", emoji: \"\\uD83E\\uDDCA\", kind: \"unknown\", band: \"look\",\n      label: \"quakes today: nobody knows\", mood: \"Wide awake. Looking around. Wondering about the ocean below.\",\n      fact: \"No spacecraft has ever landed on Europa, so no seismometer has touched it. Scientists are testing tiny ones on Earth for a possible future lander.\" }\n  ];\n  var N = WORLDS.length;\n  var $ = function (id) { return document.getElementById(id); };\n  var countEl = $(\"count\"), moodEl = $(\"mood\"), updEl = $(\"updated\"), labelEl = $(\"label\"), factEl = $(\"fact\"),\n      worldEl = $(\"world\"), slideEl = $(\"slide\"), voteEl = $(\"vote\"), btn = $(\"voteBtn\"), fuel = $(\"fuel\"),\n      gauge = $(\"gauge\"), tally = $(\"tally\"), dotsEl = $(\"dots\"), allEl = $(\"all\");\n  var reduced = window.matchMedia && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n  var cur = 0, busy = false, pauseUntil = 0;\n  var earth = { count: null, stamp: null, failed: false };\n  var votes = {}, voted = {};\n\n  var qs = location.search;\n  var demo = /[?&]demo=(\\d+)/.exec(qs);       // ?demo=NNN previews Earth's pudding at a fixed count\n  var startWorld = /[?&]world=([a-z]+)/.exec(qs);\n  if (demo) earth = { count: parseInt(demo[1], 10), stamp: new Date(), failed: false };\n\n  function bandFor(n) { var b = 0; for (var i = 0; i < BANDS.length; i++) if (n >= BANDS[i].min) b = i; return b; }\n  function fmt(n) { return n.toLocaleString(\"en-US\"); }\n\n  function drawVotes() {\n    var w = WORLDS[cur], total = 0, all = 0;\n    for (var i = 0; i < N; i++) all += votes[WORLDS[i].id] || 0;\n    allEl.textContent = all ? \"Across all worlds: \" + fmt(all) + \" votes for more seismometers\" : \"\";\n    if (w.kind === \"live\") { voteEl.hidden = true; return; }\n    voteEl.hidden = false;\n    total = votes[w.id] || 0;\n    var pct = Math.min(100, Math.round(total / GOAL * 100));\n    fuel.style.width = pct + \"%\";\n    gauge.setAttribute(\"aria-valuenow\", String(pct));\n    tally.textContent = total >= GOAL\n      ? fmt(total) + \" people want to know. Tank full! Nothing launches, but we are ready.\"\n      : fmt(total) + (total === 1 ? \" person wants\" : \" people want\") + \" to know. Nothing launches; this is a vote.\";\n    btn.disabled = !!voted[w.id];\n    btn.textContent = voted[w.id] ? \"Thanks! Your vote is in\" : \"\\uD83D\\uDE80 Send a seismometer to \" + w.name;\n  }\n\n  function draw() {\n    var w = WORLDS[cur];\n    document.body.setAttribute(\"data-world\", w.id);\n    document.body.setAttribute(\"data-kind\", w.kind === \"live\" ? \"live\" : w.kind);\n    worldEl.textContent = w.emoji + \" \" + w.name;\n    labelEl.textContent = w.label;\n    factEl.textContent = w.fact;\n    if (w.kind === \"live\") {\n      if (earth.count === null) {\n        document.body.setAttribute(\"data-band\", \"0\");\n        countEl.textContent = earth.failed ? \"?\" : \"\\u2013\";\n        moodEl.textContent = earth.failed ? \"Can't reach the seismographs. Retrying\\u2026\" : \"Shaking out the numbers\\u2026\";\n        updEl.textContent = \"\";\n      } else {\n        var b = bandFor(earth.count);\n        document.body.setAttribute(\"data-band\", String(b));\n        countEl.textContent = fmt(earth.count);\n        moodEl.textContent = BANDS[b].mood;\n        updEl.textContent = earth.failed ? \"couldn't refresh, showing the last count\"\n          : earth.stamp ? \"updated \" + earth.stamp.toISOString().slice(11, 16) + \" UTC\" : \"\";\n      }\n    } else {\n      document.body.setAttribute(\"data-band\", w.band);\n      countEl.textContent = w.kind === \"archive\" ? fmt(w.count) : \"?\";\n      moodEl.textContent = w.mood;\n      updEl.textContent = w.stamp || \"\";\n    }\n    for (var i = 0; i < dotsEl.children.length; i++) dotsEl.children[i].setAttribute(\"aria-current\", i === cur ? \"true\" : \"false\");\n    drawVotes();\n  }\n\n  function go(i, dir) {\n    i = (i + N) % N;\n    if (i === cur || busy) return;\n    var d = dir || 1;\n    if (reduced || !slideEl.animate) { cur = i; draw(); return; }\n    busy = true;\n    slideEl.animate([{ opacity: 1, transform: \"translateX(0)\" }, { opacity: 0, transform: \"translateX(\" + (-40 * d) + \"px)\" }], { duration: 160 })\n      .onfinish = function () {\n        cur = i; draw();\n        slideEl.animate([{ opacity: 0, transform: \"translateX(\" + (40 * d) + \"px)\" }, { opacity: 1, transform: \"translateX(0)\" }], { duration: 200 })\n          .onfinish = function () { busy = false; };\n      };\n  }\n  function touched() { pauseUntil = Date.now() + 25 * 1000; }\n\n  // dots + arrows\n  WORLDS.forEach(function (w, i) {\n    var d = document.createElement(\"button\");\n    d.className = \"dot\"; d.setAttribute(\"aria-label\", w.name);\n    d.onclick = function () { touched(); go(i, i > cur ? 1 : -1); };\n    dotsEl.appendChild(d);\n  });\n  $(\"prev\").onclick = function () { touched(); go(cur - 1, -1); };\n  $(\"next\").onclick = function () { touched(); go(cur + 1, 1); };\n  document.addEventListener(\"keydown\", function (e) {\n    if (e.key === \"ArrowLeft\") { touched(); go(cur - 1, -1); }\n    if (e.key === \"ArrowRight\") { touched(); go(cur + 1, 1); }\n  });\n  // swipe\n  var sx = null, sy = null;\n  var page = $(\"page\");\n  page.addEventListener(\"pointerdown\", function (e) { if (e.target.closest(\"button\")) return; sx = e.clientX; sy = e.clientY; touched(); });\n  page.addEventListener(\"pointerup\", function (e) {\n    if (sx === null) return;\n    var dx = e.clientX - sx, dy = e.clientY - sy; sx = null;\n    if (Math.abs(dx) > 50 && Math.abs(dx) > Math.abs(dy) * 1.5) go(cur + (dx < 0 ? 1 : -1), dx < 0 ? 1 : -1);\n  });\n  page.addEventListener(\"pointercancel\", function () { sx = null; });\n  // sideways scroll\n  var wheelAt = 0;\n  page.addEventListener(\"wheel\", function (e) {\n    if (Math.abs(e.deltaX) > Math.abs(e.deltaY) && Math.abs(e.deltaX) > 30 && Date.now() - wheelAt > 500) {\n      wheelAt = Date.now(); touched(); go(cur + (e.deltaX > 0 ? 1 : -1), e.deltaX > 0 ? 1 : -1);\n    }\n  }, { passive: true });\n  // auto-rotate, paused while someone is interacting\n  var hover = false;\n  page.addEventListener(\"pointerenter\", function () { hover = true; });\n  page.addEventListener(\"pointerleave\", function () { hover = false; });\n  var lastAuto = Date.now();\n  if (!reduced && !demo && !startWorld) {\n    setInterval(function () {\n      var now = Date.now();\n      if (document.hidden || hover || now < pauseUntil || now - lastAuto < ROTATE_MS) return;\n      lastAuto = now; go(cur + 1, 1);\n    }, 1000);\n  }\n\n  // votes: sharded counters, votes:<world>:<shard> = {n}. Casual and open, not tamper-proof.\n  function readVotes() {\n    if (!window.charm || !charm.all) return;\n    charm.all(\"votes:\").then(function (all) {\n      var sums = {};\n      Object.keys(all || {}).forEach(function (k) {\n        var p = k.split(\":\"), v = all[k], n = v && Number(v.n);\n        if (p.length === 3 && isFinite(n) && n >= 0 && n < 1e6) sums[p[1]] = (sums[p[1]] || 0) + Math.floor(n);\n      });\n      votes = sums; drawVotes();\n    }).catch(function () {});\n  }\n  btn.onclick = function () {\n    var w = WORLDS[cur];\n    if (w.kind === \"live\" || voted[w.id] || !window.charm) return;\n    touched();\n    voted[w.id] = true;\n    votes[w.id] = (votes[w.id] || 0) + 1;\n    drawVotes();\n    var key = \"votes:\" + w.id + \":\" + Math.floor(Math.random() * SHARDS);\n    charm.get(key).then(function (v) {\n      var n = v && isFinite(Number(v.n)) ? Math.floor(Number(v.n)) : 0;\n      return charm.set(key, { n: n + 1 });\n    }).catch(function () { tally.textContent = \"Couldn't save that vote. Try again later.\"; voted[w.id] = false; });\n  };\n  readVotes();\n  setInterval(readVotes, POLL_MS);\n\n  // Earth: live count straight from USGS\n  function utcMidnightISO() { return new Date().toISOString().slice(0, 10) + \"T00:00:00\"; }\n  function refresh() {\n    var url = \"https://earthquake.usgs.gov/fdsnws/event/1/count?format=geojson&starttime=\" + utcMidnightISO();\n    fetch(url, { cache: \"no-store\" }).then(function (r) {\n      if (!r.ok) throw new Error(\"usgs \" + r.status);\n      return r.json();\n    }).then(function (j) {\n      if (typeof j.count !== \"number\") throw new Error(\"bad count\");\n      earth = { count: j.count, stamp: new Date(), failed: false };\n    }).catch(function () { earth.failed = true; })\n      .then(function () { if (WORLDS[cur].kind === \"live\") draw(); });\n  }\n  if (startWorld) { for (var s = 0; s < N; s++) if (WORLDS[s].id === startWorld[1]) cur = s; }\n  draw();\n  if (!demo) {\n    refresh();\n    setInterval(refresh, REFRESH_MS);\n    document.addEventListener(\"visibilitychange\", function () { if (!document.hidden) refresh(); });\n  }\n})();\n</script>\n</body>\n</html>\n"
}