A local slots tax ruled unconstitutional this week by the Pennsylvania Supreme Court accounts for more than 20 percent of annual budgets in Chester, home to Harrah's Philadelphia Casino, and Bensalem Township, where Parx Casino is located.

Officials in those communities are sweating bullets after a  ruling Wednesday, which said the municipal portion of tax on slot machines outside Philadelphia violates the state constitution because it effectively imposes different rates on casinos depending on their size.

"We're devastated right now," Bensalem Mayor Joseph DiGirolemo said Thursday. "I'm very hopeful that the legislature will find a way to fix this. It's something that we certainly thought was embedded in stone and wasn't something that they would ever just take away."

The annual Bensalem budget is $48 million, DiGirolemo said, which means its $10 million cut from slot machines is close to 21 percent of the township's revenue.

In financially troubled Chester, roughly $10 million from slots in fiscal 2015 amounted to 23 percent of the budget, according to a July report on the city's recovery plan.

"If the current decision is upheld, it would be devastating for Chester.  We will work with the state legislature and do everything within our power to ensure that the current decision is overturned," the city's chief financial officer, Nafis Nichols,  said in an email.

Meanwhile, Thomas Leonard, the lead lawyer in the case brought by Mount Airy Casino Resort in the Poconos, said Thursday that he is weighing the possibility of turning to federal court to recoup the money collected under the tax that was ruled unconstitutional. The opinion said the casino was not entitled to a refund.

That could be a violation of due process under the U.S. Constitution, said Leonard,  who is chairman of Philadelphia law firm Obermayer Rebmann Maxwell & Hippel LLP. "You can't keep money that was illegally collected," he said.

Stanley R. Kaminski, a partner in Duane Morris LLP's Chicago office, who specializes in state and local taxation and was not involved in the Mount Airy case, said the U.S. Supreme Court has ruled that there has to be some type of meaningful relief on illegally collected sums.

"The question is: Is just striking it like that meaningful relief? That's the due-process issue," Kaminski said.

At issue is a huge amount of money. Nearly $1.2 billion has been collected under the now-unconstitutional local share assessment on slots revenue since the first casino opened in Pennsylvania nearly a decade ago. The state would likely be on the hook for the money, experts said.

Leonard also sees a problem in the fact that the court gave the General Assembly four months to come up with a fix.

"They are expecting people to pay an unconstitutional tax for another 120 days," Leonard said. "I don't know how you can do that," he said.

As it is, the fix won't be easy for Harrisburg, where informal discussions have begun.

"We have heard from a lot of members of the Senate on both sides of the aisle and they have expressed an interest in trying to rectify this, and in doing so making sure that whatever is done is fair and equitable for all of the parties that are involved," said Jennifer Koch, spokeswoman for Senate Majority Leader Jake Corman (R., Centre).

One challenge: The legislature  has only six more sessions scheduled this year, though more can be added.

The core problem with the tax is that casinos outside Philadelphia, except for Valley Forge Casino Resort, in Upper Merion Township, and Lady Luck Casino, in Nemacolin, have to pay 2 percent of slots revenue or $10 million a year, whichever is greater, to their host municipality.

That means casinos have effective tax rates that vary significantly depending on their size. Parx had $379 million in slots revenue last year, which means that $10 million amounts to a tax of  2.6 percent. Mount Airy, by contrast had just $140 million in slots revenue. The $10 million minimum means its effective rate was 7.1 percent. The effective rate is even higher at Presque Isle Downs & Casino, near Erie.

SugarHouse Casino is not subject to the $10 million minimum. It pays 4 percent -- 2 percent to the city and 2 percent to the county, which are the same in Philadelphia.

One straightforward fix would be to eliminate the $10 million minimum for all casinos and establish a tax rate that applies evenly. The challenge is deciding where to set the rate.

Setting the rate at 8.5 percent, which could possibly maintain stable revenue for Presque Isle's host municipality and county, would mean that Parx's township tax would soar to $32 million from $10 million, based on 2015 revenue.

State Sen. Tommy Tomlinson (R., Bucks), who helped write the legislation, said it would be unacceptable for any host municipality to get less money. "We must maintain what these communities get," he said.