/* Import vintage military-style font with fallbacks */
@import url('https://fonts.googleapis.com/css2?family=Staatliches&family=Orbitron:wght@400;700&display=swap');

/* === Root Variables === */
:root {
  --primary-green: #c7ffc7;
  --secondary-green: #90ff90;
  --accent-green: #23c483;
  --dark-green: #4B5320;
  --darker-green: #1a200a;
  --glow-color: rgba(144, 255, 144, 0.5);
  --strong-glow: rgba(144, 255, 144, 0.8);
  --scanline-opacity: 0.15;
  --military-font: 'Staatliches', 'Orbitron', 'Arial Black', sans-serif;
}

/* === Global Reset & Base === */
* {
  box-sizing: border-box;
  font-family: var(--military-font) !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  color: var(--primary-green);
  text-align: center;
  user-select: none;
}

/* === Scanlines Overlay === */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.03) 2px,
      rgba(0, 0, 0, 0.03) 4px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 0, 0, 0.06),
      rgba(255, 0, 0, 0.06) 1px,
      rgba(0, 255, 0, 0.02) 1px,
      rgba(0, 255, 0, 0.02) 2px,
      rgba(0, 0, 255, 0.06) 2px,
      rgba(0, 0, 255, 0.06) 3px
    );
  z-index: 1000;
  pointer-events: none;
  opacity: var(--scanline-opacity);
  mix-blend-mode: multiply;
  animation: scanlines 0.1s linear infinite;
}

@keyframes scanlines {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* === Subtle Flicker === */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-green);
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  animation: flicker 4s infinite;
}

@keyframes flicker {
  0%, 98% { opacity: 0; }
  99% { opacity: 0.02; }
  100% { opacity: 0; }
}

/* === Game Canvas === */
canvas#gameCanvas {
  display: none; /* JS toggles visibility */
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 50;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

canvas#gameCanvas.active { display: block; }

/* === Start Screen === */
#start-screen {
  background-image: url('https://i.ibb.co/wrs56dmm/Chat-GPT-Image-Aug-5-2025-03-24-51-PM.png');
  background-size: contain;
  background-position: center center;
  background-repeat: no-repeat;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10vh 1rem max(env(safe-area-inset-bottom), 5vh) 1rem;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: opacity 0.5s ease-out;
}

#start-screen.fade-out { opacity: 0; pointer-events: none; }

#start-screen h1 {
  color: var(--primary-green);
  text-shadow:
    0 0 5px var(--secondary-green),
    0 0 10px var(--secondary-green),
    0 0 20px var(--accent-green),
    0 0 30px var(--accent-green),
    0 0 40px var(--accent-green);
  font-size: clamp(0.3rem, 8vw, 5rem);
  letter-spacing: 0.1em;
  margin: 0 0 2rem 0;
  padding: 1rem;
  max-width: 90%;
  word-wrap: break-word;
  text-transform: uppercase;
  animation: titleGlow 3s ease-in-out infinite alternate;
  z-index: 150;
}

#start-screen h2 {
  color: #0b3d0b;
  text-shadow:
    0 0 5px var(--secondary-green),
    0 0 10px var(--secondary-green),
    0 0 20px var(--accent-green),
    0 0 30px var(--accent-green),
    0 0 40px var(--accent-green);
  font-size: clamp(2.5rem, 6vw, 5rem);
  letter-spacing: 0em;
  margin: 0 0 1rem 0;
  padding: 0.5rem;
  max-width: 70%;
  text-align: center;
  text-transform: uppercase;
  animation: titleGlow 3s ease-in-out infinite alternate;
  z-index: 150;
}

@keyframes titleGlow {
  from {
    text-shadow:
      0 0 5px var(--secondary-green),
      0 0 10px var(--secondary-green),
      0 0 20px var(--accent-green),
      0 0 30px var(--accent-green);
  }
  to {
    text-shadow:
      0 0 10px var(--secondary-green),
      0 0 20px var(--secondary-green),
      0 0 30px var(--accent-green),
      0 0 40px var(--accent-green),
      0 0 50px var(--accent-green);
  }
}

/* === End Screen === */
#end-screen {
  display: none; /* JS toggles */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: white;
  text-align: center;
  background: rgba(0,0,0,0.7);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 34px;
  z-index: 200;
  justify-content: flex-start;
  padding-top: 40vh; /* push content down */
}

#end-message {
  font-size: clamp(3rem, 8vw, 6rem);
  text-transform: uppercase;
  color: #ff4d4d;
  text-shadow: 0 0 15px #ff0000;
  margin-top: 0;
}

#final-score, #best-score {
  margin-top: 10px;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

/* === In-Game UI (optional wrapper) === */
#game-ui {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  color: var(--primary-green);
  text-shadow: 0 0 6px var(--secondary-green);
  font-size: 1.5rem;
  text-align: left;
}

/* === Buttons === */
#start-button,
#restart-button {
  font-family: var(--military-font);
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: 90%;
  max-width: 250px;
  padding: 1em 1.5em;
  margin-top: 10em;
  cursor: pointer;
  background: linear-gradient(135deg, var(--dark-green), #3a4a1a);
  border: 3px solid var(--secondary-green);
  color: var(--primary-green);
  border-radius: 8px;
  box-shadow:
    0 0 15px var(--glow-color),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

#start-button:disabled {
  cursor: wait;
  background: #555;
  color: #999;
  border-color: #777;
}

#start-button::before,
#restart-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

#start-button:not(:disabled):hover,
#restart-button:hover {
  background: linear-gradient(135deg, var(--secondary-green), #a0ffa0);
  color: var(--darker-green);
  box-shadow: 0 0 20px var(--strong-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}

#start-button:not(:disabled):hover::before,
#restart-button:hover::before { left: 100%; }

/* Hidden gameover img (referenced by JS) */
#gameover-img { display:none; }

/* Boss announcement ensures flex is applied */
#boss-announcement { display: none; align-items: center; justify-content: center; }
