The problem is northern AL went soft. It was bright red for Trump but pink and light blue for Moore. I blame senator Shelby, the patron of the northern AL technology corridor, for that. He broke his usual silence to express disapproval of Moore and advocate for a write-in the weekend before the election. That made college educated suburban types and probably some evangelicals in the northern part of the state comfortable with the idea of staying home.
Northern AL was the one variable that moved in an unexpected direction. Every other factor was predictable and all the players played their standard roles. We knew Mitch and the Washington swamp were going to backstab Moore. But who knew an Alabama senator would backstab him? You can see the Shelby effect in the write-in margin that Trump noted in his tweet.