When the coloured circles turn grey and start swapping, keep track of which one is which colour. Eventually, you will be asked to click on a certain coloured circle. If you get it wrong, it's game over. If you get it right, the colours will be revealed. Make sure you memorise them as they will turn grey and start swapping again two seconds later.
All code and graphics by me, @Pi_is_amazing.