.game-shell {
  max-width: 960px;
  margin: 0 auto;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.15), 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 80px rgba(0, 229, 255, 0.08);
  background: #05060f;
}

#game-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 540;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 5;
}

#screen-menu, #screen-gameover {
  background: linear-gradient(180deg, rgba(5, 6, 15, 0.55), rgba(5, 6, 15, 0.92));
  backdrop-filter: blur(2px);
}

.title-logo {
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 800;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 24px var(--accent, #00e5ff), 0 0 48px rgba(255, 47, 208, 0.5);
  margin-bottom: 6px;
}
.title-sub {
  color: var(--muted, #9aa3c7);
  letter-spacing: 3px;
  font-size: 12px;
  margin-bottom: 28px;
  text-transform: uppercase;
}

.best-row {
  margin-top: 18px;
  color: var(--muted, #9aa3c7);
  font-size: 13px;
  letter-spacing: 1px;
}
.best-row strong {
  display: block;
  font-size: 24px;
  color: #ffd93c;
  letter-spacing: 1px;
}

.menu-buttons, .go-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  margin-top: 18px;
}

.icon-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
}
#hud > * { pointer-events: auto; }
.hud-score-block {
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}
.hud-label { font-size: 10px; color: var(--muted, #9aa3c7); letter-spacing: 2px; }
.hud-value { font-size: 22px; }
.hud-best-block { text-align: right; }
.hud-best-block .hud-value { color: #ffd93c; }

#hud-combo {
  justify-self: center;
  font-size: 20px;
  font-weight: 800;
  color: #ff6bd6;
  text-shadow: 0 0 14px rgba(255, 107, 214, 0.8);
  animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#hud-shield {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 22px;
  filter: drop-shadow(0 0 8px #5df5ff);
  pointer-events: none;
}
#hud-effects {
  position: absolute;
  bottom: 12px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  pointer-events: none;
}
.effect-badge {
  font-size: 10px;
  letter-spacing: 1px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 3px 10px;
  color: #fff;
}

#btn-pause {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}

#countdown {
  z-index: 8;
  font-size: 72px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 30px var(--accent, #00e5ff);
}

#instructions {
  position: absolute;
  bottom: 20%;
  left: 0; right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  letter-spacing: 2px;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
#instructions.fade-out { opacity: 0; }

#pause-overlay {
  z-index: 9;
  background: rgba(5, 6, 15, 0.85);
}
#pause-overlay .panel {
  background: var(--panel, rgba(14,16,34,0.92));
  padding: 28px 32px;
  border-radius: 14px;
  border: 1px solid rgba(0, 229, 255, 0.25);
}

/* Game over */
.go-title { font-size: 30px; font-weight: 900; letter-spacing: 3px; color: #fff; margin-bottom: 14px; }
.go-record-badge { color: #ff9a3c; font-weight: 800; margin-bottom: 8px; text-shadow: 0 0 14px rgba(255,154,60,0.7); }
.go-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 340px; margin-bottom: 8px; }
.go-stat { background: rgba(255,255,255,0.04); border-radius: 10px; padding: 8px 6px; }
.go-stat .hud-label { font-size: 9px; }
.go-stat .hud-value { font-size: 18px; }
.go-compare { min-height: 20px; font-size: 13px; margin: 8px 0 4px; letter-spacing: 1px; }
.go-compare.record { color: #ff9a3c; font-weight: 800; }
.go-compare.close { color: #7cffb2; font-weight: 700; }

#go-nickname-wrap { width: 100%; max-width: 300px; margin-top: 10px; }
.nickname-row { display: flex; gap: 6px; }
#go-nickname-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 14px;
}
#go-nickname-error { color: #ff5b6a; font-size: 11px; min-height: 16px; margin-top: 4px; }
#go-submitted-msg { color: #7cffb2; font-size: 13px; margin-top: 8px; }

@media (max-width: 480px) {
  .go-stats { max-width: 100%; }
  #hud-combo { font-size: 16px; }
}

/* On narrow phones the game canvas itself stays a short 16:9 landscape
   strip (#game-wrap's aspect-ratio), which left almost no room for the
   menu/game-over overlays that were confined inside it — buttons ended up
   cramped and overlapping (e.g. "LEADERBOARD" clipped under "PLAY AGAIN").
   These full-screen overlays don't need to live inside the small canvas
   box at all: switching them to fixed positioning lets them use the
   entire phone screen for layout instead, regardless of how short the
   canvas strip is. The in-game HUD (#hud, #btn-pause) is intentionally
   untouched — it should stay pinned to the actual gameplay canvas. */
@media (max-width: 640px) {
  .overlay {
    position: fixed;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  #hud-combo { animation: none; }
}
