Olmo put Spain ahead in the 11th minute from a neat pass by Gavi which the forward lifted over Costa Rica goalkeeper Keylor Navas.

Asensio doubled their lead with a first-time shot 10 minutes later and Torres made it 3-0 from the spot in the 31st.