* { box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 25%, #344a57 0, #202e38 48%, #111a22 100%);
  color: #fff4cf;
  font-family: "Courier New", monospace;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.game-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px;
}

.game-shell {
  position: relative;
  width: min(92vw, calc(56.25dvh - 32px), 504px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #4ec0ca;
  border: 3px solid #0d141a;
  border-radius: 5px;
  box-shadow: 0 0 0 2px #53636a, 0 14px 36px #0009, 0 2px 0 #708087 inset;
  isolation: isolate;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  outline: none;
  cursor: pointer;
}

canvas:focus-visible { box-shadow: 0 0 0 3px #fff7c2 inset; }

.sound-toggle {
  position: absolute;
  z-index: 4;
  top: 9px;
  right: 9px;
  width: 32px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 2px solid #3d3a32;
  border-radius: 4px;
  background: #f8e7b5d9;
  color: #403c34;
  box-shadow: 0 2px 0 #302d2799;
  cursor: pointer;
  touch-action: manipulation;
}

.sound-toggle:hover { background: #fff5cf; transform: translateY(-1px); }
.sound-toggle:active { transform: translateY(1px); box-shadow: none; }
.sound-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sound-toggle svg { display: block; width: 20px; height: 20px; fill: currentColor; }
.sound-toggle .mute-mark,
.sound-toggle[aria-pressed="true"] .sound-waves { display: none; }
.sound-toggle[aria-pressed="true"] .mute-mark { display: block; }

.desktop-hint {
  margin: 0;
  color: #b6c3ca;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 2px #000;
}

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

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 12px;
  background: #fff0c2;
  color: #24211b;
  text-align: center;
}

@media (max-width: 640px), (max-height: 640px) {
  .game-wrap { padding: 0; gap: 0; }
  .game-shell {
    width: min(100vw, 56.25dvh);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .desktop-hint { display: none; }
  .sound-toggle {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    opacity: .84;
  }
}
