/* =========================================
   1. GLOBAL & TYPOGRAPHY
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

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

body {
  font-family: 'Poppins', sans-serif;
  /* Rich Animated Background */
  background: linear-gradient(-45deg, #4776E6, #8E54E9, #23d5ab, #23a6d5);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: #2d3436;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
header {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding: 20px 5%;
  text-align: center;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  position: static;
  top: 0;
  z-index: 1000;
  transition: all 0.3s ease;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: #212121;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
  margin-bottom: 3px;
  letter-spacing: -1px;
}

header p {
  color: #212121;
  font-size: 0.6rem;
  font-weight: 400;
}

.player-info {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.header-pill {
  background: rgba(255, 255, 255, 0.25);
  color: #212121;
  padding: 7px 15px;
  border-radius: 45px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  text-decoration: none;
  transition: transform 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
}

.header-pill:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

/* =========================================
   3. MAIN LAYOUT
   ========================================= */
main {
  flex: 1;
  padding: 40px 20px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

/* =========================================
   4. SUBJECT SELECTION
   ========================================= */
#subject-selection {
  width: 100%;
  text-align: center;
  scroll-margin-top: 140px;
}

#subject-selection h2 {
  color: #fff;
  font-size: 2.1rem;
  margin-bottom: 25px;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#subjects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
  padding: 0 10px;
}

#subjects button {
  background: rgba(255, 255, 255, 0.9);
  color: #4776E6;
  border: none;
  padding: 30px 20px;
  border-radius: 20px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

#subjects button:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  background: #fff;
}

/* =========================================
   5. QUIZ AREA (GLASS CARD)
   ========================================= */
#quiz-area {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 800px;
  border: 1px solid rgba(255,255,255,0.8);
  scroll-margin-top: 140px;
  margin-top: 10px; /* Bring it closer to the top when header is static */
  z-index: 10;
  position: relative;
}

/* Timer */
#options-box {
  display: flex; /* Changed from grid to flex for better stability */
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

#options-box button {
  width: 100%;
  min-height: 55px; /* Ensures buttons don't squash vertically */
  display: block;   /* Ensures they take full width */
  word-wrap: break-word; /* Prevents text from leaking out */
  white-space: normal;   /* Allows long questions to wrap to next line */
  width: 100%;
  padding: 18px 25px;
  text-align: left;
  background: #fff;
  border: 2px solid #e1e1e1;
  border-radius: 15px;
  color: #555;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Poppins', sans-serif;
  position: relative;
}

#timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
}

#timer-display {
  font-size: 1.8rem;
  font-weight: 800;
  color: #4776E6;
  background: #f0f3ff;
  padding: 5px 20px;
  border-radius: 12px;
  margin-bottom: 10px;
}

#timer-bar-container {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00b09b, #96c93d);
  border-radius: 10px;
  transition: width 1s linear;
  box-shadow: 0 0 10px rgba(150, 201, 61, 0.5);
}

/* Question */
#question-box {
  font-size: 1.4rem;
  font-weight: 600;
  color: #2d3436;
  margin-bottom: 30px;
  line-height: 1.6;
  padding: 20px;
  background: #f8f9fa;
  border-left: 6px solid #4776E6;
  border-radius: 8px;
}

/* Options */

#options-box button:hover:not(:disabled) {
  border-color: #4776E6;
  background: #eff3ff;
  transform: translateX(5px);
  color: #4776E6;
  box-shadow: 0 4px 10px rgba(71, 118, 230, 0.15);
}

#options-box button:disabled {
  cursor: default;
  opacity: 0.8;
}

/* Correct/Wrong States */
#options-box button.correct {
  background: #d4edda !important;
  border-color: #28a745 !important;
  color: #155724 !important;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(40, 167, 69, 0.3);
}

#options-box button.wrong {
  background: #f8d7da !important;
  border-color: #dc3545 !important;
  color: #721c24 !important;
  font-weight: 700;
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Next Button */
#next-btn {
  margin-top: 25px;
  background: linear-gradient(135deg, #4776E6 0%, #8E54E9 100%);
  color: white;
  border: none;
  padding: 16px 40px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  float: right;
  transition: all 0.3s ease;
  box-shadow: 0 10px 20px rgba(71, 118, 230, 0.3);
}

#next-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 25px rgba(71, 118, 230, 0.4);
}

/* =========================================
   6. RESULT & LEADERBOARD
   ========================================= */
#result-area, #leaderboard-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  padding: 40px;
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
  scroll-margin-top: 140px;
}

#result-area h2 {
  font-size: 2.5rem;
  color: #2d3436;
  margin-bottom: 20px;
}

#final-score {
  font-size: 1.2rem;
  color: #636e72;
}

#restart-btn {
  background: linear-gradient(135deg, #11998e, #38ef7d);
  color: white;
  border: none;
  padding: 18px 50px;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 30px;
  box-shadow: 0 10px 20px rgba(56, 239, 125, 0.3);
  transition: transform 0.2s;
}

#restart-btn:hover {
  transform: scale(1.05);
}

/* Leaderboard List */

#leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  max-height: 400px; 
  overflow-y: auto;
  padding-right: 10px;
}

/* this custom scrolblar for Leaderboard */
#leaderboard-list::-webkit-scrollbar {
  width: 8px;
}
#leaderboard-list::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05); 
  border-radius: 4px;
}
#leaderboard-list::-webkit-scrollbar-thumb {
  background: #ccc; 
  border-radius: 4px;
}
#leaderboard-list::-webkit-scrollbar-thumb:hover {
  background: #4776E6; 
}


.leaderboard-row {
  display: grid;
  grid-template-columns: 60px 1fr 100px;
  align-items: center;
  padding: 15px 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  transition: transform 0.2s;
}

.leaderboard-row:hover {
  transform: scale(1.01);
  box-shadow: 0 6px 15px rgba(0,0,0,0.08);
}

.leaderboard-row.current-player {
  background: linear-gradient(90deg, #4776E6, #8E54E9);
  color: white;
}

.leaderboard-row.current-player .player-elo {
  color: white;
}

.rank {
  font-weight: 800;
  font-size: 1.2rem;
}

.player-name {
  text-align: left;
  padding: 0 15px;
  font-weight: 500;
}

.player-elo {
  font-weight: 700;
  color: #4776E6;
}

/* =========================================
   7. WELCOME MODAL OVERLAY
   ========================================= */
#welcome-overlay {
  position: fixed;
  top: 0; 
  left: 0;
  /* CHANGED: Make it cover the full screen */
  width: 100%; 
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  /* CHANGED: Higher Z-Index than header (header is 1000) */
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#welcome-modal {
  background: #fff;
  border-radius: 30px;
  padding: 40px; /* Reduced padding slightly */
  max-width: 600px;
  width: 100%;
  position: relative;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  
  /* ADDED: Scroll handling for long content */
  max-height: 90vh; /* Never taller than 90% of screen */
  overflow-y: auto; /* Add scrollbar inside modal if text is too long */
}

/* Custom Scrollbar for the modal */
#welcome-modal::-webkit-scrollbar {
  width: 8px;
}
#welcome-modal::-webkit-scrollbar-track {
  background: #f1f1f1; 
  border-radius: 4px;
}
#welcome-modal::-webkit-scrollbar-thumb {
  background: #c1c1c1; 
  border-radius: 4px;
}
#welcome-modal::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8; 
}

@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#welcome-modal h2 {
  font-size: 1.5rem;
  color: #2d3436;
  margin-bottom: 10px;
}

.welcome-subtitle {
  color: #4776E6;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Better responsiveness */
  gap: 15px;
  margin: 25px 0;
}

.welcome-feature-item {
  background: #f8f9fa;
  padding: 15px; /* Reduced padding */
  border-radius: 16px;
  transition: transform 0.3s;
  border: 1px solid #eee;
}

.welcome-feature-item:hover {
  transform: translateY(-5px);
  background: #fff;
  box-shadow: 0 10px 20px rgba(0,0,0,0.05);
  border-color: #4776E6;
}

.welcome-feature-item h4 {
  color: #2d3436;
  margin-bottom: 5px;
  font-size: 0.95rem; /* Adjusted size */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.welcome-feature-item p {
  font-size: 0.75rem;
  color: #636e72;
}

.welcome-cta {
    margin-top: 20px;
}

#close-welcome-btn {
  background: linear-gradient(135deg, #FF8008, #FFC837);
  color: white;
  border: none;
  padding: 16px 45px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(255, 128, 8, 0.3);
  transition: transform 0.2s;
  margin-top: 15px;
}

#close-welcome-btn:hover {
  transform: translateY(-3px) scale(1);
}


/* =========================================
   8. INFO FOOTER
   ========================================= */
/* Update this part in SECTION 8 */

.info-footer {
  background: #fff;
  padding: 30px; /* Reduced from 50px */
  border-radius: 20px;
  width: 100%;
  max-width: 1000px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  margin: 30px auto 0 auto; /* Tighter margins */
  text-align: center;
}

.info-header h2 {
  font-size: 1.8rem; /* Slightly smaller for better fit */
  color: #2d3436;
  margin-bottom: 5px;
}

.info-header p {
  color: #636e72;
  margin-bottom: 25px; /* Reduced from 40px */
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px; /* Reduced gap */
  margin-bottom: 25px;
}

.feature-card {
  background: rgba(248, 249, 250, 0.5);
  padding: 20px; /* Reduced padding inside cards */
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  transition: transform 0.3s ease;
  border: 1px solid rgba(0,0,0,0.05);
}

.feature-card .icon {
  font-size: 2rem; /* Smaller icon */
  margin-bottom: 10px;
}


.info-footer h3, .info-footer h4 {
  color: #2d3436;
  margin-bottom: 15px;
}

.info-footer h3 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 30px;
}

.info-section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.highlight-box {
  background: #eef2ff;
  border-left: 5px solid #4776E6;
  padding: 20px;
  margin: 20px 0;
  border-radius: 0 12px 12px 0;
}

.cta-final {
  text-align: center;
  background: linear-gradient(135deg, #4776E6, #8E54E9);
  padding: 30px;
  border-radius: 16px;
  color: white;
  font-weight: 600;
  margin-top: 30px;
}

.cta-final p {
    color: white !important;
}

.info-header h3 {
  font-size: 2rem;
  color: white;
  margin-bottom: 10px;
}

.feature-card.highlight {
  background: white;
  border: 2px solid #4776E6;
}

.feature-card:hover {
  transform: translateY(-10px);
}

.feature-card h4 {
  color: #2d3436;
  margin-bottom: 10px;
  font-weight: 700;
}

.feature-card p {
  font-size: 0.9rem;
  color: #636e72;
  line-height: 1.6;
}

.mission-statement {
  background: dimgray;
  padding: 20px;
  border-radius: 15px;
  color: white;
  font-size: 0.95rem;
}

/* =========================================
   9. FOOTER
   ========================================= */
footer {
  text-align: center;
  padding: 25px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  background: rgba(0,0,0,0.2);
}

/* =========================================
   10. MOBILE RESPONSIVENESS (UPDATED)
   ========================================= */
@media (max-width: 768px) {
  

  
}


@media (max-width: 768px) {
  /* Global spacing reductions */
  main { 
    padding: 20px 10px; 
    margin-top: 10px;
  }
  
  header {
    padding: 15px 5%;
  }

  header h1 { 
    font-size: 1.8rem; 
  }

  /* Compact Leaderboard & Results */
  #result-area, #leaderboard-section {
    padding: 20px; /* Reduced from 40px */
  }

  .leaderboard-row { 
    grid-template-columns: 40px 1fr 60px; /* Tighter columns */
    font-size: 0.85rem; 
    padding: 10px;
  }

  #leaderboard-list {
    max-height: 300px; /* Shorter list on mobile */
  }

  /* Compact Info Footer on Mobile */
  .info-footer {
    padding: 20px 15px; /* Very tight padding */
    margin-top: 20px;
  }
  
  .info-header h2 {
    font-size: 1.5rem;
  }

  .feature-card {
    padding: 15px;
  }

  /* Quiz Area Adjustments */
  #quiz-area {
    padding: 15px; /* Tighter padding for more button space */
    width: 95%;    /* Use more of the screen width */
  }
  
  #question-box {
    font-size: 1.1rem;
    padding: 15px;
  }

  #options-box button {
    padding: 12px 15px;
    font-size: 0.9rem;
    line-height: 1.4;
  }
  
  #subjects button { 
    padding: 20px; 
  }
}
