{
  "id": "wordplete",
  "type": "module",
  "version": "1.1",
  "context": {
    "layout": "phone",
    "title": "Wordplete",
    "icon": "🟩",
    "answers": [
      "APPLE",
      "BEACH",
      "BLOOM",
      "BRAIN",
      "BREAD",
      "BRICK",
      "BRUSH",
      "CANDY",
      "CHAIR",
      "CHARM",
      "CLOUD",
      "CORAL",
      "CRANE",
      "DANCE",
      "DREAM",
      "EARTH",
      "EMBER",
      "FIELD",
      "FLAME",
      "FLOUR",
      "FOCUS",
      "FRESH",
      "FROST",
      "GHOST",
      "GLASS",
      "GRAPE",
      "GRASS",
      "GREEN",
      "HEART",
      "HONEY",
      "HOUSE",
      "IVORY",
      "JELLY",
      "JUICE",
      "LEMON",
      "LIGHT",
      "MAPLE",
      "METAL",
      "MONEY",
      "NIGHT",
      "OCEAN",
      "OLIVE",
      "PAINT",
      "PAPER",
      "PEACH",
      "PEARL",
      "PIANO",
      "PLANT",
      "PRIDE",
      "QUIET",
      "RADIO",
      "RIVER",
      "ROBIN",
      "ROUND",
      "SHORE",
      "SMILE",
      "SOLAR",
      "SPICE",
      "STONE",
      "STORM",
      "SUGAR",
      "TABLE",
      "TIGER",
      "TRAIN",
      "TRAIL",
      "WATER",
      "WHALE",
      "WHEAT",
      "WORLD",
      "YOUTH"
    ],
    "extraWords": [],
    "answer": "{{ @{answers}[${answerIndex}] }}",
    "words": "{{ @{answers} + @{extraWords} }}",
    "a0": "{{ prefix(@{answer}, 1) }}",
    "a1": "{{ prefix(suffix(@{answer}, 4), 1) }}",
    "a2": "{{ prefix(suffix(@{answer}, 3), 1) }}",
    "a3": "{{ prefix(suffix(@{answer}, 2), 1) }}",
    "a4": "{{ suffix(@{answer}, 1) }}",
    "filled": "{{ sum(map(${board}, empty(@{item}) ? 0 : 1)) }}",
    "tries": "{{ cast(@{filled} / 5, 'int') }}",
    "lastWord": "{{ @{filled} >= 5 ? ${board}[@{filled}-5] + ${board}[@{filled}-4] + ${board}[@{filled}-3] + ${board}[@{filled}-2] + ${board}[@{filled}-1] : '' }}",
    "won": "{{ @{lastWord} == @{answer} }}",
    "ended": "{{ @{won} || @{tries} == 6 }}",
    "valid": "{{ count(${draft}) == 5 }}"
  },
  "state": {
    "board": [
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      "",
      ""
    ],
    "answerIndex": 0,
    "draft": "",
    "ready": false,
    "message": "",
    "saveError": ""
  },
  "dependencies": [
    {
      "repository": {
        "local": {
          "id": "wordplete_puzzles_v1",
          "config": {}
        }
      }
    },
    {
      "service": {
        "audio": {
          "id": "wordplete_audio"
        }
      }
    },
    {
      "action": {
        "repo": {
          "id": "persist_game",
          "input": {
            "repositoryId": "wordplete_puzzles_v1",
            "operation": "create",
            "params": {
              "collection": "puzzle",
              "documentId": "current",
              "rewrite": true,
              "body": {
                "board": "${board}",
                "answerIndex": "${answerIndex}"
              }
            }
          },
          "output": {
            "success": [
              {
                "state": {
                  "id": "persist_ok",
                  "input": {
                    "saveError": ""
                  }
                }
              }
            ],
            "failure": [
              {
                "state": {
                  "id": "persist_failed",
                  "input": {
                    "saveError": "Progress could not be saved on this device. Retry before leaving."
                  }
                }
              }
            ]
          }
        }
      }
    },
    {
      "action": {
        "state": {
          "id": "new_game",
          "input": {
            "board": "{{ map(range(30), '') }}",
            "answerIndex": "{{ (${answerIndex} + random(1, count(@{answers}) - 1)) % count(@{answers}) }}",
            "draft": "",
            "ready": true,
            "message": "",
            "saveError": ""
          },
          "output": {
            "success": [
              {
                "template": {
                  "id": "save_new_game",
                  "input": "persist_game"
                }
              },
              {
                "service": {
                  "id": "new_game_tactile",
                  "input": {
                    "serviceId": "wordplete_audio",
                    "params": {
                      "haptic": "light"
                    }
                  }
                }
              }
            ]
          }
        }
      }
    },
    {
      "action": {
        "condition": {
          "id": "submit_guess",
          "input": "{{ ${ready} && !@{ended} }}",
          "output": {
            "success": [
              {
                "condition": {
                  "id": "check_word",
                  "input": "@{valid}",
                  "output": {
                    "success": [
                      {
                        "state": {
                          "id": "commit_guess",
                          "input": {
                            "board": "{{ map(range(30), @{item} >= @{filled} && @{item} < @{filled} + 5 ? prefix(suffix(${draft}, 5 - (@{item} - @{filled})), 1) : ${board}[@{item}]) }}",
                            "draft": "",
                            "message": ""
                          },
                          "output": {
                            "success": [
                              {
                                "template": {
                                  "id": "save_guess",
                                  "input": "persist_game"
                                }
                              },
                              {
                                "service": {
                                  "id": "guess_tactile",
                                  "input": {
                                    "serviceId": "wordplete_audio",
                                    "params": {
                                      "haptic": "{{ @{won} ? 'success' : 'light' }}"
                                    }
                                  }
                                }
                              }
                            ]
                          }
                        }
                      }
                    ],
                    "failure": [
                      {
                        "state": {
                          "id": "invalid_guess",
                          "input": {
                            "message": "Enter exactly five letters before checking."
                          }
                        }
                      },
                      {
                        "service": {
                          "id": "invalid_tactile",
                          "input": {
                            "serviceId": "wordplete_audio",
                            "params": {
                              "haptic": "warning"
                            }
                          }
                        }
                      }
                    ]
                  }
                }
              }
            ]
          }
        }
      }
    }
  ],
  "events": {
    "onAppear": [
      {
        "repo": {
          "id": "resume_game",
          "input": {
            "repositoryId": "wordplete_puzzles_v1",
            "operation": "read",
            "params": {
              "collection": "puzzle",
              "documentId": "current"
            }
          },
          "output": {
            "success": [
              {
                "condition": {
                  "id": "has_saved_game",
                  "input": "{{ count(@{resume_game.board}) == 30 && @{resume_game.answerIndex} >= 0 && @{resume_game.answerIndex} < count(@{answers}) }}",
                  "output": {
                    "success": [
                      {
                        "state": {
                          "id": "restore_game",
                          "input": {
                            "board": "@{resume_game.board}",
                            "answerIndex": "@{resume_game.answerIndex}",
                            "ready": true,
                            "draft": "",
                            "message": ""
                          }
                        }
                      }
                    ],
                    "failure": [
                      {
                        "template": {
                          "id": "start_if_empty",
                          "input": "new_game"
                        }
                      }
                    ]
                  }
                }
              }
            ],
            "failure": [
              {
                "template": {
                  "id": "start_first_game",
                  "input": "new_game"
                }
              }
            ]
          }
        }
      }
    ]
  },
  "children": [
    {
      "id": "play_scroll",
      "type": "scroll",
      "children": [
        {
          "id": "play_layout",
          "type": "vstack",
          "context": {
            "_spacing": 20
          },
          "style": {
            "layout": {
              "maxWidth": "infinity",
              "padding": {
                "top": 12,
                "bottom": 20,
                "leading": 16,
                "trailing": 16
              }
            }
          },
          "children": [
            {
              "id": "status_part",
              "type": "hstack",
              "context": {
                "_spacing": 12
              },
              "style": {
                "layout": {
                  "padding": {
                    "horizontal": 18,
                    "vertical": 12
                  },
                  "maxWidth": "infinity"
                },
                "common": {
                  "background": {
                    "gradient": {
                      "linear": {
                        "colors": [
                          "#143E39",
                          "#245C55"
                        ],
                        "startPoint": "leading",
                        "endPoint": "trailing"
                      }
                    }
                  },
                  "foreground": {
                    "color": "white"
                  },
                  "cornerRadius": 18
                },
                "shadow": {
                  "color": {
                    "color": "black",
                    "opacity": 0.14
                  },
                  "radius": 8,
                  "y": 3
                },
                "animation": {
                  "kind": "spring",
                  "value": "@{ended}",
                  "duration": 0.3
                }
              },
              "children": [
                {
                  "id": "status_icon",
                  "type": "image",
                  "context": {
                    "_source": "{{ @{won} ? 'sf://checkmark.seal.fill' : 'sf://square.grid.3x3.fill' }}"
                  },
                  "style": {
                    "layout": {
                      "width": 26,
                      "height": 26
                    },
                    "common": {
                      "foreground": {
                        "color": "white"
                      }
                    }
                  }
                },
                {
                  "id": "status_copy",
                  "type": "vstack",
                  "context": {
                    "_spacing": 3,
                    "_alignment": "leading"
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "alignment": "leading"
                    }
                  },
                  "children": [
                    {
                      "id": "attempts",
                      "type": "text",
                      "context": {
                        "_text": "{{ switch(!${ready}, 'Restoring your puzzle…', @{won}, 'Solved in ' + cast(@{tries}, 'str') + ' of 6', @{ended}, 'Six guesses used', cast(6 - @{tries}, 'str') + ' guesses remaining') }}"
                      },
                      "style": {
                        "common": {
                          "font": "headline",
                          "foreground": {
                            "color": "white"
                          }
                        }
                      }
                    },
                    {
                      "id": "status_hint",
                      "type": "text",
                      "context": {
                        "_text": "{{ @{ended} ? 'The word was ' + @{answer} + '.' : 'Find the hidden five-letter word.' }}"
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": "white"
                          }
                        }
                      }
                    }
                  ]
                }
              ]
            },
            {
              "id": "board_part",
              "type": "vstack",
              "context": {
                "_spacing": 10
              },
              "style": {
                "layout": {
                  "padding": 18,
                  "maxWidth": "infinity"
                },
                "common": {
                  "background": {
                    "color": "surface"
                  },
                  "foreground": {
                    "color": "onSurface"
                  },
                  "cornerRadius": 22
                },
                "shadow": {
                  "color": {
                    "color": "black",
                    "opacity": 0.12
                  },
                  "radius": 12,
                  "y": 4
                }
              },
              "children": [
                {
                  "id": "guess_grid",
                  "type": "grid",
                  "context": {
                    "_gridType": "lazyVGrid",
                    "_spacing": 4
                  },
                  "style": {
                    "grid": {
                      "columns": [
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "spacing": 4
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "spacing": 4
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "spacing": 4
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "spacing": 4
                        },
                        {
                          "kind": "flexible",
                          "minimum": 44,
                          "spacing": 4
                        }
                      ]
                    },
                    "layout": {
                      "maxWidth": "infinity"
                    }
                  },
                  "children": [
                    {
                      "id": "guess_cells",
                      "type": "dynamic",
                      "context": {
                        "_data": "${board}"
                      },
                      "prototype": {
                        "id": "guess_tile",
                        "type": "vstack",
                        "context": {
                          "_spacing": 0,
                          "i": "@{index}",
                          "col": "{{ @{i} % 5 }}",
                          "start": "{{ @{i} - @{col} }}",
                          "letter": "{{ ${board}[@{index}] }}",
                          "g0": "{{ ${board}[@{start}] }}",
                          "g1": "{{ ${board}[@{start}+1] }}",
                          "g2": "{{ ${board}[@{start}+2] }}",
                          "g3": "{{ ${board}[@{start}+3] }}",
                          "g4": "{{ ${board}[@{start}+4] }}",
                          "targetLetter": "{{ prefix(suffix(@{answer}, 5 - @{col}), 1) }}",
                          "copies": "{{ empty(@{letter}) ? 0 : count(@{answer}) - count(replace(@{answer}, @{letter}, '')) }}",
                          "exactCopies": "{{ (@{g0} == @{a0} && @{g0} == @{letter} ? 1 : 0) + (@{g1} == @{a1} && @{g1} == @{letter} ? 1 : 0) + (@{g2} == @{a2} && @{g2} == @{letter} ? 1 : 0) + (@{g3} == @{a3} && @{g3} == @{letter} ? 1 : 0) + (@{g4} == @{a4} && @{g4} == @{letter} ? 1 : 0) }}",
                          "earlierCopies": "{{ (@{col} > 0 && @{g0} == @{letter} && @{g0} != @{a0} ? 1 : 0) + (@{col} > 1 && @{g1} == @{letter} && @{g1} != @{a1} ? 1 : 0) + (@{col} > 2 && @{g2} == @{letter} && @{g2} != @{a2} ? 1 : 0) + (@{col} > 3 && @{g3} == @{letter} && @{g3} != @{a3} ? 1 : 0) }}",
                          "remainingCopies": "{{ @{copies} - @{exactCopies} }}",
                          "clue": "{{ empty(${board}[@{index}]) ? -1 : switch(@{letter} == @{targetLetter}, 2, @{earlierCopies} < @{remainingCopies}, 1, 0) }}",
                          "active": "{{ ${ready} && !@{ended} && @{start} == @{filled} }}",
                          "displayLetter": "{{ notEmpty(@{letter}) ? @{letter} : (@{active} && @{col} < count(${draft}) ? prefix(suffix(${draft}, count(${draft}) - @{col}), 1) : '') }}",
                          "tileFill": "{{ switch(notEmpty(${board}[@{index}]) && @{clue} == 2, {'color':'#216253'}, notEmpty(${board}[@{index}]) && @{clue} == 1, {'color':'#855B13'}, notEmpty(${board}[@{index}]) && @{clue} == 0, {'light':'#555C65','dark':'#454D56'}, @{active} && notEmpty(${message}), {'light':'#FCE4E1','dark':'#552B2B'}, @{active}, {'light':'#DDEEE7','dark':'#263F38'}, {'light':'#F0F2F3','dark':'#252A30'}) }}",
                          "tileInk": "{{ notEmpty(${board}[@{index}]) && @{clue} >= 0 ? {'color':'white'} : {'light':'#182F28','dark':'#F2F6F4'} }}"
                        },
                        "style": {
                          "layout": {
                            "height": 44,
                            "maxWidth": "infinity"
                          },
                          "common": {
                            "background": "@{tileFill}",
                            "foreground": "@{tileInk}",
                            "cornerRadius": 8,
                            "scale": "{{ notEmpty(@{displayLetter}) ? 1 : 0.96 }}"
                          },
                          "animation": {
                            "kind": "spring",
                            "value": "@{displayLetter}",
                            "duration": 0.25,
                            "bounce": 0.2
                          }
                        },
                        "children": [
                          {
                            "id": "tile_letter",
                            "type": "text",
                            "context": {
                              "_text": "@{displayLetter}"
                            },
                            "style": {
                              "common": {
                                "font": {
                                  "kind": "title3",
                                  "weight": "bold"
                                },
                                "foreground": "@{tileInk}"
                              }
                            }
                          },
                          {
                            "id": "tile_mark",
                            "type": "image",
                            "context": {
                              "_source": "{{ switch(@{clue} == 2, 'sf://checkmark', @{clue} == 1, 'sf://arrow.right', 'sf://minus') }}"
                            },
                            "style": {
                              "layout": {
                                "width": 9,
                                "height": 9
                              },
                              "common": {
                                "foreground": "@{tileInk}",
                                "opacity": "{{ notEmpty(${board}[@{index}]) && @{clue} >= 0 ? 1 : 0 }}"
                              }
                            }
                          }
                        ]
                      }
                    }
                  ]
                },
                {
                  "id": "clue_legend",
                  "type": "hstack",
                  "context": {
                    "_spacing": 10
                  },
                  "children": [
                    {
                      "id": "legend_exact",
                      "type": "label",
                      "context": {
                        "_title": "Exact",
                        "_icon": "sf://checkmark"
                      },
                      "style": {
                        "common": {
                          "font": "caption2",
                          "foreground": {
                            "color": "onSurface"
                          }
                        }
                      }
                    },
                    {
                      "id": "legend_present",
                      "type": "label",
                      "context": {
                        "_title": "Elsewhere",
                        "_icon": "sf://arrow.right"
                      },
                      "style": {
                        "common": {
                          "font": "caption2",
                          "foreground": {
                            "color": "onSurface"
                          }
                        }
                      }
                    },
                    {
                      "id": "legend_absent",
                      "type": "label",
                      "context": {
                        "_title": "Absent",
                        "_icon": "sf://minus"
                      },
                      "style": {
                        "common": {
                          "font": "caption2",
                          "foreground": {
                            "color": "onSurface"
                          }
                        }
                      }
                    }
                  ]
                }
              ]
            },
            {
              "id": "keyboard_part",
              "type": "vstack",
              "children": [
                {
                  "id": "keyboard_visible",
                  "type": "conditional",
                  "context": {
                    "_condition": "{{ ${ready} && !@{ended} }}",
                    "_trueComponent": {
                      "id": "keyboard_card",
                      "type": "vstack",
                      "context": {
                        "_spacing": 10
                      },
                      "style": {
                        "layout": {
                          "padding": 18,
                          "maxWidth": "infinity"
                        },
                        "common": {
                          "background": {
                            "color": "surface"
                          },
                          "foreground": {
                            "color": "onSurface"
                          },
                          "cornerRadius": 22
                        },
                        "shadow": {
                          "color": {
                            "color": "black",
                            "opacity": 0.12
                          },
                          "radius": 10,
                          "y": 4
                        }
                      },
                      "children": [
                        {
                          "id": "keyboard_feedback",
                          "type": "text",
                          "context": {
                            "_text": "{{ notEmpty(${message}) ? ${message} : (count(${draft}) == 5 ? 'Ready? Tap ✓ to check your word.' : 'Tap letters to fill the highlighted row.') }}"
                          },
                          "style": {
                            "layout": {
                              "maxWidth": "infinity",
                              "alignment": "leading"
                            },
                            "common": {
                              "font": "caption",
                              "foreground": "{{ notEmpty(${message}) ? {'light':'#9C2828','dark':'#FFB3AC'} : {'color':'onSurfaceVariant'} }}"
                            },
                            "animation": {
                              "kind": "spring",
                              "value": "${message}",
                              "duration": 0.2
                            }
                          }
                        },
                        {
                          "id": "key_grid",
                          "type": "grid",
                          "context": {
                            "_gridType": "lazyVGrid",
                            "_spacing": 5
                          },
                          "style": {
                            "grid": {
                              "columns": [
                                {
                                  "kind": "flexible",
                                  "minimum": 44,
                                  "spacing": 5
                                },
                                {
                                  "kind": "flexible",
                                  "minimum": 44,
                                  "spacing": 5
                                },
                                {
                                  "kind": "flexible",
                                  "minimum": 44,
                                  "spacing": 5
                                },
                                {
                                  "kind": "flexible",
                                  "minimum": 44,
                                  "spacing": 5
                                },
                                {
                                  "kind": "flexible",
                                  "minimum": 44,
                                  "spacing": 5
                                },
                                {
                                  "kind": "flexible",
                                  "minimum": 44,
                                  "spacing": 5
                                }
                              ]
                            },
                            "layout": {
                              "maxWidth": "infinity"
                            }
                          },
                          "children": [
                            {
                              "id": "alphabet_keys",
                              "type": "dynamic",
                              "context": {
                                "_data": [
                                  "A",
                                  "B",
                                  "C",
                                  "D",
                                  "E",
                                  "F",
                                  "G",
                                  "H",
                                  "I",
                                  "J",
                                  "K",
                                  "L",
                                  "M",
                                  "N",
                                  "O",
                                  "P",
                                  "Q",
                                  "R",
                                  "S",
                                  "T",
                                  "U",
                                  "V",
                                  "W",
                                  "X",
                                  "Y",
                                  "Z",
                                  "⌫",
                                  "✓"
                                ]
                              },
                              "prototype": {
                                "id": "letter_key",
                                "type": "button",
                                "context": {
                                  "keyLetter": "@{item}",
                                  "_label": "@{item}"
                                },
                                "style": {
                                  "button": {
                                    "custom": {
                                      "layout": {
                                        "height": 44,
                                        "maxWidth": "infinity"
                                      },
                                      "common": {
                                        "background": "{{ @{keyLetter} == '✓' ? {'color':'#216253'} : {'light':'#E7ECE9','dark':'#343F3B'} }}",
                                        "foreground": "{{ @{keyLetter} == '✓' ? {'color':'white'} : {'light':'#162D25','dark':'#F3F7F5'} }}",
                                        "cornerRadius": 9,
                                        "font": {
                                          "kind": "headline",
                                          "weight": "semibold"
                                        }
                                      }
                                    }
                                  }
                                },
                                "events": {
                                  "onTap": [
                                    {
                                      "condition": {
                                        "id": "key_check",
                                        "input": "{{ @{keyLetter} == '✓' }}",
                                        "output": {
                                          "success": [
                                            {
                                              "template": {
                                                "id": "keyboard_submit",
                                                "input": "submit_guess"
                                              }
                                            }
                                          ],
                                          "failure": [
                                            {
                                              "state": {
                                                "id": "edit_draft",
                                                "input": {
                                                  "draft": "{{ @{keyLetter} == '⌫' ? prefix(${draft}, max([0, count(${draft}) - 1])) : (count(${draft}) < 5 ? ${draft} + @{keyLetter} : ${draft}) }}",
                                                  "message": "{{ @{keyLetter} == '⌫' ? (empty(${draft}) ? 'The row is empty. Tap a letter to begin.' : '') : (count(${draft}) == 5 ? 'Five letters entered. Tap ✓ to check, or ⌫ to edit.' : '') }}"
                                                }
                                              }
                                            },
                                            {
                                              "service": {
                                                "id": "keyboard_tactile",
                                                "input": {
                                                  "serviceId": "wordplete_audio",
                                                  "params": {
                                                    "haptic": "light"
                                                  }
                                                }
                                              }
                                            }
                                          ]
                                        }
                                      }
                                    }
                                  ]
                                }
                              }
                            }
                          ]
                        },
                        {
                          "id": "keyboard_note",
                          "type": "text",
                          "context": {
                            "_text": "⌫ Erase   ·   ✓ Check   ·   Any five letters"
                          },
                          "style": {
                            "common": {
                              "font": "caption2",
                              "foreground": {
                                "color": "onSurfaceVariant"
                              }
                            },
                            "text": {
                              "multilineTextAlignment": "center"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              ]
            },
            {
              "id": "result_part",
              "type": "vstack",
              "context": {
                "_spacing": 12
              },
              "children": [
                {
                  "id": "restoring_visible",
                  "type": "conditional",
                  "context": {
                    "_condition": "{{ !${ready} }}",
                    "_trueComponent": {
                      "id": "restoring_spinner",
                      "type": "progress",
                      "context": {
                        "_label": "Restoring puzzle"
                      }
                    }
                  }
                },
                {
                  "id": "finished_visible",
                  "type": "conditional",
                  "context": {
                    "_condition": "{{ ${ready} && @{ended} }}",
                    "_trueComponent": {
                      "id": "finished_card",
                      "type": "vstack",
                      "context": {
                        "_spacing": 12
                      },
                      "style": {
                        "layout": {
                          "padding": 20,
                          "maxWidth": "infinity"
                        },
                        "common": {
                          "background": {
                            "gradient": {
                              "linear": {
                                "colors": [
                                  "#143E39",
                                  "#245C55"
                                ],
                                "startPoint": "topLeading",
                                "endPoint": "bottomTrailing"
                              }
                            }
                          },
                          "foreground": {
                            "color": "white"
                          },
                          "cornerRadius": 22
                        },
                        "shadow": {
                          "color": {
                            "color": "black",
                            "opacity": 0.16
                          },
                          "radius": 12,
                          "y": 4
                        },
                        "animation": {
                          "kind": "spring",
                          "value": "@{ended}",
                          "duration": 0.35
                        }
                      },
                      "children": [
                        {
                          "id": "finished_heading",
                          "type": "label",
                          "context": {
                            "_title": "{{ @{won} ? 'Word found' : 'The hidden word' }}",
                            "_image": "{{ @{won} ? 'sf://checkmark.seal.fill' : 'sf://textformat.abc' }}"
                          },
                          "style": {
                            "common": {
                              "font": "headline",
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        },
                        {
                          "id": "answer_reveal",
                          "type": "text",
                          "context": {
                            "_text": "@{answer}"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "largeTitle",
                                "weight": "bold"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        },
                        {
                          "id": "finished_caption",
                          "type": "text",
                          "context": {
                            "_text": "{{ @{won} ? 'All five letters are in place.' : 'All six tries are used. A fresh puzzle is ready when you are.' }}"
                          },
                          "style": {
                            "common": {
                              "font": "subheadline",
                              "foreground": {
                                "color": "white"
                              }
                            },
                            "text": {
                              "multilineTextAlignment": "center"
                            }
                          }
                        },
                        {
                          "id": "next_puzzle",
                          "type": "button",
                          "style": {
                            "layout": {
                              "minHeight": 44,
                              "maxWidth": "infinity"
                            },
                            "button": {
                              "standard": {
                                "type": "borderedProminent",
                                "shape": "capsule"
                              }
                            },
                            "common": {
                              "tint": {
                                "color": "#D3EBDD"
                              },
                              "foreground": {
                                "color": "#143E39"
                              }
                            }
                          },
                          "children": [
                            {
                              "id": "next_puzzle_label",
                              "type": "label",
                              "context": {
                                "_title": "New puzzle",
                                "_image": "sf://arrow.clockwise"
                              },
                              "style": {
                                "common": {
                                  "foreground": {
                                    "color": "#143E39"
                                  }
                                }
                              }
                            }
                          ],
                          "events": {
                            "onTap": [
                              {
                                "template": {
                                  "id": "request_new_puzzle",
                                  "input": "new_game"
                                }
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                },
                {
                  "id": "save_problem_visible",
                  "type": "conditional",
                  "context": {
                    "_condition": "{{ notEmpty(${saveError}) }}",
                    "_trueComponent": {
                      "id": "save_problem_card",
                      "type": "vstack",
                      "context": {
                        "_spacing": 12
                      },
                      "style": {
                        "layout": {
                          "padding": 18,
                          "maxWidth": "infinity"
                        },
                        "common": {
                          "background": {
                            "color": "surface"
                          },
                          "foreground": {
                            "color": "onSurface"
                          },
                          "cornerRadius": 18
                        },
                        "shadow": {
                          "color": {
                            "color": "black",
                            "opacity": 0.1
                          },
                          "radius": 8,
                          "y": 3
                        }
                      },
                      "children": [
                        {
                          "id": "save_problem_title",
                          "type": "label",
                          "context": {
                            "_title": "Progress not saved",
                            "_image": "sf://exclamationmark.triangle"
                          },
                          "style": {
                            "common": {
                              "font": "headline",
                              "foreground": {
                                "color": "onSurface"
                              }
                            }
                          }
                        },
                        {
                          "id": "save_problem_message",
                          "type": "text",
                          "context": {
                            "_text": "${saveError}"
                          },
                          "style": {
                            "common": {
                              "font": "subheadline",
                              "foreground": {
                                "color": "onSurface"
                              }
                            }
                          }
                        },
                        {
                          "id": "save_again",
                          "type": "button",
                          "style": {
                            "layout": {
                              "minHeight": 44
                            },
                            "button": {
                              "standard": {
                                "type": "bordered",
                                "shape": "capsule"
                              }
                            }
                          },
                          "children": [
                            {
                              "id": "save_again_label",
                              "type": "label",
                              "context": {
                                "_title": "Retry save",
                                "_image": "sf://arrow.clockwise"
                              },
                              "style": {
                                "common": {
                                  "foreground": {
                                    "color": "onSurface"
                                  }
                                }
                              }
                            }
                          ],
                          "events": {
                            "onTap": [
                              {
                                "template": {
                                  "id": "retry_persistence",
                                  "input": "persist_game"
                                }
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                },
                {
                  "id": "offline_dictionary_note",
                  "type": "text",
                  "context": {
                    "_text": "Offline puzzles · Progress saves on this device.\nAny five-letter entry is accepted."
                  },
                  "style": {
                    "common": {
                      "font": "caption2",
                      "foreground": {
                        "color": "secondary"
                      }
                    },
                    "text": {
                      "multilineTextAlignment": "center"
                    }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}