How should I choose which graduate programs to apply to for the PhD?
Yes, the rankings (roughly) reflect the selectivity of the program, as far as I know.  Your choice to focus on mid-tier programs makes sense.  (I think defining mid-tier as starting in the 40s is plausible, though I suspect you'll get conflicting answers from different people.) However


Don't confuse the quality of the program overall with the quality of their specialty that you hope to study.  Their specialty program could be much better or worse than the program overall.  In math departments (as opposed to, say, some computer science departments), students are typically admitted to the department, rather than to a professor's research group or a specialty area.  Taking advantage of this could get you into a specialty program that's rated higher than you "deserve".
Don't exclude a school just because it's too highly rated.  It's good to apply to a wide range of schools, some "reach" schools that you think it unlikely you'll be admitted to, and some "safety" schools that you would be quite surprised not to be admitted to.  All sorts of factors influence how likely it is you'll be admitted to a given school in a given year, many of them completely unknowable to you.  For example, maybe a new faculty member will be coming and looking for students (or maybe one will be leaving).  Maybe the program has all their TA positions tied up with current students who haven't finished yet, or maybe not.  Maybe a dean wants to grow the program, etc.  Many of these things you just can't know.  Most likely, you won't get into MIT, Harvard, Princeton, or Stanford.  But once you get into the 20s, 30s and below, the outlook is less clear.
Focus on fit, rather than solely on ranking.  Think about where the school is located.  If you plan to live there for 5 or 6 years, you don't want to hate the place.  This can include proximity to your family or friends, climate, scenery, nightlife, etc.  If you know what specialty you want to study, the school should have at least 1, but hopefully 2 or 3 folks that you would potentially like as an adviser.
Focus on aspects of your application that you can still change.  With a transcript no stronger than yours, I got into a top-25 school.  The cool part is that for the specialty I chose, they were top-10.  At this point, most of your transcript (and much of your application in total) is fixed.  But you didn't mention your GRE scores.  (The surprising thing about the GRE is that you can do pretty well if you're just really good at Calculus (through multivariable), Dif. Eq., and Linear Algebra.)  I think my subject test was something like 65th percentile.  That's not terribly good, but I think it was enough to convince the admissions committee that even though I was coming from a small LAC that no one had heard of, I did know something.  The other thing I did, which I highly recommend you try, is get a letter of recommendation from a faculty member at that school (where I was admitted).  I wrote code for him for 3 or 4 weeks (about 30 hours/week, I think) during Christmas break of my senior year.  In exchange, he wrote a recommendation for me.  I'm sure it didn't say that I was a math wunderkind, but whatever it said added just enough to my application to get me in.