Oil retreats on surprise rise in U.S. stocks, weakening demand outlook