/* Reset and Body Setup */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  background-image: url("bg.avif");
  background-size: cover;
  background-position: center;
  overflow: hidden; /* Prevent scrolling */
  touch-action: none; /* Prevent browser zooming/swiping on mobile */
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Game Container */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 600px; /* Max width for desktop */
  /* Slightly darkened glass frame for the game area to contrast with bright garden */
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  border-right: 1px solid rgba(255, 255, 255, 0.4);
  border-left: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

/* The Canvas where the game is drawn */
canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* UI Overlay (Start Screen, Game Over, HUD) */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to canvas when playing */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 20; /* Ensure menus are on top of everything */
}

/* Heads Up Display (Score & Lives) */
#hud {
  position: absolute;
  top: 20px;
  left: 0;
  width: 100%;
  padding: 0 25px;
  display: flex;
  justify-content: space-between;
  align-items: center; /* Align items vertically */
  font-size: 20px; /* Slightly smaller base size to fit 3 items */
  font-weight: 800;
  /* White text with strong shadow for visibility over garden */
  color: #ffffff;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s;
}

/* Specific styling for HUD elements */
#score-display {
  min-width: 100px;
  text-align: left;
  font-size: 26px;
}
#lives-display {
  min-width: 100px;
  text-align: right;
  font-size: 26px;
}

/* New High Score Style */
#high-score-display {
  text-align: center;
  font-size: 18px;
  color: #fca311; /* Gold color for high score */
  background: rgba(0, 0, 0, 0.3);
  padding: 5px 15px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Override display for hidden HUD */
#hud.hidden {
  display: none;
}

/* Screens (Start, Game Over) */
.screen {
  /* Glassmorphism Effect */
  background: rgba(
    255,
    255,
    255,
    0.95
  ); /* Increased opacity slightly for better text contrast */
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 40px;
  border-radius: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.8);
  pointer-events: auto; /* Re-enable clicks for buttons */
  transition: opacity 0.3s, transform 0.3s;
  max-width: 85%;
}

.hidden {
  opacity: 0;
  pointer-events: none;
  display: none; /* Completely hide to prevent interference */
}

h1 {
  /* Palette update: Deeper Red/Pink Gradient */
  background: linear-gradient(45deg, #e63946, #d62828);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 3.5rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 2px;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.15));
}

p {
  /* Palette update: Darker slate for better readability */
  color: #1a202c;
  font-size: 1.3rem;
  margin-bottom: 25px;
  font-weight: 700;
}

.score-big {
  font-size: 4rem;
  /* Palette update: Vibrant Orange/Gold */
  color: #fca311;
  margin: 15px 0;
  font-weight: 900;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
  -webkit-text-stroke: 1px #e5e5e5;
}

/* Primary Buttons (Play, Try Again) */
button {
  /* Palette update: Berry/Pink Gradient */
  background: linear-gradient(45deg, #ff416c, #ff4b2b);
  color: white;
  border: none;
  padding: 16px 45px;
  font-size: 1.6rem;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 10px 20px rgba(255, 75, 43, 0.4);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  margin: 10px;
  display: inline-block;
  min-width: 200px; /* Ensure uniform width */
}

button:active {
  transform: scale(0.95);
  box-shadow: 0 5px 10px rgba(255, 75, 43, 0.4);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 25px rgba(255, 75, 43, 0.5);
  background: linear-gradient(
    45deg,
    #ff5e83,
    #ff6347
  ); /* Slightly lighter on hover */
}

/* Secondary Button (Back to Menu) */
#menu-btn {
  /* Palette update: Cool Blue/Purple Gradient */
  background: linear-gradient(45deg, #4776e6, #8e54e9);
  box-shadow: 0 10px 20px rgba(71, 118, 230, 0.4);
  font-size: 1.3rem; /* Slightly smaller than primary actions */
  padding: 14px 40px;
}

#menu-btn:hover {
  box-shadow: 0 15px 25px rgba(71, 118, 230, 0.5);
  background: linear-gradient(45deg, #5a85ee, #9d6bf5);
}

/* Controls hint */
.controls-hint {
  margin-top: 20px;
  font-size: 1rem;
  color: #2d3748;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px 20px;
  border-radius: 20px;
  display: inline-block;
  font-weight: bold;
  border: 1px solid rgba(0, 0, 0, 0.5);
}
