Japan produced a second-half fightback to beat Costa Rica 3-1 in Tampa as both teams continued their preparations for the World Cup.