DOM access is impossible with SSJS. When you execute a script block with the runat="server" it only has access to whatever it inside the script block. I suggest using the ?SQ_VIEW_SERVER_JS query parameter to view the code that is executed by the JS engine, it’s helpful to get a feel for what is and isn’t possible. (https://matrix.squiz.net/manuals/concepts/chapters/server-side-javascript#viewing-ssjs)
The keyword you’re attempting to print out doesn’t work because keywords are evaluated before SSJS is executed.
SSJS is much simpler than it might seem at first glance. It really is just an extra step in the page rendering pipeline that can execute simple self-contained JS. It’s very useful within those bounds, but many people (everyone I’ve ever seen try to use it) find that those bounds are more limited than they initially hope.
Server to client (normal) javascript comms should be doable by storing values in the page markup that are then later available to client side JS. Some level of comms between them might be possible to achieve that way and through the client side then calling on assets containing server side code, but I’ve not played in that space - we tend to have a firm divide between server generated content and then client code to augment whatever the server code has put in place.