{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"village-scoreboard-with-enamel-number-plates-that-drop-onto-brass-hooks-and-swing","type":"registry:block","title":"Village Scoreboard with Enamel Number Plates That Drop onto Brass Hooks and Swing","description":"Scoreboard on a canvas: a painted wooden board where enamel number plates fall off brass hooks and new ones drop on and swing. Free React and HTML code.","dependencies":[],"files":[{"path":"components/we-inc/village-scoreboard-with-enamel-number-plates-that-drop-onto-brass-hooks-and-swing.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\n// Everything a visitor is likely to change sits here.\nconst sides = [\"Home\", \"Visitors\"]; // painted above each pair of plates\nconst START = { scores: [12, 9], period: 2 }; // what hangs on the board at load\nconst PERIODS = 4; // the small red plate counts 1 to this, then starts again\nconst PAINT = [\"#1f4d3b\", \"#173b2d\"]; // board colour: lit and shaded\nconst ENAMEL = [\"#fbf6e8\", \"#17191c\"]; // plate and numeral\nconst ACCENT = [\"#c2311f\", \"#fff6e4\"]; // period plate and its numeral\nconst DEMO = true; // score by itself until a visitor does\n\ntype Slot = { x: number; y: number; w: number; h: number; red?: boolean };\nconst layoutFor = (narrow: boolean) =>\n  narrow\n    ? { W: 380, H: 560, plank: 62, labels: [{ x: 143, y: 64 }, { x: 143, y: 300 }], minor: { x: 310, y: 196 }, big: 21,\n        slots: [{ x: 96, y: 96, w: 84, h: 114 }, { x: 190, y: 96, w: 84, h: 114 }, { x: 96, y: 332, w: 84, h: 114 }, { x: 190, y: 332, w: 84, h: 114 }, { x: 310, y: 226, w: 56, h: 76, red: true }] as Slot[] }\n    : { W: 900, H: 384, plank: 75, labels: [{ x: 219, y: 82 }, { x: 681, y: 82 }], minor: { x: 450, y: 150 }, big: 30,\n        slots: [{ x: 150, y: 132, w: 124, h: 168 }, { x: 288, y: 132, w: 124, h: 168 }, { x: 612, y: 132, w: 124, h: 168 }, { x: 750, y: 132, w: 124, h: 168 }, { x: 450, y: 184, w: 76, h: 104, red: true }] as Slot[] };\nconst PAD = { x: 36, top: 34, bottom: 78 }; // room round the board for its shadow and for plates that fall away\nconst TAU = Math.PI * 2;\nconst pct = (v: number, of: number) => `${(v / of) * 100}%`;\nconst digitsOf = (scores: number[], period: number) => [Math.floor(scores[0] / 10) % 10, scores[0] % 10, Math.floor(scores[1] / 10) % 10, scores[1] % 10, period];\n\nexport default function VillageScoreboard() {\n  const stage = useRef<HTMLDivElement>(null);\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const [narrow, setNarrow] = useState(false);\n  const [scores, setScores] = useState(START.scores);\n  const [period, setPeriod] = useState(START.period);\n  const live = useRef({ scores: START.scores, period: START.period });\n  const api = useRef<{ show: (digits: number[]) => void; quiet: () => void } | null>(null);\n\n  useEffect(() => {\n    const el = stage.current;\n    if (!el) return;\n    const ro = new ResizeObserver(() => setNarrow(el.clientWidth < 760));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  useEffect(() => {\n    const box = stage.current, cv = canvas.current;\n    if (!box || !cv) return;\n    const ctx = cv.getContext(\"2d\");\n    if (!ctx) return;\n    const L = layoutFor(narrow), CW = L.W + PAD.x * 2, CH = L.H + PAD.top + PAD.bottom;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let k = 1, seed = 3;\n    const rand = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };\n    const rr = (c: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, r: number) => { c.beginPath(); c.moveTo(x + r, y); c.arcTo(x + w, y, x + w, y + h, r); c.arcTo(x + w, y + h, x, y + h, r); c.arcTo(x, y + h, x, y, r); c.arcTo(x, y, x + w, y, r); c.closePath(); };\n\n    // One hanging plate per hook, plus the plates that have been lifted off and are falling away.\n    const first = digitsOf(live.current.scores, live.current.period);\n    const hung = L.slots.map((_, i) => ({ digit: first[i], a: reduce ? 0 : (i % 2 ? -0.05 : 0.06), v: 0, drop: 0, dropV: 0, chips: i * 7 + 1 }));\n    const loose: { slot: number; digit: number; x: number; y: number; vx: number; vy: number; a: number; va: number; chips: number }[] = [];\n    const S = { auto: DEMO && !reduce, born: performance.now(), step: 0, gust: 0 };\n\n    // Each numeral plate is painted once per digit and reused: enamel, rim, chips, gloss.\n    const stock = new Map<string, HTMLCanvasElement>();\n    const plate = (digit: number, slot: Slot, chips: number) => {\n      const key = `${digit}/${slot.w}/${slot.red ? 1 : 0}/${chips % 5}`;\n      const have = stock.get(key);\n      if (have) return have;\n      const c = document.createElement(\"canvas\"), m = 4, w = slot.w, h = slot.h;\n      c.width = Math.ceil((w + m * 2) * k); c.height = Math.ceil((h + m * 2) * k);\n      const p = c.getContext(\"2d\");\n      if (!p) return c;\n      p.setTransform(k, 0, 0, k, m * k, m * k);\n      const [base, ink] = slot.red ? ACCENT : ENAMEL, r = w * 0.07;\n      rr(p, 0, 0, w, h, r); p.fillStyle = \"#2a1b12\"; p.fill(); // the steel shows at the very edge\n      rr(p, 0.7, 0.7, w - 1.4, h - 1.4, r); p.fillStyle = base; p.fill();\n      p.save(); rr(p, 0.7, 0.7, w - 1.4, h - 1.4, r); p.clip();\n      const dome = p.createLinearGradient(0, 0, w * 0.6, h);\n      dome.addColorStop(0, \"rgba(255,255,255,0.3)\"); dome.addColorStop(0.4, \"rgba(255,255,255,0)\"); dome.addColorStop(1, \"rgba(60,40,10,0.24)\");\n      p.fillStyle = dome; p.fillRect(0, 0, w, h);\n      // Rolled edge: dark where the enamel thins, bright where it catches the light.\n      rr(p, 3.2, 3.2, w - 6.4, h - 6.4, r * 0.7); p.lineWidth = 1.5; p.strokeStyle = slot.red ? \"rgba(255,240,220,0.75)\" : ink; p.stroke();\n      rr(p, 1.2, 1.2, w - 2.4, h - 2.4, r); p.lineWidth = 1.4; p.strokeStyle = \"rgba(255,255,255,0.55)\"; p.stroke();\n      p.fillStyle = ink; p.textAlign = \"center\"; p.textBaseline = \"alphabetic\";\n      p.font = `800 ${h * 0.76}px \"Arial Narrow\", \"Helvetica Neue\", Helvetica, Arial, sans-serif`;\n      const met = p.measureText(String(digit)), th = met.actualBoundingBoxAscent;\n      p.save(); p.translate(w / 2, h * 0.56 + th / 2); p.scale(Math.min(1, (w * 0.7) / met.width), 1); p.fillText(String(digit), 0, 0); p.restore();\n      // Chips and rust where years of hooks and stacking have knocked the enamel off.\n      let s2 = chips * 977 + digit * 131 + 11;\n      const rnd = () => { s2 = (s2 * 16807) % 2147483647; return s2 / 2147483647; };\n      for (let i = 0; i < 5; i++) {\n        const edge = Math.floor(rnd() * 4), t = rnd(), cx = edge % 2 ? (edge === 1 ? w - 1 : 1) : t * w, cy = edge % 2 ? t * h : edge === 0 ? 1 : h - 1, size = 1.6 + rnd() * 3.4;\n        p.beginPath(); for (let j = 0; j < 7; j++) { const a = (j / 7) * TAU, d = size * (0.6 + rnd() * 0.7); p.lineTo(cx + Math.cos(a) * d, cy + Math.sin(a) * d); } p.closePath();\n        p.fillStyle = \"#3a2416\"; p.fill(); p.lineWidth = 0.7; p.strokeStyle = \"rgba(150,80,30,0.7)\"; p.stroke();\n      }\n      for (let i = 0; i < 260; i++) { p.fillStyle = rnd() > 0.5 ? \"rgba(255,255,255,0.1)\" : \"rgba(70,50,20,0.07)\"; p.fillRect(rnd() * w, rnd() * h, 0.8, 0.8); }\n      // Gloss: a soft window across the top corner.\n      const gloss = p.createLinearGradient(0, 0, w * 0.9, h * 0.62);\n      gloss.addColorStop(0, \"rgba(255,255,255,0.5)\"); gloss.addColorStop(0.3, \"rgba(255,255,255,0.16)\"); gloss.addColorStop(0.32, \"rgba(255,255,255,0.03)\"); gloss.addColorStop(1, \"rgba(255,255,255,0)\");\n      p.fillStyle = gloss; p.fillRect(0, 0, w, h);\n      p.restore();\n      // The punched hole with its ring of bare, darkened steel.\n      const hy = h * 0.085;\n      p.beginPath(); p.arc(w / 2, hy, w * 0.058, 0, TAU); p.fillStyle = \"#3a2416\"; p.fill();\n      p.globalCompositeOperation = \"destination-out\"; p.beginPath(); p.arc(w / 2, hy, w * 0.04, 0, TAU); p.fill(); p.globalCompositeOperation = \"source-over\";\n      stock.set(key, c);\n      return c;\n    };\n\n    // The board itself: frame, painted boards, lettering and the screw end of each hook.\n    const board = document.createElement(\"canvas\");\n    const paintBoard = () => {\n      board.width = cv.width; board.height = cv.height; stock.clear(); seed = 3;\n      const b = board.getContext(\"2d\");\n      if (!b) return;\n      b.setTransform(k, 0, 0, k, PAD.x * k, PAD.top * k);\n      b.save(); b.shadowColor = \"rgba(40,30,15,0.42)\"; b.shadowBlur = 26 * k; b.shadowOffsetX = 8 * k; b.shadowOffsetY = 18 * k; rr(b, 0, 0, L.W, L.H, 5); b.fillStyle = \"#e9e1cf\"; b.fill(); b.restore();\n      b.save(); b.shadowColor = \"rgba(30,20,10,0.5)\"; b.shadowBlur = 4 * k; b.shadowOffsetY = 3 * k; rr(b, 0, 0, L.W, L.H, 5); b.fill(); b.restore();\n      // Mitred frame: each side takes the light differently.\n      const F = 15;\n      const side = (pts: number[], col: string) => { b.beginPath(); b.moveTo(pts[0], pts[1]); for (let i = 2; i < pts.length; i += 2) b.lineTo(pts[i], pts[i + 1]); b.closePath(); b.fillStyle = col; b.fill(); };\n      side([0, 0, L.W, 0, L.W - F, F, F, F], \"#fffaf0\"); side([0, 0, F, F, F, L.H - F, 0, L.H], \"#f3ecdc\");\n      side([L.W, 0, L.W, L.H, L.W - F, L.H - F, L.W - F, F], \"#d6cdb8\"); side([0, L.H, F, L.H - F, L.W - F, L.H - F, L.W, L.H], \"#c3b9a2\");\n      b.lineWidth = 0.6; b.strokeStyle = \"rgba(90,70,40,0.5)\";\n      for (const [x0, y0, x1, y1] of [[0, 0, F, F], [L.W, 0, L.W - F, F], [0, L.H, F, L.H - F], [L.W, L.H, L.W - F, L.H - F]]) { b.beginPath(); b.moveTo(x0, y0); b.lineTo(x1, y1); b.stroke(); }\n      // Painted tongue-and-groove boards.\n      b.save(); b.beginPath(); b.rect(F, F, L.W - F * 2, L.H - F * 2); b.clip();\n      const wash = b.createLinearGradient(0, 0, L.W, L.H);\n      wash.addColorStop(0, PAINT[0]); wash.addColorStop(1, PAINT[1]);\n      b.fillStyle = wash; b.fillRect(0, 0, L.W, L.H);\n      for (let x = F; x < L.W; x += L.plank) {\n        b.fillStyle = `rgba(${rand() > 0.5 ? \"255,255,255\" : \"0,0,0\"},${0.02 + rand() * 0.05})`; b.fillRect(x, 0, L.plank, L.H);\n        for (let i = 0; i < 26; i++) {\n          const gx = x + rand() * L.plank, sway = (rand() - 0.5) * 7, y0 = rand() * L.H, len = 60 + rand() * 260;\n          b.beginPath(); b.moveTo(gx, y0); b.bezierCurveTo(gx + sway, y0 + len * 0.3, gx - sway, y0 + len * 0.7, gx + sway * 0.4, y0 + len);\n          b.lineWidth = 0.5 + rand() * 0.7; b.strokeStyle = rand() > 0.45 ? `rgba(0,0,0,${0.05 + rand() * 0.1})` : `rgba(255,255,255,${0.03 + rand() * 0.05})`; b.stroke();\n        }\n        b.fillStyle = \"rgba(0,0,0,0.5)\"; b.fillRect(x - 1.1, 0, 1.6, L.H); b.fillStyle = \"rgba(255,255,255,0.13)\"; b.fillRect(x + 0.5, 0, 1, L.H);\n      }\n      const sun = b.createLinearGradient(0, 0, L.W * 0.75, L.H);\n      sun.addColorStop(0, \"rgba(255,250,220,0.16)\"); sun.addColorStop(0.45, \"rgba(255,250,220,0.03)\"); sun.addColorStop(1, \"rgba(0,0,0,0.18)\");\n      b.fillStyle = sun; b.fillRect(0, 0, L.W, L.H);\n      const inset = b.createLinearGradient(0, F, 0, F + 16); inset.addColorStop(0, \"rgba(0,0,0,0.4)\"); inset.addColorStop(1, \"rgba(0,0,0,0)\");\n      b.fillStyle = inset; b.fillRect(F, F, L.W, 16);\n      const insetL = b.createLinearGradient(F, 0, F + 12, 0); insetL.addColorStop(0, \"rgba(0,0,0,0.3)\"); insetL.addColorStop(1, \"rgba(0,0,0,0)\");\n      b.fillStyle = insetL; b.fillRect(F, F, 12, L.H);\n      // Signwriter's lettering, slightly thin where the brush ran dry.\n      const letter = (text: string, x: number, y: number, size: number) => {\n        b.font = `700 ${size}px Georgia, \"Times New Roman\", serif`; b.textBaseline = \"middle\"; b.textAlign = \"left\";\n        const gap = size * 0.2, chars = [...text.toUpperCase()], widths = chars.map((ch) => b.measureText(ch).width + gap);\n        let at = x - (widths.reduce((a, c) => a + c, 0) - gap) / 2;\n        chars.forEach((ch, i) => { b.fillStyle = \"rgba(0,0,0,0.3)\"; b.fillText(ch, at + 0.8, y + 1.2); b.fillStyle = `rgba(250,244,228,${0.86 + rand() * 0.12})`; b.fillText(ch, at, y); at += widths[i]; });\n        return at - x;\n      };\n      sides.forEach((name, i) => {\n        const half = letter(name, L.labels[i].x, L.labels[i].y, L.big);\n        b.fillStyle = \"rgba(250,244,228,0.75)\"; b.fillRect(L.labels[i].x - half, L.labels[i].y + L.big * 0.78, half * 2, 1.6);\n      });\n      letter(\"Period\", L.minor.x, L.minor.y, L.big * 0.5);\n      b.restore();\n      // Brass screw plates the hooks grow out of.\n      for (const s of L.slots) {\n        const r = s.w * 0.062, y = s.y - s.h * 0.1;\n        b.beginPath(); b.arc(s.x + 1, y + 2, r + 1, 0, TAU); b.fillStyle = \"rgba(0,0,0,0.45)\"; b.fill();\n        const g = b.createRadialGradient(s.x - r * 0.4, y - r * 0.4, 0.5, s.x, y, r);\n        g.addColorStop(0, \"#fff1b8\"); g.addColorStop(0.5, \"#c99a3a\"); g.addColorStop(1, \"#6e4c14\");\n        b.beginPath(); b.arc(s.x, y, r, 0, TAU); b.fillStyle = g; b.fill();\n        b.beginPath(); b.moveTo(s.x, y); b.lineTo(s.x, s.y); b.lineWidth = s.w * 0.05; b.lineCap = \"round\"; b.strokeStyle = \"#8a6520\"; b.stroke();\n      }\n    };\n\n    const drawPlate = (slot: Slot, digit: number, chips: number, x: number, y: number, a: number, fade: number) => {\n      const img = plate(digit, slot, chips), m = 4, hy = slot.h * 0.085, away = Math.min(1, Math.abs(a) * 3 + (1 - fade));\n      ctx.save(); ctx.globalAlpha = fade; ctx.translate(x, y); ctx.rotate(a);\n      ctx.shadowColor = \"rgba(8,20,14,0.5)\"; ctx.shadowBlur = (7 + away * 10) * k; ctx.shadowOffsetX = (4 + away * 6) * k; ctx.shadowOffsetY = (7 + away * 8) * k;\n      ctx.drawImage(img, -slot.w / 2 - m, -hy - m, slot.w + m * 2, slot.h + m * 2);\n      ctx.restore();\n    };\n    const drawHook = (s: Slot) => {\n      // The upturned end of the cup hook, in front of the plate.\n      const w = s.w * 0.052, g = ctx.createLinearGradient(s.x - w, 0, s.x + w, 0);\n      g.addColorStop(0, \"#7a5618\"); g.addColorStop(0.35, \"#ffe9a3\"); g.addColorStop(0.6, \"#c6953a\"); g.addColorStop(1, \"#5d4010\");\n      ctx.save(); ctx.shadowColor = \"rgba(0,0,0,0.45)\"; ctx.shadowBlur = 2 * k; ctx.shadowOffsetX = 1.5 * k; ctx.shadowOffsetY = 2 * k;\n      ctx.beginPath(); ctx.moveTo(s.x, s.y + s.w * 0.02); ctx.lineTo(s.x, s.y - s.h * 0.06); ctx.lineWidth = w * 2; ctx.lineCap = \"round\"; ctx.strokeStyle = g; ctx.stroke(); ctx.restore();\n    };\n\n    const draw = () => {\n      ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, cv.width, cv.height); ctx.drawImage(board, 0, 0);\n      ctx.setTransform(k, 0, 0, k, PAD.x * k, PAD.top * k);\n      L.slots.forEach((s, i) => { const h = hung[i]; drawPlate(s, h.digit, h.chips, s.x, s.y + h.drop, h.a, 1); if (h.drop > -4) drawHook(s); });\n      for (const f of loose) drawPlate(L.slots[f.slot], f.digit, f.chips, f.x, f.y, f.a, Math.max(0, Math.min(1, (L.H + PAD.bottom - 20 - f.y) / 60)));\n    };\n\n    let raf = 0, last = performance.now(), seen = true;\n    const frame = (now: number) => {\n      raf = 0;\n      const dt = Math.min(0.033, (now - last) / 1000); last = now;\n      if (S.auto) {\n        const due = Math.floor(((now - S.born) / 1000 - 0.4) / 3.4);\n        if (due > S.step) { S.step = due; const who = due % 2 ? 0 : 1, next = live.current.scores.map((v, i) => (i === who ? (v + 1) % 100 : v)); live.current = { ...live.current, scores: next }; setScores(next); api.current?.show(digitsOf(next, live.current.period)); }\n      }\n      // A breath of wind now and then keeps the plates from ever hanging dead still.\n      if (now > S.gust) { S.gust = now + 1500 + rand() * 1800; const push = (rand() - 0.5) * 0.5; hung.forEach((h, i) => { h.v += push * (0.6 + ((i * 37) % 10) / 14); }); }\n      for (const h of hung) {\n        for (let i = 0; i < 2; i++) { const st = dt / 2; h.v += (-58 * Math.sin(h.a) - 1.5 * h.v) * st; h.a += h.v * st; }\n        if (h.drop < 0 || h.dropV !== 0) {\n          h.dropV += 2600 * dt; h.drop += h.dropV * dt;\n          if (h.drop >= 0) { h.drop = 0; if (h.dropV > 160) { h.dropV = -h.dropV * 0.22; h.drop = -0.01; } else h.dropV = 0; }\n        }\n      }\n      for (let i = loose.length - 1; i >= 0; i--) { const f = loose[i]; f.vy += 2200 * dt; f.x += f.vx * dt; f.y += f.vy * dt; f.a += f.va * dt; if (f.y > L.H + PAD.bottom + 40) loose.splice(i, 1); }\n      draw();\n      if (seen && !document.hidden) raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!reduce && !raf && seen && !document.hidden) { last = performance.now(); raf = requestAnimationFrame(frame); } };\n\n    api.current = {\n      quiet: () => { S.auto = false; },\n      show: (digits) => {\n        digits.forEach((d, i) => {\n          const h = hung[i], s = L.slots[i];\n          if (h.digit === d) return;\n          if (!reduce) {\n            // The old plate is flicked off its hook and falls; the new one drops on and swings.\n            const dir = i % 2 ? 1 : -1;\n            loose.push({ slot: i, digit: h.digit, x: s.x, y: s.y, vx: dir * (30 + rand() * 50), vy: -260, a: h.a, va: dir * (1.2 + rand() * 1.6), chips: h.chips });\n            h.drop = -(s.y + s.h + PAD.top); h.dropV = 300; h.a = dir * 0.1; h.v = -dir * (1.6 + rand() * 1.2);\n          }\n          h.digit = d; h.chips += 3;\n        });\n        if (reduce) draw(); else wake();\n      },\n    };\n\n    const onMove = (e: PointerEvent) => {\n      const r = cv.getBoundingClientRect(), x = ((e.clientX - r.left) / r.width) * CW - PAD.x, y = ((e.clientY - r.top) / r.height) * CH - PAD.top;\n      L.slots.forEach((s, i) => { if (Math.abs(x - s.x) < s.w / 2 && y > s.y && y < s.y + s.h) hung[i].v += Math.max(-0.5, Math.min(0.5, e.movementX * 0.035)); });\n      wake();\n    };\n    const size = () => {\n      const w = cv.clientWidth;\n      if (!w) return;\n      k = (w / CW) * Math.min(2, window.devicePixelRatio || 1);\n      cv.width = Math.round(CW * k); cv.height = Math.round(CH * k);\n      paintBoard(); draw(); wake();\n    };\n    const ro = new ResizeObserver(size); ro.observe(cv);\n    const io = new IntersectionObserver(([entry]) => { seen = entry.isIntersecting; if (seen) wake(); });\n    io.observe(cv);\n    const onVis = () => { if (!document.hidden) wake(); };\n    document.addEventListener(\"visibilitychange\", onVis);\n    box.addEventListener(\"pointermove\", onMove);\n    size();\n    return () => {\n      cancelAnimationFrame(raf); ro.disconnect(); io.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVis); box.removeEventListener(\"pointermove\", onMove);\n      api.current = null;\n    };\n  }, [narrow]);\n\n  const L = layoutFor(narrow), CW = L.W + PAD.x * 2, CH = L.H + PAD.top + PAD.bottom;\n  const put = (nextScores: number[], nextPeriod: number) => {\n    api.current?.quiet();\n    live.current = { scores: nextScores, period: nextPeriod };\n    setScores(nextScores); setPeriod(nextPeriod);\n    api.current?.show(digitsOf(nextScores, nextPeriod));\n  };\n  const over = (a: Slot, b: Slot) => ({ left: pct(PAD.x + a.x - a.w / 2 - 6, CW), top: pct(PAD.top + a.y - a.h * 0.16, CH), width: pct(b.x - a.x + a.w + 12, CW), height: pct(a.h * 1.16, CH) });\n  const ring = \"absolute cursor-pointer rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-amber-300 focus-visible:ring-offset-2 focus-visible:ring-offset-[#1f4d3b]\";\n  const two = (n: number) => String(n).padStart(2, \"0\");\n\n  return (\n    <div ref={stage} className=\"flex min-h-[720px] w-full flex-col items-center justify-center bg-[#ddd5c4] bg-[radial-gradient(80%_70%_at_40%_30%,#efe9db_0%,#ddd5c4_55%,#c9bfaa_100%)] px-2 py-8\">\n      <div className=\"relative w-full\" style={{ maxWidth: narrow ? 440 : 1010, aspectRatio: `${CW} / ${CH}` }}>\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 h-full w-full\" />\n        {sides.map((name, i) => (\n          <button\n            key={name}\n            type=\"button\"\n            aria-label={`Add a point for ${name}. Score ${scores[i]}`}\n            onClick={() => put(scores.map((v, j) => (j === i ? (v + 1) % 100 : v)), period)}\n            style={over(L.slots[i * 2], L.slots[i * 2 + 1])}\n            className={ring}\n          />\n        ))}\n        <button type=\"button\" aria-label={`Next period. Now period ${period}`} onClick={() => put(scores, (period % PERIODS) + 1)} style={over(L.slots[4], L.slots[4])} className={ring} />\n      </div>\n      <div className=\"relative z-10 -mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-2 px-2\">\n        <p aria-live=\"polite\" className=\"text-center font-mono text-[11px] uppercase leading-5 tracking-[0.18em] text-stone-600\">\n          <span className=\"font-semibold text-stone-900\">{sides[0]} {two(scores[0])}</span>\n          <span className=\"mx-2 text-stone-400\">/</span>\n          <span className=\"font-semibold text-stone-900\">{sides[1]} {two(scores[1])}</span>\n          <span className=\"mx-2 text-stone-400\">/</span>\n          Period {period}\n        </p>\n        <button\n          type=\"button\"\n          onClick={() => put([0, 0], 1)}\n          className=\"min-h-[40px] rounded-full border border-stone-500/50 px-4 font-mono text-[11px] uppercase tracking-[0.18em] text-stone-800 outline-none transition-colors hover:bg-stone-900/5 focus-visible:ring-2 focus-visible:ring-stone-800 motion-reduce:transition-none\"\n        >\n          Clear the board\n        </button>\n      </div>\n    </div>\n  );\n}\n"}]}
