{
  "id": "bg_root",
  "type": "module",
  "version": "1.1",
  "context": {
    "layout": "phone",
    "title": "Binary Grid",
    "icon": "🧩"
  },
  "state": {
    "clues": [
      0,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      1,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      -1,
      -1,
      0,
      1,
      -1,
      1,
      1,
      -1,
      -1,
      -1,
      -1,
      -1,
      1,
      -1,
      0,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      0
    ],
    "board": [
      0,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      1,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      -1,
      -1,
      0,
      1,
      -1,
      1,
      1,
      -1,
      -1,
      -1,
      -1,
      -1,
      1,
      -1,
      0,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      0
    ],
    "tool": 0,
    "message": "",
    "showResetAlert": false,
    "celebrated": false,
    "puzzleVariant": 0,
    "nextClues": [
      0,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      1,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      -1,
      -1,
      0,
      1,
      -1,
      1,
      1,
      -1,
      -1,
      -1,
      -1,
      -1,
      1,
      -1,
      0,
      -1,
      1,
      -1,
      -1,
      1,
      -1,
      0
    ]
  },
  "dependencies": [
    {
      "repository": {
        "local": {
          "id": "binary_grid_store",
          "config": {}
        }
      }
    },
    {
      "service": {
        "audio": {
          "id": "binary_audio"
        }
      }
    }
  ],
  "events": {
    "onAppear": [
      {
        "repo": {
          "id": "load_game",
          "input": {
            "repositoryId": "binary_grid_store",
            "operation": "read",
            "params": {
              "collection": "games",
              "documentId": "current"
            }
          },
          "output": {
            "success": [
              {
                "state": {
                  "id": "hydrate_board",
                  "input": {
                    "clues": "{{ count(@{load_game.clues}) == 36 ? @{load_game.clues} : ${clues} }}",
                    "board": "{{ count(@{load_game.board}) == 36 ? @{load_game.board} : ${board} }}"
                  }
                }
              }
            ]
          }
        }
      }
    ]
  },
  "children": [
    {
      "id": "game_scroll",
      "type": "scroll",
      "style": {
        "layout": {
          "maxWidth": "infinity",
          "maxHeight": "infinity"
        }
      },
      "children": [
        {
          "id": "game_stack",
          "type": "vstack",
          "context": {
            "_spacing": 18,
            "_alignment": "leading",
            "filledCount": "{{ sum(map(range(36), ${board}[@{item}] == -1 ? 0 : 1)) }}",
            "allFilled": "{{ @{filledCount} == 36 }}",
            "row0Complete": "{{ ${board}[0] != -1 && ${board}[1] != -1 && ${board}[2] != -1 && ${board}[3] != -1 && ${board}[4] != -1 && ${board}[5] != -1 }}",
            "row1Complete": "{{ ${board}[6] != -1 && ${board}[7] != -1 && ${board}[8] != -1 && ${board}[9] != -1 && ${board}[10] != -1 && ${board}[11] != -1 }}",
            "row2Complete": "{{ ${board}[12] != -1 && ${board}[13] != -1 && ${board}[14] != -1 && ${board}[15] != -1 && ${board}[16] != -1 && ${board}[17] != -1 }}",
            "row3Complete": "{{ ${board}[18] != -1 && ${board}[19] != -1 && ${board}[20] != -1 && ${board}[21] != -1 && ${board}[22] != -1 && ${board}[23] != -1 }}",
            "row4Complete": "{{ ${board}[24] != -1 && ${board}[25] != -1 && ${board}[26] != -1 && ${board}[27] != -1 && ${board}[28] != -1 && ${board}[29] != -1 }}",
            "row5Complete": "{{ ${board}[30] != -1 && ${board}[31] != -1 && ${board}[32] != -1 && ${board}[33] != -1 && ${board}[34] != -1 && ${board}[35] != -1 }}",
            "col0Complete": "{{ ${board}[0] != -1 && ${board}[6] != -1 && ${board}[12] != -1 && ${board}[18] != -1 && ${board}[24] != -1 && ${board}[30] != -1 }}",
            "col1Complete": "{{ ${board}[1] != -1 && ${board}[7] != -1 && ${board}[13] != -1 && ${board}[19] != -1 && ${board}[25] != -1 && ${board}[31] != -1 }}",
            "col2Complete": "{{ ${board}[2] != -1 && ${board}[8] != -1 && ${board}[14] != -1 && ${board}[20] != -1 && ${board}[26] != -1 && ${board}[32] != -1 }}",
            "col3Complete": "{{ ${board}[3] != -1 && ${board}[9] != -1 && ${board}[15] != -1 && ${board}[21] != -1 && ${board}[27] != -1 && ${board}[33] != -1 }}",
            "col4Complete": "{{ ${board}[4] != -1 && ${board}[10] != -1 && ${board}[16] != -1 && ${board}[22] != -1 && ${board}[28] != -1 && ${board}[34] != -1 }}",
            "col5Complete": "{{ ${board}[5] != -1 && ${board}[11] != -1 && ${board}[17] != -1 && ${board}[23] != -1 && ${board}[29] != -1 && ${board}[35] != -1 }}",
            "row0Sum": "{{ ${board}[0] + ${board}[1] + ${board}[2] + ${board}[3] + ${board}[4] + ${board}[5] }}",
            "row1Sum": "{{ ${board}[6] + ${board}[7] + ${board}[8] + ${board}[9] + ${board}[10] + ${board}[11] }}",
            "row2Sum": "{{ ${board}[12] + ${board}[13] + ${board}[14] + ${board}[15] + ${board}[16] + ${board}[17] }}",
            "row3Sum": "{{ ${board}[18] + ${board}[19] + ${board}[20] + ${board}[21] + ${board}[22] + ${board}[23] }}",
            "row4Sum": "{{ ${board}[24] + ${board}[25] + ${board}[26] + ${board}[27] + ${board}[28] + ${board}[29] }}",
            "row5Sum": "{{ ${board}[30] + ${board}[31] + ${board}[32] + ${board}[33] + ${board}[34] + ${board}[35] }}",
            "col0Sum": "{{ ${board}[0] + ${board}[6] + ${board}[12] + ${board}[18] + ${board}[24] + ${board}[30] }}",
            "col1Sum": "{{ ${board}[1] + ${board}[7] + ${board}[13] + ${board}[19] + ${board}[25] + ${board}[31] }}",
            "col2Sum": "{{ ${board}[2] + ${board}[8] + ${board}[14] + ${board}[20] + ${board}[26] + ${board}[32] }}",
            "col3Sum": "{{ ${board}[3] + ${board}[9] + ${board}[15] + ${board}[21] + ${board}[27] + ${board}[33] }}",
            "col4Sum": "{{ ${board}[4] + ${board}[10] + ${board}[16] + ${board}[22] + ${board}[28] + ${board}[34] }}",
            "col5Sum": "{{ ${board}[5] + ${board}[11] + ${board}[17] + ${board}[23] + ${board}[29] + ${board}[35] }}",
            "rowsBalanced": "{{ @{row0Complete} && @{row0Sum} == 3 && @{row1Complete} && @{row1Sum} == 3 && @{row2Complete} && @{row2Sum} == 3 && @{row3Complete} && @{row3Sum} == 3 && @{row4Complete} && @{row4Sum} == 3 && @{row5Complete} && @{row5Sum} == 3 }}",
            "colsBalanced": "{{ @{col0Complete} && @{col0Sum} == 3 && @{col1Complete} && @{col1Sum} == 3 && @{col2Complete} && @{col2Sum} == 3 && @{col3Complete} && @{col3Sum} == 3 && @{col4Complete} && @{col4Sum} == 3 && @{col5Complete} && @{col5Sum} == 3 }}",
            "r0s": "{{ cast(${board}[0], 'str') + cast(${board}[1], 'str') + cast(${board}[2], 'str') + cast(${board}[3], 'str') + cast(${board}[4], 'str') + cast(${board}[5], 'str') }}",
            "r1s": "{{ cast(${board}[6], 'str') + cast(${board}[7], 'str') + cast(${board}[8], 'str') + cast(${board}[9], 'str') + cast(${board}[10], 'str') + cast(${board}[11], 'str') }}",
            "r2s": "{{ cast(${board}[12], 'str') + cast(${board}[13], 'str') + cast(${board}[14], 'str') + cast(${board}[15], 'str') + cast(${board}[16], 'str') + cast(${board}[17], 'str') }}",
            "r3s": "{{ cast(${board}[18], 'str') + cast(${board}[19], 'str') + cast(${board}[20], 'str') + cast(${board}[21], 'str') + cast(${board}[22], 'str') + cast(${board}[23], 'str') }}",
            "r4s": "{{ cast(${board}[24], 'str') + cast(${board}[25], 'str') + cast(${board}[26], 'str') + cast(${board}[27], 'str') + cast(${board}[28], 'str') + cast(${board}[29], 'str') }}",
            "r5s": "{{ cast(${board}[30], 'str') + cast(${board}[31], 'str') + cast(${board}[32], 'str') + cast(${board}[33], 'str') + cast(${board}[34], 'str') + cast(${board}[35], 'str') }}",
            "c0s": "{{ cast(${board}[0], 'str') + cast(${board}[6], 'str') + cast(${board}[12], 'str') + cast(${board}[18], 'str') + cast(${board}[24], 'str') + cast(${board}[30], 'str') }}",
            "c1s": "{{ cast(${board}[1], 'str') + cast(${board}[7], 'str') + cast(${board}[13], 'str') + cast(${board}[19], 'str') + cast(${board}[25], 'str') + cast(${board}[31], 'str') }}",
            "c2s": "{{ cast(${board}[2], 'str') + cast(${board}[8], 'str') + cast(${board}[14], 'str') + cast(${board}[20], 'str') + cast(${board}[26], 'str') + cast(${board}[32], 'str') }}",
            "c3s": "{{ cast(${board}[3], 'str') + cast(${board}[9], 'str') + cast(${board}[15], 'str') + cast(${board}[21], 'str') + cast(${board}[27], 'str') + cast(${board}[33], 'str') }}",
            "c4s": "{{ cast(${board}[4], 'str') + cast(${board}[10], 'str') + cast(${board}[16], 'str') + cast(${board}[22], 'str') + cast(${board}[28], 'str') + cast(${board}[34], 'str') }}",
            "c5s": "{{ cast(${board}[5], 'str') + cast(${board}[11], 'str') + cast(${board}[17], 'str') + cast(${board}[23], 'str') + cast(${board}[29], 'str') + cast(${board}[35], 'str') }}",
            "rowsUnique": "{{ @{r0s} != @{r1s} && @{r0s} != @{r2s} && @{r0s} != @{r3s} && @{r0s} != @{r4s} && @{r0s} != @{r5s} && @{r1s} != @{r2s} && @{r1s} != @{r3s} && @{r1s} != @{r4s} && @{r1s} != @{r5s} && @{r2s} != @{r3s} && @{r2s} != @{r4s} && @{r2s} != @{r5s} && @{r3s} != @{r4s} && @{r3s} != @{r5s} && @{r4s} != @{r5s} }}",
            "colsUnique": "{{ @{c0s} != @{c1s} && @{c0s} != @{c2s} && @{c0s} != @{c3s} && @{c0s} != @{c4s} && @{c0s} != @{c5s} && @{c1s} != @{c2s} && @{c1s} != @{c3s} && @{c1s} != @{c4s} && @{c1s} != @{c5s} && @{c2s} != @{c3s} && @{c2s} != @{c4s} && @{c2s} != @{c5s} && @{c3s} != @{c4s} && @{c3s} != @{c5s} && @{c4s} != @{c5s} }}",
            "selectedLabel": "{{ ${tool} == 0 ? '0' : (${tool} == 1 ? '1' : 'Clear') }}",
            "noTriples": "{{ !(${board}[0] == ${board}[1] && ${board}[1] == ${board}[2] && ${board}[0] != -1) && !(${board}[1] == ${board}[2] && ${board}[2] == ${board}[3] && ${board}[1] != -1) && !(${board}[2] == ${board}[3] && ${board}[3] == ${board}[4] && ${board}[2] != -1) && !(${board}[3] == ${board}[4] && ${board}[4] == ${board}[5] && ${board}[3] != -1) && !(${board}[6] == ${board}[7] && ${board}[7] == ${board}[8] && ${board}[6] != -1) && !(${board}[7] == ${board}[8] && ${board}[8] == ${board}[9] && ${board}[7] != -1) && !(${board}[8] == ${board}[9] && ${board}[9] == ${board}[10] && ${board}[8] != -1) && !(${board}[9] == ${board}[10] && ${board}[10] == ${board}[11] && ${board}[9] != -1) && !(${board}[12] == ${board}[13] && ${board}[13] == ${board}[14] && ${board}[12] != -1) && !(${board}[13] == ${board}[14] && ${board}[14] == ${board}[15] && ${board}[13] != -1) && !(${board}[14] == ${board}[15] && ${board}[15] == ${board}[16] && ${board}[14] != -1) && !(${board}[15] == ${board}[16] && ${board}[16] == ${board}[17] && ${board}[15] != -1) && !(${board}[18] == ${board}[19] && ${board}[19] == ${board}[20] && ${board}[18] != -1) && !(${board}[19] == ${board}[20] && ${board}[20] == ${board}[21] && ${board}[19] != -1) && !(${board}[20] == ${board}[21] && ${board}[21] == ${board}[22] && ${board}[20] != -1) && !(${board}[21] == ${board}[22] && ${board}[22] == ${board}[23] && ${board}[21] != -1) && !(${board}[24] == ${board}[25] && ${board}[25] == ${board}[26] && ${board}[24] != -1) && !(${board}[25] == ${board}[26] && ${board}[26] == ${board}[27] && ${board}[25] != -1) && !(${board}[26] == ${board}[27] && ${board}[27] == ${board}[28] && ${board}[26] != -1) && !(${board}[27] == ${board}[28] && ${board}[28] == ${board}[29] && ${board}[27] != -1) && !(${board}[30] == ${board}[31] && ${board}[31] == ${board}[32] && ${board}[30] != -1) && !(${board}[31] == ${board}[32] && ${board}[32] == ${board}[33] && ${board}[31] != -1) && !(${board}[32] == ${board}[33] && ${board}[33] == ${board}[34] && ${board}[32] != -1) && !(${board}[33] == ${board}[34] && ${board}[34] == ${board}[35] && ${board}[33] != -1) && !(${board}[0] == ${board}[6] && ${board}[6] == ${board}[12] && ${board}[0] != -1) && !(${board}[6] == ${board}[12] && ${board}[12] == ${board}[18] && ${board}[6] != -1) && !(${board}[12] == ${board}[18] && ${board}[18] == ${board}[24] && ${board}[12] != -1) && !(${board}[18] == ${board}[24] && ${board}[24] == ${board}[30] && ${board}[18] != -1) && !(${board}[1] == ${board}[7] && ${board}[7] == ${board}[13] && ${board}[1] != -1) && !(${board}[7] == ${board}[13] && ${board}[13] == ${board}[19] && ${board}[7] != -1) && !(${board}[13] == ${board}[19] && ${board}[19] == ${board}[25] && ${board}[13] != -1) && !(${board}[19] == ${board}[25] && ${board}[25] == ${board}[31] && ${board}[19] != -1) && !(${board}[2] == ${board}[8] && ${board}[8] == ${board}[14] && ${board}[2] != -1) && !(${board}[8] == ${board}[14] && ${board}[14] == ${board}[20] && ${board}[8] != -1) && !(${board}[14] == ${board}[20] && ${board}[20] == ${board}[26] && ${board}[14] != -1) && !(${board}[20] == ${board}[26] && ${board}[26] == ${board}[32] && ${board}[20] != -1) && !(${board}[3] == ${board}[9] && ${board}[9] == ${board}[15] && ${board}[3] != -1) && !(${board}[9] == ${board}[15] && ${board}[15] == ${board}[21] && ${board}[9] != -1) && !(${board}[15] == ${board}[21] && ${board}[21] == ${board}[27] && ${board}[15] != -1) && !(${board}[21] == ${board}[27] && ${board}[27] == ${board}[33] && ${board}[21] != -1) && !(${board}[4] == ${board}[10] && ${board}[10] == ${board}[16] && ${board}[4] != -1) && !(${board}[10] == ${board}[16] && ${board}[16] == ${board}[22] && ${board}[10] != -1) && !(${board}[16] == ${board}[22] && ${board}[22] == ${board}[28] && ${board}[16] != -1) && !(${board}[22] == ${board}[28] && ${board}[28] == ${board}[34] && ${board}[22] != -1) && !(${board}[5] == ${board}[11] && ${board}[11] == ${board}[17] && ${board}[5] != -1) && !(${board}[11] == ${board}[17] && ${board}[17] == ${board}[23] && ${board}[11] != -1) && !(${board}[17] == ${board}[23] && ${board}[23] == ${board}[29] && ${board}[17] != -1) && !(${board}[23] == ${board}[29] && ${board}[29] == ${board}[35] && ${board}[23] != -1) }}",
            "solved": "{{ @{allFilled} && @{noTriples} && @{rowsBalanced} && @{colsBalanced} && @{rowsUnique} && @{colsUnique} }}"
          },
          "style": {
            "layout": {
              "maxWidth": "infinity",
              "padding": {
                "top": 14,
                "bottom": 28,
                "leading": 16,
                "trailing": 16
              }
            }
          },
          "children": [
            {
              "id": "hero_card",
              "type": "vstack",
              "context": {
                "_spacing": 14,
                "_alignment": "leading"
              },
              "style": {
                "layout": {
                  "padding": 18
                },
                "common": {
                  "background": {
                    "light": "#F6F7FB",
                    "dark": "#171A24"
                  },
                  "foreground": {
                    "light": "#161826",
                    "dark": "#F7F8FC"
                  },
                  "cornerRadius": 22
                },
                "shadow": {
                  "color": {
                    "color": "black",
                    "opacity": 0.16
                  },
                  "radius": 14,
                  "y": 6
                }
              },
              "children": [
                {
                  "id": "hero_top",
                  "type": "hstack",
                  "context": {
                    "_spacing": 12,
                    "_alignment": "center"
                  },
                  "children": [
                    {
                      "id": "hero_icon_wrap",
                      "type": "zstack",
                      "style": {
                        "layout": {
                          "width": 50,
                          "height": 50
                        },
                        "common": {
                          "background": {
                            "gradient": {
                              "linear": {
                                "colors": [
                                  "#5B7CFA",
                                  "#38B6FF"
                                ],
                                "startPoint": "topLeading",
                                "endPoint": "bottomTrailing"
                              }
                            }
                          },
                          "foreground": {
                            "color": "white"
                          },
                          "cornerRadius": 16
                        },
                        "shadow": {
                          "color": {
                            "color": "#5B7CFA",
                            "opacity": 0.28
                          },
                          "radius": 10,
                          "y": 4
                        }
                      },
                      "children": [
                        {
                          "id": "hero_icon",
                          "type": "image",
                          "context": {
                            "_source": "sf://square.grid.3x3.fill"
                          },
                          "style": {
                            "layout": {
                              "width": 24,
                              "height": 24
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "hero_texts",
                      "type": "vstack",
                      "context": {
                        "_spacing": 4,
                        "_alignment": "leading"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "hero_value",
                          "type": "text",
                          "context": {
                            "_text": "{{ cast(@{filledCount}, 'str') + ' / 36 filled' }}"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "title3",
                                "weight": "bold"
                              },
                              "foreground": {
                                "color": "onSurface"
                              }
                            }
                          }
                        },
                        {
                          "id": "hero_copy",
                          "type": "text",
                          "context": {
                            "_text": "Keep every line balanced, unique, and free of triples."
                          },
                          "style": {
                            "common": {
                              "font": "subheadline",
                              "foreground": {
                                "color": "secondary"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "tool_pill",
                      "type": "vstack",
                      "context": {
                        "_spacing": 2,
                        "_alignment": "center"
                      },
                      "style": {
                        "layout": {
                          "padding": {
                            "top": 8,
                            "bottom": 8,
                            "leading": 12,
                            "trailing": 12
                          }
                        },
                        "common": {
                          "background": {
                            "light": "#E8EDFF",
                            "dark": "#22304F"
                          },
                          "foreground": {
                            "light": "#233A8B",
                            "dark": "#D8E3FF"
                          },
                          "cornerRadius": 14
                        }
                      },
                      "children": [
                        {
                          "id": "tool_cap",
                          "type": "text",
                          "context": {
                            "_text": "Tool"
                          },
                          "style": {
                            "common": {
                              "font": "caption2"
                            }
                          }
                        },
                        {
                          "id": "tool_val",
                          "type": "text",
                          "context": {
                            "_text": "@{selectedLabel}"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "headline",
                                "weight": "bold"
                              }
                            }
                          }
                        }
                      ]
                    }
                  ]
                },
                {
                  "id": "rule_row",
                  "type": "hstack",
                  "context": {
                    "_spacing": 10,
                    "_alignment": "center"
                  },
                  "children": [
                    {
                      "id": "runs_chip",
                      "type": "vstack",
                      "context": {
                        "_title": "No triples",
                        "_image": "sf://checkmark.shield.fill"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity",
                          "padding": 12
                        },
                        "common": {
                          "background": "{{ @{noTriples} ? {'color': '#173F2B'} : {'color': '#4A1F27'} }}",
                          "foreground": "{{ @{noTriples} ? {'color': '#D8F6E5'} : {'color': '#FFD9DE'} }}",
                          "cornerRadius": 16
                        }
                      },
                      "children": [
                        {
                          "id": "runs_head",
                          "type": "label",
                          "context": {
                            "_title": "No triples",
                            "_icon": "checkmark.shield.fill"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "caption",
                                "weight": "semibold"
                              }
                            }
                          }
                        },
                        {
                          "id": "runs_sub",
                          "type": "text",
                          "context": {
                            "_text": "{{ @{noTriples} ? 'Safe so far' : 'Fix the run' }}"
                          },
                          "style": {
                            "common": {
                              "font": "caption2",
                              "foreground": "{{ @{noTriples} ? {'color': '#D8F6E5'} : {'color': '#FFD9DE'} }}"
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "balance_chip",
                      "type": "vstack",
                      "context": {
                        "_spacing": 4,
                        "_alignment": "leading",
                        "ok": "{{ @{rowsBalanced} && @{colsBalanced} }}"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity",
                          "padding": 12
                        },
                        "common": {
                          "background": "{{ @{ok} ? {'color': '#173F2B'} : (@{allFilled} ? {'color': '#4A1F27'} : {'color': '#3B314B'}) }}",
                          "foreground": "{{ @{ok} ? {'color': '#D8F6E5'} : (@{allFilled} ? {'color': '#FFD9DE'} : {'color': '#F0E7FF'}) }}",
                          "cornerRadius": 16
                        }
                      },
                      "children": [
                        {
                          "id": "balance_head",
                          "type": "label",
                          "context": {
                            "_title": "3 of each",
                            "_image": "sf://equal.square.fill"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "caption",
                                "weight": "semibold"
                              }
                            }
                          }
                        },
                        {
                          "id": "balance_sub",
                          "type": "text",
                          "context": {
                            "_text": "{{ @{ok} ? 'Every line balanced' : (@{allFilled} ? 'Counts are off' : 'Ends checked on fill') }}"
                          },
                          "style": {
                            "common": {
                              "font": "caption2",
                              "foreground": "{{ @{ok} ? {'color': '#D8F6E5'} : (@{allFilled} ? {'color': '#FFD9DE'} : {'color': '#F0E7FF'}) }}"
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "unique_chip",
                      "type": "vstack",
                      "context": {
                        "_spacing": 4,
                        "_alignment": "leading",
                        "ok": "{{ @{rowsUnique} && @{colsUnique} && @{allFilled} }}"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity",
                          "padding": 12
                        },
                        "common": {
                          "background": "{{ @{ok} ? {'color': '#173F2B'} : (@{allFilled} ? {'color': '#4A1F27'} : {'color': '#2C394E'}) }}",
                          "foreground": "{{ @{ok} ? {'color': '#D8F6E5'} : (@{allFilled} ? {'color': '#FFD9DE'} : {'color': '#D9EEFF'}) }}",
                          "cornerRadius": 16
                        }
                      },
                      "children": [
                        {
                          "id": "unique_head",
                          "type": "label",
                          "context": {
                            "_title": "Unique lines",
                            "_image": "sf://sparkles.rectangle.stack.fill"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "caption",
                                "weight": "semibold"
                              }
                            }
                          }
                        },
                        {
                          "id": "unique_sub",
                          "type": "text",
                          "context": {
                            "_text": "{{ @{ok} ? 'All different' : (@{allFilled} ? 'Duplicate line found' : 'Final check later') }}"
                          },
                          "style": {
                            "common": {
                              "font": "caption2",
                              "foreground": "{{ @{ok} ? {'color': '#D8F6E5'} : (@{allFilled} ? {'color': '#FFD9DE'} : {'color': '#D9EEFF'}) }}"
                            }
                          }
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "id": "board_card",
              "type": "vstack",
              "context": {
                "_spacing": 12,
                "_alignment": "leading"
              },
              "style": {
                "layout": {
                  "padding": 16
                },
                "common": {
                  "background": {
                    "light": "#F4F5FA",
                    "dark": "#141720"
                  },
                  "foreground": {
                    "light": "#151826",
                    "dark": "#F4F7FF"
                  },
                  "cornerRadius": 24
                },
                "shadow": {
                  "color": {
                    "color": "black",
                    "opacity": 0.18
                  },
                  "radius": 16,
                  "y": 8
                }
              },
              "children": [
                {
                  "id": "board_copy",
                  "type": "text",
                  "context": {
                    "_text": "Tap any lighter square to place the selected value. Darker squares are fixed clues."
                  },
                  "style": {
                    "common": {
                      "font": "subheadline",
                      "foreground": {
                        "color": "secondary"
                      }
                    }
                  }
                },
                {
                  "id": "board_grid",
                  "type": "grid",
                  "context": {
                    "_gridType": "lazyVGrid",
                    "_spacing": 8
                  },
                  "style": {
                    "grid": {
                      "columns": [
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "maximum": 60,
                          "spacing": 8
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "maximum": 60,
                          "spacing": 8
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "maximum": 60,
                          "spacing": 8
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "maximum": 60,
                          "spacing": 8
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "maximum": 60,
                          "spacing": 8
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "maximum": 60,
                          "spacing": 8
                        }
                      ]
                    },
                    "layout": {
                      "maxWidth": "infinity"
                    }
                  },
                  "children": [
                    {
                      "id": "board_cells",
                      "type": "dynamic",
                      "context": {
                        "_data": "{{ range(36) }}"
                      },
                      "prototype": {
                        "id": "board_cell",
                        "type": "button",
                        "context": {
                          "_label": "",
                          "i": "@{index}",
                          "clue": "{{ ${clues}[@{index}] != -1 }}",
                          "value": "{{ ${board}[@{index}] }}",
                          "empty": "{{ @{value} == -1 }}",
                          "rowStart": "{{ cast(@{index} / 6, 'int') * 6 }}",
                          "col": "{{ @{index} % 6 }}",
                          "r0": "{{ @{index} == @{rowStart} + 0 ? ${tool} : ${board}[@{rowStart} + 0] }}",
                          "r1": "{{ @{index} == @{rowStart} + 1 ? ${tool} : ${board}[@{rowStart} + 1] }}",
                          "r2": "{{ @{index} == @{rowStart} + 2 ? ${tool} : ${board}[@{rowStart} + 2] }}",
                          "r3": "{{ @{index} == @{rowStart} + 3 ? ${tool} : ${board}[@{rowStart} + 3] }}",
                          "r4": "{{ @{index} == @{rowStart} + 4 ? ${tool} : ${board}[@{rowStart} + 4] }}",
                          "r5": "{{ @{index} == @{rowStart} + 5 ? ${tool} : ${board}[@{rowStart} + 5] }}",
                          "c0": "{{ @{index} == 0 * 6 + @{col} ? ${tool} : ${board}[0 * 6 + @{col}] }}",
                          "c1": "{{ @{index} == 1 * 6 + @{col} ? ${tool} : ${board}[1 * 6 + @{col}] }}",
                          "c2": "{{ @{index} == 2 * 6 + @{col} ? ${tool} : ${board}[2 * 6 + @{col}] }}",
                          "c3": "{{ @{index} == 3 * 6 + @{col} ? ${tool} : ${board}[3 * 6 + @{col}] }}",
                          "c4": "{{ @{index} == 4 * 6 + @{col} ? ${tool} : ${board}[4 * 6 + @{col}] }}",
                          "c5": "{{ @{index} == 5 * 6 + @{col} ? ${tool} : ${board}[5 * 6 + @{col}] }}",
                          "makesTriple": "{{ (@{r0} == @{r1} && @{r1} == @{r2} && @{r0} != -1) || (@{r1} == @{r2} && @{r2} == @{r3} && @{r1} != -1) || (@{r2} == @{r3} && @{r3} == @{r4} && @{r2} != -1) || (@{r3} == @{r4} && @{r4} == @{r5} && @{r3} != -1) || (@{c0} == @{c1} && @{c1} == @{c2} && @{c0} != -1) || (@{c1} == @{c2} && @{c2} == @{c3} && @{c1} != -1) || (@{c2} == @{c3} && @{c3} == @{c4} && @{c2} != -1) || (@{c3} == @{c4} && @{c4} == @{c5} && @{c3} != -1) }}"
                        },
                        "style": {
                          "layout": {
                            "height": 56,
                            "maxWidth": "infinity"
                          },
                          "button": {
                            "custom": {
                              "layout": {
                                "height": 56,
                                "maxWidth": "infinity",
                                "minHeight": 56
                              },
                              "common": {
                                "background": "{{ @{clue} ? {'gradient': {'linear': {'colors': ['#485CF6', '#27B6F6'], 'startPoint': 'topLeading', 'endPoint': 'bottomTrailing'}}} : (@{empty} ? {'light': '#E7E9F1', 'dark': '#232737'} : (@{value} == 0 ? {'light': '#D9EBFF', 'dark': '#15314D'} : {'light': '#FFE8D0', 'dark': '#4A2D13'})) }}",
                                "cornerRadius": 14
                              }
                            }
                          },
                          "common": {
                            "disabled": "@{clue}",
                            "scale": "{{ @{empty} ? 1 : 0.97 }}"
                          },
                          "animation": {
                            "kind": "spring",
                            "value": "@{value}",
                            "duration": 0.28,
                            "bounce": 0.34
                          }
                        },
                        "children": [
                          {
                            "id": "board_cell_text",
                            "type": "text",
                            "context": {
                              "_text": "{{ @{empty} ? '' : cast(@{value}, 'str') }}"
                            },
                            "style": {
                              "common": {
                                "font": {
                                  "kind": "title3",
                                  "weight": "bold"
                                },
                                "foreground": "{{ @{clue} ? {'color': 'white'} : (@{empty} ? {'color': 'secondary'} : (@{value} == 0 ? {'light': '#0F2A4D', 'dark': '#DCEBFF'} : {'light': '#5A3200', 'dark': '#FFE9D3'})) }}"
                              }
                            }
                          }
                        ],
                        "events": {
                          "onTap": [
                            {
                              "condition": {
                                "id": "move_ok",
                                "input": "{{ ${tool} == -1 || !@{makesTriple} }}",
                                "output": {
                                  "success": [
                                    {
                                      "state": {
                                        "id": "apply_move",
                                        "input": {
                                          "board": "{{ setAt(${board}, @{i}, ${tool}) }}",
                                          "message": "",
                                          "celebrated": false
                                        },
                                        "output": {
                                          "success": [
                                            {
                                              "repo": {
                                                "id": "save_board",
                                                "input": {
                                                  "repositoryId": "binary_grid_store",
                                                  "operation": "create",
                                                  "params": {
                                                    "collection": "games",
                                                    "documentId": "current",
                                                    "body": {
                                                      "board": "${board}",
                                                      "clues": "${clues}"
                                                    },
                                                    "rewrite": true
                                                  }
                                                }
                                              }
                                            },
                                            {
                                              "service": {
                                                "id": "move_haptic",
                                                "input": {
                                                  "serviceId": "binary_audio",
                                                  "params": {
                                                    "haptic": "light"
                                                  }
                                                }
                                              }
                                            },
                                            {
                                              "condition": {
                                                "id": "check_solved",
                                                "input": "@{solved}",
                                                "output": {
                                                  "success": [
                                                    {
                                                      "state": {
                                                        "id": "mark_solved",
                                                        "input": {
                                                          "celebrated": true
                                                        },
                                                        "output": {
                                                          "success": [
                                                            {
                                                              "service": {
                                                                "id": "win_haptic",
                                                                "input": {
                                                                  "serviceId": "binary_audio",
                                                                  "params": {
                                                                    "haptic": "success"
                                                                  }
                                                                }
                                                              }
                                                            }
                                                          ]
                                                        }
                                                      }
                                                    }
                                                  ]
                                                }
                                              }
                                            }
                                          ]
                                        }
                                      }
                                    }
                                  ],
                                  "failure": [
                                    {
                                      "state": {
                                        "id": "move_blocked",
                                        "input": {
                                          "message": "That placement would create three matching numbers."
                                        },
                                        "output": {
                                          "success": [
                                            {
                                              "service": {
                                                "id": "blocked_haptic",
                                                "input": {
                                                  "serviceId": "binary_audio",
                                                  "params": {
                                                    "haptic": "warning"
                                                  }
                                                }
                                              }
                                            }
                                          ]
                                        }
                                      }
                                    }
                                  ]
                                }
                              }
                            }
                          ]
                        }
                      }
                    }
                  ]
                }
              ]
            },
            {
              "id": "palette_card",
              "type": "vstack",
              "context": {
                "_spacing": 14,
                "_alignment": "leading"
              },
              "style": {
                "layout": {
                  "padding": 16
                },
                "common": {
                  "background": {
                    "light": "#F4F5FA",
                    "dark": "#141720"
                  },
                  "foreground": {
                    "light": "#151826",
                    "dark": "#F4F7FF"
                  },
                  "cornerRadius": 22
                },
                "shadow": {
                  "color": {
                    "color": "black",
                    "opacity": 0.14
                  },
                  "radius": 14,
                  "y": 6
                }
              },
              "children": [
                {
                  "id": "palette_head",
                  "type": "label",
                  "context": {
                    "_title": "Place a value",
                    "_image": "sf://hand.tap.fill"
                  },
                  "style": {
                    "common": {
                      "font": {
                        "kind": "headline",
                        "weight": "semibold"
                      }
                    }
                  }
                },
                {
                  "id": "palette_row",
                  "type": "vstack",
                  "context": {
                    "_spacing": 10,
                    "_alignment": "leading"
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity"
                    }
                  },
                  "children": [
                    {
                      "id": "palette_value_row",
                      "type": "hstack",
                      "context": {
                        "_spacing": 10,
                        "_alignment": "center"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "tool_zero",
                          "type": "button",
                          "context": {
                            "_label": "0"
                          },
                          "style": {
                            "layout": {
                              "maxWidth": "infinity",
                              "minHeight": 78
                            },
                            "button": {
                              "custom": {
                                "common": {
                                  "background": "{{ ${tool} == 0 ? {'gradient': {'linear': {'colors': ['#4F74FF', '#35BCFF'], 'startPoint': 'topLeading', 'endPoint': 'bottomTrailing'}}} : {'light': '#E2EDFF', 'dark': '#1D3153'} }}",
                                  "foreground": "{{ ${tool} == 0 ? {'color': 'white'} : {'light': '#234181', 'dark': '#DCE9FF'} }}",
                                  "cornerRadius": 18,
                                  "font": {
                                    "kind": "largeTitle",
                                    "weight": "bold"
                                  }
                                },
                                "layout": {
                                  "maxWidth": "infinity",
                                  "minHeight": 78
                                }
                              }
                            }
                          },
                          "events": {
                            "onTap": [
                              {
                                "state": {
                                  "id": "pick_zero",
                                  "input": {
                                    "tool": 0,
                                    "message": ""
                                  },
                                  "output": {
                                    "success": [
                                      {
                                        "service": {
                                          "id": "pick_zero_haptic",
                                          "input": {
                                            "serviceId": "binary_audio",
                                            "params": {
                                              "haptic": "light"
                                            }
                                          }
                                        }
                                      }
                                    ]
                                  }
                                }
                              }
                            ]
                          }
                        },
                        {
                          "id": "tool_one",
                          "type": "button",
                          "context": {
                            "_label": "1"
                          },
                          "style": {
                            "layout": {
                              "maxWidth": "infinity",
                              "minHeight": 78
                            },
                            "button": {
                              "custom": {
                                "common": {
                                  "background": "{{ ${tool} == 1 ? {'gradient': {'linear': {'colors': ['#FF9F4A', '#FF6E5E'], 'startPoint': 'topLeading', 'endPoint': 'bottomTrailing'}}} : {'light': '#FFF0DF', 'dark': '#4B2D1A'} }}",
                                  "foreground": "{{ ${tool} == 1 ? {'color': 'white'} : {'light': '#7A4200', 'dark': '#FFE9D2'} }}",
                                  "cornerRadius": 18,
                                  "font": {
                                    "kind": "largeTitle",
                                    "weight": "bold"
                                  }
                                },
                                "layout": {
                                  "maxWidth": "infinity",
                                  "minHeight": 78
                                }
                              }
                            }
                          },
                          "events": {
                            "onTap": [
                              {
                                "state": {
                                  "id": "pick_one",
                                  "input": {
                                    "tool": 1,
                                    "message": ""
                                  },
                                  "output": {
                                    "success": [
                                      {
                                        "service": {
                                          "id": "pick_one_haptic",
                                          "input": {
                                            "serviceId": "binary_audio",
                                            "params": {
                                              "haptic": "light"
                                            }
                                          }
                                        }
                                      }
                                    ]
                                  }
                                }
                              }
                            ]
                          }
                        }
                      ]
                    },
                    {
                      "id": "tool_clear",
                      "type": "button",
                      "context": {
                        "_label": "Clear"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity",
                          "minHeight": 56
                        },
                        "button": {
                          "custom": {
                            "common": {
                              "background": "{{ ${tool} == -1 ? {'light': '#DDE4F8', 'dark': '#2B3954'} : {'light': '#E8EBF4', 'dark': '#232838'} }}",
                              "foreground": "{{ ${tool} == -1 ? {'light': '#203A79', 'dark': '#DBE8FF'} : {'color': 'secondary'} }}",
                              "cornerRadius": 16,
                              "font": {
                                "kind": "headline",
                                "weight": "semibold"
                              }
                            }
                          }
                        }
                      },
                      "events": {
                        "onTap": [
                          {
                            "state": {
                              "id": "pick_clear",
                              "input": {
                                "tool": -1,
                                "message": ""
                              },
                              "output": {
                                "success": [
                                  {
                                    "service": {
                                      "id": "pick_clear_haptic",
                                      "input": {
                                        "serviceId": "binary_audio",
                                        "params": {
                                          "haptic": "light"
                                        }
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          }
                        ]
                      }
                    }
                  ]
                },
                {
                  "id": "restart_hint",
                  "type": "text",
                  "context": {
                    "_text": "Restart generates a fresh 6×6 clue layout with fixed 0 and 1 cells."
                  },
                  "style": {
                    "common": {
                      "font": "caption",
                      "foreground": {
                        "color": "secondary"
                      }
                    }
                  }
                },
                {
                  "id": "restart_btn",
                  "type": "button",
                  "context": {
                    "_label": "Restart puzzle"
                  },
                  "style": {
                    "button": {
                      "standard": {
                        "type": "bordered",
                        "shape": "capsule"
                      }
                    },
                    "common": {
                      "tint": {
                        "color": "accentColor"
                      }
                    },
                    "modal": {
                      "alert": {
                        "isPresented": "${showResetAlert}",
                        "title": "Restart this puzzle?",
                        "message": "All filled-in squares will be cleared and a fresh clue layout will be generated.",
                        "actions": [
                          {
                            "id": "keep_board",
                            "type": "button",
                            "context": {
                              "_label": "Keep board"
                            },
                            "events": {
                              "onTap": [
                                {
                                  "state": {
                                    "id": "dismiss_reset",
                                    "input": {
                                      "showResetAlert": false
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          {
                            "id": "confirm_restart",
                            "type": "button",
                            "context": {
                              "_label": "Restart"
                            },
                            "style": {
                              "common": {
                                "tint": "red"
                              }
                            },
                            "events": {
                              "onTap": [
                                {
                                  "state": {
                                    "id": "pick_variant",
                                    "input": {
                                      "puzzleVariant": "{{ random(0, 7) }}"
                                    },
                                    "output": {
                                      "success": [
                                        {
                                          "interval": {
                                            "id": "restart_after_variant",
                                            "input": {
                                              "delay": 0.01
                                            },
                                            "output": {
                                              "success": [
                                                {
                                                  "state": {
                                                    "id": "build_next_clues",
                                                    "input": {
                                                      "nextClues": "{{ switch(${puzzleVariant} == 0, [0,-1,1,-1,-1,-1,-1,1,-1,-1,-1,1,1,-1,-1,-1,0,-1,-1,1,-1,0,-1,-1,-1,-1,1,-1,-1,1,1,-1,-1,-1,1,-1], ${puzzleVariant} == 1, [-1,0,-1,1,-1,-1,0,-1,-1,-1,1,-1,-1,-1,1,-1,-1,0,1,1,-1,-1,-1,-1,-1,-1,-1,0,0,-1,-1,-1,0,1,-1,-1], ${puzzleVariant} == 2, [-1,-1,-1,-1,0,1,-1,1,0,-1,-1,-1,1,-1,-1,1,-1,-1,-1,-1,0,-1,-1,0,0,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1], ${puzzleVariant} == 3, [0,-1,-1,-1,-1,1,-1,-1,0,0,-1,-1,-1,0,-1,-1,0,-1,1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1], ${puzzleVariant} == 4, [1,-1,0,-1,-1,-1,-1,0,-1,-1,-1,0,0,-1,-1,-1,1,-1,-1,0,-1,1,-1,-1,-1,-1,0,-1,-1,0,0,-1,-1,-1,0,-1], ${puzzleVariant} == 5, [-1,1,-1,0,-1,-1,1,-1,-1,-1,0,-1,-1,-1,0,-1,-1,1,0,0,-1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,1,0,-1,-1], ${puzzleVariant} == 6, [-1,-1,-1,-1,1,0,-1,0,1,-1,-1,-1,0,-1,-1,0,-1,-1,-1,-1,1,-1,-1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,-1], [1,-1,-1,-1,-1,0,-1,-1,1,1,-1,-1,-1,1,-1,-1,1,-1,0,-1,-1,-1,0,-1,-1,0,-1,-1,-1,0,0,-1,-1,0,-1,-1]) }}"
                                                    },
                                                    "output": {
                                                      "success": [
                                                        {
                                                          "interval": {
                                                            "id": "restart_after_clues",
                                                            "input": {
                                                              "delay": 0.01
                                                            },
                                                            "output": {
                                                              "success": [
                                                                {
                                                                  "state": {
                                                                    "id": "do_restart",
                                                                    "input": {
                                                                      "clues": "${nextClues}",
                                                                      "board": "${nextClues}",
                                                                      "message": "New puzzle ready.",
                                                                      "celebrated": false,
                                                                      "showResetAlert": false
                                                                    },
                                                                    "output": {
                                                                      "success": [
                                                                        {
                                                                          "repo": {
                                                                            "id": "save_restart",
                                                                            "input": {
                                                                              "repositoryId": "binary_grid_store",
                                                                              "operation": "create",
                                                                              "params": {
                                                                                "collection": "games",
                                                                                "documentId": "current",
                                                                                "body": {
                                                                                  "board": "${board}",
                                                                                  "clues": "${clues}"
                                                                                },
                                                                                "rewrite": true
                                                                              }
                                                                            }
                                                                          }
                                                                        },
                                                                        {
                                                                          "service": {
                                                                            "id": "restart_haptic",
                                                                            "input": {
                                                                              "serviceId": "binary_audio",
                                                                              "params": {
                                                                                "haptic": "medium"
                                                                              }
                                                                            }
                                                                          }
                                                                        }
                                                                      ]
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "interval": {
                                                                    "id": "restart_after_clues",
                                                                    "input": {
                                                                      "cancel": true
                                                                    }
                                                                  }
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        }
                                                      ]
                                                    }
                                                  }
                                                },
                                                {
                                                  "interval": {
                                                    "id": "restart_after_variant",
                                                    "input": {
                                                      "cancel": true
                                                    }
                                                  }
                                                }
                                              ]
                                            }
                                          }
                                        }
                                      ]
                                    }
                                  }
                                }
                              ]
                            }
                          }
                        ]
                      }
                    }
                  },
                  "events": {
                    "onTap": [
                      {
                        "state": {
                          "id": "show_reset",
                          "input": {
                            "showResetAlert": true
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            },
            {
              "id": "status_zone",
              "type": "vstack",
              "context": {
                "_spacing": 14,
                "_alignment": "leading"
              },
              "children": [
                {
                  "id": "progress_card",
                  "type": "vstack",
                  "context": {
                    "_spacing": 10,
                    "_alignment": "leading"
                  },
                  "style": {
                    "layout": {
                      "padding": 16
                    },
                    "common": {
                      "background": {
                        "light": "#F4F5FA",
                        "dark": "#141720"
                      },
                      "foreground": {
                        "light": "#151826",
                        "dark": "#F4F7FF"
                      },
                      "cornerRadius": 20
                    },
                    "shadow": {
                      "color": {
                        "color": "black",
                        "opacity": 0.12
                      },
                      "radius": 12,
                      "y": 5
                    }
                  },
                  "children": [
                    {
                      "id": "progress_row",
                      "type": "hstack",
                      "context": {
                        "_spacing": 10,
                        "_alignment": "center"
                      },
                      "children": [
                        {
                          "id": "progress_label",
                          "type": "label",
                          "context": {
                            "_title": "Progress",
                            "_image": "sf://chart.bar.fill"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "headline",
                                "weight": "semibold"
                              }
                            }
                          }
                        },
                        {
                          "id": "progress_remaining",
                          "type": "text",
                          "context": {
                            "_text": "{{ cast(36 - @{filledCount}, 'str') + ' left' }}"
                          },
                          "style": {
                            "layout": {
                              "maxWidth": "infinity"
                            },
                            "text": {
                              "multilineTextAlignment": "trailing"
                            },
                            "common": {
                              "font": "subheadline",
                              "foreground": {
                                "color": "secondary"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "progress_bar",
                      "type": "progress",
                      "context": {
                        "_value": "{{ @{filledCount} / 36 }}"
                      },
                      "style": {
                        "common": {
                          "tint": {
                            "light": "#5B7CFA",
                            "dark": "#6C8EFF"
                          }
                        }
                      }
                    },
                    {
                      "id": "progress_note",
                      "type": "text",
                      "context": {
                        "_text": "{{ @{allFilled} ? 'Board filled. Final rules are checked below.' : 'Choose 0, 1, or Clear, then tap a lighter square.' }}"
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": "secondary"
                          }
                        }
                      }
                    }
                  ]
                },
                {
                  "id": "solved_banner",
                  "type": "conditional",
                  "context": {
                    "_condition": "@{solved}",
                    "_trueComponent": {
                      "id": "solved_banner_card",
                      "type": "hstack",
                      "context": {
                        "_spacing": 10,
                        "_alignment": "center"
                      },
                      "style": {
                        "layout": {
                          "padding": {
                            "top": 14,
                            "bottom": 14,
                            "leading": 18,
                            "trailing": 18
                          }
                        },
                        "common": {
                          "background": {
                            "gradient": {
                              "linear": {
                                "colors": [
                                  "#35C77C",
                                  "#2DB7C8"
                                ],
                                "startPoint": "topLeading",
                                "endPoint": "bottomTrailing"
                              }
                            }
                          },
                          "foreground": {
                            "color": "white"
                          },
                          "cornerRadius": 20
                        },
                        "shadow": {
                          "color": {
                            "color": "#35C77C",
                            "opacity": 0.28
                          },
                          "radius": 12,
                          "y": 5
                        },
                        "animation": {
                          "kind": "spring",
                          "value": "@{solved}",
                          "duration": 0.35,
                          "bounce": 0.42
                        }
                      },
                      "children": [
                        {
                          "id": "solved_icon",
                          "type": "image",
                          "context": {
                            "_source": "sf://checkmark.seal.fill"
                          },
                          "style": {
                            "layout": {
                              "width": 24,
                              "height": 24
                            }
                          }
                        },
                        {
                          "id": "solved_texts",
                          "type": "vstack",
                          "context": {
                            "_spacing": 2,
                            "_alignment": "leading"
                          },
                          "style": {
                            "layout": {
                              "maxWidth": "infinity"
                            }
                          },
                          "children": [
                            {
                              "id": "solved_title",
                              "type": "text",
                              "context": {
                                "_text": "Solved!"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "headline",
                                    "weight": "bold"
                                  },
                                  "foreground": {
                                    "color": "white"
                                  }
                                }
                              }
                            },
                            {
                              "id": "solved_copy",
                              "type": "text",
                              "context": {
                                "_text": "Every square is filled and all three rules are satisfied."
                              },
                              "style": {
                                "common": {
                                  "font": "subheadline",
                                  "foreground": {
                                    "color": "white"
                                  }
                                }
                              }
                            }
                          ]
                        },
                        {
                          "id": "solved_badge",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${celebrated} ? 'Fresh win' : 'Solved' }}"
                          },
                          "style": {
                            "layout": {
                              "padding": {
                                "top": 6,
                                "bottom": 6,
                                "leading": 10,
                                "trailing": 10
                              }
                            },
                            "common": {
                              "background": {
                                "color": "white",
                                "opacity": 0.18
                              },
                              "foreground": {
                                "color": "white"
                              },
                              "cornerRadius": 12,
                              "font": {
                                "kind": "caption",
                                "weight": "bold"
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                {
                  "id": "feedback_card",
                  "type": "vstack",
                  "context": {
                    "_spacing": 8,
                    "_alignment": "leading",
                    "statusTitle": "{{ @{solved} ? 'Perfect finish.' : (notEmpty(${message}) ? ${message} : (!@{allFilled} ? 'The dark clues are locked in place.' : (!@{noTriples} ? 'A line contains three matching values together.' : (!@{rowsBalanced} || !@{colsBalanced} ? 'Every row and column must finish with exactly three 0s and three 1s.' : 'Two rows or columns still match.')))) }}",
                    "statusDetail": "{{ @{solved} ? 'You can restart any time for another round.' : (notEmpty(${message}) ? 'Try the other value or clear a nearby square.' : (!@{allFilled} ? 'Balanced lines and unique rows/columns are checked automatically as the board fills.' : (!@{rowsBalanced} || !@{colsBalanced} ? 'A full line that sums to 3 has the right balance.' : 'Change at least one square in a repeated line.'))) }}",
                    "statusBg": "{{ @{solved} ? {'color': '#173F2B'} : (notEmpty(${message}) ? {'color': '#4A3A13'} : {'light': '#F4F5FA', 'dark': '#141720'}) }}",
                    "statusFg": "{{ @{solved} ? {'color': '#D8F6E5'} : (notEmpty(${message}) ? {'color': '#FFE8B3'} : {'light': '#151826', 'dark': '#F4F7FF'}) }}",
                    "statusIcon": "{{ @{solved} ? 'sf://sparkles' : (notEmpty(${message}) ? 'sf://exclamationmark.triangle.fill' : 'sf://lightbulb.fill') }}"
                  },
                  "style": {
                    "layout": {
                      "padding": 16
                    },
                    "common": {
                      "background": "@{statusBg}",
                      "foreground": "@{statusFg}",
                      "cornerRadius": 20
                    },
                    "shadow": {
                      "color": {
                        "color": "black",
                        "opacity": 0.1
                      },
                      "radius": 10,
                      "y": 4
                    }
                  },
                  "children": [
                    {
                      "id": "feedback_head",
                      "type": "hstack",
                      "context": {
                        "_spacing": 10,
                        "_alignment": "center"
                      },
                      "children": [
                        {
                          "id": "feedback_icon",
                          "type": "image",
                          "context": {
                            "_source": "@{statusIcon}"
                          },
                          "style": {
                            "layout": {
                              "width": 20,
                              "height": 20
                            },
                            "common": {
                              "foreground": "@{statusFg}"
                            }
                          }
                        },
                        {
                          "id": "feedback_title",
                          "type": "text",
                          "context": {
                            "_text": "@{statusTitle}"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "headline",
                                "weight": "semibold"
                              },
                              "foreground": "@{statusFg}"
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "feedback_copy",
                      "type": "text",
                      "context": {
                        "_text": "@{statusDetail}"
                      },
                      "style": {
                        "common": {
                          "font": "subheadline",
                          "foreground": "@{statusFg}"
                        }
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}