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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Press Start 2P', monospace;
  background: linear-gradient(180deg, #4ec0ca 0%, #1e3a5f 50%, #0a1428 100%);
  color: #fff;
  touch-action: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Responsive viewport scaling: keep canvas at native 400x600,
   scale the wrapper down on smaller screens.

   We use a CSS variable --game-scale so JS can compute the largest uniform
   scale that fits the available viewport while preserving the 2:3 aspect
   ratio. On large screens --game-scale defaults to 1. */
#game-wrap {
  position: relative;
  width: 400px;
  height: 600px;
  /* 2:3 aspect ratio for responsive layouts (mobile portrait). */
  aspect-ratio: 2 / 3;
  /* Clamp to viewport so the canvas never overflows on narrow phones. */
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  transform: scale(var(--game-scale, 1));
  transform-origin: center center;
}

#game {
  display: block;
  width: 400px;
  height: 600px;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5),
              inset 0 0 0 4px #fff;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: #70c5ce;
  touch-action: none;
  /* Pinch-zoom on the canvas itself would feel weird on mobile - gesture
     belongs to the game. Combined with `touch-action: none` on body this
     eliminates the 300ms tap delay. */
  user-select: none;
  -webkit-user-select: none;
}

/* HUD overlay layer - positioned directly over the canvas */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 400px;
  height: 600px;
  pointer-events: none;
  /* prevent the wrapper's transform from warping children */
  transform: translate(0, 0);
}

#hud > div {
  position: absolute;
  display: none;          /* hidden by default; JS toggles .visible */
  text-align: center;
  font-size: 16px;
  text-shadow: 2px 2px 0 #000;
  user-select: none;
  pointer-events: auto;
  opacity: 0;             /* start invisible; fade in on .visible */
  transition: opacity 200ms ease;
}

/* Mute icon: a small button at the top-left of the canvas.
   The wrapper #hud is pointer-events:none, so we re-enable it just for
   this control. Sits above all other HUD content via z-index. */
#mute-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 120ms ease;
}
#mute-icon:hover  { background: rgba(0, 0, 0, 0.55); }
#mute-icon:active { transform: scale(0.92); }
#mute-icon:focus-visible {
  outline: 2px solid #ffdf3a;
  outline-offset: 2px;
}

/* When .visible is added by JS, fade in. When removed, fade out then go
   display:none via the transitionend reset in game.js (200ms). */
#hud > div.visible {
  display: block;
  opacity: 1;
}

/* Score during play: large, top-center. */
#score {
  top: 20px;
  left: 0;
  right: 0;
  font-size: 48px;
}

/* Best score: small, top of canvas. Shown on start + game-over screens. */
#best {
  top: 60px;
  left: 0;
  right: 0;
  font-size: 14px;
  opacity: 0.85;
}

/* Start screen: centered title + subtitle + animated prompt. */
#start-screen {
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  font-size: 20px;
  line-height: 1.6;
}

#start-screen .title,
#game-over-screen .title {
  font-size: 32px;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

#start-screen .subtitle,
#game-over-screen .final-score,
#game-over-screen .best-score {
  font-size: 16px;
  margin-bottom: 12px;
}

/* Animated "tap to start" prompt - gentle bounce. */
#start-screen .prompt,
#game-over-screen .prompt {
  margin-top: 24px;
  font-size: 14px;
  opacity: 0.85;
  animation: prompt-bounce 1s ease-in-out infinite;
}

@keyframes prompt-bounce {
  0%, 100% { transform: translateY(0);    opacity: 0.6; }
  50%      { transform: translateY(-8px); opacity: 1.0; }
}

/* Game-over screen: positioned a bit above center to leave room below. */
#game-over-screen {
  top: 40%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  font-size: 24px;
  line-height: 1.8;
}

/* On small viewports the game-wrap's max-width/max-height (set above) clamp
   the wrapper. The JS computed --game-scale variable handles fine-grained
   scaling if we ever need it (e.g. fitting the canvas into a sidebar), but
   for typical phones the CSS clamp is enough. */
