/* Root Variables for Neon Theme */
:root {
  --bg-primary: #0a0a16;
  --bg-secondary: rgba(15, 15, 35, 0.7);
  --color-text: #e6e6fa;
  --color-text-muted: #8b8ba8;
  
  /* Neon Palette */
  --neon-pink: #ff007f;
  --neon-yellow: #ffdf00;
  --neon-green: #39ff14;
  --neon-blue: #00f0ff;
  --neon-purple: #bd00ff;
  
  /* Glowing drop-shadows */
  --glow-pink: 0 0 10px rgba(255, 0, 127, 0.6), 0 0 20px rgba(255, 0, 127, 0.3);
  --glow-yellow: 0 0 10px rgba(255, 223, 0, 0.6), 0 0 20px rgba(255, 223, 0, 0.3);
  --glow-green: 0 0 10px rgba(57, 255, 20, 0.6), 0 0 20px rgba(57, 255, 20, 0.3);
  --glow-blue: 0 0 10px rgba(0, 240, 255, 0.6), 0 0 20px rgba(0, 240, 255, 0.3);
  
  --font-title: 'Orbitron', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--bg-primary);
  color: var(--color-text);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(90, 0, 150, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 120, 200, 0.15) 0%, transparent 40%);
}

/* Container limits width and centers game elements */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 900px;
  max-height: 700px;
  background: rgba(10, 10, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

@media (min-width: 901px) {
  #game-container {
    border-radius: 16px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.05), 0 20px 50px rgba(0, 0, 0, 0.7);
  }
}

/* Screens System */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.screen.overlay {
  background: rgba(5, 5, 15, 0.85);
  backdrop-filter: blur(8px);
  z-index: 20;
}

/* Glassmorphic Panels */
.glass-panel {
  background: var(--bg-secondary);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 2.5rem;
  width: 85%;
  max-width: 500px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: panelSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes panelSlideIn {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Game Title Typography */
.game-title {
  font-family: var(--font-title);
  font-size: 3rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--neon-blue) 0%, var(--neon-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 240, 255, 0.3));
  margin-bottom: 0.2rem;
  animation: titlePulse 3s ease-in-out infinite alternate;
}

@keyframes titlePulse {
  0% { transform: scale(1); filter: drop-shadow(0 2px 5px rgba(0, 240, 255, 0.2)); }
  100% { transform: scale(1.03); filter: drop-shadow(0 4px 15px rgba(255, 0, 127, 0.4)); }
}

.game-subtitle {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--color-text-muted);
  letter-spacing: 6px;
  margin-bottom: 2rem;
  text-transform: uppercase;
}

/* Cute illustration inside menu */
.menu-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: 2rem;
  gap: 1.5rem;
}

.illustration-cat {
  animation: floatCat 3s ease-in-out infinite;
}

.illustration-mouse {
  animation: floatMouse 3s ease-in-out infinite 1.5s;
}

.illustration-chase {
  color: var(--neon-yellow);
  font-size: 2.2rem;
  text-shadow: var(--glow-yellow);
  animation: lightning 1s linear infinite;
}

@keyframes floatCat {
  0%, 100% { transform: translateY(0) rotate(5deg); }
  50% { transform: translateY(-10px) rotate(-5deg); }
}

@keyframes floatMouse {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-8px) rotate(10deg); }
}

@keyframes lightning {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Difficulty Buttons */
.mode-select {
  width: 100%;
  margin-bottom: 2rem;
  text-align: center;
}

.mode-select h3, .how-to-play h3 {
  font-family: var(--font-title);
  font-size: 0.9rem;
  letter-spacing: 2px;
  margin-bottom: 0.8rem;
  color: var(--color-text-muted);
}

.difficulty-buttons {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
}

.diff-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-muted);
  padding: 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text);
  border-color: rgba(255, 255, 255, 0.3);
}

.diff-btn.active[data-diff="easy"] {
  background: rgba(57, 255, 20, 0.15);
  border-color: var(--neon-green);
  color: var(--neon-green);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.2);
}

.diff-btn.active[data-diff="medium"] {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.diff-btn.active[data-diff="hard"] {
  background: rgba(255, 0, 127, 0.15);
  border-color: var(--neon-pink);
  color: var(--neon-pink);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.2);
}

/* Beautiful Interactive Buttons */
.primary-btn {
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  color: #fff;
  border: none;
  padding: 1rem 2.5rem;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 2px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(189, 0, 255, 0.4);
  transition: var(--transition-smooth);
  width: 100%;
  max-width: 280px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.primary-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: skewX(-30deg);
  transition: 0.75s;
}

.primary-btn:hover::after {
  left: 120%;
}

.primary-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 240, 255, 0.6);
  filter: brightness(1.1);
}

.primary-btn:active {
  transform: translateY(1px);
}

.secondary-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.8rem 2rem;
  font-family: var(--font-title);
  font-size: 0.95rem;
  letter-spacing: 1px;
  border-radius: 50px;
  cursor: pointer;
  margin-top: 0.8rem;
  transition: var(--transition-smooth);
  width: 100%;
  max-width: 280px;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* How to play instruction panel */
.how-to-play {
  margin-top: 2rem;
  width: 100%;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.5rem;
}

.how-to-play ul {
  list-style: none;
  text-align: left;
}

.how-to-play li {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.4;
}

.how-to-play span {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-title);
  font-size: 0.75rem;
}

/* Game Interface Layout */
#game-screen {
  justify-content: flex-start;
  padding: 1rem;
}

/* Heads Up Display (HUD) */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 600px;
  background: rgba(15, 15, 35, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 0.6rem 1.2rem;
  margin-bottom: 0.8rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-item .label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.1rem;
  font-family: var(--font-title);
}

.hud-item .value {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
}

#score-val {
  color: var(--neon-yellow);
  text-shadow: 0 0 5px rgba(255, 223, 0, 0.3);
}

#lives-val {
  color: var(--neon-pink);
  letter-spacing: 2px;
}

#level-val {
  color: var(--neon-blue);
}

#highscore-val {
  color: var(--color-text-muted);
}

/* Sound Icon Button */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  transition: var(--transition-smooth);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text);
}

/* Canvas Wrapper with glowing border */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1; /* Keep it square */
  background: #020208;
  border: 2px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Active Power-up Overlay indicators */
#powerup-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.powerup-indicator {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  font-family: var(--font-title);
  color: #fff;
  animation: indicatorFlash 1s ease infinite alternate;
  display: flex;
  align-items: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

#power-speed {
  background: rgba(255, 0, 127, 0.85);
  border: 1px solid var(--neon-pink);
}

#power-freeze {
  background: rgba(57, 255, 20, 0.85);
  border: 1px solid var(--neon-green);
}

#power-shield {
  background: rgba(0, 240, 255, 0.85);
  border: 1px solid var(--neon-blue);
}

.hidden {
  display: none !important;
}

@keyframes indicatorFlash {
  from { opacity: 0.6; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1.02); }
}

/* Screen Shaking Effect (when caught) */
.shake-screen {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-4px, 2px); }
  20%, 40%, 60%, 80% { transform: translate(4px, -2px); }
}

/* Keyboard hint text below arena */
.keyboard-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 1rem;
  text-align: center;
}

.keyboard-hint span {
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-title);
}

/* Game Over styling */
.glow-text {
  font-family: var(--font-title);
  font-size: 2.5rem;
  color: var(--neon-pink);
  text-shadow: var(--glow-pink);
  margin-bottom: 1rem;
  letter-spacing: 2px;
}

.final-score-text {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.final-score-text span {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--neon-yellow);
  font-size: 1.5rem;
}

.new-highscore-badge {
  background: rgba(255, 223, 0, 0.15);
  border: 1px solid var(--neon-yellow);
  color: var(--neon-yellow);
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: bold;
  margin-bottom: 1.5rem;
  text-shadow: var(--glow-yellow);
  animation: pulseNewRecord 0.8s alternate infinite ease-in-out;
}

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

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

/* D-Pad Touch Interface (for mobile devices) */
#touch-controls {
  display: none; /* Hidden by default on desktop, shown conditionally */
  margin-top: 1rem;
  z-index: 15;
}

.d-pad {
  display: grid;
  grid-template-rows: repeat(3, 50px);
  grid-template-columns: repeat(3, 50px);
  justify-content: center;
  align-items: center;
}

.pad-btn {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--color-text-muted);
  font-size: 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.pad-btn:active {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

#btn-up { grid-row: 1; grid-column: 2; }
#btn-left { grid-row: 2; grid-column: 1; }
.pad-center { grid-row: 2; grid-column: 2; width: 50px; height: 50px; }
#btn-right { grid-row: 2; grid-column: 3; }
#btn-down { grid-row: 3; grid-column: 2; }

/* Responsive styles to show touch overlay if screen size is mobile */
@media (max-width: 768px) {
  #touch-controls {
    display: block; /* Show virtual D-pad on mobile screens */
  }
  
  .keyboard-hint {
    display: none; /* Hide keyboard shortcut hints on mobile */
  }
  
  #game-container {
    height: 100vh;
    max-height: 100vh;
  }
  
  .glass-panel {
    padding: 1.5rem;
    width: 90%;
  }

  .game-title {
    font-size: 2.2rem;
  }

  .menu-illustration {
    font-size: 2.2rem;
    margin-bottom: 1.2rem;
  }
}
