I became friends with an American who was residing in Japan.
In order to extend your residency, you have to leave the country and then come back.
Visas and residence status are two different things.
The place you're detained is where you exist. As long as you're in this place, this will be your residence. Note: mainly means "residence" in the broader sense and is parts of words like "residence card" or "foreign residents."
This is a jukugo word that uses the on'yomi readings of the kanji. You should be able to read this on your own.