/* ===== CSS RESET & ROOT ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

:root {
  --primary: #7c3aed;
  --primary-glow: #a855f7;
  --accent: #06b6d4;
  --accent-glow: #22d3ee;
  --danger: #ef4444;
  --gold: #fbbf24;
  --bg-deep: #00000a;
  --bg-space: #050510;
  --text-primary: #f8fafc;
  --text-dim: #94a3b8;
  --glass-bg: rgba(255,255,255,0.05);
  --glass-border: rgba(255,255,255,0.1);
  --font-game: 'Orbitron', monospace;
  --font-ui: 'Inter', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: var(--font-ui);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ===== CANVAS ===== */
#gameCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg-deep);
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 100;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
}

#hud.hidden { display: none; }

#score-display, #lives-display, #wave-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-family: var(--font-game);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

#score {
  font-family: var(--font-game);
  font-size: 22px;
  font-weight: 900;
  color: var(--accent-glow);
  text-shadow: 0 0 15px var(--accent);
  letter-spacing: 1px;
}

#wave {
  font-family: var(--font-game);
  font-size: 22px;
  font-weight: 900;
  color: var(--primary-glow);
  text-shadow: 0 0 15px var(--primary);
}

#lives-icons {
  display: flex;
  gap: 4px;
}

.life-icon {
  font-size: 16px;
  filter: drop-shadow(0 0 4px rgba(239,68,68,0.8));
  transition: all 0.3s ease;
}

.life-icon.lost {
  filter: grayscale(1) opacity(0.3);
  transform: scale(0.8);
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.screen.hidden {
  display: none;
}

.screen-content {
  width: min(420px, 90vw);
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(6,182,212,0.08));
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px 28px;
  backdrop-filter: blur(20px);
  box-shadow: 0 0 60px rgba(124,58,237,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* ===== MAIN MENU ===== */
#mainMenu {
  background: var(--bg-deep);
}

.menu-bg-stars {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(124,58,237,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.1) 0%, transparent 50%);
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  from { opacity: 0.7; transform: scale(1); }
  to { opacity: 1; transform: scale(1.05); }
}

.menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  padding: 40px 20px;
}

.logo-container {
  position: relative;
  text-align: center;
}

.logo-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 200px;
  background: radial-gradient(ellipse, rgba(124,58,237,0.3) 0%, transparent 70%);
  border-radius: 50%;
  animation: logoGlow 3s ease-in-out infinite alternate;
}

@keyframes logoGlow {
  from { opacity: 0.5; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.game-title {
  font-family: var(--font-game);
  font-size: clamp(32px, 8vw, 52px);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  color: var(--text-primary);
  text-shadow: 0 0 30px rgba(124,58,237,0.8), 0 0 60px rgba(124,58,237,0.4);
  letter-spacing: 3px;
  animation: titleFloat 4s ease-in-out infinite;
}

.title-highlight {
  color: var(--accent-glow);
  text-shadow: 0 0 30px var(--accent), 0 0 60px rgba(6,182,212,0.5);
}

@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.game-subtitle {
  font-family: var(--font-ui);
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 8px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(300px, 80vw);
}

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

#bestScoreMenu {
  font-family: var(--font-game);
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 15px rgba(251,191,36,0.6);
}

/* ===== BUTTONS ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 32px;
  border: none;
  border-radius: 50px;
  font-family: var(--font-game);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
  border-radius: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4), 0 0 0 1px rgba(124,58,237,0.3);
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 30px rgba(124,58,237,0.6), 0 0 0 1px rgba(124,58,237,0.5);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover, .btn-secondary:active {
  background: rgba(255,255,255,0.1);
  transform: translateY(-2px);
}

.btn-icon {
  font-size: 18px;
}

/* ===== INSTRUCTIONS ===== */
.screen-title {
  font-family: var(--font-game);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--accent-glow);
  text-shadow: 0 0 20px var(--accent);
  text-align: center;
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
}

.instruction-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.instruction-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.instruction-text strong {
  color: var(--text-primary);
}

/* ===== GAME OVER ===== */
.game-over-icon {
  font-size: 52px;
  animation: deathPulse 1s ease-in-out infinite alternate;
}

@keyframes deathPulse {
  from { transform: scale(1); filter: drop-shadow(0 0 10px rgba(239,68,68,0.5)); }
  to { transform: scale(1.1); filter: drop-shadow(0 0 25px rgba(239,68,68,0.9)); }
}

.game-over-title {
  color: var(--danger) !important;
  text-shadow: 0 0 20px rgba(239,68,68,0.8) !important;
}

.final-score-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
}

.final-score {
  font-family: var(--font-game);
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-glow);
}

.final-best {
  font-family: var(--font-game);
  font-size: 24px;
  font-weight: 900;
  color: var(--gold);
}

.final-level {
  font-family: var(--font-game);
  font-size: 24px;
  font-weight: 900;
  color: var(--primary-glow);
}

.game-over-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.new-record {
  font-family: var(--font-game);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(251,191,36,0.8);
  letter-spacing: 2px;
  animation: recordPop 0.5s ease-out;
}

.new-record.hidden { display: none; }

@keyframes recordPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== PAUSE BUTTON ===== */
.pause-btn {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 150;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  color: white;
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-btn.hidden { display: none; }
.pause-btn:active { transform: scale(0.9); }

/* ===== PAUSE SCREEN ===== */
.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* ===== LEVEL UP TOAST ===== */
.level-up-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 300;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-family: var(--font-game);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  padding: 16px 32px;
  border-radius: 50px;
  box-shadow: 0 0 50px rgba(124,58,237,0.6);
  text-align: center;
  pointer-events: none;
}

.level-up-toast.hidden { display: none; }

.level-up-toast.show {
  animation: toastAnim 1.8s ease-out forwards;
}

@keyframes toastAnim {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1); }
  75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(0.9); opacity: 0; }
}

/* ===== LOVE MESSAGE ===== */
.love-message {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 300;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 800;
  color: #fda4af;
  text-shadow: 0 0 15px rgba(244, 63, 94, 0.9);
  pointer-events: none; /* Tıklamaları engellememesi için */
  animation: heartbeat 1.5s ease-in-out infinite;
  letter-spacing: 1px;
}

@keyframes heartbeat {
  0% { transform: scale(1); opacity: 0.9; }
  15% { transform: scale(1.1); opacity: 1; }
  30% { transform: scale(1); opacity: 0.9; }
  45% { transform: scale(1.1); opacity: 1; }
  60%, 100% { transform: scale(1); opacity: 0.9; }
}
