Japanese shares gain tracking US futures; tech and pharma stocks boost