Behold in terror and glory the lithium-ion discharge curve:
https://siliconlightworks.com/image/data/Info_Pages/Li-ion%2...This is great for the powered device, since it's nice and flat, but annoying for determining state of charge from terminal voltage, since it's awful and flat. I have not personally developed a state-of-charge indicator, but I would guess that one might use columb counting for the first half of the curve, then voltage monitoring for the second half, introducing odd discontinuities in the 80%-30% range. A truly clapped out battery will up and die before it got to the second half; a merely old battery will just be strange and inconsistent.
>If I turned the phone on again without charging it at all, the battery indicator would tell me that it did indeed have around the 60% charge I estimated.
Another delightful behavior of battery cells is "voltage sag". Battery voltage drops under load. The more current you draw, the bigger the drop. If you draw a big whack of current, then leave the battery alone, the voltage will drift back up: https://www.powerstream.com/x/Christopher-Suozzo-engine-cran... Additionally, the more you ask of a battery, the less capacity it will have https://www.cloudynights.com/uploads/monthly_09_2014/post-21... (1C is 1x the capacity rating of the battery. A 1C discharge of a 2 amp hour battery is 2 amps, 2C 4 amps, etc) and the shorter its lifespan will be https://www.batteryuniversity.com/_img/content/DST-cycles-we...
Combine these factors, we discover that while your phone was behaving very unintuitively, it might not have been lying. If you hit an old cell phone with a big enough draw, (prime95, bitcoin mining, opening a cnn.com story without adblock) the battery indicator could correctly say that only 4% of the battery is left. Shut it off, letting the battery recover a bit, then turn it back on, and ta dah, by the voltage curve with a light idle discharge, it's got 60% left.
Cell phone batteries generally last two or three years. Four years+ requires light discharges and not recharging it fully. Essentially, not using it at all.