/* ── Outer wrap: fills viewport, dark outer bg ────────────── */
.game-wrap {
  position: fixed;
  inset: 0;
  background: #050510;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Portrait game viewport ───────────────────────────────── */
.game-viewport {
  position: relative;
  /* Portrait 9:16 — fills screen height, caps width at 9/16 of that */
  width: min(100vw, calc(100vh * 9 / 16));
  aspect-ratio: 9 / 16;
  max-height: 100vh;
  overflow: hidden;
  box-shadow: 0 0 80px rgba(0, 150, 255, 0.08);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── HUD ─────────────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 1rem;
  pointer-events: none;
  z-index: 5;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hud-right  { align-items: flex-end; }
.hud-center { flex: 1; align-items: center; justify-content: center; }

.hud-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  color: #00b8d4;
  letter-spacing: 0.12em;
  opacity: 0.7;
}

.hud-value {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  color: #00f5ff;
  text-shadow: 0 0 8px #00f5ff;
  letter-spacing: 0.1em;
}

.hud-powerup {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.35rem, 1.1vw, 0.5rem);
  color: #ffd700;
  text-shadow: 0 0 8px #ffd700;
  letter-spacing: 0.08em;
  text-align: center;
  min-height: 1.5em;
}

/* ── Overlays ────────────────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 2, 16, 0.82);
  z-index: 10;
}

.overlay.hidden { display: none; }

.overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 1.75rem 2rem;
  border: 2px solid #00a8cc;
  background: rgba(2, 6, 20, 0.92);
  width: 88%;
  box-shadow: 0 0 30px rgba(0, 200, 255, 0.2), inset 0 0 20px rgba(0, 200, 255, 0.04);
}

.overlay-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 5vw, 1.8rem);
  color: #00f5ff;
  text-shadow: 0 0 12px #00f5ff, 0 0 30px #007fa3;
  margin: 0;
  letter-spacing: 0.1em;
}

.overlay-title-red {
  color: #ff4466;
  text-shadow: 0 0 12px #ff4466, 0 0 30px #cc0033;
}

.overlay-sub {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.4rem, 1.5vw, 0.6rem);
  color: #00b8d4;
  letter-spacing: 0.2em;
  margin: 0;
}

.overlay-body {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.4rem, 1.3vw, 0.55rem);
  color: #aaccdd;
  text-align: center;
  line-height: 2.2;
  margin: 0;
  letter-spacing: 0.05em;
}

.overlay-controls {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.42rem, 1.3vw, 0.58rem);
  color: #556677;
  letter-spacing: 0.05em;
  margin: 0;
  text-align: center;
}

.overlay-cta {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.4rem, 1.4vw, 0.55rem);
  color: #00f5ff;
  letter-spacing: 0.08em;
  margin: 0.4rem 0 0;
  text-align: center;
}

.blink-text {
  animation: blink 1s step-end infinite;
}

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

.overlay-back {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.45rem;
  color: #445566;
  text-decoration: none;
  letter-spacing: 0.08em;
  margin-top: 0.4rem;
  transition: color 0.15s;
}

.overlay-back:hover { color: #00b8d4; }

/* ── Touch controls ───────────────────────────────────────── */
.touch-controls {
  position: absolute;
  bottom: 1.5rem;
  left: 0;
  right: 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 1.25rem;
  z-index: 6;
  pointer-events: none;
}

.touch-left-group {
  display: flex;
  gap: 0.6rem;
  pointer-events: all;
}

.touch-right-group {
  pointer-events: all;
}

.touch-btn {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  background: rgba(0, 20, 40, 0.7);
  border: 2px solid rgba(0, 168, 204, 0.6);
  color: #00f5ff;
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
  transition: background 0.08s, border-color 0.08s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-btn:active {
  background: rgba(0, 100, 160, 0.5);
  border-color: #00f5ff;
}

.touch-jump {
  width: 80px;
  height: 62px;
  font-size: 0.45rem;
  letter-spacing: 0.05em;
}

/* Show touch controls only on touch devices */
@media (hover: none) and (pointer: coarse) {
  .touch-controls { display: flex; }
}

/* ── Music button — bottom-left ───────────────────────────── */
.game-sfx-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 5.5rem;
  z-index: 7;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
  color: #00f5ff;
  background: rgba(0, 10, 30, 0.6);
  border: 1px solid #00a8cc;
  padding: 0.4rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.game-sfx-btn:hover { background: rgba(0, 40, 80, 0.8); }
.game-sfx-btn.muted { color: #334455; border-color: #223344; }

@media (hover: none) and (pointer: coarse) {
  .game-sfx-btn { bottom: 6.5rem; }
}

.game-music-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 7;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: #00f5ff;
  background: rgba(0, 10, 30, 0.6);
  border: 1px solid #00a8cc;
  padding: 0.4rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.game-music-btn:hover { background: rgba(0, 40, 80, 0.8); }
.game-music-btn.muted { color: #334455; border-color: #223344; }

/* On touch devices: raise music btn above touch controls */
@media (hover: none) and (pointer: coarse) {
  .game-music-btn {
    bottom: 6.5rem;
  }
}
