Stuck trying to make a etch-sketch project

Hello I’m currently stuck on a problem with my etch-sketch project as of right now the project is pretty much done everything functionality works, but any time I try to add more cells (28+)to the grid the cells go outside of the container’s border I have set for it. How can I keep the cells to stay within the border and make the cells themselves get smaller as they increase in quantity?

Here is a link to my GitHub were the code is.