/*
  Resurrection W: Save the Plant
  Customize main colors here.
  charity: water inspired palette: yellow, dark navy/black, white, and light blue.
*/
:root {
  --charity-yellow: #FFC907;
  --charity-blue: #2E9DF7;
  --charity-light-blue: #8BD1CB;
  --charity-green: #4FCB53;
  --charity-orange: #FF902A;
  --charity-red: #F5402C;
  --charity-dark-green: #159A48;
  --charity-pink: #F16061;
  --dark-navy: #111827;
  --white: #ffffff;
  --light-blue: var(--charity-light-blue);
  --clean-blue: var(--charity-blue);
  --dirty-brown: #8b6f47;
  --soft-gray: #f3f4f6;
  --green: var(--charity-green);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--dark-navy);
  background:
    radial-gradient(circle at top left, rgba(139, 211, 255, 0.45), transparent 30%),
    linear-gradient(135deg, var(--charity-yellow), #ffe784 45%, var(--white));
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.game-card {
  width: min(720px, 100%);
  padding: 24px;
  border: 4px solid var(--dark-navy);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 10px 10px 0 rgba(17, 24, 39, 0.18);
  text-align: center;
}

.brand-label {
  display: inline-block;
  margin: 0 0 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--dark-navy);
  color: var(--charity-yellow);
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Official horizontal charity: water logo. Keep proportions with height:auto. */
.cw-logo {
  display: block;
  width: min(210px, 70%);
  height: auto;
  margin: 0 auto 14px;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  line-height: 1;
}

.subtitle {
  margin: 10px 0 0;
  font-size: clamp(1rem, 3vw, 1.25rem);
}

.stats-panel {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 20px 0 12px;
}

.stat-box {
  min-width: 130px;
  padding: 12px 18px;
  border: 3px solid var(--dark-navy);
  border-radius: 14px;
  background: var(--charity-yellow);
  font-size: 1.2rem;
  font-weight: bold;
}

.feedback-text {
  min-height: 28px;
  margin: 8px 0 14px;
  font-weight: bold;
}

.game-area {
  position: relative;
  overflow: hidden;
  height: 420px;
  border: 4px solid var(--dark-navy);
  border-radius: 20px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.1)),
    linear-gradient(to bottom, #dff4ff 0%, #f7fbff 58%, #d8b878 58%, #c99b55 100%);
  touch-action: manipulation;
}

/* This reusable class hides elements when JavaScript adds it. */
.hidden {
  display: none;
}

.plant {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: 150px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 0.4s ease, background 0.4s ease;
  z-index: 1;
}

.plant-emoji {
  font-size: 4.5rem;
  line-height: 1;
  filter: saturate(0.6);
}

.sun {
  font-size: 1.8rem;
}

#plantLabel {
  margin: 4px 0 0;
  font-weight: bold;
}

.plant.healthy {
  transform: translateX(-50%) scale(1.14);
  background: rgba(255, 255, 255, 0.9);
}

.plant.healthy .plant-emoji {
  filter: saturate(1.3);
}

.water-drop {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 3px solid var(--dark-navy);
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  cursor: pointer;
  animation: popIn 0.2s ease, floatDrop 1.6s ease-in-out infinite alternate;
  z-index: 2;
}

.water-drop::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}

.water-drop.clean {
  background: var(--clean-blue);
}

.water-drop.dirty {
  background: var(--dirty-brown);
}

.water-drop.jerry-can {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  animation: popIn 0.2s ease, floatDrop 1.6s ease-in-out infinite alternate;
}

.water-drop.jerry-can::after {
  display: none;
}

/* Jerry Can bonus image: fixed responsive width, original proportions. */
.jerry-can-image {
  display: block;
  width: 54px;
  height: auto;
  pointer-events: none;
}

.water-drop:hover,
.water-drop:focus {
  transform: rotate(-45deg) scale(1.12);
}

.water-drop.jerry-can:hover,
.water-drop.jerry-can:focus {
  transform: translateY(-3px) scale(1.08);
}

.water-drop:active {
  transform: rotate(-45deg) scale(0.9);
}

.water-drop.jerry-can:active {
  transform: translateY(2px) scale(0.96);
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* Center the Start button over the game area before gameplay begins. */
.start-button-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.game-button {
  margin-top: 18px;
  padding: 13px 22px;
  border: 3px solid var(--dark-navy);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.button-row .game-button {
  margin-top: 0;
}

.start-button {
  background: var(--charity-yellow);
  color: var(--dark-navy);
}

.big-start-button {
  min-width: 230px;
  padding: 22px 34px;
  border-width: 4px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffe56b 0%, var(--charity-yellow) 55%, #e0a900 100%);
  color: var(--dark-navy);
  font-size: 1.45rem;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 0 #9b7400, 0 20px 26px rgba(17, 24, 39, 0.35);
}

.reset-button {
  background: var(--dark-navy);
  color: var(--white);
}

.game-button:hover,
.game-button:focus {
  transform: translateY(-2px);
  background: var(--charity-yellow);
  color: var(--dark-navy);
}

.big-start-button:hover,
.big-start-button:focus {
  transform: translateY(-6px);
  box-shadow: 0 16px 0 #9b7400, 0 26px 32px rgba(17, 24, 39, 0.38);
}

.big-start-button:active {
  transform: translateY(6px);
  box-shadow: 0 5px 0 #9b7400, 0 10px 16px rgba(17, 24, 39, 0.3);
}

.game-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: confettiFall 1.8s linear forwards;
  z-index: 5;
}

.result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.72);
  z-index: 20;
}

.result-overlay.hidden {
  display: none;
}

.result-modal {
  width: min(430px, 100%);
  padding: 28px;
  border: 4px solid var(--dark-navy);
  border-radius: 24px;
  background: var(--white);
  text-align: center;
  box-shadow: 10px 10px 0 rgba(255, 201, 7, 0.55);
  animation: modalPop 0.25s ease;
}

.result-modal h2 {
  margin: 0 0 10px;
  font-size: 2rem;
}

.star-rating {
  margin: 10px 0;
  color: var(--charity-yellow);
  font-size: 3rem;
  letter-spacing: 4px;
  text-shadow: 2px 2px 0 var(--dark-navy);
}

.final-score,
.result-message {
  margin: 10px 0;
  font-size: 1.15rem;
  font-weight: bold;
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.modal-buttons .game-button {
  margin-top: 0;
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    scale: 0.3;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes floatDrop {
  from {
    margin-top: 0;
  }
  to {
    margin-top: 8px;
  }
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(460px) rotate(720deg);
    opacity: 0;
  }
}

@media (max-width: 560px) {
  .page-wrapper {
    padding: 12px;
    align-items: flex-start;
  }

  .game-card {
    padding: 16px;
    border-width: 3px;
    border-radius: 18px;
    box-shadow: 6px 6px 0 rgba(17, 24, 39, 0.18);
  }

  .game-area {
    height: 360px;
  }

  .stat-box {
    flex: 1 1 120px;
    min-width: 0;
    padding: 10px;
    font-size: 1rem;
  }

  .water-drop {
    width: 48px;
    height: 48px;
  }

  .jerry-can-image {
    width: 44px;
    height: auto;
  }

  .plant {
    width: 125px;
  }

  .plant-emoji {
    font-size: 3.8rem;
  }

  .game-button {
    width: 100%;
  }

  .start-button-container {
    width: 82%;
  }

  .big-start-button {
    width: 100%;
    min-width: 0;
    padding: 20px 18px;
    font-size: 1.3rem;
  }

  .star-rating {
    font-size: 2.3rem;
  }

  .result-modal {
    padding: 20px;
  }
}