Think things will be rosy for Democrats in 2018? Not so fast.

President Trump’s approval rating is at 38 percent. His base is said to be eroding. Average approval of the Republican-controlled Congress is at 16 percent. And the president is at war with his party’s leaders. For Democrats, what’s not to like? The answer isn’t as obvious as it might sound.

Trump and the Republicans have concluded one of the least productive first six months of a new presidency. No signature piece of legislation has reached the president’s desk, and the notable failure to enact a health-care bill stands as an indictment against both the president and GOP congressional leaders.

That’s not to say Trump hasn’t had successes. On some fronts, particularly the regulatory rollback that he and Republicans have promised, the president has made progress. He has followed through on his pledge to crack down on illegal immigration (and now even legal immigration). The toughened policies appease his supporters and alarm his opponents. In other areas, trade for example, his presidency has been more bold talk than vigorous action.

With each presidential stumble or controversy, Democrats look to 2018 and anticipate significant gains. They are virtually guaranteed to pick up seats in the House, given the history of midterm elections. The question is how many. A tidal wave of opposition to a Republican president, like that of 2006, could sweep Republicans out of power in the House. But is that in the offing?

Democrats see evidence in polls and focus groups of an electorate receptive to moving in their direction. They see energy in the number of candidates willing to step forward and run for office. They are confident that the anger that put so many people on the streets early in Trump’s president will carry forward to the ballot box 15 months from now, although evidence about enthusiasm among Democrats and Republicans offers a mixed picture.

But there are other factors that could frustrate the Democrats, from the state of the economy to obstacles created by structural aspects of a polarized electorate to the peculiar ways in which the president defies or at least confounds some traditional measures of public opinion.

It is remarkable that the president’s average approval rating is below 40 percent at a time when the unemployment rate is at a 16-year low and the stocks have hit record highs this summer, at least until jittery markets reacted to warnings by the president of possible military conflict with North Korea.

The economy is not soaring, as the president often suggests. But it remains on the path of steady, if slow, growth that marked the Obama years. The benefits of growth remain uneven; many Americans either don’t see bigger paychecks or don’t feel they are getting ahead. Trump promises even more robust growth, a pledge that could be difficult to fulfill.

Democratic strategists are aware of the mismatch between the president’s approval and the state of the economy and hope that the midterm elections will be simply a referendum on the president, as first midterms often are. But if there is no significant economic retrenchment over the coming year, the headwinds buffeting Republicans could be reduced.

The president’s approval is lower than any past president after 200-plus days in office, a few points lower than former president Bill Clinton’s was at this point in his presidency. Clinton saw his party lose control of the House in 1994.

Democrats hope to see a replay of the 2006 midterm, when they took advantage of dissatisfaction with President George W. Bush to regain control of the House. But between 2006 and today, something important happened. The shape of congressional districts changed and changed in the direction of the Republicans.

Part of this was through redistricting and the success of Republicans in the states to draw lines most favorable to them. Part of it has come through the sorting out of the population. Democrats are now heavily clustered in urban areas; Republicans are spread more evenly elsewhere. That makes it more difficult for Democrats to compete in some congressional districts.

Add to that the reality that in a red-blue nation, red areas have become redder and blue areas bluer. Especially in Senate races, that tilts the field toward the Republicans.

Democratic strategists with long experience in House races say that the overall environment looks as good or better now than it did at this point in the 2006 cycle, by which they mean the president’s standing, the strength or weakness of Republican incumbents and the quality of Democratic recruits. But the shape of the map is challenging, more so than in 2006.

David Wasserman of the Cook Political Report noted this past week that the pro-Republican bias of the House and Senate puts Democrats at an obvious disadvantage now and possibly well into the future.

“Even if Democrats were to win every single 2018 House and Senate race for seats representing places that Hillary Clinton won or that Trump won by less than three percentage points—a pretty good midterm by historical standards—they could still fall short of the House majority and lose five Senate seats,” he wrote.

He said that, while Trump lost the popular vote in 2016 by 2.1 percentage points, Republicans won the median House seat by 3.4 points and the median Senate seat by 3.6 points, the widest difference for the Senate in history and tied for the widest House difference.

“That doesn’t mean Democrats can’t win the House and Senate back,” he added. “They won control of both chambers in 2006 despite a Republican-bias that year, for example. But they’re starting from a truly historic geographic disadvantage, even with the political wind at their back.”

Another difference today compared with 2006 is that partisan lines have hardened even further, meaning the number of swing voters has been reduced. Midterm electorates tend to favor Republicans—the voters are on average older and sometimes include a smaller percentage of minority voters than in presidential years. Democrats must offset that disadvantage by capturing a bigger percentage of independent or swing voters. But fewer voters today are genuinely independent.

John Lapp, a Democratic strategist who was executive director of the Democratic Congressional Campaign Committee when the party captured the House in 2006, said, “I think the battlefield will increase for Democrats. But there is much more partisanship than in 2006. There were more persuadable voters then. it’s much, much tougher to persuade that tinier sliver of persuadable votes.”

One other wild card is the relationship between Trump’s numbers and the GOP’s fate in the fall of 2018. His approval ratings are so low that Republicans should brace for substantial losses, big enough to cost them the House. Also, his current distemper toward his party’s leaders could pose turnout issues next year.

But Trump’s numbers sometimes defy conventional analysis. On Election Day last November, about six in 10 voters said they did not think Trump was qualified to be president. Enough of them cast their votes for him to make him president.

Lastly, but not insignificantly, there are the Democrats’ internal problems — the divisions between the left wing of the party and more moderate progressives, and the related challenge of developing a message with broader appeal. Democrats could do well in 2018 with a nothing more than an anti-Trump message but that might be short sighted.

Democrats can win the popular vote for president by rolling up huge margins in California and New York and big cities elsewhere, as they did in 2016. They can’t win the House and particularly the Senate that way. They need a message that appeals beyond their base and they need more candidates who can compete effectively in less friendly territory.