WARSAW, Poland — The ruling pro-European Civic Platform party was heading to its first electoral defeat in nine years, as …