:root {
  color-scheme: dark;
  font-family: Geneva, "Helvetica Neue", Arial, sans-serif;
  background: #05080c;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(38, 77, 104, 0.28), transparent 45%),
    #05080c;
  color: #f4f5f6;
}

.game-shell {
  width: min(100%, 960px);
  padding: clamp(8px, 2vw, 20px);
  display: grid;
  justify-items: center;
  gap: 12px;
}

canvas {
  display: block;
  width: min(100%, calc((100svh - 96px) * 4 / 3), 960px);
  height: auto;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 3px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.65);
  outline: none;
  touch-action: none;
}

canvas:focus-visible {
  box-shadow: 0 0 0 3px #f3cf55, 0 22px 70px rgba(0, 0, 0, 0.65);
}

.touch-controls {
  width: min(100%, 640px);
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 7px;
  user-select: none;
}

.touch-controls button {
  min-height: 44px;
  padding: 6px 4px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 7px;
  background: linear-gradient(#273440, #111820);
  color: #fff;
  font: 700 18px/1 Geneva, "Helvetica Neue", Arial, sans-serif;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.15), 0 2px 7px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}

.touch-controls button:active,
.touch-controls button.is-active {
  transform: translateY(1px);
  background: linear-gradient(#b9972c, #6f5818);
}

.touch-controls button[data-action="restart"] {
  font-size: 13px;
}

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

@media (hover: hover) and (pointer: fine) and (min-height: 620px) {
  .touch-controls {
    opacity: 0.78;
  }

  .touch-controls:hover,
  .touch-controls:focus-within {
    opacity: 1;
  }
}

@media (max-width: 520px) {
  body {
    place-items: start center;
  }

  .game-shell {
    padding-inline: 4px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .touch-controls {
    gap: 4px;
  }

  .touch-controls button {
    min-width: 0;
    min-height: 42px;
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
