Henry
What to do if I miss the last train?
Cheryl
First of all, you do not need to worry if you miss the last train in Japan.
Capsule Hotel
If you really tired and need some sleep try to search for capsule hotels nearby. For about 3,000 yen you can sleep in the bed, with alarm clock, a light, and a shower in the morning. See a list of capsule hotels in Tokyo: https://www.booking.com/capsule-hotel/city/jp/tokyo.html?aid=300323
Karaoke Bar
If you not tired and want to have some fun with your friends, you can try to go to Karaoke Bar. Most of Karaoke bar offer freetime package which allow you to sing from midnight until 5:00 am on the next day for only 1000-2000 yen and including drink bar.
Internet Cafe
You can enjoy 24 hours internet access, reading comics, and watching TVs or DVDs. Japan's internet Cafes also offer a range of options includes sofas, private rooms, and even beds. In addition, they also provides shower rooms to overnight customers.