/* ============================================
   Shooty Game for Jameson!
   Plants vs Zombies Style - CSS
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: linear-gradient(170deg, #1a4d1a 0%, #2d7a2d 40%, #1b5e1b 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: "Fredoka One", "Comic Sans MS", cursive, sans-serif;
  overflow: hidden;
}

/* Subtle grass / leaf texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(50, 180, 50, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(100, 220, 60, 0.10) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Game Container ---------- */
#game-container {
  position: relative;
  width: 1200px;
  height: 700px;
  z-index: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 0 0 4px #3a2a10,
    0 0 0 8px #6b4c1e,
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(50, 200, 50, 0.15);
}

/* ---------- Canvas ---------- */
#game-container canvas,
#game-canvas {
  display: block;
  width: 1200px;
  height: 700px;
  border-radius: 16px;
  background: #4a8c3f;
}

/* ---------- Game Wrapper ---------- */
#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  /* The board is a fixed 1200x700 with the plant bar below it. Scale the whole
     stack down on smaller windows, or the plant picker sits under the fold
     where body{overflow:hidden} makes it unreachable. --fit is set in
     index.html; pointer coordinates are read from getBoundingClientRect, which
     already accounts for the transform. */
  transform: scale(var(--fit, 1));
  transform-origin: center top;
}

/* ---------- Plant Selector Bar ---------- */
#plant-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 20px;
  width: 1200px;
  background: linear-gradient(
    to top,
    rgba(15, 10, 5, 0.95),
    rgba(25, 20, 10, 0.88)
  );
  border-radius: 0 0 16px 16px;
  border-top: 2px solid rgba(255, 220, 80, 0.3);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* ---------- Plant Cards ---------- */
.plant-card {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(145deg, #5cb85c, #3d8b3d);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Shiny highlight on cards */
.plant-card::before {
  content: "";
  position: absolute;
  top: -40%;
  left: -40%;
  width: 80%;
  height: 80%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.25) 0%,
    transparent 70%
  );
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.plant-card:hover {
  transform: translateY(-6px) scale(1.08);
  border-color: rgba(255, 255, 100, 0.7);
  background: linear-gradient(145deg, #6fcf6f, #4a9f4a);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(100, 255, 100, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.plant-card:active {
  transform: translateY(-2px) scale(1.02);
  transition-duration: 0.05s;
}

/* Selected state - glowing border */
.plant-card.selected {
  border-color: #ffdd44;
  background: linear-gradient(145deg, #78d878, #52a852);
  box-shadow:
    0 0 8px rgba(255, 221, 68, 0.6),
    0 0 20px rgba(255, 221, 68, 0.35),
    0 0 40px rgba(255, 200, 50, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  animation: selectedGlow 1.5s ease-in-out infinite alternate;
}

@keyframes selectedGlow {
  0% {
    box-shadow:
      0 0 8px rgba(255, 221, 68, 0.6),
      0 0 20px rgba(255, 221, 68, 0.35),
      0 0 40px rgba(255, 200, 50, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
  100% {
    box-shadow:
      0 0 12px rgba(255, 221, 68, 0.8),
      0 0 30px rgba(255, 221, 68, 0.5),
      0 0 50px rgba(255, 200, 50, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
}

/* Locked / not yet unlocked */
.plant-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(80%);
  transform: none;
  border-color: rgba(255,255,255,0.1);
  background: linear-gradient(145deg, #444, #333);
}

.plant-card.locked:hover {
  transform: none;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  border-color: rgba(255,255,255,0.15);
  background: linear-gradient(145deg, #444, #333);
}

/* Disabled / can't afford state */
.plant-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(50%);
  transform: none;
}

.plant-card.disabled:hover {
  transform: none;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
  background: linear-gradient(145deg, #5cb85c, #3d8b3d);
}

/* Plant card icon area */
.plant-card .plant-icon {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 2px;
}

/* Plant card cost label */
.plant-card .plant-cost {
  font-size: 11px;
  color: #ffe066;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* ---------- Pulse Animation ---------- */
.pulse {
  animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.85;
  }
}

/* ---------- HUD / Score / Sun Counter ---------- */
#hud, .hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 22px;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 10;
}

.sun-counter, #sun-counter {
  color: #ffe066;
  font-size: 26px;
  font-weight: bold;
  text-shadow:
    0 0 8px rgba(255, 200, 0, 0.4),
    2px 2px 4px rgba(0, 0, 0, 0.6);
}

.score, #score {
  color: #fff;
  font-size: 22px;
  font-weight: bold;
}

/* ---------- Wave / Level Banner ---------- */
.wave-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  color: #ff4444;
  text-shadow:
    0 0 10px rgba(255, 50, 50, 0.6),
    3px 3px 6px rgba(0, 0, 0, 0.7);
  z-index: 20;
  pointer-events: none;
  animation: waveBannerIn 0.5s ease-out;
}

@keyframes waveBannerIn {
  0% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* ---------- Start / Game Over Screens ---------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 50;
  border-radius: 16px;
}

.overlay-screen h1 {
  font-size: 56px;
  color: #ffe066;
  text-shadow:
    0 0 20px rgba(255, 200, 0, 0.5),
    3px 3px 6px rgba(0, 0, 0, 0.8);
  margin-bottom: 20px;
}

.overlay-screen p {
  font-size: 22px;
  color: #ddd;
  margin-bottom: 30px;
}

.overlay-screen button,
.btn {
  font-family: "Fredoka One", "Comic Sans MS", cursive, sans-serif;
  font-size: 24px;
  font-weight: bold;
  padding: 14px 48px;
  border: none;
  border-radius: 50px;
  color: #fff;
  background: linear-gradient(145deg, #ff6b35, #e64a19);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow:
    0 4px 15px rgba(255, 107, 53, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.3);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}

.overlay-screen button:hover,
.btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 8px 25px rgba(255, 107, 53, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.3);
}

.overlay-screen button:active,
.btn:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.05s;
}

/* ---------- Tooltip ---------- */
.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

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

.bounce-in {
  animation: bounceIn 0.5s cubic-bezier(0.17, 0.67, 0.35, 1.3) forwards;
}

@keyframes bounceIn {
  0%   { transform: scale(0); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- World leaderboard: name prompt (js/globalboard.js) ---------- */
.gb-backdrop {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 16px;
}

.gb-card {
  width: 480px;
  max-width: 90%;
  padding: 28px 32px 26px;
  text-align: center;
  color: #fff;
  background: linear-gradient(160deg, #2f6b2a, #1b3f18);
  border: 3px solid #ffe066;
  border-radius: 22px;
  box-shadow: 0 0 30px rgba(255, 224, 102, 0.35), 0 10px 30px rgba(0, 0, 0, 0.6);
}

.gb-title {
  font-size: 28px;
  font-weight: bold;
  color: #ffe066;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
  margin-bottom: 10px;
}

.gb-sub {
  font-size: 17px;
  color: #e6f5e0;
  margin-bottom: 18px;
  line-height: 1.35;
}

.gb-input {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 26px;
  font-weight: bold;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-radius: 14px;
  outline: none;
  margin-bottom: 20px;
}

.gb-input::placeholder { color: rgba(255, 255, 255, 0.45); }
.gb-input:focus { border-color: #ffe066; box-shadow: 0 0 12px rgba(255, 224, 102, 0.5); }

.gb-row { display: flex; justify-content: center; gap: 16px; }

.gb-btn {
  font-family: inherit;
  font-size: 22px;
  font-weight: bold;
  padding: 10px 34px;
  border: none;
  border-radius: 50px;
  color: #fff;
  cursor: pointer;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease;
}

.gb-btn:hover:not(:disabled) { transform: translateY(-2px) scale(1.04); }
.gb-save { background: linear-gradient(145deg, #4caf50, #388e3c); }
.gb-skip { background: linear-gradient(145deg, #607d8b, #455a64); }
.gb-btn:disabled { opacity: 0.45; cursor: not-allowed; }
