Change mode with button not working properly, can't see why

Perhaps when you toggle the opto there is something dragging down the power, and the code is resetting and the led is going off with the reset, not the program logic.