:root {
  color-scheme: dark;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background: #080b08;
  color: #e8f0e7;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(97, 255, 112, 0.07), transparent 38rem),
    #080b08;
}

button {
  font: inherit;
}

.game {
  width: min(88vw, 34rem);
  padding: 2rem 0 1.5rem;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  padding: 0 0.2rem;
}

.scoreboard p {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin: 0;
}

.scoreboard span,
.hint {
  color: #728072;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scoreboard strong {
  min-width: 2ch;
  color: #baff8f;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.board {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid #283329;
  border-radius: 1rem;
  background: #0e140e;
  box-shadow:
    0 1.75rem 5rem rgba(0, 0, 0, 0.44),
    0 0 0 1px rgba(186, 255, 143, 0.025) inset;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.35rem;
  background: rgba(8, 11, 8, 0.7);
  backdrop-filter: blur(5px);
  transition: opacity 150ms ease;
}

.overlay[hidden] {
  display: none;
}

.wordmark {
  margin: 0;
  color: #eaf6e7;
  font-size: clamp(2.2rem, 9vw, 4.3rem);
  font-weight: 500;
  letter-spacing: -0.08em;
  line-height: 0.9;
}

.play {
  min-width: 7rem;
  border: 1px solid #92d875;
  border-radius: 999px;
  padding: 0.7rem 1.25rem;
  background: #baff8f;
  color: #0b100b;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  transition: transform 120ms ease, background 120ms ease;
}

.play:hover {
  background: #d0ffb1;
  transform: translateY(-1px);
}

.play:focus-visible,
.d-pad button:focus-visible {
  outline: 2px solid #e5ffd5;
  outline-offset: 3px;
}

.d-pad {
  display: none;
  grid-template-columns: repeat(3, 3.5rem);
  grid-template-rows: repeat(2, 3.5rem);
  justify-content: center;
  gap: 0.45rem;
  margin: 1.25rem auto 0;
}

.d-pad button {
  border: 1px solid #2d392e;
  border-radius: 0.75rem;
  background: #111711;
  color: #a9b8a8;
  cursor: pointer;
  font-size: 1.15rem;
  -webkit-tap-highlight-color: transparent;
}

.d-pad button:active {
  border-color: #79b95f;
  background: #1d291d;
  color: #caffaa;
}

.d-pad button[data-direction="up"] {
  grid-column: 2;
  grid-row: 1;
}

.d-pad button[data-direction="left"] {
  grid-column: 1;
  grid-row: 2;
}

.d-pad button[data-direction="down"] {
  grid-column: 2;
  grid-row: 2;
}

.d-pad button[data-direction="right"] {
  grid-column: 3;
  grid-row: 2;
}

.hint {
  margin: 1rem 0 0;
  text-align: center;
}

.hint span {
  margin: 0 0.45rem;
  color: #3d493d;
}

.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;
}

@media (pointer: coarse), (max-width: 720px) {
  .game {
    width: min(91vw, 31rem);
    padding-top: 1rem;
  }

  .d-pad {
    display: grid;
  }

  .hint {
    display: none;
  }
}

@media (max-height: 720px) and (pointer: coarse) {
  .game {
    width: min(69svh, 88vw);
  }

  .d-pad {
    grid-template-columns: repeat(3, 2.8rem);
    grid-template-rows: repeat(2, 2.8rem);
    margin-top: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .play {
    transition: none;
  }
}
