Das Mädchen hatte Angst vor ihrem eigenen Schatten.

Das Mädchen hatte Angst vor seinem eigenen Schatten.

This is a well known problem in German.
Sometimes the grammatical gender and the “natural” gender are obviously at odds.
In cases like that both variants are okay.

You just have to be consequent. Compare:

Das Mädchen zögerte, denn es hatte Angst vor seinem eigenen Schatten.
Das Mädchen zögerte, denn sie hatte Angst vor ihrem eigenen Schatten.

If the German gender rules drive you crazy, you are in good company.
Just read Mark Twain’s Tthe awful German language. “Das Mädchen” is one of his favourites.

3 Likes