:root {
  color-scheme: dark;
  --ink: #f7f3e8;
  --page: #111418;
  --rim: #28313b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 207, 92, 0.16), transparent 26%),
    linear-gradient(140deg, #111418 0%, #182028 48%, #1d2522 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#game-shell {
  width: min(100vw, var(--game-shell-width, 1312px));
  height: min(100vh, var(--game-shell-height, 752px));
  display: grid;
  place-items: center;
  padding: 16px;
  touch-action: none;
}

#game {
  width: min(var(--game-display-width, 1280px), calc(100vw - 32px), calc((100vh - 32px) * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  min-height: 320px;
  border: 1px solid rgba(247, 243, 232, 0.14);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  background: #182028;
  touch-action: none;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

@supports (height: 100dvh) {
  #game-shell {
    height: min(100dvh, var(--game-shell-height, 752px));
  }

  #game {
    width: min(var(--game-display-width, 1280px), calc(100vw - 32px), calc((100dvh - 32px) * 16 / 9));
  }
}

@media (pointer: coarse), (max-width: 900px), (max-height: 540px) {
  body {
    background: #111418;
  }

  #game-shell {
    width: 100vw;
    height: 100vh;
    padding: 0;
  }

  #game {
    width: min(100vw, calc(100vh * 16 / 9));
    height: min(100vh, calc(100vw * 9 / 16));
    min-height: 0;
    border: 0;
    box-shadow: none;
  }
}

@supports (height: 100dvh) {
  @media (pointer: coarse), (max-width: 900px), (max-height: 540px) {
    #game-shell {
      height: 100dvh;
    }

    #game {
      width: min(100vw, calc(100dvh * 16 / 9));
      height: min(100dvh, calc(100vw * 9 / 16));
    }
  }
}
