:root {
  color-scheme: dark;
  background: #15232a;
  color: #e7eee6;
  font: 15px/1.5 system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px 18px;
}

main { width: min(1024px, 100%, max(260px, calc((100dvh - 140px) * 1.6))); }

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px 20px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4.2vw, 2.2rem);
  font-weight: 720;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

header p, .controls { font-size: 0.9rem; color: #b6c6c7; }
header p { margin: 5px 0 0; }
.controls { margin: 10px 0 0; }

button {
  padding: 6px 11px;
  color: inherit;
  background: #283d44;
  border: 1px solid #476268;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
}

button:hover { background: #345059; }
button:disabled { opacity: 0.6; cursor: default; }
button:focus-visible { outline: 2px solid #e7eee6; outline-offset: 3px; }

#stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 8 / 5;
  box-shadow: 0 0 0 1px #48666d;
  background: #4379b7;
}

#stage:fullscreen { box-shadow: none; background: #0e191e; }
#stage:-webkit-full-screen { box-shadow: none; background: #0e191e; }

#game {
  display: block;
  width: min(100%, var(--game-width, 100%));
  height: auto;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: none;
}

#game:focus { outline: none; }
#game:focus-visible { outline: 2px solid #f1d384; outline-offset: -2px; }

#loading {
  display: grid;
  position: absolute;
  inset: 0;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  color: #e7eee6;
  background: #1e323a;
  text-align: center;
}

#loading p { margin: 0; }
[hidden] { display: none !important; }

@media (max-width: 530px) {
  body { padding-inline: 10px; }
  header { align-items: start; }
  header p { font-size: 0.8rem; }
  button { font-size: 0.85rem; }
}
