@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600;700&display=swap');

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

:root {
  --neon-green: #39ff14;
  --neon-cyan: #00ffff;
  --neon-blue: #0080ff;
  --neon-orange: #ff6600;
  --neon-red: #ff0040;
  --neon-purple: #bf00ff;
  --neon-yellow: #ffff00;
  --bg-dark: #050a18;
  --bg-panel: rgba(5, 20, 50, 0.85);
  --text-primary: #e0f0ff;
  --text-dim: rgba(150, 200, 255, 0.6);
}

body {
  background: var(--bg-dark);
  font-family: 'Exo 2', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  cursor: default;
}

/* ===================== SCREENS ===================== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.screen.hidden { display: none; }

/* ===================== CANVAS ===================== */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: none;
}

/* Ensure buttons on screens have proper cursor */
.screen button, .level-btn, .btn-start, .btn, #pauseBtn {
  cursor: pointer;
}


/* ===================== MENU SCREEN ===================== */
#menuScreen {
  background: radial-gradient(ellipse at center, #0a1628 0%, #050a18 70%);
  text-align: center;
  gap: 20px;
}

.menu-logo {
  position: relative;
  margin-bottom: 10px;
}

.menu-logo h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue), var(--neon-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0, 200, 255, 0.5));
  animation: titlePulse 3s ease-in-out infinite;
}

.menu-logo .subtitle {
  font-family: 'Orbitron', monospace;
  font-size: clamp(0.7rem, 1.5vw, 1rem);
  color: var(--neon-cyan);
  letter-spacing: 8px;
  opacity: 0.7;
  margin-top: 5px;
}

@keyframes titlePulse {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(0, 200, 255, 0.5)); }
  50% { filter: drop-shadow(0 0 40px rgba(0, 200, 255, 0.9)); }
}

.stars-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.star-particle {
  position: absolute;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--dur) ease-in-out infinite var(--delay);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.5); }
}

/* Level Selector */
.level-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

.level-selector label {
  font-family: 'Orbitron', monospace;
  color: var(--neon-cyan);
  font-size: 0.85rem;
  letter-spacing: 3px;
}

.level-buttons {
  display: flex;
  gap: 12px;
}

.level-btn {
  padding: 10px 24px;
  border: 1px solid var(--neon-cyan);
  background: transparent;
  color: var(--neon-cyan);
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.level-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--neon-cyan);
  transform: translateX(-100%);
  transition: transform 0.3s;
  z-index: -1;
}

.level-btn:hover::before, .level-btn.active::before {
  transform: translateX(0);
}

.level-btn:hover, .level-btn.active {
  color: var(--bg-dark);
  box-shadow: 0 0 20px var(--neon-cyan);
}

/* Start Button */
.btn-start {
  padding: 16px 56px;
  border: 2px solid var(--neon-green);
  background: transparent;
  color: var(--neon-green);
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 15px rgba(57, 255, 20, 0.3), inset 0 0 15px rgba(57, 255, 20, 0.05);
}

.btn-start::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--neon-green);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-start:hover {
  color: var(--bg-dark);
  box-shadow: 0 0 40px rgba(57, 255, 20, 0.7), inset 0 0 20px rgba(57, 255, 20, 0.2);
}

.btn-start:hover::after { opacity: 1; }
.btn-start span { position: relative; z-index: 1; }

/* Stats Preview */
.menu-stats {
  display: flex;
  gap: 30px;
  margin-top: 5px;
}

.stat-item {
  text-align: center;
}

.stat-item .val {
  font-family: 'Orbitron', monospace;
  font-size: 1.4rem;
  color: var(--neon-yellow);
  font-weight: 700;
}

.stat-item .lbl {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Instructions */
.instructions {
  max-width: 500px;
  text-align: left;
  background: rgba(0, 100, 200, 0.1);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 8px;
  padding: 16px 24px;
  margin-top: 5px;
}

.instructions h3 {
  font-family: 'Orbitron', monospace;
  color: var(--neon-cyan);
  font-size: 0.7rem;
  letter-spacing: 3px;
  margin-bottom: 10px;
}

.instructions ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.instructions li {
  font-size: 0.82rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.instructions li::before {
  content: '▸';
  color: var(--neon-cyan);
  flex-shrink: 0;
}

/* ===================== HUD (in-game) ===================== */
#gameHUD {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 5;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#gameHUD.hidden { display: none; }

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-center {
  text-align: center;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-icon {
  font-size: 14px;
}

.hud-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  min-width: 50px;
}

.hud-value {
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--neon-cyan);
  min-width: 60px;
}

.hud-value.score { color: var(--neon-yellow); }
.hud-value.lives { color: var(--neon-red); }
.hud-value.accuracy { color: var(--neon-green); }

.level-display {
  font-family: 'Orbitron', monospace;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 900;
  color: var(--neon-green);
  letter-spacing: 4px;
  text-shadow: 0 0 20px var(--neon-green);
}

.lives-hearts {
  display: flex;
  gap: 4px;
}

.heart {
  font-size: 16px;
  transition: all 0.3s;
}
.heart.empty { filter: grayscale(1) opacity(0.3); }

/* Pause Button */
#pauseBtn {
  position: absolute;
  top: 12px;
  right: 20px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 20;
  pointer-events: all;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#pauseBtn:hover {
  background: var(--neon-cyan);
  color: var(--bg-dark);
  box-shadow: 0 0 15px var(--neon-cyan);
}

#pauseBtn.hidden { display: none; }

/* ===================== INPUT ZONE ===================== */
#inputZone {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#inputZone.hidden { display: none; }

#typingInput {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  padding: 10px 30px;
  min-width: 300px;
  border-radius: 4px;
  outline: none;
  pointer-events: all;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3), inset 0 0 10px rgba(0, 255, 255, 0.05);
  transition: all 0.2s;
  text-transform: uppercase;
}

#typingInput:focus {
  box-shadow: 0 0 35px rgba(0, 255, 255, 0.6), inset 0 0 15px rgba(0, 255, 255, 0.1);
}

#typingInput.error {
  border-color: var(--neon-red);
  color: var(--neon-red);
  box-shadow: 0 0 25px rgba(255, 0, 64, 0.6);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

#typingInput.success {
  border-color: var(--neon-green);
  box-shadow: 0 0 35px rgba(57, 255, 20, 0.8);
}

/* Word preview tooltip */
#wordPreview {
  background: rgba(0, 20, 60, 0.95);
  border: 1px solid var(--neon-cyan);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 300px;
}

#wordPreview.visible { opacity: 1; }

#previewImage {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
}

#previewText {
  font-family: 'Exo 2', sans-serif;
}

#previewWord {
  font-size: 1rem;
  font-weight: 700;
  color: var(--neon-yellow);
  letter-spacing: 2px;
}

#previewMeaning {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ===================== COMBO DISPLAY ===================== */
#comboDisplay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 30;
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s;
}

#comboDisplay.show {
  animation: comboAnim 1.5s ease forwards;
}

@keyframes comboAnim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.3); }
  80% { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(0.8); }
}

.combo-text {
  font-family: 'Orbitron', monospace;
  font-size: 2rem;
  font-weight: 900;
  color: var(--neon-yellow);
  text-shadow: 0 0 30px var(--neon-yellow);
}

/* ===================== PAUSE SCREEN ===================== */
#pauseScreen {
  background: rgba(0, 5, 20, 0.9);
  backdrop-filter: blur(10px);
  z-index: 50;
}

.pause-panel {
  background: var(--bg-panel);
  border: 1px solid var(--neon-cyan);
  border-radius: 12px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 0 50px rgba(0, 200, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pause-panel h2 {
  font-family: 'Orbitron', monospace;
  color: var(--neon-cyan);
  font-size: 1.5rem;
  letter-spacing: 6px;
}

/* ===================== GAME OVER / WIN ===================== */
#gameOverScreen, #levelCompleteScreen {
  background: rgba(0, 0, 10, 0.92);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.result-panel {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 40px 60px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 500px;
  width: 90vw;
}

.result-panel.game-over-panel {
  border: 2px solid var(--neon-red);
  box-shadow: 0 0 60px rgba(255, 0, 64, 0.3);
}

.result-panel.win-panel {
  border: 2px solid var(--neon-green);
  box-shadow: 0 0 60px rgba(57, 255, 20, 0.3);
}

.result-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 4px;
}

.result-title.fail { color: var(--neon-red); text-shadow: 0 0 30px var(--neon-red); }
.result-title.win { color: var(--neon-green); text-shadow: 0 0 30px var(--neon-green); }

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0;
}

.result-stat {
  background: rgba(0, 50, 100, 0.4);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 8px;
  padding: 12px;
}

.result-stat .r-val {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--neon-yellow);
}

.result-stat .r-lbl {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

.btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Generic Buttons */
.btn {
  padding: 12px 30px;
  border-radius: 4px;
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid;
}

.btn-primary {
  background: transparent;
  border-color: var(--neon-green);
  color: var(--neon-green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.2);
}

.btn-primary:hover {
  background: var(--neon-green);
  color: var(--bg-dark);
  box-shadow: 0 0 30px rgba(57, 255, 20, 0.6);
}

.btn-secondary {
  background: transparent;
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.btn-secondary:hover {
  background: var(--neon-cyan);
  color: var(--bg-dark);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.btn-danger {
  background: transparent;
  border-color: var(--neon-red);
  color: var(--neon-red);
}

.btn-danger:hover {
  background: var(--neon-red);
  color: white;
  box-shadow: 0 0 20px rgba(255, 0, 64, 0.5);
}

/* ===================== LEVEL UP NOTIFICATION ===================== */
#levelUpNotif {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Orbitron', monospace;
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 900;
  color: var(--neon-green);
  text-shadow: 0 0 50px var(--neon-green);
  letter-spacing: 6px;
  pointer-events: none;
  z-index: 40;
  opacity: 0;
}

#levelUpNotif.show {
  animation: levelUpAnim 2s ease forwards;
}

@keyframes levelUpAnim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}

/* ===================== WORD CARD ON ENEMY ===================== */
.enemy-word-display {
  position: absolute;
  pointer-events: none;
  transform: translateX(-50%);
  text-align: center;
  z-index: 15;
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
::-webkit-scrollbar-thumb { background: var(--neon-cyan); border-radius: 2px; }

/* ===================== LOADING ===================== */
#loadingScreen {
  background: var(--bg-dark);
  z-index: 100;
}

.loading-bar-wrap {
  width: 300px;
  height: 4px;
  background: rgba(0, 200, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan));
  border-radius: 2px;
  animation: loadingProgress 1.5s ease forwards;
  box-shadow: 0 0 10px var(--neon-cyan);
}

@keyframes loadingProgress {
  from { width: 0%; }
  to { width: 100%; }
}

.loading-text {
  font-family: 'Orbitron', monospace;
  color: var(--neon-cyan);
  font-size: 0.75rem;
  letter-spacing: 3px;
  margin-bottom: 16px;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 600px) {
  .level-buttons { flex-wrap: wrap; }
  .result-stats { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; align-items: center; }
}
