:root {
  color-scheme: dark;
  font-family: Geneva, Verdana, system-ui, sans-serif;
  background: #101025;
  color: #f2f2ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: start center;
  background:
    radial-gradient(circle at 50% 12%, #30306f 0, #171738 34rem, #0b0b19 72rem),
    #0b0b19;
}

main {
  width: min(100%, 710px);
  padding: 18px 16px 36px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 5vw, 2rem);
  letter-spacing: 0.06em;
}

.lede,
.note {
  margin: 7px auto 14px;
  color: #d9d9fa;
}

.game-shell {
  display: grid;
  justify-items: center;
  gap: 11px;
}

canvas {
  display: block;
  width: min(100%, 640px);
  height: auto;
  aspect-ratio: 4 / 3;
  border: 2px solid #05050c;
  outline: 1px solid #7777c7;
  background: #000;
  box-shadow: 0 18px 45px rgb(0 0 0 / 48%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
}

canvas:focus-visible {
  outline: 3px solid #ffff7d;
  outline-offset: 3px;
}

button,
summary {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #8585d5;
  border-radius: 6px;
  background: #2b2b63;
  color: #fff;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: #404093;
  outline: 2px solid #ffff7d;
  outline-offset: 1px;
}

.utility-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  width: min(100%, 640px);
}

.utility-bar button {
  padding: 7px 10px;
}

.touch-controls {
  width: min(100%, 640px);
  border: 1px solid #55559b;
  border-radius: 8px;
  background: rgb(20 20 52 / 82%);
  text-align: left;
}

.touch-controls summary {
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}

.touch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 0 10px 10px;
}

.player-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.player-pad legend {
  padding: 0 5px;
  font-size: 0.78rem;
  font-weight: 700;
}

.player-pad button {
  min-width: 0;
  padding: 5px 0;
  font-size: 1.2rem;
  touch-action: none;
}

.player-pad.red { color: #ff6666; }
.player-pad.green { color: #63ef63; }
.player-pad.white { color: #f2f2f2; }
.player-pad.blue { color: #68a0ff; }

.note {
  width: min(100%, 640px);
  font-size: 0.86rem;
  line-height: 1.45;
}

kbd {
  border: 1px solid #7777a8;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  background: #222248;
  font-family: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.game-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  gap: 0;
  overflow: hidden;
  background: #000;
}

.game-shell:fullscreen canvas {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(100vh, calc(100vw * 3 / 4));
  max-width: none;
  max-height: none;
  border: 0;
  outline: 0;
  box-shadow: none;
}

.game-shell:fullscreen .utility-bar,
.game-shell:fullscreen .touch-controls {
  display: none;
}

@media (max-width: 520px) {
  main {
    padding-inline: 8px;
  }

  .utility-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .touch-grid {
    grid-template-columns: 1fr;
  }
}
