There’s a perception out there that the new GOP tax law screws over only blue states.

That’s wrong.

It creates huge political problems for almost every state. With relatively little fanfare, Congress effectively sent ticking time bombs to statehouses across the country, which are scrambling to assess and contain the damage.

Yes, it’s true that the federal law’s new limits on state and local tax deductions disproportionately hurt high-tax, mostly Democratic states.

New York, New Jersey and California are all now exploring workarounds, such as essentially reclassifying state taxes as charitable contributions. (It’s not clear yet that the IRS will buy this scheme.)

There are, however, lots of other ways the federal law will scramble blue- and red-state budgets and plunge some of them deeper into fiscal and political crisis. During an election year, no less.

Why? To keep things simpler for taxpayers, most state tax codes are automatically linked to the federal tax code.

For example, of the 41 states with a broad-based personal income tax, almost all use as a starting point either federal adjusted gross income or federal taxable income. Taxpayers simply take a number they’ve already calculated while filling out their 1040s, then plug it into their state tax returns.

That means if Congress changes how either of those numbers is measured, it can cause big swings in state revenue, too.

Each state tax code is different and interacts with the federal law differently. Right now there’s a lot of confusion and disagreement in statehouses about what this sloppily drafted federal law will do.

Some states stand to lose tons of money. Federal provisions such as the near-doubling of the standard deduction and the giveaway to pass-through entities will not only blow up federal deficits; they can also blow up state deficits. These deficits will only get worse if Congress follows through on plans to cut entitlement and safety net funding this year.

Montana, already dealing with a budget crisis, expects the federal tax law to cost it an additional $46 million in 2018. Unfortunately, Montana also happens to be one of several states whose legislatures aren’t scheduled to meet at all in 2018, which means it has been caught a bit flat-footed.

In many states, on the other hand, tax revenue is likely to go up — in some cases by hundreds of millions of dollars.

That’s because (for example) a state tax code may mirror the feds’ use of personal exemptions, which the Trump tax law eliminates. This would mean that families with a lot of children will see their taxes rise, absent any additional change to state law.

This revenue “windfall” may not exactly be a blessing.

Some of the states expecting to get a revenue boost, such as Maryland and Colorado, are debating whether to just pocket the money. But remember — this is an election year: Standing by and allowing state taxes to rise is risky.

As a result, some states are saying no-way-no-how will they let state tax hikes happen. Idaho, Michigan, Maine and Minnesota are among the states considering new tax cuts to offset these accidental tax hikes.

But rushing through offsetting tax cuts is also highly risky.

The roughly 500-page federal law was jammed through with no hearings, no expert testimony and no time to fully vet it for glitches and accidental loopholes. Needless to say, that process also didn’t leave time for states — which have far fewer resources, and legislative days, than Congress — to figure out how clever accountants might game the law.

“How in the world are you going to estimate the revenue here, under these circumstances?” said Max Behlke, director of budget and tax for the National Conference of State Legislatures. “If you think you’ve got $800 million more that allows you to reduce taxes, and you’re off by $400 million, that’s kind of a problem.”

Especially, he adds, since nearly every state is bound by a balanced-budget requirement.

One option states have is to “decouple” from the federal code, says Richard Auxier, a Tax Policy Center research associate. Oklahoma did this pre-emptively last spring to avoid taking a big revenue hit if Congress ultimately doubled the standard deduction (which it did).

But “decoupling” makes filing taxes more complex, since taxpayers must do earning calculations multiple ways. Allegedly, one of the objectives of the Trump plan was to simplify tax planning and preparation. This would essentially be trickle-down complexity.

The moral of the story: The tax fight isn’t over. In fact, in almost every state across the country, it’s just beginning.

Catherine Rampell