/* --- Global Resets & Base Styles --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden; /* Prevent scrollbars caused by off-screen particles */
  transition: background-color 0.5s ease-in-out, color 0.5s ease-in-out; /* Smooth transition for dark mode */
}

body {
  font-family: "Poppins", sans-serif;
  background-color: #ffffff; /* Default white background */
  color: #1a1a1a; /* Default dark color for text */
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative; /* Needed for absolute positioning of particles */
}

/* --- Utility Classes --- */
.hidden {
  display: none !important;
}

/* --- Content Container & Word Styling --- */
.content-container {
  position: relative; /* Ensure text is above particles */
  z-index: 10;
  text-align: center;
}

.word {
  display: inline-flex; /* Align letters horizontally */
  /* Using the larger font size from previous request */
  font-size: clamp(6rem, 15vw, 12rem);
  font-weight: 600;
  user-select: none; /* Prevent text selection */
  position: relative;
}

.letter {
  display: inline-block;
  min-width: 0.5ch;
  transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1),
    color 0.3s ease-in-out;
  position: relative;
  cursor: default;
  /* Default color inherited from body */
}

/* --- Specific Letter Styling --- */
span.letter[data-letter="c"] {
  color: orange; /* Make 'c' orange by default */
  cursor: pointer; /* Indicate it's clickable */
}

/* Add a subtle animation class for interaction */
.letter.hit {
  animation: shake 0.4s ease-in-out;
  color: #007bff; /* Interaction color (blue) - applies to all letters including 'c' when hit */
}

/* Letter damage states for game mode */
.letter.damage-1 {
  opacity: 0.8;
  text-shadow: 2px 2px 4px rgba(255, 0, 0, 0.3);
}

.letter.damage-2 {
  opacity: 0.6;
  text-shadow: 2px 2px 6px rgba(255, 0, 0, 0.6);
  transform: scale(0.95);
}

.letter.destroyed {
  opacity: 0;
  transform: scale(0.8) rotate(180deg);
  pointer-events: none;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  25% {
    transform: translateX(-3px) rotate(-2deg);
  }
  50% {
    transform: translateX(3px) rotate(2deg);
  }
  75% {
    transform: translateX(-2px) rotate(-1deg);
  }
}

/* --- Game Input Interface --- */
#game-input-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  text-align: center;
  backdrop-filter: blur(10px);
}

body.dark-mode #game-input-container {
  background: rgba(26, 26, 26, 0.95);
  color: #ffffff;
}

#game-input {
  width: 300px;
  height: 100px;
  padding: 1rem;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  resize: none;
  margin-bottom: 1rem;
  transition: border-color 0.3s ease;
}

#game-input:focus {
  outline: none;
  border-color: orange;
}

body.dark-mode #game-input {
  background: #333;
  color: #fff;
  border-color: #555;
}

#submit-input,
#cancel-input {
  padding: 0.8rem 1.5rem;
  margin: 0 0.5rem;
  border: none;
  border-radius: 8px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

#submit-input {
  background: orange;
  color: white;
}

#submit-input:hover {
  background: #ff8c00;
  transform: translateY(-2px);
}

#cancel-input {
  background: #6c757d;
  color: white;
}

#cancel-input:hover {
  background: #5a6268;
  transform: translateY(-2px);
}

/* --- Spaceship Styling --- */
#spaceship {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  z-index: 15;
  transition: left 0.1s ease;
}

#spaceship::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 40px solid #007bff;
  filter: drop-shadow(0 0 10px rgba(0, 123, 255, 0.5));
}

body.dark-mode #spaceship::before {
  border-bottom-color: #4dabf7;
}

/* Spaceship damage states */
#spaceship.damage-1::before {
  filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.3));
  animation: damage-flash 0.5s ease-in-out;
}

#spaceship.damage-2::before {
  filter: drop-shadow(0 0 15px rgba(255, 0, 0, 0.6));
  animation: damage-flash 1s ease-in-out;
}

@keyframes damage-flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* --- Bullets --- */
.bullet {
  position: absolute;
  width: 4px;
  height: 15px;
  background: #007bff;
  border-radius: 2px;
  z-index: 12;
  box-shadow: 0 0 8px rgba(0, 123, 255, 0.6);
}

body.dark-mode .bullet {
  background: #4dabf7;
  box-shadow: 0 0 8px rgba(77, 171, 247, 0.6);
}

.bullet.super {
  width: 8px;
  height: 20px;
  background: linear-gradient(45deg, #ff6b35, #f7931e);
  box-shadow: 0 0 15px rgba(255, 107, 53, 0.8);
}

/* --- Game UI --- */
#game-ui {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 20;
  font-family: "Poppins", sans-serif;
}

#spaceship-health {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

#super-blast-timer {
  background: linear-gradient(45deg, #ff6b35, #f7931e);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
  animation: pulse-timer 1s ease-in-out infinite;
}

@keyframes pulse-timer {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* --- Particle Container & Styling --- */
#particle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.particle {
  position: absolute;
  background-color: #1a1a1a; /* Default Black particles */
  border-radius: 50%;
  opacity: 0.7;
  will-change: transform;
  transition: background-color 0.5s ease-in-out; /* Smooth transition for dark mode */
  pointer-events: none;
}

/* Power-up particle styling */
.particle.powerup {
  background: linear-gradient(45deg, #00ff00, #32cd32);
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.6);
  animation: flash-green 0.5s ease-in-out infinite alternate;
  pointer-events: auto;
}

@keyframes flash-green {
  0% {
    opacity: 0.7;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* --- Dark Mode Styles --- */
body.dark-mode {
  background-color: #1a1a1a; /* Black background */
  color: #ffffff; /* White text */
}

body.dark-mode .particle {
  background-color: #ffffff; /* White particles */
  opacity: 0.8; /* Maybe slightly more opaque in dark mode */
}

/* Ensure 'c' stays orange in dark mode */
body.dark-mode span.letter[data-letter="c"] {
  color: orange;
}

/* Optional: Adjust hit color in dark mode for better contrast */
body.dark-mode .letter.hit {
  color: #4dabf7; /* Lighter blue for dark mode */
}

/* --- Responsive Styles --- */
@media (max-width: 767px) {
  /* Target screens smaller than 768px (most phones, small tablets) */

  .word {
    /* Mobile font size - smaller range */
    font-size: clamp(4rem, 18vw, 7rem); /* Adjust these values as needed */
  }

  #game-input-container {
    width: 90%;
    padding: 1.5rem;
  }

  #game-input {
    width: 100%;
  }

  #spaceship {
    width: 35px;
    height: 35px;
    bottom: 40px;
  }

  #spaceship::before {
    border-left-width: 17px;
    border-right-width: 17px;
    border-bottom-width: 35px;
  }
}
