@import url("https://fonts.googleapis.com/css?family=Comfortaa");

html,
body {
  margin: 0;
  overflow: hidden;
  height: 100%;
  width: 100%;
  position: relative;
  font-family: "Comfortaa", cursive;
}

#container {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
  font-size: 2vh; 
}

#container #score {
  position: absolute;
  top: 20px;
  width: 100%;
  text-align: center;
  font-size: 10vh;
  transition: transform 0.5s ease;
  color: #334;
  transform: translatey(-200px) scale(1);
}

#container #game {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

/* --- NEW RESPONSIVE GAME OVER POPUP BOX --- */

#container .game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  
  /* Responsive sizing: It will be 80% of the screen width, but never wider than 500px */
  width: clamp(280px, 80vw, 500px); 
  padding: clamp(20px, 4vh, 40px);
  
  /* Popup Card Styling */
  background-color: #ffffff; 
  border: clamp(2px, 0.5vw, 4px) solid #334;
  border-radius: 15px; /* Gives the box nicely rounded corners */
  box-shadow: 0px 20px 40px rgba(0, 0, 0, 0.3); /* Adds a cool 3D shadow behind the box */
  
  /* Flexbox to neatly center the text inside */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  
  /* Hide the box by default and set up the pop-in animation */
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -30%); /* Starts slightly higher up */
  transition: opacity 0.5s ease, transform 0.5s ease;
  z-index: 10; /* Ensures the popup stays on top of the 3D blocks */
}

#container .game-over h2 {
  margin: 0 0 2vh 0;
  padding: 0;
  font-size: clamp(30px, 6vw, 50px);
  font-weight: 900;
  color: #334;
  text-transform: uppercase;
}

#container .game-over p {
  margin: 1vh 0;
  font-size: clamp(14px, 3vw, 20px);
  color: #334;
  font-weight: bold;
}

/* ------------------------------------------ */

#container .game-ready {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between; 
  padding-top: 30vh;  
  padding-bottom: 10vh; 
  box-sizing: border-box; 
  pointer-events: none; 
}

#container .game-ready #game-title {
  margin: 0; 
  padding: 0;
  font-size: clamp(40px, 8vw, 80px); 
  font-weight: 900; 
  color: #334;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 0;
  transform: translatey(-50px);
}

#container #instructions {
  position: absolute;
  width: 100%;
  top: 16vh;
  left: 0;
  text-align: center;
  transition: opacity 0.5s ease, transform 0.5s ease;
  opacity: 0;
}

#container #instructions.hide {
  opacity: 0 !important;
}

#container.playing #score,
#container.resetting #score {
  transform: translatey(0px) scale(1);
}

#container.playing #instructions {
  opacity: 1;
}

#container.ready .game-ready {
  pointer-events: auto; 
}

#container.ready .game-ready #game-title {
  opacity: 1;
  transform: translatey(0);
}

#container.ended #score {
  transform: translatey(6vh) scale(1.5);
}

/* --- GAME OVER POPUP ANIMATION TRIGGER --- */
#container.ended .game-over {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%); /* Slides perfectly into the center when you lose! */
}

/* --- NEW GAME OVER BUTTONS --- */
#container .game-over-buttons {
  display: flex;
  gap: 20px;
  margin-top: 3vh;
  pointer-events: auto; /* Ensures you can click them */
}

#container .game-over-buttons button {
  border: clamp(2px, 0.5vw, 4px) solid #334;
  padding: 10px 20px;
  background-color: #D0CBC7;
  color: #334;
  font-size: clamp(16px, 4vw, 22px);
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px; /* Slightly rounded button corners */
  transition: background-color 0.2s ease;
  font-family: "Comfortaa", cursive;
}

#container .game-over-buttons button:hover {
  background-color: #b5b0ac; /* Makes the button darker when you hover over it */
}

/* --- SOUND BUTTON STYLING (POPUP UI STYLE) --- */
#sound-button {
  position: absolute;
  top: clamp(15px, 3vh, 30px);
  right: clamp(15px, 3vw, 30px);
  
  /* Made the button slightly larger to act as a proper box */
  width: clamp(40px, 8vw, 60px); 
  height: clamp(40px, 8vw, 60px);
  
  /* Popup Box Styling */
  background-color: #ffffff;
  border: clamp(2px, 0.5vw, 4px) solid #334;
  border-radius: 12px; /* Nicely rounded corners */
  box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.2); /* 3D floating shadow */
  
  /* Centers the icon perfectly inside the box */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(6px, 1.5vw, 10px); 
  box-sizing: border-box;

  cursor: pointer;
  z-index: 20; 
  
  /* Hidden by default on the start screen */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* IMPORTANT: Forces the white SVG icon to be dark so we can see it on the white button! */
#sound-button svg {
  fill: #334 !important;
  width: 100%;
  height: 100%;
}

/* Adds a satisfying "lift" effect when you hover over the button */
#sound-button:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0px 12px 20px rgba(0, 0, 0, 0.3); 
}

/* ONLY show the button when the container has the 'playing' class */
#container.playing #sound-button {
  opacity: 1;
  pointer-events: auto;
}

/* Logic to swap the icons when muted */
#sound-button.muted .icon-on {
  display: none;
}
#sound-button.muted .icon-off {
  display: block !important;
}