html, body {
  margin: 0;
  height: 100%;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
}
canvas {
  background: #0b0b0b;
  border: 2px solid #444;
  image-rendering: pixelated;
  /* Display size is set by src/main.js (fitCanvas) from the config aspect ratio,
     so the playfield scales to nearly fill the viewport. These caps are a
     no-JS fallback. */
  max-width: 98vw;
  max-height: 96vh;
  /* Hidden until the first frame is drawn (avoids the unstyled black-square
     flash on load); revealed via body.ready from src/main.js. */
  opacity: 0;
  transition: opacity 0.25s ease;
}
body.ready canvas {
  opacity: 1;
}

/* Loading screen — shown immediately on first paint, hidden once ready. */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #0b0b0b;
  color: #eef2f7;
  letter-spacing: 2px;
  z-index: 10;
}
#loading p {
  margin: 0;
  font-size: 16px;
  opacity: 0.85;
}
#loading .spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ffd84d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
body.ready #loading {
  display: none;
}
