Put both of the sugars and the margarine into a bowl and beat into a cream with an electric hand whisk.
Add the vanilla extract and the egg, and beat again briefly.
Sift in the ground buckwheat, gorund almonds, ground rice, potato starch, xanthan gum, bicarbonate of soda and salt (tipping any lumps straight into the bowl.
Fold the flour mixture into the rest of the batter, to form a dough.
Roll the dough into a piece of cling-film and freeze for one hour.
Preheat the oven to 170°C (350°F), and line a couple of oven trays with baking parchment.
Remove the dough from the freezer. Roll 12 pieces of dough into balls, and place each ball onto the baking parchment, leaving a gap of a few inches between each cookie. This can get quite messy, as the dough is likely to be soft and sticky.
When all the cookies are on the trays, refrigerate for 30 minutes.
Remove the cookies from the fridge and bake on the middle shelf of the oven for just 15 minutes, until the cookies are golden on top and crispy around the edges.
Allow to cool on the tray for 10 minutes, then remove the cookies to a wire rack to cool completely.