detect endgame and enter endgame mode