/* Basic Reset */
body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Prevent scrolling since canvas will take full screen */
  background-color: #111827;
  /* Darker slate for better contrast */
  font-family: "Inter", sans-serif;
  color: white;
  user-select: none;
  /* Prevent text selection while clicking fast */
  touch-action: none;
  /* Prevent browser gestures from hijacking game controls */
  cursor: default;
  /* We will use orbit controls, but keep default pointer normally */
}

/* Three.js Canvas */
canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* UI Overlay with Glassmorphism */
#ui-container {
  position: absolute;
  top: 30px;
  left: 30px;
  z-index: 10;
  pointer-events: none;
  /* Let clicks pass through the UI background */

  /* Glassmorphism Effect */
  background: rgba(31, 41, 55, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  padding: 24px;
  border-radius: 16px;

  transition: opacity 0.3s;
}

#title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #fca5a5;
  /* Vibrant light red */
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: -0.5px;
}

#instructions {
  margin: 8px 0 16px 0;
  font-size: 14px;
  color: #d1d5db;
  /* Mild gray */
}

#score-display {
  font-size: 18px;
  font-weight: bold;
  color: #e5e7eb;
}

/* Crosshair Reticle */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  /* Let clicks pass through to Three.js */
  z-index: 15;
  opacity: 0.8;
}

/* Vertical line */
#crosshair::before {
  content: "";
  position: absolute;
  top: 0;
  left: 11px;
  width: 2px;
  height: 24px;
  background-color: #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  border-radius: 1px;
}

/* Horizontal line */
#crosshair::after {
  content: "";
  position: absolute;
  top: 11px;
  left: 0;
  width: 24px;
  height: 2px;
  background-color: #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  border-radius: 1px;
}

/* Win Screen specifically */
#win-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 1;
  transition: opacity 0.5s ease-in-out;
}

#win-screen h2 {
  font-size: 56px;
  margin-bottom: 12px;
  color: #10b981;
  /* Success Green */
  text-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  letter-spacing: -1px;
}

#win-screen p {
  font-size: 20px;
  margin-bottom: 40px;
  color: #d1d5db;
}

/* Retry Button */
#retry-btn {
  padding: 16px 40px;
  font-size: 18px;
  font-family: "Inter", sans-serif;
  font-weight: bold;
  color: white;
  background-color: #ef4444;
  /* Clean Red button */
  border: none;
  border-radius: 50px;
  /* Pill shape */
  cursor: pointer;
  box-shadow: 0 10px 20px -5px rgba(239, 68, 68, 0.5);
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  pointer-events: auto;
  /* Ensure button can be clicked */
}

#retry-btn:hover {
  background-color: #dc2626;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 15px 25px -5px rgba(239, 68, 68, 0.6);
}

#retry-btn:active {
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 5px 10px -5px rgba(239, 68, 68, 0.5);
}

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

/* Weapon Toolbar */
#weapon-toolbar {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  gap: 16px;

  /* Glassmorphism Effect */
  background: rgba(31, 41, 55, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 12px 24px;
  border-radius: 50px;

  /* Slide-up entrance on load */
  animation: slideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(80px);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.weapon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 16px;
  width: 60px;
  height: 64px;
  font-size: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  color: white;
}

.weapon-label {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
}

.weapon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-4px);
}

.weapon-btn.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: #fca5a5;
  box-shadow:
    0 0 15px rgba(252, 165, 165, 0.5),
    inset 0 0 10px rgba(252, 165, 165, 0.3);
  transform: scale(1.1);
  animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow:
      0 0 15px rgba(252, 165, 165, 0.5),
      inset 0 0 10px rgba(252, 165, 165, 0.3);
  }

  50% {
    box-shadow:
      0 0 25px rgba(252, 165, 165, 0.8),
      inset 0 0 15px rgba(252, 165, 165, 0.5);
  }
}

/* Floating Damage Text */
.float-text {
  position: absolute;
  pointer-events: none;
  z-index: 25;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 24px;
  color: #fca5a5;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-60px) scale(1.5);
  }
}

/* Combo Counter */
#combo-display {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 25;
  pointer-events: none;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 64px;
  color: #facc15;
  text-shadow:
    0 4px 20px rgba(250, 204, 21, 0.6),
    0 0 40px rgba(250, 204, 21, 0.3);
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

#combo-display.visible {
  opacity: 1;
  animation: comboPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes comboPop {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
  }

  60% {
    transform: translate(-50%, -50%) scale(1.2);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Stats Win Screen */
#win-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 30px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 100px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: #fca5a5;
  display: block;
}

.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #9ca3af;
  letter-spacing: 1px;
  margin-top: 4px;
  display: block;
}

/* ===== Responsive: Tablets (≤768px) ===== */
@media (max-width: 768px) {
  #ui-container {
    top: 16px;
    left: 16px;
    padding: 16px;
    border-radius: 12px;
  }

  #title {
    font-size: 20px;
  }

  #instructions {
    font-size: 12px;
    margin: 4px 0 10px 0;
  }

  #score-display {
    font-size: 15px;
  }

  #weapon-toolbar {
    bottom: 16px;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 40px;
  }

  .weapon-btn {
    width: 46px;
    height: 46px;
    font-size: 22px;
  }

  #win-screen h2 {
    font-size: 36px;
  }

  #win-screen p {
    font-size: 16px;
    margin-bottom: 24px;
  }

  #retry-btn {
    padding: 12px 32px;
    font-size: 16px;
  }

  #crosshair {
    width: 18px;
    height: 18px;
  }

  #crosshair::before {
    left: 8px;
    height: 18px;
  }

  #crosshair::after {
    top: 8px;
    width: 18px;
  }
}

/* ===== Responsive: Phones (≤480px) ===== */
@media (max-width: 480px) {
  #ui-container {
    top: 10px;
    left: 10px;
    right: 10px;
    padding: 12px;
    border-radius: 10px;
  }

  #title {
    font-size: 16px;
  }

  #instructions {
    font-size: 11px;
    margin: 2px 0 8px 0;
  }

  #score-display {
    font-size: 13px;
  }

  #weapon-toolbar {
    bottom: 10px;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 30px;
  }

  .weapon-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-width: 1.5px;
  }

  #win-screen h2 {
    font-size: 28px;
  }

  #win-screen p {
    font-size: 14px;
    margin-bottom: 20px;
  }

  #retry-btn {
    padding: 10px 28px;
    font-size: 14px;
  }

  #crosshair {
    width: 14px;
    height: 14px;
  }

  #crosshair::before {
    left: 6px;
    height: 14px;
  }

  #crosshair::after {
    top: 6px;
    width: 14px;
  }
}
