-4
When I try to change the value of a css variable with js the following error:
index.html:27 Uncaught ReferenceError: root is not defined
    at HTMLBodyElement.<anonymous> (index.html:27)
i declared the variables in css so:
:root{
        --topV: 0%;
        --leftV: 0%;
      }
to try to change the top and the left of an html element. Code in html:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!--nam é o nome da função-->
<body onload="nam()">
<div id="divisor">O</div>
</body>
</html>
whole code of js:
 var ws = 0
        var ad = 0
        var a = document.getElementById("aaaaa")
      function nam() {
        document.body.addEventListener("keydown" ,(e)=>{
          if(e.key === "w"){
            ws + 1
            root.style.setProperty('--topV', ws)
            console.log(ws)
          }
          if(e.keyCode === "s"){
            ws- 10
            a.style.top = `${ws}px`
          }
          if(e.keyCode === "a"){
            ad+ 10
            a.style.top = `${ad}px`
          }
          if(e.keyCode === "d"){
            ad- 10
            
          }
        });
      }
no js i tried to change the value of the variable so:
//ws é uma variavel que eu defini anteriormente no programa
  document.body.addEventListener("keydown" ,(e)=>{
          if(e.key === "w"){
            ws + 1
            root.style.setProperty('--topV', ws)
            console.log(ws)
          }
what I could do to solve this problem in my code(I’m new in the area and I don’t know much about website programming)?