From this image he doesn't look offside and the angle is in line with Hendry and the defender.
Game was rigged, Scotland were never getting anything out of that - and on balance Spain deserved the win - but the ref certainly gave them every chance he could, reffing "highlights" apart from the ghost goal :
McGinn flattened on the edge of the Spain box in the first half
Laporte constantly fouling and gets eventual yellow in last 10 mins
Robertson getting booked for getting his shoulder dislocated
Patterson yellow for not touching that nippy wee winger.