Pure number of votes. THough the regions will declare separately, it's the net remain vs leave votes overall that matter.
Probably the saddest referendum result in my lifetime https://en.wikipedia.org/wiki/United_Kingdom_Alternative_Vot...
It was genuinely one of the worst referendum campaigns of all time though. I'm still haunted by the 'if you vote for this then babies will die' adverts.
Something like Approval Voting or even better range voting would have been worth it.
Elections, however, are not based on popular vote.