/* ============================================================
   TYPEBLAST — game.css
   Canvas wrapper, game UI, fullscreen, mobile overlay
   ============================================================ */

/* ─── Game Container ─────────────────────────────────────── */
.game-container {
  position: relative;
  width: 100%;
  background: #000c1a;
  overflow: hidden;
  /* Aspect ratio enforced via JS, fallback below */
  min-height: calc(100vh - var(--nav-h, 56px));
  display: flex;
  align-items: stretch;
}

.game-container.fullscreen-active {
  position: fixed;
  inset: 0;
  z-index: 9000;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ─── Canvas ─────────────────────────────────────────────── */
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

/* ─── HUD Layer ──────────────────────────────────────────── */
#game-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-stat {
  text-align: center;
  min-width: 80px;
}

.hud-label {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: #00aaff;
  opacity: 0.65;
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.hud-value {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 12px #00aaff, 0 0 24px #00aaff;
  line-height: 1;
}

/* Lives hearts */
#hud-lives {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  justify-content: center;
}

.life-heart {
  font-size: 16px;
  filter: drop-shadow(0 0 6px #ff0055);
  transition: all 0.2s;
}

.life-heart.dead {
  opacity: 0.15;
  filter: none;
}

.life-heart.losing {
  animation: heartLose 0.4s ease forwards;
}

@keyframes heartLose {
  0%   { transform: scale(1.5); filter: drop-shadow(0 0 10px #ff0055); }
  100% { transform: scale(1);   opacity: 0.15; filter: none; }
}

/* ─── Wave Announce Banner ───────────────────────────────── */
#wave-announce {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', monospace;
  font-size: clamp(24px, 5vw, 52px);
  font-weight: 900;
  color: #00aaff;
  letter-spacing: 10px;
  text-shadow: 0 0 30px #00aaff, 0 0 60px rgba(0,170,255,0.4);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.4s ease;
  text-align: center;
}

#wave-announce.visible {
  opacity: 1;
}

/* ─── Combo Display ──────────────────────────────────────── */
#combo-display {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  letter-spacing: 4px;
  color: #ffaa00;
  text-shadow: 0 0 16px #ffaa00, 0 0 30px rgba(255,170,0,0.5);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-transform: uppercase;
  white-space: nowrap;
}

#combo-display.visible { opacity: 1; }

#combo-display.combo-mega {
  color: #ff4400;
  text-shadow: 0 0 20px #ff4400, 0 0 40px rgba(255,68,0,0.6);
  animation: comboPulse 0.3s ease;
}

@keyframes comboPulse {
  0%   { transform: translateX(-50%) scale(1); }
  50%  { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ─── Game Screens (Start / Pause / GameOver) ────────────── */
.game-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 24px;
  text-align: center;
}

.game-screen.hidden {
  display: none;
}

.game-screen h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(135deg, #00aaff, #0055ff, #00ccff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.screen-tagline {
  font-family: 'Roboto Slab', monospace;
  font-size: 13px;
  letter-spacing: 4px;
  color: #00aaff;
  opacity: 0.6;
  margin-bottom: 32px;
  text-transform: uppercase;
}

.screen-tagline.danger { color: #ff0055; opacity: 0.8; }

.screen-desc {
  font-family: 'Roboto Slab', monospace;
  color: #7ab0cc;
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  max-width: 400px;
  line-height: 1.8;
}

.screen-desc.gold { color: #ffaa00; font-size: 12px; }

/* Final score display */
#gameover-score {
  font-family: 'Orbitron', monospace;
  font-size: clamp(36px, 8vw, 60px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 20px #00aaff, 0 0 50px rgba(0,170,255,0.4);
  margin: 12px 0;
  line-height: 1;
}

#gameover-wave {
  font-family: 'Roboto Slab', monospace;
  font-size: 12px;
  letter-spacing: 3px;
  color: #7ab0cc;
  margin-bottom: 24px;
}

/* High score badge */
.new-highscore-badge {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  color: #ffaa00;
  background: rgba(255,170,0,0.12);
  border: 1px solid rgba(255,170,0,0.4);
  padding: 4px 16px;
  border-radius: 2px;
  text-transform: uppercase;
  margin-bottom: 16px;
  animation: glowPulse 1.5s ease infinite;
}

@keyframes glowPulse {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 20px rgba(255,170,0,0.4); }
}

/* Game buttons */
.game-btn {
  margin-top: 20px;
  padding: 14px 48px;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  background: transparent;
  color: #00aaff;
  border: 2px solid #00aaff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
  text-transform: uppercase;
  border-radius: 3px;
}

.game-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #00aaff;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
  z-index: 0;
}

.game-btn span { position: relative; z-index: 1; }

.game-btn:hover {
  color: #000;
  box-shadow: 0 0 30px rgba(0,170,255,0.6);
}

.game-btn:hover::before { transform: scaleX(1); }

.game-btn + .game-btn { margin-top: 10px; }

.game-btn.secondary {
  color: #7ab0cc;
  border-color: rgba(122,176,204,0.4);
}
.game-btn.secondary::before { background: rgba(122,176,204,0.3); }
.game-btn.secondary:hover { color: #fff; }

/* How to play */
.how-to-play {
  margin: 20px 0;
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.key-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.key-hint kbd {
  display: inline-block;
  padding: 4px 10px;
  font-family: 'Roboto Slab', monospace;
  font-size: 13px;
  color: #00aaff;
  background: rgba(0,170,255,0.1);
  border: 1px solid rgba(0,170,255,0.4);
  border-radius: 3px;
  min-width: 36px;
  text-align: center;
}

.key-hint span {
  font-size: 10px;
  color: #3a607a;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ─── Pause Overlay ──────────────────────────────────────── */
#pause-screen h1 {
  font-size: clamp(28px, 6vw, 48px);
}

.pause-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-top: 8px;
}

/* ─── Score Submit Form ───────────────────────────────────── */
.score-submit {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.score-submit input {
  padding: 10px 16px;
  background: rgba(0,170,255,0.08);
  border: 1px solid rgba(0,170,255,0.3);
  border-radius: 3px;
  color: #fff;
  font-family: 'Roboto Slab', monospace;
  font-size: 13px;
  letter-spacing: 2px;
  text-align: center;
  width: 180px;
  outline: none;
  transition: border-color 0.2s;
}

.score-submit input::placeholder { color: #3a607a; }
.score-submit input:focus { border-color: #00aaff; }

.score-submit .game-btn { margin-top: 0; padding: 10px 24px; font-size: 11px; }

/* ─── Touch Input Overlay (Mobile) ───────────────────────── */
#touch-input-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 80;
  background: linear-gradient(transparent, rgba(0,0,0,0.9) 20%);
  padding: 16px 16px 24px;
  display: none;
}

.mobile-type-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,30,50,0.9);
  border: 1px solid rgba(0,170,255,0.35);
  border-radius: 6px;
  padding: 10px 14px;
}

.mobile-type-display {
  flex: 1;
  font-family: 'Orbitron', monospace;
  font-size: 16px;
  color: #00aaff;
  letter-spacing: 3px;
  min-height: 24px;
}

.mobile-type-cursor {
  width: 2px;
  height: 20px;
  background: #00aaff;
  animation: blink 0.8s step-end infinite;
  flex-shrink: 0;
}

@keyframes blink { 50% { opacity: 0; } }

.mobile-clear-btn {
  font-size: 18px;
  color: #ff0055;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.mobile-clear-btn:hover { opacity: 1; }

#touch-keyboard-trigger {
  display: none;
  position: absolute;
  bottom: 100px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,170,255,0.15);
  border: 2px solid rgba(0,170,255,0.4);
  color: #00aaff;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 80;
  transition: all 0.2s;
}

#touch-keyboard-trigger:hover {
  background: rgba(0,170,255,0.3);
  box-shadow: 0 0 20px rgba(0,170,255,0.4);
}

/* ─── Fullscreen Button ──────────────────────────────────── */
#fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(0,170,255,0.25);
  border-radius: 3px;
  color: rgba(122,176,204,0.7);
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: all;
}

#fullscreen-btn:hover {
  background: rgba(0,170,255,0.15);
  border-color: #00aaff;
  color: #00aaff;
}

#fullscreen-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ─── Sound Toggle Button ─────────────────────────────────── */
#sound-toggle-btn {
  position: absolute;
  top: 12px;
  right: 56px;
  z-index: 30;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(0,170,255,0.25);
  border-radius: 3px;
  color: rgba(122,176,204,0.7);
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: all;
}

#sound-toggle-btn:hover {
  background: rgba(0,170,255,0.15);
  border-color: #00aaff;
  color: #00aaff;
}

#sound-toggle-btn.muted { color: rgba(255,0,85,0.6); border-color: rgba(255,0,85,0.3); }

/* ─── Screen Shake ───────────────────────────────────────── */
.game-container.shake-sm {
  animation: shakeSm 0.12s ease;
}

.game-container.shake-md {
  animation: shakeMd 0.2s ease;
}

@keyframes shakeSm {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-4px, 3px); }
  50%  { transform: translate(4px, -2px); }
  75%  { transform: translate(-3px, 1px); }
  100% { transform: translate(0, 0); }
}

@keyframes shakeMd {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-7px, 5px); }
  40%  { transform: translate(6px, -5px); }
  60%  { transform: translate(-5px, 3px); }
  80%  { transform: translate(4px, -2px); }
  100% { transform: translate(0, 0); }
}

/* ─── Flash effect ───────────────────────────────────────── */
.game-container.flash-red::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,0,85,0.12);
  pointer-events: none;
  z-index: 5;
  animation: flashFade 0.25s ease forwards;
}

.game-container.flash-blue::after {
  background: rgba(0,170,255,0.1);
  animation: flashFade 0.25s ease forwards;
}

@keyframes flashFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── Difficulty selector ─────────────────────────────────── */


.diff-btn {
  padding: 8px 20px;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 1px solid rgba(0,170,255,0.3);
  border-radius: 3px;
  color: #3a607a;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.diff-btn:hover, .diff-btn.active {
  background: rgba(0,170,255,0.12);
  border-color: #00aaff;
  color: #00aaff;
}

.diff-btn.easy.active   { border-color: #00ff88; color: #00ff88; background: rgba(0,255,136,0.08); }
.diff-btn.medium.active { border-color: #00aaff; color: #00aaff; }
.diff-btn.hard.active   { border-color: #ffaa00; color: #ffaa00; background: rgba(255,170,0,0.08); }
.diff-btn.expert.active { border-color: #ff0055; color: #ff0055; background: rgba(255,0,85,0.08); }

/* ─── Mobile Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .hud-value { font-size: 18px; }
  .hud-label { font-size: 8px; }
  .hud-top   { padding: 10px 14px; }

  .game-screen h1 { letter-spacing: 3px; }

  #touch-input-overlay { display: block; }
  #touch-keyboard-trigger { display: flex; }

  .game-btn { padding: 12px 36px; font-size: 12px; }

  .how-to-play { display: none; }

  #gameover-score { font-size: clamp(28px, 10vw, 52px); }

  #fullscreen-btn  { top: 8px; right: 8px; }
  #sound-toggle-btn { top: 8px; right: 50px; }

  #combo-display { bottom: 120px; }
}

@media (max-width: 480px) {
  .hud-top { justify-content: space-around; }
  .hud-stat { min-width: 60px; }
  .score-submit input { width: 150px; }
  
  .diff-btn { padding: 6px 12px; font-size: 9px; }
}
