Input validation and game loop