Gabriel Martinelli's 96th-minute winner saw Brazil dramatically come from behind to advance to the World Cup last 16 and cruelly deny Japan a first-ever knockout stage win in the competition.