President Trump wrote that his vote advantage in key states had “magically” disappeared.