How do we use oxygen isotopes as temperature proxy? As far as I know scientists use oxygen isotope 16 to 18 ratio in air trapped in glaciers (or in old foraminiftera shells) as proxy for temperature in the past. I know that $\ce{^18O}$ is heavier, and it precipitates faster, and $\ce{^16O}$ is lighter, and it evaporates faster.

I understand that when it's warmer, there is more evaporation and more heavy isotope left in water. Vapor moves toward poles, where it falls as rain or snow and goes back to water (this doesn't count) or stays in glacier for hundreds of thousands of years.

So when it's warm, we should have more $\ce{^18O}$ in ocean sediments, and less in arctic glaciers, right? So more $\ce{^16O}$ (less $\ce{^18O}$) in glaciers -> warm period.

On the other hand, when it's cold, precipitation occurs earlier while air moves to the poles, and heavy isotope falls down earlier, on bigger latitudes. In the air that goes to the poles there is only little heavy isotope left. So more $\ce{^16O}$ (and less $\ce{^18O}$) in glaciers -> cold period. This is contrary to the above. So how to figure out temperature from ice and sediments cores?
This is somewhat a general answer.  According to the Royal Chemical Society webpage Chemical climate proxies (Evans, 2013), the rarer and heavier $\ce{^18O}$ isotope in water generally evaporates after and condenses (and precipitates) out earlier than the lighter and more common $\ce{^16O}$ isotope, shown in the diagram below:



Source: University of Michigan's page Past Climates on Earth

The colder the environment, the quicker the atmospheric water vapour condenses, hence the quicker the $\ce{^18O}$ isotope is depleted, giving a lower ratio of $\ce{^18O}$ to $\ce{^16O}$ (referred to by the RSC page as $\delta{\ce{^18O}}$) by the time it reaches the poles.  In contrast, a warmer environment would mean that the water vapour condenses later and slower, meaning that less $\ce{^18O}$ laden water vapour condenses, resulting in a higher $\delta{\ce{^18O}}$ value.

In short, it is not so much of the amount of $\ce{^16O}$, but rather the ratio of $\ce{^18O}$ to $\ce{^16O}$ isotopes present, otherwise known as $\delta{\ce{^18O}}$.

The following Earth Observatory diagram demonstrates the present-time process, showing the differences between warm and cold environments:



Source: Earth Observatory's page: Paleoclimatology: The Oxygen Balance