Public support for Democrats and Republicans has hardened in recent months, leaving an increasingly narrow sliver of undecided voters.