American voters handed Democrats both chambers of Congress after a campaign dominated by high prices and the war with Iran.