# Country Guess > Play a 10-round map game: guess the country shaded in red on a 3D globe before the timer runs out. Practice effect cleanup, countdown timers, and resetting state between rounds. - Difficulty: intermediate - Tags: useEffect, setTimeout, timers, useState, game - Estimated time: 60 minutes - Tests: 19 - Requires subscription: yes ## Overview Build a 10-round timed globe-guessing game that practices `useEffect` cleanup, self-scheduling countdown timers, and resetting round state with `useState`. ## Requirements - Implement the game in `App.tsx`. `WorldMap.tsx`, `AnswerOverlay.tsx`, `SuggestionsList.tsx`, `TimerPie.tsx`, `utils.ts` and `index.css` are read-only; `world.ts` is hidden but importable. - The app starts idle: `start-game` reads "Start", the globe has no `data-active-code`, `guess-form` is not rendered, `timer` reads `15s`, and `score` reads `Solved 0 of 0`. - Clicking `start-game` starts round 1: the form appears, `start-game` hides, and `world-map` gets a `data-active-code`. - During a round the globe highlights exactly one `active-country`, exposes the target as `data-active-code`, its center as `data-center="lon,lat"` (one decimal) and a `data-zoom` greater than 1. - `timer` counts down one second per tick from 15 using the `${timeLeft}s` format, and `score` reads `Solved {solved} of {played}`. - `time-pie` animates while playing and pauses once the round is revealed. - `guess-form` contains `guess-input` (with `autoComplete` off) and `guess-submit`; guesses are trimmed and compared case-insensitively against the country name or ISO code. - Empty or whitespace-only guesses are ignored and keep the round alive. - Typing filters up to six name matches through `SuggestionsList`; clicking a suggestion submits that country. - A correct guess adds one solved and one played round; a wrong guess adds only one played round. Both reveal `AnswerOverlay` with the country name and disable the input. - `reveal` ends the round without a point, disables the input and ignores later submissions. - The countdown stops as soon as the round is revealed, and reaching 0 ends the round without a point. - After `AUTO_ADVANCE_MS` the next round starts with a different country, a 15s clock, an empty input and no overlay; the score persists. - After 10 rounds the game ends: `timer` reads `Done`, the form hides, the final score stays visible, and `start-game` reads "Play again" and starts a fresh game at `Solved 0 of 0`. ## Notes - Use a self-rescheduling `setTimeout` (not `setInterval`) and return `clearTimeout`; stop scheduling once the round is revealed. - Update the clock with a functional setter: `setTimeLeft((current: number) => current - 1)`. - Pick the target with a lazy `useState` initializer and pass the previous code to `pickCountry` so rounds never repeat. - A round is revealed when `outcome !== null`; use it to stop the timer and disable the form. - Auto-advance from an effect that watches `outcome` with `AUTO_ADVANCE_MS`. Guard `round >= TOTAL_ROUNDS` so no 11th round starts, and clean up the timeout. - Reset target, clock, guess and outcome together on a new round; keep `solved` and `played` outside that reset. - Wire the read-only `TimerPie`, `AnswerOverlay` and `SuggestionsList` instead of reimplementing them. Pass `paused`/`done` to the pie and the filtered countries to the suggestions. - Tests find the random target through `data-active-code`, so the globe must expose it. ## Tests 01. renders the visible hemisphere with exactly one active country 02. centers the globe on the highlighted country 03. zooms the globe in to make the target easier to read 04. only shows the locator for tiny target countries 05. starts idle and begins a game from the Start button 06. counts down one second per tick 07. filters suggestions as the user types and caps them at six 08. submits the clicked suggestion as a guess 09. ends the round after a wrong guess and advances automatically 10. ignores empty and whitespace-only guesses 11. accepts the country name case-insensitively 12. accepts the ISO country code 13. shows the answer over the globe and advances when time runs out 14. disables the input and ignores guesses after the reveal 15. stops the countdown while the revealed answer is shown 16. pauses the radial timer when the round is revealed 17. starts a new round with a different country and a reset clock 18. plays exactly 10 rounds and offers a replay 19. tracks solved and played across rounds