Prime minister is scrambling to clean up her government after youth vote powered a damaging referendum defeat