It’s not off the cuff. It uses the site’s background as it’s own and has to guesstimate what color the letters on top must have in order to remain legible.
Compare the job of this algorithm, having to deal with a crazy amount of possible color combo, to that of an experienced UX designer making just a dark and light theme, both thoroughly tested, and you can begin to grasp the trouble they’ve put themselves into.