api & rewrite: buy gems, reroll, fully converted server to JS, bug fixes