The UK is waking up to an election result that not many people expected – including Theresa May, who called a snap election to increase her majority and now looks like she'll be left with no majority at all.
To win an election outright, a party must in theory secure 326 of 650 seats in the House of Commons, gaining a (very slim) majority and earning the right to form the next government.
As it stands, while the Conservatives are predicted to come very close to this total, with a forecasted 318 seats, they will not exceed it. Labour's performance is set to strongly outperform expectations but will leave the party well short of the 326 total, with a predicted 262 seats.
So, if no one has a majority, what happens now?
For now, Theresa May is still prime minister.
As the incumbent prime minister, Theresa May is entitled to stay in Number 10 until it's clear she has no prospect of forming a working government and someone else does. This also means – on paper at least – that she has the first right to attempt to form a government by persuading other parties to either enter coalition with her or back her up on key votes.
However, there is nothing stopping other parties conducting talks at the same time to see if they can come to some sort of rival arrangement. If it became clear one of these could create a majority, May would be obliged to resign and let someone else enter Number 10.
In practice, civil servants in the Cabinet Office will work frenetically behind the scenes seeing what deals different parties will or won't do, and will offer to host talks and discussions for any parties that want to carry them out.
How long do parties have to work out a deal?
Theresa May has the right to force a party that says it can form a government to prove it before she has to resign, though she may not opt to do this in practice. This would be done by the party offering a vote in the House of Commons saying MPs had confidence in that government. The earliest this could happen would be Tuesday 13 June. If Jeremy Corbyn were to hold this vote and win, Theresa May would step down and Corbyn would enter 10 Downing Street.
If this step wasn't taken, Theresa May (or any acting Conservative leader) would have another week to work something out. The crunch moment would come at the Queen's Speech, in which the government lays out its legislative programme. If the Conservatives couldn't pass that vote, they would step down as government, and Corbyn, as leader of the next largest party, would become prime minister – but he'd then have to pass a vote himself.
If he too fails to get a Queen's Speech passed within two weeks, the UK would be forced to have another general election. Yep: another. This would likely fall sometime in August.
What have parties said about deals?
Both Labour and the Liberal Democrats have said they would not make deals with other parties. But what parties say before an election is not necessarily what they say when presented with the reality of a hung parliament. And there are informal deals that fall short of a full coalition like that of the Conservatives and Liberal Democrats between 2010 and 2015. These include agreements to support the government on key votes but not other votes, in exchange for some concessions.
Labour has said that if it has the chance, it will offer a Queen's Speech without doing any deals and let other parties vote on it as they wish. This would seem unlikely to form a lasting government.
Theresa May's best hope is Northern Ireland's Democratic Unionist Party, which is expected to win 10 seats. The DUP, a long-term ally of the Tories, says it is willing to look at an arrangement to build a government.
What deals might make a majority? Is a "rainbow coalition" possible?
In the run-up to the general election, some on the left said they hoped for a "progressive alliance" or "rainbow coalition" to end the Conservative government. That prospect was dubbed a "coalition of chaos" by Theresa May.
Realistically, even if the parties were to look at doing this, it would be unlikely to work.
Using the forecasted result as it stands, adding Labour (262 seats), the SNP (35), the Liberal Democrats (12), Plaid Cymru (4), and the Greens (1) – an incredibly difficult-to-manage five-party coalition – would still leave the alliance on 314 seats, 12 short of a majority. Plus, several parties concerned have said they would not want this deal even if it would work.
If the Conservatives did decide to do a deal with the DUP – which would definitely come at a price – this could result in a small majority, albeit one that would be smaller than the one the Conservatives had before the election, and that would be fractious and difficult to hold together.
If the Conservatives had taken (roughly) 318 seats and the DUP 10, this would give a seat total of 328, a theoretical majority of just 8 – one of the smallest possible.
In practice, this majority would be larger, thanks largely to the DUP's arch-rival in Northern Irish politics: Sinn Féin, which wants the reunification of Ireland. Sinn Féin's candidates do not take their parliamentary seats, as its members refuse to swear loyalty to the Queen.
Sinn Féin is expected to win 7 seats – its best ever performance – meaning the "real" total of MPs becomes 643. This means the actual target for a majority becomes 322 seats.
So a combined Conservative/DUP count of 328 seats would leave a working majority of 11 (the Speaker counts as a Conservative but doesn't vote) – slightly smaller than the Conservatives had before election.
Such an outcome would be humiliating, would be difficult to maintain for a full five-year term, and would leave the Conservatives with a smaller and less manageable majority than the one May claimed was too small to deliver Brexit.
Even if a government forms and an election is delayed, don't expect much stability in the months to come.
James Ball is a special correspondent for BuzzFeed News and is based in London. PGP: here
Contact James Ball at James.Ball@buzzfeed.com.
Got a confidential tip? Submit it here.