“BREXIT-plus-plus-plus” was how Donald Trump—who also called himself “Mr Brexit”—termed his pitch to voters during his successful presidential campaign. Sure enough, many Americans will soon be waking up soon to a feeling similar to the one Remainers in Britain experienced on the morning of June 24th: bafflement at the failure of so many polls to predict the result, shock at the electorate’s defiance of expert opinion, concern for liberal values. If Mr Trump relishes the comparisons it is because he identifies with the architects of Britain’s departure from the European Union: like him, privileged demagogues deft at manipulating the public’s worst fears and instincts.

Yet these affinities confer few obvious advantages on Britain. Mr Trump may admire the country’s recent decision, but he will make an unpredictable, unfamiliar partner—especially compared with Hillary Clinton, an instinctive Anglophile. It says something about the immediate future of the “special relationship” so revered in London that the British politicians most experienced in dealing with America’s president-elect are Nigel Farage, a Brexiteering rabble-rouser (who stumped for him and is currently flying to Washington, DC to ingratiate himself further with the incoming administration) and Alex Salmond, a former first minister of Scotland (whom Mr Trump branded “a has-been and totally irrelevant” in a tiff over a Scottish golf resort).

What about the country’s leaders? Theresa May could hardly be more different in temperament from her new counterpart. The foreign secretary, Boris Johnson, though closer to him in style, has said: “The only reason I wouldn't visit some parts of New York is the real risk of meeting Donald Trump.” In January British MPs debated banning Mr Trump from the country, calling him a “buffoon”, a “demagogue” and a “joke” (one using the word “idiot” thrice in five minutes). To say the British establishment is unenthusiastic about America’s president-elect would be to put it politely.

Nonetheless, the risks of a Trump presidency—protectionism, geopolitical turmoil, American isolationism—weigh heavy on British interests. And they do so all the more thanks to the decision in June that so animated Mr Trump: Brexit removes many of the shock absorbers that might have helped Britain to ride out the next few years.

Take trade. Mr Trump has long pledged to pursue a tough line in negotiations and seems to fancy a tariff war with China. Protectionism is infectious. If, as seems likely, Britain leaves the EU’s customs union on quitting the organisation, it may well find itself trying to negotiate new trade terms at a time when economies around the world are pulling up the drawbridge.

Meanwhile the British economy was already in a fragile state before last night’s result, with the pound weakened, business uncertainty mounting and some evidence of slowing investment. The economic shock of a Trump presidency may exacerbate these trends (though the pound briefly rose against the dollar as Mr Trump’s victory became clear). It will also harden politics in the mainland European countries with which Britain will shortly start negotiating, where populists emboldened by his win (most notably Marine Le Pen of France’s National Front) will reduce mainstream leaders’ freedom to approve a pragmatic deal with Britain.

Then there is security. A staple of the pro-Brexit campaign was that the existence of NATO made European defence cooperation unnecessary and that quitting the EU would thus not knock Britain’s influence as a military power. That did not reckon with America’s next president being as equivocal about NATO as is Mr Trump, who has pledged an “America first” doctrine requiring countries under its security umbrella to make their own arrangements. Britain could thus find itself falling into the gap between a less effective, more divided NATO on the one side and rapid moves towards EU defence integration on the other.

A single theme unifies these risks. Brexit is a giant shock to Britain’s place in the world. It will sever old links and require new ones to be forged. As some of its keenest proponents concede, this transition will bring painful costs. Most of all it demands lots of good will and flexibility on all sides. In so far as Mr Trump’s win means a meaner, more fractious, more volatile global order, it raises those costs and shrinks that space for compromise and consensus essential for a smooth Brexit.

Limiting the damage of a Trump presidency on a Brexiting Britain demands ambition and perspective from Mrs May. Her approach should be two-sided. First, build a new, closer alliance with Angela Merkel, not just on Brexit but on wider issues: the world economy, security, Russia and China. In Berlin and other European capitals officials complain that June’s referendum result has taken Britain’s mind off all other matters. The prime minister must not allow that to happen and instead work with Mrs Merkel as a bloc capable of countering Mr Trump’s worst traits.

Second, Mrs May should use Britain’s influence in America (which is significant, if not as much as Britons like to imagine) to attempt to moderate the new president, staying his hand when he does wrong and indulging his vanity when he does right. Mrs May already had her hands full with Brexit. Now, for Britain’s sake and that of the world, she must also deal with Mr Brexit himself.