static int state=0;static uint32_t ready=0,result=0;
void appSetup(){}
void appLoop(){uint32_t now=Mio::elapsed();if(Mio::pressedB())state=0;if(state==1&&now>=ready)state=2;if(Mio::pressedA()){if(state==0||state==3||state==4){state=1;ready=now+random(1200,4000);}else if(state==1)state=4;else if(state==2){result=now-ready;state=3;}}}
void appDraw(){auto &c=Mio::canvas;uint16_t bg=state==2?c.color565(29,112,75):c.color565(36,27,54);c.fillSprite(bg);c.setTextDatum(MC_DATUM);c.setTextColor(TFT_WHITE,bg);c.drawString("QUICK PAWS",160,24,2);char s[32];if(state==3)snprintf(s,sizeof(s),"%lu ms",(unsigned long)result);else snprintf(s,sizeof(s),"%s",state==0?"Ready?":state==1?"wait for green...":state==2?"GO!":"too soon!");c.drawString(s,160,83,4);c.drawString("A play / B reset",160,148,2);}
