Gonçalo Ramos scored a stoppage time winner to send Portugal past Croatia into a last 16 showdown with Spain.