* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Baloo Bhaijaan 2", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.28), transparent 32%),
    linear-gradient(160deg, #4aa8ff 0%, #6fc9ff 38%, #a9e2ff 72%, #fcd7ff 100%);
  color: #2c3e66;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-x: hidden;
}

/* ---------- Background scene (decorations only) ---------- */

.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.sun {
  position: absolute;
  top: 5%;
  right: 7%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe98a, #ffb703 72%);
  box-shadow: 0 0 30px rgba(255, 183, 3, 0.55), 0 0 70px rgba(255, 183, 3, 0.3);
  animation: sun-pulse 6s ease-in-out infinite;
}

.cloud {
  position: absolute;
  background: #ffffff;
  border-radius: 60px;
  opacity: 0.85;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
}

.cloud-1 {
  width: 140px;
  height: 40px;
  top: 8%;
  left: 6%;
  animation: float-drift 9s ease-in-out infinite;
}

.cloud-1::before {
  width: 50px;
  height: 50px;
  top: -24px;
  left: 18px;
}

.cloud-1::after {
  width: 72px;
  height: 72px;
  top: -34px;
  left: 52px;
}

.cloud-2 {
  width: 100px;
  height: 30px;
  top: 17%;
  right: 8%;
  opacity: 0.7;
  animation: float-drift 12s ease-in-out infinite reverse;
}

.cloud-2::before {
  width: 40px;
  height: 40px;
  top: -20px;
  left: 14px;
}

.cloud-2::after {
  width: 54px;
  height: 54px;
  top: -26px;
  left: 40px;
}

.cloud-3 {
  width: 170px;
  height: 45px;
  bottom: 12%;
  left: -30px;
  opacity: 0.55;
  animation: float-drift 14s ease-in-out infinite;
}

.cloud-3::before {
  width: 60px;
  height: 60px;
  top: -28px;
  left: 22px;
}

.cloud-3::after {
  width: 84px;
  height: 84px;
  top: -42px;
  left: 66px;
}

.bubble {
  position: absolute;
  bottom: -40px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.22);
  animation: bubble-rise 12s linear infinite;
}

.bubble-1 {
  left: 12%;
  width: 20px;
  height: 20px;
  animation-duration: 11s;
  animation-delay: 0s;
}

.bubble-2 {
  left: 28%;
  width: 32px;
  height: 32px;
  animation-duration: 14s;
  animation-delay: 2s;
}

.bubble-3 {
  left: 58%;
  width: 24px;
  height: 24px;
  animation-duration: 12s;
  animation-delay: 1s;
}

.bubble-4 {
  left: 78%;
  width: 36px;
  height: 36px;
  animation-duration: 15s;
  animation-delay: 3s;
}

.bubble-5 {
  left: 90%;
  width: 18px;
  height: 18px;
  animation-duration: 13s;
  animation-delay: 4s;
}

/* ---------- Game card ---------- */

.game-container {
  position: relative;
  z-index: 1;
  background: #fffdf6;
  border: 4px solid #ffffff;
  border-radius: 28px;
  box-shadow: 0 12px 30px rgba(31, 90, 160, 0.25), 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 36px 32px;
  width: 100%;
  max-width: 460px;
  animation: card-enter 0.5s ease-out;
}

h1 {
  font-size: 2.4rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 14px;
  background: linear-gradient(90deg, #ff9a3d, #ff5d8f);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.title-star {
  display: inline-block;
  animation: emoji-bob 3s ease-in-out infinite;
}

h1 .title-star:last-child {
  animation-delay: 0.6s;
}

.instructions {
  font-size: 1.15rem;
  line-height: 1.8;
  color: #4a5a78;
  background: #f3f9ff;
  border: 2px dashed #9ecbff;
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 22px;
  text-align: center;
}

.instructions strong {
  color: #ff5d8f;
  font-weight: 800;
}

/* ---------- Form ---------- */

#guess-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

label {
  font-size: 1.15rem;
  font-weight: 700;
  color: #2c3e66;
}

input[type="number"] {
  padding: 14px;
  font-size: 1.6rem;
  font-weight: 700;
  color: #2c3e66;
  text-align: center;
  background: #ffffff;
  border: 3px solid #bfd8ff;
  border-radius: 18px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="number"]:focus {
  outline: none;
  border-color: #ff8a3d;
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.25);
}

button {
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}

#guess-button {
  padding: 16px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, #ffb03d, #ff8a3d);
  box-shadow: 0 6px 0 #e06b14, 0 8px 16px rgba(224, 107, 20, 0.35);
}

#guess-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

#guess-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #e06b14;
}

#guess-button:disabled {
  background: #c7d3e0;
  color: #6b7a90;
  box-shadow: 0 4px 0 #93a4b8;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* ---------- Attempts ---------- */

.attempts {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.attempts p {
  flex: 1;
  padding: 10px 12px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  border-radius: 16px;
}

#attempts-used {
  background: #eaf4ff;
  color: #2563eb;
  border: 2px solid #b7d6ff;
}

#attempts-used::before {
  content: "🎯 ";
}

#attempts-remaining {
  background: #fff7e6;
  color: #b45309;
  border: 2px solid #ffd9a0;
}

#attempts-remaining::before {
  content: "❤️ ";
}

/* ---------- Feedback ---------- */

.feedback {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  padding: 10px;
  border-radius: 18px;
  margin-bottom: 18px;
}

.feedback.high {
  color: #ff8a3d;
  background: #fff4e5;
  animation: pop 0.35s ease;
}

.feedback.high::before {
  content: "⬆️ ";
}

.feedback.low {
  color: #2f8fff;
  background: #eaf4ff;
  animation: pop 0.35s ease;
}

.feedback.low::before {
  content: "⬇️ ";
}

.feedback.win {
  color: #16a34a;
  background: #e6f9ee;
  animation: pop 0.5s ease;
}

.feedback.win::before {
  content: "🎉 ";
}

.feedback.lose {
  color: #e11d48;
  background: #ffeaf0;
  animation: shake 0.4s ease;
}

.feedback.lose::before {
  content: "💪 ";
}

.feedback.invalid {
  color: #b45309;
  background: #fff4e5;
  animation: pop 0.3s ease;
}

.feedback.invalid::before {
  content: "⚠️ ";
}

/* ---------- Restart button ---------- */

.restart-button {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, #4cd08a, #22b573);
  box-shadow: 0 6px 0 #128a4f, 0 8px 16px rgba(18, 138, 79, 0.3);
}

.restart-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.restart-button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #128a4f;
}

/* ---------- Confetti (shown on win) ---------- */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  visibility: hidden;
}

.confetti span {
  position: absolute;
  top: -30px;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  opacity: 0;
}

body:has(.feedback.win) .confetti {
  visibility: visible;
}

body:has(.feedback.win) .confetti span {
  animation: confetti-fall 2.6s ease-in forwards;
}

.confetti span:nth-child(1) { left: 8%;  background: #ff5d8f; animation-delay: 0s; }
.confetti span:nth-child(2) { left: 16%; background: #ffd166; animation-delay: 0.2s; width: 8px; height: 12px; }
.confetti span:nth-child(3) { left: 25%; background: #06d6a0; animation-delay: 0.4s; }
.confetti span:nth-child(4) { left: 33%; background: #4d96ff; animation-delay: 0.6s; width: 12px; height: 10px; }
.confetti span:nth-child(5) { left: 41%; background: #ff8a3d; animation-delay: 0.8s; }
.confetti span:nth-child(6) { left: 49%; background: #b388ff; animation-delay: 1s; width: 8px; height: 8px; border-radius: 50%; }
.confetti span:nth-child(7) { left: 57%; background: #ffd166; animation-delay: 1.2s; }
.confetti span:nth-child(8) { left: 65%; background: #06d6a0; animation-delay: 1.4s; width: 11px; height: 15px; }
.confetti span:nth-child(9) { left: 73%; background: #ff5d8f; animation-delay: 1.6s; }
.confetti span:nth-child(10) { left: 81%; background: #4d96ff; animation-delay: 1.8s; width: 9px; height: 13px; }
.confetti span:nth-child(11) { left: 88%; background: #ff8a3d; animation-delay: 2s; }
.confetti span:nth-child(12) { left: 94%; background: #b388ff; animation-delay: 2.2s; }

/* ---------- Animations ---------- */

@keyframes pop {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes float-drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(30px); }
}

@keyframes bubble-rise {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 0.7; }
  100% { transform: translateY(-110vh); opacity: 0; }
}

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

@keyframes emoji-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes card-enter {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes confetti-fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .game-container {
    padding: 24px 18px;
    border-radius: 22px;
  }

  h1 {
    font-size: 1.9rem;
  }

  input[type="number"] {
    font-size: 1.4rem;
  }

  .feedback {
    font-size: 1.2rem;
  }

  .attempts {
    flex-direction: column;
    gap: 8px;
  }

  .sun {
    width: 60px;
    height: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Back to hub link ---------- */

.back-hub {
  position: fixed;
  top: 14px;
  inset-inline-start: 14px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35em 0.9em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #2c3e66;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(44, 62, 102, 0.22);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.back-hub:hover,
.back-hub:focus-visible {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 7px 18px rgba(44, 62, 102, 0.30);
}