Bad semester - Math PhD application
It is unlikely that a single bad semester will be decisive, given everything else, especially good letters. You aren't alone in stalling for the final semester, of course. If it is burn-out, then you need to deal with that explicitly as the overhang can be pretty bad as you start a new program. You need to start with a fresh and eager perspective.
But &quot;top 20&quot; is an incredibly narrow range of schools to apply to. I'd suggest, instead that you cover yourself by taking a broader attack against the full range of research (R1) institutions. There is a lot of competition as you note yourself.
And, other than the small effect on your GPA a failing grade in art history is unlikely to be a block for a mathematician. You do have to fulfill all graduation requirements, of course.

From your description, I've assumed this is the US.