* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #fff;
  font-family: 'Courier New', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

#game-container {
  position: relative;
  text-align: center;
  width: 100%;
  max-width: 560px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

#hud {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 18px;
  color: #ff0;
}

#game-canvas {
  display: block;
  border: 2px solid #222;
  background: #000;
  width: 100%;
  height: auto;
  aspect-ratio: 560 / 620;
  max-width: 560px;
}

/* When viewport height is too short for the native canvas (620px) plus HUD,
   switch to height-based sizing. Condition: landscape aspect AND height < 600px.
   This keeps desktop (1080p tall) using width-based sizing capped at 560px.
   The canvas uses max-height to constrain its display size while preserving
   aspect-ratio (width derives proportionally from clamped height). */
@media (min-aspect-ratio: 1/1) and (max-height: 600px) {
  #game-container {
    width: auto;
  }
  #game-canvas {
    width: auto;
    /* max-height constrains the canvas to fit in viewport minus HUD + margins.
       aspect-ratio then proportionally derives width from this clamped height,
       keeping the 28:31 proportion. */
    max-height: calc(100vh - 80px);
  }
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

#overlay.hidden {
  display: none;
}

#overlay-text {
  font-size: 48px;
  color: #ff0;
  margin-bottom: 16px;
  text-shadow: 2px 2px #f80;
}

#overlay-sub {
  font-size: 18px;
  color: #fff;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
