When Jan. 1 rolls around, California will not merely be permitting adults 21 and older to legally buy marijuana for recreational purposes. The state and its cities will be creating a new regime to regulate and tax cannabis.

The stakes are high: Successful cannabis legalization in America’s largest state could help end the devastating drug war in the United States. But if this transition turns messy, the Trump administration, which is devoted both to debasing California and promoting thoughtless “law-and-order” policies, could bogart everything, stepping up arrests and criminal penalties for drug violations.

There is reason to worry. Smoking weed is said to expand your mind, but I’m not sure if there’s enough marijuana in the state for anyone’s brain to comprehend the complexities of all the new rules, much less enforce them.

Legalization requires moving a shadowy $7 billion industry into a highly regulated structure, with extensive taxes and permitting. California governments that once took a live-and-let-live approach to cannabis now find themselves having to step up enforcement against cannabis businesses to make sure companies choose to move out of the black market.

Such policing requires striking difficult balances. If regulatory compliance is too loose, and taxes and permits are too cheap, scofflaws could plague the new industry. But if regulatory compliance is too costly and taxes too high, too many firms might stay in the black market.

At this point, it’s hard to be optimistic that California’s governments will find that balance.

The state has been slow to create an interconnected framework of rules covering both newly legal recreational adult use and medical use, which has been legal since 1996 but poorly regulated.

Then there are California’s cities, which have tremendous discretion in whether to issue permits but are in many cases still debating what to do. Municipalities that have issued rules are creating so many different standards that California’s cannabis market will resemble a crazy-quilt.

The federal government is also undermining the transition. By maintaining its prohibitions of marijuana, the U.S. is creating both legal jeopardy for those in the legal industry and real difficulties with banking, since few financial institutions will serve businesses selling a product the federal government considers illegal.

Because the industry is badly undercapitalized, it hasn’t built all the infrastructure — compliance systems, lab testing, centralized distribution — necessary for its new regulated reality.

While attending three cannabis conferences this fall, I was struck by the high anxiety around the conundrum of making a business legal without ending up in trouble over the new rules. Many are coping by devoting themselves to California’s real drug of choice: marketing.

Cannabis already resembles other forms of American commerce, with varieties of products of dubious necessity: cannaboid eye drops to treat your glaucoma, hemp oil to stop your brain seizures, and cannabis-infused items to get you off addictive opioids.

Amid all this smoke, Los Angeles and Oakland are among the cities working on “social equity programs” to make sure communities hurt by the drug war enjoy the benefits of investment in the newly legalized market. But the cannabis industry may mirror California’s inequality.

Poorer communities have been more open to permitting the businesses, while wealthier places have kept them out. In effect, many places with the enforcement resources to shrink the black market and protect legal businesses are sitting this transition out.

This will be a New Year’s Eve of high spirits, as some Californians legally buy marijuana for the first time. But the rest of the transition may feel like a bad trip.