{
  "id": "sudoku",
  "name": "Sudoku",
  "category": "gaming",
  "tags": ["sudoku", "puzzle", "number game", "logic"],
  "description": "Sudoku puzzle grid with number picker and check solution.",
  "triggers": ["sudoku", "puzzle", "number game", "sudoku puzzle"],
  "defaultSize": { "w": 4, "h": 4 },
  "source": "const Sudoku = () => {\n  const initial = [\n    [5,3,0,0,7,0,0,0,0],\n    [6,0,0,1,9,5,0,0,0],\n    [0,9,8,0,0,0,0,6,0],\n    [8,0,0,0,6,0,0,0,3],\n    [4,0,0,8,0,3,0,0,1],\n    [7,0,0,0,2,0,0,0,6],\n    [0,6,0,0,0,0,2,8,0],\n    [0,0,0,4,1,9,0,0,5],\n    [0,0,0,0,8,0,0,7,9]\n  ];\n  const solution = [\n    [5,3,4,6,7,8,9,1,2],\n    [6,7,2,1,9,5,3,4,8],\n    [1,9,8,3,4,2,5,6,7],\n    [8,5,9,7,6,1,4,2,3],\n    [4,2,6,8,5,3,7,9,1],\n    [7,1,3,9,2,4,8,5,6],\n    [9,6,1,5,3,7,2,8,4],\n    [2,8,7,4,1,9,6,3,5],\n    [3,4,5,2,8,6,1,7,9]\n  ];\n  const [grid, setGrid] = React.useState(initial.map(r => [...r]));\n  const [selected, setSelected] = React.useState(null);\n  const [message, setMessage] = React.useState('');\n\n  const handleCellClick = (r, c) => {\n    if (initial[r][c] !== 0) return;\n    setSelected({ r, c });\n    setMessage('');\n  };\n\n  const handleNumber = (n) => {\n    if (!selected) return;\n    const newGrid = grid.map(r => [...r]);\n    newGrid[selected.r][selected.c] = n;\n    setGrid(newGrid);\n  };\n\n  const checkSolution = () => {\n    for (let r = 0; r < 9; r++) {\n      for (let c = 0; c < 9; c++) {\n        if (grid[r][c] !== solution[r][c]) {\n          setMessage('Not quite right. Keep trying!');\n          return;\n        }\n      }\n    }\n    setMessage('Congratulations! Puzzle solved!');\n  };\n\n  const reset = () => {\n    setGrid(initial.map(r => [...r]));\n    setSelected(null);\n    setMessage('');\n  };\n\n  return React.createElement('div', { style: { fontFamily: 'system-ui, sans-serif', padding: '16px', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '12px', height: '100%', overflow: 'auto' } },\n    React.createElement('h3', { style: { margin: 0, fontSize: '16px', fontWeight: 600, color: '#111827' } }, 'Sudoku'),\n    React.createElement('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(9, 32px)', gap: '1px', background: '#374151', padding: '2px', borderRadius: '4px' } },\n      grid.map((row, r) => row.map((cell, c) => {\n        const isFixed = initial[r][c] !== 0;\n        const isSelected = selected && selected.r === r && selected.c === c;\n        const thickRight = (c + 1) % 3 === 0 && c !== 8;\n        const thickBottom = (r + 1) % 3 === 0 && r !== 8;\n        return React.createElement('div', {\n          key: r + '-' + c,\n          onClick: () => handleCellClick(r, c),\n          style: {\n            width: '32px',\n            height: '32px',\n            display: 'flex',\n            alignItems: 'center',\n            justifyContent: 'center',\n            fontSize: '16px',\n            fontWeight: isFixed ? 700 : 500,\n            background: isSelected ? '#bfdbfe' : '#fff',\n            color: isFixed ? '#111827' : '#2563eb',\n            cursor: isFixed ? 'default' : 'pointer',\n            borderRight: thickRight ? '2px solid #374151' : 'none',\n            borderBottom: thickBottom ? '2px solid #374151' : 'none'\n          }\n        }, cell || '');\n      }))\n    ),\n    React.createElement('div', { style: { display: 'flex', gap: '6px' } },\n      [1,2,3,4,5,6,7,8,9].map(n => React.createElement('button', {\n        key: n,\n        onClick: () => handleNumber(n),\n        style: {\n          width: '32px',\n          height: '32px',\n          borderRadius: '4px',\n          border: '1px solid #d1d5db',\n          background: '#f9fafb',\n          fontSize: '15px',\n          fontWeight: 600,\n          color: '#111827',\n          cursor: 'pointer'\n        }\n      }, n))\n    ),\n    React.createElement('div', { style: { display: 'flex', gap: '8px' } },\n      React.createElement('button', { onClick: checkSolution, style: { fontSize: '12px', padding: '6px 14px', borderRadius: '4px', border: 'none', background: '#16a34a', color: '#fff', cursor: 'pointer', fontWeight: 600 } }, 'Check'),\n      React.createElement('button', { onClick: reset, style: { fontSize: '12px', padding: '6px 14px', borderRadius: '4px', border: 'none', background: '#6b7280', color: '#fff', cursor: 'pointer', fontWeight: 600 } }, 'Reset')\n    ),\n    message && React.createElement('div', { style: { fontSize: '13px', fontWeight: 600, color: message.includes('Congratulations') ? '#16a34a' : '#dc2626', textAlign: 'center' } }, message)\n  );\n};\nrender(<Sudoku/>);",
  "placeholders": []
}
