html, body { margin: 0; height: 100%; background: #04101e; overflow: hidden; } main { height: 100%; display: grid; place-items: center; } /* The sea keeps its 16:9 shape and fits the window: letterboxed in portrait. */ canvas { display: block; width: min(100vw, calc(100vh * 16 / 9)); height: auto; aspect-ratio: 16 / 9; touch-action: none; cursor: crosshair; }