How stays work: your visa has an entry-validity date (enter by this date) and a duration of stay (days allowed after entry, e.g. 30 days for most L visas). Residence permits are counted by their expiry date.
Extensions: apply to the local exit-entry administration before your stay expires, with passport, reason for extension, accommodation registration and supporting documents. Tourist visa extensions are typically granted up to 30 days at a time.
Overstay: expect daily fines (usually ¥500/day, capped) and possible entry restrictions or records. If you are close to or past expiry, go to the exit-entry office proactively and regularize your status — never delay or try to exit quietly.