/* style.css */
html, body {
  width: 100vw;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: sans-serif;
  background-color: #a3c2d1; /* Charity: Water blue */
  overflow: hidden;
}

#game-container {
  max-width: 100vw;
  min-width: 0;
  overflow-x: hidden;
  height: 100svh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@supports not (height: 100svh) {
  #game-container {
    height: 100dvh;
  }
}

#game-area {
  flex-grow: 1;
  width: 100vw;
  max-width: 100vw;
  position: relative;
  overflow: hidden;
  touch-action: none;
  min-height: 0;
}

header {
  text-align: center;
  color: #2c3e50;
  width: 100%;
  padding: 1rem;
  position: relative;
}

header h1 {
  white-space: nowrap;
  font-size: min(2.2rem, 7vw);
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

#status-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-top: 0.5rem;
  font-weight: bold;
  color: #264b7a;
  flex-wrap: nowrap;
  font-size: min(1.2rem, 4vw);
  width: 100%;
  min-width: 0;
  max-width: 100vw;
}

#status-bar > div, #goal-points {
  white-space: nowrap;
  min-width: 0;
  max-width: 100vw;
  flex-shrink: 1;
  overflow: visible;
}

@media (max-width: 900px) {
  #status-bar {
    font-size: 1rem;
  }
}
@media (max-width: 600px) {
  #status-bar {
    font-size: min(0.7rem, 3vw);
    flex-direction: row !important;
    gap: 0.2rem;
    flex-wrap: nowrap;
  }
}
@media (max-width: 400px) {
  #status-bar {
    font-size: min(0.5rem, 2.5vw);
  }
}

#charity-logo {
  position: absolute;
  top: 10px;
  right: 10px;
  height: min(90px, 13vw);
  max-width: min(38vw, 150px);
}

@media (max-width: 900px) {
  #charity-logo {
    height: min(65px, 10vw);
    max-width: min(50vw, 110px);
  }
}
@media (max-width: 600px) {
  #charity-logo {
    height: min(44px, 9vw);
    max-width: min(70vw, 80px);
  }
}
@media (max-width: 400px) {
  #charity-logo {
    height: min(30px, 7vw);
    max-width: min(50vw, 50px);
  }
}

#bucket {
  position: absolute;
  bottom: 10px;
  width: 60px;
  height: auto;
  left: 50%;
  transform: translateX(-50%);
  max-width: 18vw;
}

.droplet {
  position: absolute;
  width: 20px;
  height: 30px;
  pointer-events: none;
}

.clean {
  background: url('images/clean\ raindrop.png') no-repeat center / contain;
}

.dirty {
  background: url('images/dirty\ raindrop.png') no-repeat center / contain;
}

#title-screen, #success-screen, #fail-screen, #congrats-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #a3c2d1;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2vw;
}

#title-screen-title, #success-title, #fail-title, #congrats-title {
  color: #2c3e50;
  font-size: min(3rem, 9vw);
  margin-bottom: 2rem;
  text-align: center;
  word-break: break-word;
}

#start-btn, #reset-btn, #quit-btn, #success-reset-btn, #success-quit-btn, #fail-reset-btn, #fail-quit-btn, #next-level-btn, #congrats-reset-btn, #congrats-quit-btn, #success-reset-level-btn, #success-reset-game-btn, #congrats-reset-level-btn, #congrats-reset-game-btn {
  background: #3fa9f5; /* Raindrop blue */
  color: #fff;
  border: none;
  border-radius: 1.5rem;
  padding: 1rem 3rem;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(44,62,80,0.08);
  transition: background 0.2s;
  margin-bottom: 1rem;
  margin-top: 0;
  display: block;
  margin-left: auto;
  margin-right: auto;
  max-width: 90vw;
}

#start-btn:hover, #start-btn:focus,
#reset-btn:hover, #reset-btn:focus,
#quit-btn:hover, #quit-btn:focus,
#success-reset-btn:hover, #success-reset-btn:focus,
#success-quit-btn:hover, #success-quit-btn:focus,
#fail-reset-btn:hover, #fail-reset-btn:focus,
#fail-quit-btn:hover, #fail-quit-btn:focus,
#next-level-btn:hover, #next-level-btn:focus,
#congrats-reset-btn:hover, #congrats-reset-btn:focus,
#congrats-quit-btn:hover, #congrats-quit-btn:focus,
#success-reset-level-btn:hover, #success-reset-level-btn:focus,
#success-reset-game-btn:hover, #success-reset-game-btn:focus,
#congrats-reset-level-btn:hover, #congrats-reset-level-btn:focus,
#congrats-reset-game-btn:hover, #congrats-reset-game-btn:focus {
  background: #7fd3ff; /* Lighter blue */
  outline: none;
}

#goal-points {
  color: #264b7a;
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 0;
  align-self: center;
}

/* Align the in-level buttons side by side */
#game-container header > div {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* Stack buttons in overlays */
#success-screen button, #fail-screen button, #congrats-screen button {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.confetti-container {
  pointer-events: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
}
.confetti {
  position: absolute;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  opacity: 0.8;
  animation: confetti-fall 1.5s linear forwards;
}
@keyframes confetti-fall {
  0% {
    transform: translateY(-40px) rotate(0deg);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(300px) rotate(360deg);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  #title-screen-title, #success-title, #fail-title, #congrats-title {
    font-size: min(2.2rem, 7vw);
  }
  #start-btn, #reset-btn, #quit-btn, #success-reset-btn, #success-quit-btn, #fail-reset-btn, #fail-quit-btn, #next-level-btn, #congrats-reset-btn, #congrats-quit-btn, #success-reset-level-btn, #success-reset-game-btn, #congrats-reset-level-btn, #congrats-reset-game-btn {
    font-size: 1.1rem;
    padding: 0.7rem 2rem;
  }
  #bucket {
    width: 40px;
    max-width: 15vw;
  }
  .droplet {
    width: 14px;
    height: 20px;
  }
  #charity-logo {
    height: min(65px, 10vw);
    max-width: min(50vw, 110px);
  }
  #status-bar {
    font-size: 1rem;
  }
}
@media (max-width: 600px) {
  #title-screen-title, #success-title, #fail-title, #congrats-title {
    font-size: min(1.3rem, 5vw);
    margin-bottom: 1rem;
  }
  #start-btn, #reset-btn, #quit-btn, #success-reset-btn, #success-quit-btn, #fail-reset-btn, #fail-quit-btn, #next-level-btn, #congrats-reset-btn, #congrats-quit-btn, #success-reset-level-btn, #success-reset-game-btn, #congrats-reset-level-btn, #congrats-reset-game-btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
  }
  #bucket {
    width: 28px;
    max-width: 18vw;
  }
  .droplet {
    width: 10px;
    height: 14px;
  }
  #charity-logo {
    height: min(44px, 9vw);
    max-width: min(70vw, 80px);
  }
  #status-bar {
    font-size: min(0.7rem, 3vw);
    flex-direction: row !important;
    gap: 0.2rem;
    flex-wrap: nowrap;
  }
  header {
    padding: 0.5rem;
  }
  #game-area {
    min-height: 120px;
  }
}

#difficulty-select {
  display: block;
  margin: 0.5rem auto 1.5rem auto;
  padding: 0.7rem 2rem;
  font-size: 1.2rem;
  border-radius: 1.2rem;
  border: 1px solid #3fa9f5;
  background: #fff;
  color: #2c3e50;
  max-width: 90vw;
  box-shadow: 0 2px 8px rgba(44,62,80,0.04);
  outline: none;
  text-align: center;
}

#difficulty-select:focus {
  border-color: #7fd3ff;
}

/* Footer styles */
footer {
  width: 100%;
  text-align: center;
  position: fixed;
  left: 0;
  bottom: 0;
  background: transparent;
  padding: 0.2rem 0 0.2rem 0;
  z-index: 2001;
  box-shadow: none;
}

/* Charity Water link styles */
.charity-link {
  display: inline-block; /* Only wrap the text, not the full width */
  text-decoration: none;
  color: #264b7a;
  transition: color 0.2s;
  font-size: 0.95rem;
}

.charity-link h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: normal;
}

.charity-link:hover, .charity-link:focus {
  color: #5ec6fa; /* Light blue on hover */
}

/* Import Google Fonts substitutes */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@700&family=Georgia&display=swap');

/* FF Meta Serif substitute for main titles */
#title-screen-title,
header h1,
#success-title,
#fail-title,
#congrats-title {
  font-family: 'Merriweather', serif;
  font-weight: 700;
}

/* Classic serif for all other text */
body,
button,
#status-bar,
#goal-points,
#level,
#score,
#time,
#success-screen button,
#fail-screen button,
#congrats-screen button,
#difficulty-select {
  font-family: 'Georgia', serif;
}

#goal-message {
  display: none;
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-size: min(2.5rem, 8vw);
  color: #2c3e50;
  text-align: center;
  margin-top: 0.2em;
  margin-bottom: 0.2em;
  letter-spacing: 0.08em;
  z-index: 10;
  position: relative;
  filter: drop-shadow(0 2px 8px #7fd3ff88);
  pointer-events: none;
  user-select: none;
  animation: goal-pop 1.2s cubic-bezier(.25,1.7,.5,1.2);
}

@keyframes goal-pop {
  0% { transform: scale(0.7); opacity: 0.2; }
  40% { transform: scale(1.15); opacity: 1; }
  70% { transform: scale(1); }
  100% { transform: scale(1); opacity: 1; }
}

#goal-message-container {
  min-height: 2.5em;
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

#goal-confetti.confetti-container {
  pointer-events: none;
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 11;
}

#congrats-level-scores {
  font-family: 'Georgia', serif;
  font-size: min(1.3rem, 3.8vw);
  color: #2c3e50;
  margin-bottom: 0.5em;
  margin-top: 0.2em;
  text-align: center;
  width: 100%;
  max-width: 320px;
  line-height: 1.3;
  word-break: break-word;
  white-space: normal;
  flex-shrink: 1;
  flex-grow: 1;
  overflow: visible;
}

#congrats-level-scores .level-score-row {
  margin: 0.08em 0;
  font-size: min(1.1em, 3.5vw);
  font-weight: normal;
  letter-spacing: 0.01em;
  white-space: normal;
  word-break: break-word;
  flex-shrink: 1;
  flex-grow: 1;
  overflow: visible;
}
