Boy, the president is off his game tonight After watching a videotape of his Denver performance, Mr Obama agreed. "If I give up a couple of points of likeability and come across as snarky, so be it," he told aides. It was almost too late. Within days, Mr Romney was surging in the opinion polls. He hit parity with the president in national surveys and more importantly was making up ground in several key swing states. Indeed, Neil Newhouse, the Romney campaign pollster, was telling his boss that polls were over-estimating Democrat support because they were wrongly anticipating the same high turnout among young people and blacks as in 2008, when those groups voted in historically large numbers for Mr Obama. But despite the dismay within Team Obama after the Denver debacle, there was no panic at his re-election headquarters in Chicago, a vast open-plan office that felt like a cross between a hi-tech computer start-up and an insurance business. Their own polls never showed Mr Romney overtaking the president. And they also had the numbers from "the cave." In an operation cloaked in such secrecy that codenames were used, the Obama campaign was deploying data wizardry unprecedented in its sophistication and intensity to raise funds and target potential voters. Jim Messina, Obama's campaign manager, recruited a team of behavioural scientists and number crunchers to mine data and demographic information with the sort of precision used by state-of-the-art retail marketers. Asked what the mysterious team was doing in their secluded windowless room, campaign spokesman Ben LaBolt would only say cryptically that they had the "nuclear codes." In terms of Election 2012, that was barely an exaggeration. The databases initially provided the basis for a money operation that raised $1 billion by election day. And in recent months, they had provided the data for the most elaborate get-out-the-vote operation in political history, one that stunned the Romney team when results started to come in on Tuesday night. After the Denver debate, they established that in all-important Ohio, for example, their poll numbers were slipping because voters who'd been lured away from supporting Mr Romney earlier in the campaign were now returning to the Republican challenger again. But the crucial analysis for Team Obama was that the coalition it needed to win the state - car workers, African-Americans, young people, women and Latinos - remained solid. They could still win, so long as they could just turn them out to vote. The polling and voter-contact data was re-processed in 66,000 computer simulations each night of election scenarios in swing states. "Every morning we got the spit-out - here are your chances of winning these states," a senior official told Time magazine, which first revealed details of the operation after the election last week. And that is how we allocated resources. Data of course was not enough. The president had to play his part after his dismal performance in Denver. "The first debate turned a switch for him," said Dan Pfeiffer, a long-time adviser. He came out of that very focused on ensuring it would never happen again. But at the Romney headquarters in Boston, the candidate and his senior strategists believed that the tide had finally turned in their direction. Until that moment their prospects had never looked rosy as they had consistently failed to close the gap with the Obama campaign. The choice of Paul Ryan, a budget hawk congressman, as vice-presidential running mate had done little to shift the dial. And Mr Romney's showpiece speech at the Republican convention in Tampa in late August was overshadowed by Clint Eastwood's unscripted stunt with an empty chair that had several senior strategists shaking their heads in despair. Worse was to come for Mr Romney in September with a leaked video recording of him at a meeting with wealthy donors in which he dismissed the 47 per cent of Americans who pay no federal income tax. The Obama campaign had for months been blitzing swing states with television attack ads depicting the Republican as a private equity asset-stripper who stashed his millions in tax havens. Now here was Mr Romney sounding off like an uncaring plutocrat in his own words. Denver appeared to have changed that trajectory. Mr Romney finally seemed relaxed and confident on the hustings, apparently enjoying himself for the first time. He was striking a more moderate stance on issues such as abortion and immigration - hot-button social topics on which he had adopted a hard line during the bruising Republican primary campaign to fend off challenges from the Right by conservatives such as Rick Santorum and Newt Gingrich. His wife Ann and oldest son Tagg had led behind-the-scenes calls for him to strike a more moderate tone and remind voters that he had reached across the aisle to work with Democrats when he was governor of Massachusetts. And as crowd started to swell at rallies during the final month. Mr Romney and his team started to talk about how they had enthusiasm and intensity on their side. What did it matter that his foes were laying old charges of flip-flopping against him? But the long campaign to defeat his Republican rivals in the primaries earlier in the year had not just taken a heavy toll on Mr Romney in terms of policy positions, they had also drained his financial resources. And since his defeat, Romney aides have revealed just how damaging that was to the candidate. Despite being a rich man, Mr Romney was forced to spend months focused on fund-raising, often devoting more time to meetings with donors than to political rallies. At the same time, driven by the demographic data delivered by its number-crunching team, the Obama campaign was already blitzing key voting blocs in swing states with advertisements blasting Mr Romney's record in business and politics. "In the end, Romney raised the money he needed, but in the process lost the opportunity to define himself to the American people after the primaries," said a Republican strategist who spoke regularly to the Romney team. That in retrospect cost him very dearly. There were of course other mistakes as Mr Stevens, Mr Romney's one-man brains trust, insisted on a campaign focused relentlessly on the struggling US economy. Early on, his team decided that the candidate's image was too wooden and not "likeable enough." So they reduced what they feared would be opportunities for him not to be liked by cutting down on press conferences, interviews and lengthy exchanges with voters. Yet many who spent even a limited time in his company during the campaign were surprised to find him so likeable, funny - if in a cringe-making way at times - and unfailingly well-intentioned. "The first time I met him, I thought, 'Who is this guy?" " said a member of the travelling media entourage. If they had let that Romney out it might have been a different story. Mr Romney did belatedly present a more personal face on the campaign, telling stories about his life as a family man and a Mormon minister and counsellor, after his wife pressured strategists to "let Mitt be Mitt." But it was all too late. On election day, as Mr Romney and Mr Ryan took to their plane for one last tilt at two swing states, many low-level aides feared the worst. At the top of the campaign, however, optimism reigned and the candidate prepared only one speech - for victory. Mr Newhouse, the in-house pollster, remained convinced that a wave of enthusiasm to dump Mr Obama would carry enough swing states. "He kept saying the Democrats won't turn out like they did in 2008, so all these polls were wrong," said an insider. But instead he was over-estimating the Republican turnout. Indeed, it is not just that the widely-predicted "enthusiasm gap" failed to materialise among ethnic minorities, particular African-Americans, who backed the president so overwhelmingly four years ago. Significantly many Obama supporters proved even more motivated than in 2008 and his key voting blocs turned out in similar numbers. "In 2008, everything about Obama was very exciting and new," said Maria Wilson, 64, an African-American campaign volunteer who travelled to the swing states of Iowa and Wisconsin to canvas. But in 2012, it was even more important for him to win. We had to defend and build on the progress we'd made. I could just about have lived with defeat four years ago. But now we all knew how much was at stake. Enthusiasm gap? We were even more enthusiastic this time around. Early returns and exit polls signalled that Mr Romney was in deep trouble. And then swing state after swing state remained in Mr Obama's column. As Mr Romney called the president to concede, his wife Ann shed tears in their Boston hotel suite. Mr Ryan seemed in a state of shock and his wife Janna cried quietly. "There's nothing worse than when you think you're going to win, and you don't," an adviser told CBS News. It was like a sucker punch. Mr Romney hurriedly composed a brief concession speech. "He was shell-shocked," said another adviser. At Mr Obama's victory party in Chicago, exuberance was mixed with relief. They had always had the comfort of the numbers from the "cave." But only now was it confirmed that these really had been right. Next day he returned to his campaign headquarters where, with tears in his eyes, he paid an emotional tribute to his staff, among them the number-crunchers who had made it all possible. Additional reporting by Alex Spillius in Boston