The Spanish-American war was closer to the USA opportunistically feasting upon the remains of the fallen empire (The British already overtook the Spanish in terms of power).
It's hard to pinpoint the fall of the Spanish Empire. But it's even harder to point out military action between Spain and Britain (undoubtedly the rising star in the next centuries). There is the big war of Spanish Succession but that's more opportunistic and more like a major civil war that spilled out of Spain and across Europe.
Lots of war between Spain, HRR, France and other parties. But strangely not so much with Britain....
---------
In both Spanish and British cases, the real enemy the whole time was just a boatload of debt.
But quite beyond that, I'm just saying that the Thucydides trap is not an iron rule. The first place I looked was a counterexample and I'm sure there have been many more over the centuries.
No war was "needed" to settle who was #1, it was clear that we (the UK) simply couldn't maintain the empire as it was and we definitely couldn't have fought the US.
We went into WW2 the clear naval power in the world, We exited it in the #2 spot utterly broke.
In less than 4 years the US produced enough ships to eclipse our navy and did it while also producing ridiculously vast amounts of equipment for themselves and their allies across every sphere.
No one with a brain in our foreign office would have even contemplated poking that (and realistically while the US has at times been a questionable ally on the whole in that era they were a reliable ally).
In that kind of total war the side with the larger industrial base wins the war of attrition.
It doesn't matter if the enemy sinks ships if your production rate exceeds the sink rate on a sustained basis you win (somewhat related it's also why naval strategists have been sounding the clarion call about the fact that China now makes more than half of all global shipping, the US is somewhere around 1% - those peacetime yards/skilled works transfer over in a war).
The US did that, they won the war (or their part of it) in the factory lines/mines as much as they did on the actual front.
War is costly, so (in the absence of bargaining frictions) game theory suggests that an agreement can be reached that leaves both parties better off compared to going to war.