Hi Steve,
Only citizens and permanent residents can have firearms.
If you plan to retire in Costa Rica, you’ll most likely get the retiree, or pensionado, form of residency, which is considered a temporary residency because you have to renew it regularly. But after three years as a temporary resident you can apply for permanent residency.
There are restrictions on firearms in CR, including background checks and firearms knowledge and psychological testing.
Once you’re eligible you can bring firearms from the U.S., if they meet local laws, or buy them in CR.