Involved in the biosynthesis of caffeine. Catalyzes the conversion of 7-methylxanthine (7mX) to theobromine and of theobromine to caffeine. Has 1-N-methylation activity. 7-methylxanthine + S-adenosyl-L-methionine = H(+) + S-adenosyl-L-homocysteine + theobromine S-adenosyl-L-methionine + theobromine = caffeine + H(+) + S-adenosyl-L-homocysteine 1,7-dimethylxanthine + S-adenosyl-L-methionine = caffeine + H(+) + S-adenosyl-L-homocysteine Binds 1 Mg(2+) ion per subunit. Alkaloid biosynthesis. Highly expressed in developing endosperm (PubMed:12527364). Detected in young leaves and flower buds (PubMed:12527364, PubMed:25249475). Present in immature fruits (grains), but barely in mature fruits (PubMed:25249475). Belongs to the methyltransferase superfamily. Type-7 methyltransferase family.