Don't want to go over teacher's head, but...

The OP has received plenty of advice, and I don’t have a lot to add in that area. It feels awful to be treated unfairly, especially if you are an adolescent (or are the parent of same).
I can share what was helpful for me. I took the attitude, that I shared with my kids, that a grade is the teacher’s attempt to guess how well a student has mastered the material. Sometimes they are on the mark. Sometimes they over- or under- estimate. All the teacher can do is find a way to sample knowledge/performance.
What really matters is how much the student is learning. My son (more than my daughter) took risks regarding grading. He knew that he sometimes lucked out (homework wasn’t checked) and other times luck failed him. My daughter was quite compulsive about the details, leaving much less to chance.
I could easily see my son making the same error as the OP’s son. My stance would be a very sympathetic “you gambled and you lost this time.” It sounds as if he did an admirable job of advocating.