Your iPhone says "Storage Full" while iCloud happily claims you have 5GB free. Somebody is lying. The answer is: both, and neither.

The Two Storage Games

iCloud measures one thing. Your iPhone measures another. They do not talk to each other in any useful way.

iCloud free tier (5GB): Your total cloud allocation. It includes backups, iCloud Photos, Messages in iCloud, app data, and documents. It does not mean your phone can hold 5GB more photos.

iPhone local storage: The physical NAND on your device. iOS caches, system data, apps, and your photo library all compete for this space. "System Data" alone can balloon to 20GB with no explanation.