/* CSS Variables for Color Palette */
:root {
  --primary-pink: #E91E63;
  --secondary-pink: #F06292;
  --background-light: #FCF0F5; /* Main body background (used as a gradient stop) */
  --card-background-start: #F8BBD0; /* A lighter pink for the start of the card gradient */
  --card-background-end: #F48FB1;   /* A slightly darker pink for the end of the card gradient */
  --leaderboard-background: rgba(252, 240, 245, 0.4); /* MODIFIED: More transparent background (0.4 alpha) */
  --text-dark: #333333; /* Dark text for questions and general content */
  --text-medium: #555555;
  --border-light: #EEEEEE;
  --border-medium: #D8BFD8; /* Muted lavender-gray for dashed borders */
  --shadow-color: rgba(0, 0, 0, 0.08); /* General box shadows */
  --pink-shadow-color: rgba(240, 98, 146, 0.25); /* Pink shadows for interactive elements */
  --heart-color: #F5A9BC; /* Lighter, ethereal pink for hearts */
  --hover-background: #fce7ef; /* Existing hover color, keeping it consistent */
  --success-button: #4CAF50;
  --success-button-hover: #81C784;
  --disabled-button: #CCCCCC;

  /* New variables for gradient specific colors */
  --gradient-start: #FCF0F5; /* A very pale pink */
  --gradient-middle: #F5A9BC; /* Your heart color, as a gradient stop */
  --gradient-end: #F06292;   /* Your secondary pink */
}

/* General Resets & Body Styling */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Poppins', sans-serif;
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 40px;

  /* --- ANIMATED GRADIENT BACKGROUND --- */
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-middle) 50%, var(--gradient-end) 100%);
  background-size: 400% 400%; /* Make the gradient larger than the viewport to allow for movement */
  animation: gradientShift 7s ease infinite alternate; /* FASTER ANIMATION: Changed duration to 7s */
}

/* Keyframes for the gradient animation */
@keyframes gradientShift {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 0%; }
  100% { background-position: 0% 100%; }
}


/* Card Container */
.card {
  margin-top: 30px;
  background: linear-gradient(135deg, var(--card-background-start) 0%, var(--card-background-end) 100%);
  border-radius: 15px;
  box-shadow: 0 8px 25px var(--pink-shadow-color);
  padding: 35px;
  width: 90%;
  max-width: 550px;
  text-align: center;
  position: relative;
  overflow: hidden; /* Ensure content doesn't spill out */
  z-index: 2; /* Ensure card has a defined z-index (important for stacking context) */
}

/* Headings */
h1 {
  font-family: 'Montserrat', sans-serif;
  color: var(--primary-pink);
  font-size: 2.2em;
  margin: 0 0 10px;
  font-weight: 700;
}

h1::after {
  content: " 💖";
  color: var(--primary-pink);
}

#subtext {
  margin-bottom: 30px;
  color: var(--text-medium);
  font-size: 1.1em;
  line-height: 1.5;
}

/* Progress Bar */
#progress-bar {
  height: 10px;
  background: rgba(255,255,255, 0.3);
  border-radius: 51px;
  overflow: hidden;
  margin: 15px 0 25px;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: white;
  transition: width 0.4s ease-in-out;
}

/* Main Content Area */
#content {
  margin-top: 10px;
  text-align: left;
  width: 100%; /* Important for children to respect this width */
}

#content p {
  font-size: 1.2em;
  margin-bottom: 25px;
  line-height: 1.6;
  color: var(--text-dark);
  font-weight: 600;
}

/* Leaderboard */
#leaderboard {
  margin-top: 20px;
  background: var(--leaderboard-background); /* This will now be more transparent */
  border: 2px dashed var(--border-medium); /* Existing border will be clearly visible */
  padding: 15px;
  border-radius: 10px;
  font-size: 1em;
  box-shadow: inset 0 2px 8px var(--shadow-color);
  width: 90%;
  max-width: 500px;
  box-sizing: border-box;
  margin-bottom: 20px;
  transition: all 0.3s ease-in-out;
  z-index: 2;
}

#leaderboard h3 {
  font-family: 'Montserrat', sans-serif;
  text-align: center;
  color: var(--primary-pink);
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.6em;
  font-weight: 700;
}

#leaderboard ol {
  padding-left: 0;
  list-style: none;
}

#leaderboard li {
  margin-bottom: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-medium);
  font-size: 1.05em;
}
#leaderboard li:last-child {
  border-bottom: none;
}
#leaderboard li span:first-child {
  font-weight: 600;
  color: var(--text-dark);
}
#leaderboard li span:last-child {
  font-weight: 700;
  color: var(--secondary-pink);
}

/* Leaderboard SMALL version for start page */
#leaderboard.small-leaderboard {
  padding: 8px 12px;
  margin-top: 10px;
  margin-bottom: 10px;
  /* Adjusting for wider and shorter */
  width: 90%; /* Make it take up more width responsively */
  max-width: 450px; /* Wider max-width */
  max-height: 220px; /* **Retained from previous desktop adjustment, as it was working** */
  overflow: hidden; /* Ensures no scrollbar */
  font-size: 1em; /* Keep existing font size for small leaderboard */
}

#leaderboard.small-leaderboard h3 {
  font-size: 1.2em;
  margin-bottom: 5px;
}

#leaderboard.small-leaderboard ol {
  padding-right: 0;
}

#leaderboard.small-leaderboard li {
  font-size: 1em;
  margin-bottom: 3px;
  padding: 3px 0;
}

/* Buttons */
button {
  background: white;
  border: none;
  padding: 15px 30px;
  color: var(--primary-pink);
  font-size: 1.1em;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 30px;
  transition: background-color 0.3s ease, transform 0.2s ease;
  width: 100%;
  max-width: 280px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  font-weight: 600;
  letter-spacing: 0.5px;
  z-index: 2;
}

button:hover:not(:disabled) {
  background: var(--hover-background);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255,255,255,0.25);
}

button:disabled {
  background: var(--disabled-button);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Textarea & Text Input */
textarea,
input[type="text"] {
  width: 100%;
  padding: 12px;
  margin-top: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255, 0.5);
  box-sizing: border-box;
  font-size: 1.05em;
  font-family: 'Poppins', sans-serif;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  z-index: 2;
  background-color: rgba(255,255,255,0.1);
  color: var(--text-dark);
}

textarea::placeholder,
input[type="text"]::placeholder {
  color: rgba(0,0,0,0.5);
}

textarea:focus,
input[type="text"]:focus {
  border-color: var(--primary-pink);
  outline: none;
  box-shadow: 0 0 8px rgba(233,30,99,0.5);
}

/* Labels for MCQ/Multi-MCQ */
label {
  display: block;
  margin: 12px 0;
  padding: 12px 15px;
  border: 1px solid rgba(255,255,255, 0.5);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.05em;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  text-align: left;
  z-index: 2;
  color: var(--text-dark);
  background-color: rgba(255,255,255,0.1);
}

label:hover {
  background-color: rgba(255,255,255,0.2);
  border-color: var(--primary-pink);
}

/* Style for actual radio/checkbox inputs */
input[type="radio"],
input[type="checkbox"] {
  margin-right: 12px;
  transform: scale(1.2);
  vertical-align: middle;
  accent-color: var(--primary-pink);
}

/* Specific styling for checked labels */
input[type="radio"]:checked + span,
input[type="checkbox"]:checked + span {
  font-weight: 600;
  color: var(--primary-pink);
}

label input[type="radio"]:checked,
label input[type="checkbox"]:checked {
  /* No direct styling here, handled by general rules or parent label */
}

/* GIF Wrapper */
#gif-wrapper {
  margin-top: 10px;
  width: 90%;
  max-width: 550px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 25px;
  text-align: center;
  position: relative;
  overflow: hidden;
  z-index: 2;
}

#gif-wrapper img {
  max-width: 100%;
  width: 220px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 6px 20px var(--shadow-color);
}

/* Floating Hearts */
#heart-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.heart {
  position: absolute;
  bottom: -50px;
  width: 30px;
  height: 30px;
  transform: rotate(-45deg);
  background-color: var(--heart-color);
  opacity: 0;
  box-shadow: 0 2px 8px var(--heart-color);
}

.heart::before,
.heart::after {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  background-color: var(--heart-color);
  border-radius: 50%;
}

.heart::before {
  top: -15px;
  left: 0;
}

.heart::after {
  top: 0;
  left: 15px;
}

/* Animation */
@keyframes float {
  0% { transform: translateY(0) rotate(-45deg); opacity: 0; }
  10% { opacity: 0.8; }
  90% { opacity: 0.8; }
  100% { transform: translateY(-100vh) rotate(-45deg); opacity: 0; }
}

/* Staggering hearts */
.heart:nth-child(1) { left: 10%; animation: float 10s linear infinite; animation-delay: 0s; }
.heart:nth-child(2) { left: 20%; animation: float 11s linear infinite; animation-delay: 1s; }
.heart:nth-child(3) { left: 30%; animation: float 9s linear infinite; animation-delay: 2s; }
.heart:nth-child(4) { left: 40%; animation: float 12s linear infinite; animation-delay: 3s; }
.heart:nth-child(5) { left: 50%; animation: float 10.5s linear infinite; animation-delay: 4s; }
.heart:nth-child(6) { left: 60%; animation: float 9.5s linear infinite; animation-delay: 0.5s; }
.heart:nth-child(7) { left: 70%; animation: float 11s linear infinite; animation-delay: 1.5s; }
.heart:nth-child(8) { left: 80%; animation: float 8.5s linear infinite; animation-delay: 2.5s; }
.heart:nth-child(9) { left: 5%; animation: float 10s linear infinite; animation-delay: 3.5s; }
.heart:nth-child(10) { left: 95%; animation: float 12.5s linear infinite; animation-delay: 4.5s; }


/* Utility class to hide hearts during quiz */
.hide-hearts {
  display: none !important;
}


/* Media Queries for Responsiveness */
@media (max-width: 600px) {
  .card {
      margin-top: 20px;
      padding: 25px 20px;
  }
  h1 {
      font-size: 1.8em;
  }
  #subtext {
      font-size: 1em;
  }
  #content p {
      font-size: 1.1em;
  }
  button {
      padding: 12px 25px;
      font-size: 1em;
  }
  input[type="text"],
  textarea {
      padding: 10px;
      font-size: 0.95em;
      width: calc(100% - 20px);
  }
  label {
      padding: 10px 12px;
      font-size: 0.95em;
  }
  #leaderboard {
    padding: 15px;
    font-size: 0.9em;
    margin-top: 15px;
  }
  #leaderboard h3 {
      font-size: 1.3em;
  }
  #leaderboard.small-leaderboard {
      padding: 5px 8px;
      margin-top: 8px;
      margin-bottom: 8px;
      /* Adjusting for wider and shorter */
      width: 90%; /* Maintain responsive width */
      max-width: 350px; /* Wider max-width for smaller screens */
      max-height: 180px; /* **GREATLY INCREASED:** Ensure 5 entries + heading are fully visible on mobile, with buffer */
      overflow: hidden; /* Ensures no scrollbar */
      font-size: 0.9em; /* Keep existing font size for small leaderboard */
  }
  #leaderboard.small-leaderboard h3 {
      font-size: 1.1em;
      margin-bottom: 5px;
  }
  #leaderboard.small-leaderboard ol {
      padding-right: 0;
  }
  #leaderboard.small-leaderboard li {
      font-size: 0.9em;
      margin-bottom: 2px;
      padding: 2px 0;
  }
  #gif-wrapper {
      margin-top: 5px;
      margin-bottom: 15px;
  }
  #gif-wrapper img {
      width: 180px;
  }
  /* Smaller hearts on mobile */
  .heart {
      width: 20px;
      height: 20px;
  }
  .heart::before,
  .heart::after {
      width: 20px;
      height: 20px;
  }
  .heart::before {
      top: -10px;
  }
  .heart::after {
      left: 10px;
  }
}

/* NEW: Container for floating images on failure screen */
#floating-image-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none; /* Allows clicks to pass through */
    z-index: 999; /* NEW: Very high z-index to ensure it's on top of everything */
    overflow: hidden; /* Ensures images don't overflow */
    display: none; /* Hidden by default */
}

/* NEW: Style for the individual floating images */
.floating-failure-image {
    position: absolute;
    top: -100px; /* Start above the viewport */
    width: 70px; /* Adjust size of your custom image */
    height: auto;
    opacity: 0; /* Start invisible */
    transform: rotate(0deg); /* Initial rotation */
    animation: fallFailureImage 15s linear infinite; /* Animation name */
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.3)); /* Optional: Add a subtle shadow */
}

/* NEW: Animation for the falling images */
@keyframes fallFailureImage {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.7; } /* Fade in */
    90% { opacity: 0.7; } /* Stay visible */
    100% { transform: translateY(120vh) rotate(360deg); opacity: 0; } /* Move down and rotate, then fade out */
}

/* Media Query for smaller screens (adjust size if needed) */
@media (max-width: 600px) {
    .floating-failure-image {
        width: 40px; /* Smaller image size on mobile */
    }
}