/* ===================================================
   KALOMITI STUDIO — SPACE SHOOTER  v2.0
   Style Sheet
   =================================================== */

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

:root {
  --bg:        #0a0a14;
  --bg2:       #0f0f1e;
  --purple:    #7B2FBE;
  --blue:      #3B82F6;
  --cyan:      #00E5FF;
  --pink:      #e040fb;
  --white:     #ffffff;
  --gray:      #8892a4;
  --grad:      linear-gradient(135deg, #7B2FBE 0%, #3B82F6 50%, #00E5FF 100%);
  --grad-text: linear-gradient(90deg, #7B2FBE, #3B82F6, #00E5FF);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Heebo', sans-serif;
  color: var(--white);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

/* ── SCREENS ─────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 10;
}
.screen.active { opacity: 1; pointer-events: all; }

.screen-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  padding: 20px 24px;
  text-align: center;
  width: 100%; max-width: 480px;
  overflow: visible;
}

#bg-canvas, #bg-canvas-go {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 1;
}

/* ── LOGO ────────────────────────────────────────── */
.logo-wrap { display: flex; justify-content: center; }
.logo-img {
  width: 80px; height: 80px; object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(0,229,255,0.65));
}
.logo-wrap.small .logo-img { width: 56px; height: 56px; }

/* ── TITLE ───────────────────────────────────────── */
.game-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.5rem, 5vw, 2.6rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-shadow: 0 0 30px rgba(123,47,190,0.8);
}
.gradient-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.game-subtitle {
  font-size: 0.88rem; color: var(--gray);
  letter-spacing: 0.2em; text-transform: uppercase;
}

/* ── PLAYER NAME INPUT ───────────────────────────── */
.name-input-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 100%; max-width: 260px;
}
.name-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.12em; color: var(--gray);
  text-transform: uppercase;
}
.name-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(0,229,255,0.3);
  border-radius: 8px;
  color: var(--cyan);
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem; font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  caret-color: var(--cyan);
}
.name-input:focus {
  border-color: var(--cyan);
  background: rgba(0,229,255,0.07);
}
.name-input::placeholder { color: rgba(0,229,255,0.25); }

/* ── BUTTONS ─────────────────────────────────────── */
.btn-primary {
  background: var(--grad);
  border: none; border-radius: 10px;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem; font-weight: 700;
  letter-spacing: 0.1em;
  padding: 14px 40px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(0,229,255,0.35), 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  min-width: 200px;
}
.btn-primary:hover  { transform: scale(1.05); box-shadow: 0 0 36px rgba(0,229,255,0.65); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: inline-block;
  background: transparent;
  border: 1.5px solid rgba(0,229,255,0.35);
  border-radius: 10px;
  color: var(--cyan);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.08em;
  padding: 12px 32px;
  cursor: pointer; text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
  min-width: 200px; text-align: center;
}
.btn-secondary:hover { background: rgba(0,229,255,0.08); border-color: var(--cyan); }

/* ── LANG TOGGLE ─────────────────────────────────── */
/* lang-toggle removed — English only */

/* ── MUTE BUTTON (in-game) ───────────────────────── */
#btn-mute {
  position: fixed; top: 12px; right: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--white);
  font-size: 1.1rem;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 200;
  transition: background 0.2s;
}
#btn-mute:hover { background: rgba(255,255,255,0.12); }

/* ── CONTROLS HINT ───────────────────────────────── */
.controls-hint { display: flex; gap: 18px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }
.hint-row { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--gray); }
.key {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px; padding: 4px 8px;
  font-family: 'Orbitron', sans-serif; font-size: 0.68rem; color: var(--cyan);
}

/* ── HIGH SCORE DISPLAY (start) ──────────────────── */
.score-display {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem; color: var(--cyan);
  letter-spacing: 0.1em; min-height: 20px;
}

/* ── HUD ─────────────────────────────────────────── */
#hud {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 540px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 56px 12px 20px;
  background: linear-gradient(to bottom, rgba(10,10,20,0.97) 0%, transparent 100%);
  z-index: 100; pointer-events: none;
}
.hud-left, .hud-right { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.hud-center { display: flex; align-items: center; }
.hud-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.58rem; font-weight: 700;
  letter-spacing: 0.15em; color: var(--gray);
}
.hud-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.3rem; font-weight: 900;
  background: var(--grad-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lives-container { display: flex; gap: 6px; }
.life-icon {
  width: 22px; height: 22px; object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(0,229,255,0.7));
  transition: opacity 0.3s;
}
.life-icon.lost { opacity: 0.15; filter: none; }

/* ── COMBO DISPLAY ───────────────────────────────── */
.combo-display {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1rem, 3.5vw, 1.5rem); font-weight: 900;
  letter-spacing: 0.12em;
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255,215,0,0.8), 0 0 40px rgba(255,215,0,0.4);
  z-index: 210; pointer-events: none;
  animation: comboPop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.combo-display.hidden { display: none; }
@keyframes comboPop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to   { transform: translateX(-50%) scale(1);   opacity: 1; }
}

/* ── GAME CANVAS ─────────────────────────────────── */
#screen-game {
  background: var(--bg);
  flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 5;
}
#game-canvas { display: block; }

/* ── WAVE BANNER ─────────────────────────────────── */
.wave-banner {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.4rem, 5vw, 2.5rem); font-weight: 900;
  background: var(--grad-text);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0,229,255,0.8));
  z-index: 200; pointer-events: none;
  letter-spacing: 0.1em;
  transition: opacity 0.5s;
}
.wave-banner.hidden { opacity: 0; }

/* ── MOBILE CONTROLS — JOYSTICK LAYOUT ──────────── */
#mobile-controls {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 140px;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 20px;
  z-index: 150;
  background: linear-gradient(to top, rgba(10,10,20,0.9) 60%, transparent);
  pointer-events: none;
}

/* Left joystick zone — large touch area */
#joystick-zone {
  width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: all;
  position: relative;
  flex-shrink: 0;
}

/* Joystick base circle */
#joystick-base {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(123,47,190,0.18);
  border: 2px solid rgba(123,47,190,0.45);
  box-shadow: 0 0 22px rgba(0,229,255,0.2), inset 0 0 18px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}

/* Joystick thumb (draggable dot) */
#joystick-thumb {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(0,229,255,0.9), rgba(123,47,190,0.8));
  border: 2px solid rgba(0,229,255,0.6);
  box-shadow: 0 0 14px rgba(0,229,255,0.6);
  position: absolute;
  transition: transform 0.05s ease-out;
  pointer-events: none;
}

/* Right fire zone */
#fire-zone {
  width: 100px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: all;
  flex-shrink: 0;
}

.fire-btn {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--grad);
  border: none;
  color: #fff; font-size: 2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 28px rgba(0,229,255,0.55);
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  pointer-events: all;
}
.fire-btn:active, .fire-btn.pressed {
  transform: scale(0.88);
  box-shadow: 0 0 44px rgba(0,229,255,0.85);
}

@media (pointer: coarse) { #mobile-controls { display: flex; } }

/* ── GAME OVER ───────────────────────────────────── */
.gameover-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2rem, 7vw, 3.5rem); font-weight: 900;
  color: var(--pink);
  text-shadow: 0 0 30px rgba(224,64,251,0.7);
  letter-spacing: 0.1em;
}

/* Player name on death screen */
.go-player-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem; font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0,229,255,0.6);
  min-height: 22px;
}

.score-block {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 20px 32px;
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 12px;
}
.score-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.score-row.highlight { border-top: 1px solid rgba(0,229,255,0.15); padding-top: 12px; }
.score-label { font-size: 0.82rem; color: var(--gray); font-family: 'Orbitron', sans-serif; letter-spacing: 0.05em; }
.score-val {
  font-family: 'Orbitron', sans-serif; font-size: 1.35rem; font-weight: 900;
  background: var(--grad-text);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.new-record {
  font-family: 'Orbitron', sans-serif; font-size: 1rem; font-weight: 700;
  color: #FFD700; text-shadow: 0 0 16px rgba(255,215,0,0.7);
  animation: pulse 0.8s ease-in-out infinite alternate;
}
.new-record.hidden { display: none; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
.gameover-buttons { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 280px; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 480px) {
  .controls-hint { gap: 10px; }
  .score-block { padding: 16px 18px; }
  .hud-value { font-size: 1.1rem; }
  .hud-label { font-size: 0.55rem; }
}
@media (max-height: 600px) {
  .screen-content { gap: 10px; padding: 14px; }
  .logo-img { width: 50px; height: 50px; }
  .game-title { font-size: 2rem; }
}

/* ── HERO SHIP (start screen) ────────────────────── */
.hero-ship-wrap {
  position: relative;
  /* Wider than the 480px parent — use negative margins to break out symmetrically */
  width: min(100vw, 640px);
  margin-left: calc((min(100vw, 640px) - 100%) / -2);
  margin-right: calc((min(100vw, 640px) - 100%) / -2);
  height: 300px;
  display: flex; align-items: center; justify-content: center;
  overflow: visible;
  flex-shrink: 0;
}
.hero-ship {
  width: 260px; height: 260px;
  object-fit: contain;
  animation: heroFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 28px rgba(123,47,190,0.8))
          drop-shadow(0 0 55px rgba(0,229,255,0.4));
  position: relative; z-index: 2;
}
.hero-glow {
  position: absolute; bottom: 10px; left: 50%;
  transform: translateX(-50%);
  width: 200px; height: 40px;
  background: radial-gradient(ellipse, rgba(0,229,255,0.5) 0%, transparent 70%);
  border-radius: 50%;
  animation: glowPulse 3s ease-in-out infinite;
  z-index: 1;
}
@keyframes heroFloat {
  0%   { transform: translateY(0px)   rotate(0deg); }
  25%  { transform: translateY(-10px) rotate(-1deg); }
  50%  { transform: translateY(-14px) rotate(0deg); }
  75%  { transform: translateY(-6px)  rotate(1deg); }
  100% { transform: translateY(0px)   rotate(0deg); }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: translateX(-50%) scaleX(1); }
  50%       { opacity: 1;   transform: translateX(-50%) scaleX(0.7); }
}
@media (max-height: 700px) {
  .hero-ship-wrap { height: 200px; }
  .hero-ship { width: 160px; height: 160px; }
}
@media (max-height: 560px) {
  .hero-ship-wrap { display: none; }
}

/* ── FLOATING ENEMIES (start screen) ────────────── */
.start-enemy {
  position: absolute;
  object-fit: contain;
  opacity: 0.72;
  z-index: 1;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(123,47,190,0.7))
          drop-shadow(0 0 22px rgba(0,229,255,0.3));
  transform-origin: center center;
}

/* Left side enemies — positioned relative to the wide wrap */
.start-enemy-1 {
  width: 76px; height: auto;
  left: 5%; top: 30%;
  animation: enemyFloat1 4.2s ease-in-out infinite;
}
.start-enemy-2 {
  width: 60px; height: auto;
  left: 9%; top: 62%;
  animation: enemyFloat2 3.6s ease-in-out infinite;
  animation-delay: -1.1s;
  opacity: 0.52;
  filter: drop-shadow(0 0 8px rgba(0,229,255,0.4)) blur(0.5px);
}
.start-enemy-3 {
  width: 86px; height: auto;
  left: 2%; top: 4%;
  animation: enemyFloat3 5.0s ease-in-out infinite;
  animation-delay: -2.3s;
  opacity: 0.32;
  filter: drop-shadow(0 0 8px rgba(123,47,190,0.5)) blur(1.5px);
  z-index: 0;
}

/* Right side enemies */
.start-enemy-4 {
  width: 68px; height: auto;
  right: 5%; top: 28%;
  animation: enemyFloat1 3.8s ease-in-out infinite;
  animation-delay: -0.7s;
}
.start-enemy-5 {
  width: 94px; height: auto;
  right: 2%; top: 4%;
  animation: enemyFloat2 5.5s ease-in-out infinite;
  animation-delay: -3.0s;
  opacity: 0.30;
  filter: drop-shadow(0 0 8px rgba(123,47,190,0.5)) blur(1.5px);
  z-index: 0;
}
.start-enemy-6 {
  width: 62px; height: auto;
  right: 9%; top: 60%;
  animation: enemyFloat3 4.0s ease-in-out infinite;
  animation-delay: -1.8s;
  opacity: 0.52;
  filter: drop-shadow(0 0 8px rgba(0,229,255,0.4)) blur(0.5px);
}

@keyframes enemyFloat1 {
  0%   { transform: translateY(0px)   rotate(0deg);   }
  30%  { transform: translateY(-12px) rotate(-3deg);  }
  60%  { transform: translateY(-18px) rotate(2deg);   }
  100% { transform: translateY(0px)   rotate(0deg);   }
}
@keyframes enemyFloat2 {
  0%   { transform: translateY(0px)   rotate(2deg);   }
  40%  { transform: translateY(-10px) rotate(-2deg);  }
  70%  { transform: translateY(-6px)  rotate(3deg);   }
  100% { transform: translateY(0px)   rotate(2deg);   }
}
@keyframes enemyFloat3 {
  0%   { transform: translateY(0px)   rotate(-1deg);  }
  50%  { transform: translateY(-14px) rotate(2deg);   }
  100% { transform: translateY(0px)   rotate(-1deg);  }
}
/* Right-side enemies use same float animations, mirrored via scaleX in keyframes */
.start-enemy-4 { animation-name: enemyFloat1; }
.start-enemy-5 { animation-name: enemyFloat2; }
.start-enemy-6 { animation-name: enemyFloat3; }

/* ── POWER-UP BADGE ──────────────────────────────── */
.powerup-badge {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(10,10,20,0.88);
  border: 1px solid rgba(0,229,255,0.5);
  border-radius: 10px; padding: 6px 18px 8px;
  z-index: 210; pointer-events: none;
  animation: badgePop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.powerup-badge.hidden { display: none; }
#powerup-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--grad-text);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#powerup-bar {
  width: 120px; height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px; overflow: hidden;
}
#powerup-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--purple), var(--cyan));
  border-radius: 3px;
  transition: width 0.1s linear;
}
@keyframes badgePop {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to   { transform: translateX(-50%) scale(1);   opacity: 1; }
}

/* ── SHIELD BADGE ────────────────────────────────── */
.shield-badge {
  position: fixed; top: 58px; right: 14px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,20,0.88);
  border: 1px solid rgba(59,130,246,0.6);
  border-radius: 10px; padding: 6px 14px;
  z-index: 210; pointer-events: none;
  animation: badgePop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.shield-badge.hidden { display: none; }
.shield-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue);
}

/* ── PLAYER POWER-UP GLOW ────────────────────────── */
#game-canvas.powered {
  filter: drop-shadow(0 0 12px rgba(0,229,255,0.6));
}
#game-canvas.shielded {
  filter: drop-shadow(0 0 14px rgba(59,130,246,0.7));
}
