they were also very wealthy. they pulled an enormous amount of gold and silver from mines in mexico and peru from 1550- 1750. Then the mines ran out. Spain then fell back into poverty. All the money they brought back to europe went north to pay for their two centuries of extravagance.
that’s what happens to mere resource economies.
And Spain’s (Hapsburg’s) constant wars with the rest of Europe. (For example Spain’s effort to keep Protestant Netherlands under their control!).