/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, #0a2e1a 0%, #1a3a2f 50%, #0f291f 100%);
  color: #fff;
  overflow: hidden;
  /* Prevent scrolling */
  height: 100vh;
  /* Fixed height */
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('assets/background.jpeg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.15;
  z-index: 0;
  pointer-events: none;
}

/* Animated background effect */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(34, 197, 94, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(5, 150, 105, 0.1) 0%, transparent 50%);
  animation: bgPulse 10s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes bgPulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

/* ===== GAME CONTAINER ===== */
.game-container {
  text-align: center;
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100vh;
  /* Strict full height */
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* Start from top */
  overflow: hidden;
  /* No scrolling */
}

/* Ensure header and info don't grow */
header,
.info-panel {
  flex-shrink: 0;
}

header {
  margin-bottom: 5px;
}

h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.7), 0 0 20px rgba(34, 197, 94, 0.5);
  margin: 0;
  letter-spacing: 2px;
}

p.subtitle {
  color: #a7f3d0;
  font-size: 0.85rem;
  margin-top: 5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.8;
}

/* ===== INFO PANEL ===== */
.info-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
  width: 100%;
  max-width: 600px;
  align-self: center;
  /* Center panel horizontally */
}

.stat-box {
  flex: 0 1 150px;
  /* Don't grow too large */
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

/* ===== CANVAS WRAPPER ===== */
.canvas-wrapper {
  flex: 1;
  /* Take all remaining height */
  width: 100%;
  height: 100%;
  /* Fill flex parent */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  /* Critical for flex scrolling fix */
  overflow: hidden;
}

canvas {
  /* Canvas size will be handled by JS, but this ensures it behaves */
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: linear-gradient(180deg, rgba(26, 31, 58, 0.85) 0%, rgba(15, 24, 41, 0.85) 100%), url('assets/background.jpeg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 15px;
  border: 2px solid rgba(0, 255, 136, 0.3);
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.2);
  cursor: none;
}

/* ===== INSTRUCTIONS ===== */
.instructions {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 39, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.5s ease-out;
}

.instruction-content {
  text-align: center;
  padding: 20px;
  max-width: 90%;
}

.instruction-content h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.5rem, 5vw, 2rem);
  margin-bottom: 20px;
  background: linear-gradient(135deg, #00ff88, #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.instruction-content p {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  margin: 12px 0;
  color: #cbd5e0;
  line-height: 1.6;
}

.start-btn {
  margin-top: 25px;
  padding: 15px 40px;
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: linear-gradient(135deg, #00ff88, #00d4ff);
  color: #0a0e27;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 255, 136, 0.4);
  position: relative;
  overflow: hidden;
}

.start-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.start-btn:hover::before {
  left: 100%;
}

.start-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 255, 136, 0.6);
}

.start-btn:active {
  transform: translateY(0) scale(1);
}

/* ===== GAME OVER ===== */
.game-over {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.5s ease-out;
}

.game-over-content {
  text-align: center;
  padding: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(0, 255, 136, 0.3);
  border-radius: 25px;
  max-width: 90%;
  animation: scaleIn 0.5s ease-out;
}

.game-over-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  background: linear-gradient(135deg, #ff0080, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 25px;
  letter-spacing: 3px;
}

.final-stats {
  margin: 25px 0;
}

.final-stats p {
  font-size: clamp(1rem, 4vw, 1.3rem);
  margin: 10px 0;
  color: #cbd5e0;
}

.final-stats span {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: linear-gradient(135deg, #00ff88, #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: clamp(1.2rem, 5vw, 1.6rem);
}

.restart-btn {
  margin-top: 20px;
  padding: 15px 40px;
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: linear-gradient(135deg, #00ff88, #00d4ff);
  color: #0a0e27;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 255, 136, 0.4);
}

.restart-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 25px rgba(0, 255, 136, 0.6);
}

.restart-btn:active {
  transform: translateY(0) scale(1);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .game-container {
    padding: 15px;
  }

  .stat-box {
    padding: 12px;
  }

  .instruction-content {
    padding: 20px;
  }

  .game-over-content {
    padding: 30px 20px;
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 10px;
  }

  .info-panel {
    gap: 10px;
    margin-bottom: 15px;
  }

  .stat-box {
    padding: 10px;
  }

  canvas {
    border-radius: 15px;
  }

  .instruction-content p {
    margin: 8px 0;
  }

  .start-btn,
  .restart-btn {
    padding: 12px 30px;
  }
}

/* ===== LANDSCAPE MODE (Mobile) ===== */
@media (max-height: 600px) and (orientation: landscape) {
  body {
    overflow-y: auto;
  }

  .game-container {
    max-width: 400px;
  }

  .game-header {
    margin-bottom: 10px;
  }

  .info-panel {
    margin-bottom: 10px;
  }

  .instruction-content {
    padding: 15px;
  }

  .instruction-content h2 {
    margin-bottom: 10px;
  }

  .instruction-content p {
    margin: 5px 0;
    font-size: 0.85rem;
  }

  .start-btn {
    margin-top: 15px;
    padding: 10px 25px;
  }
}