Bottom phonetic
元 — supplies the sound, shifting to wán through n/y onset substitution. The 'origin, whole, complete' sense of
元 also tints the meaning: a building reaches its complete original form. Same phonetic in
院 (courtyard) where it again pairs with a building radical.