/* ===== ROOT VARIABLES ===== */
:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --card-bg: #0f3460;
  --white: #ffffff;
  --yellow: #FFE66D;
  --pink: #FF6B6B;
  --teal: #4ECDC4;
  --purple: #A29BFE;
  --green: #55efc4;
  --orange: #fd9644;
  --font-main: 'Nunito', sans-serif;
  --font-title: 'Fredoka One', cursive;
  --radius: 20px;
  --radius-sm: 12px;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ===== STARS BACKGROUND ===== */
.stars-bg {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.star {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0.1; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.4); }
}

/* ===== HEADER ===== */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(15, 52, 96, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid rgba(255,230,109,0.3);
}
.logo {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--yellow);
  letter-spacing: 1px;
}
.score-bar { display: flex; gap: 16px; align-items: center; }
.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 30px;
  padding: 6px 14px;
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--yellow);
}
.streak-box { color: var(--orange); }
.score-icon { font-size: 1rem; }

/* ===== SCREENS ===== */
.screen { display: none; position: relative; z-index: 1; padding-top: 80px; }
.screen.active { display: block; }

/* ===== HOME SCREEN ===== */
#homeScreen { padding: 80px 20px 40px; }

.home-hero {
  text-align: center;
  margin-bottom: 40px;
}
.hero-emoji {
  font-size: 5rem;
  display: block;
  margin-bottom: 16px;
}
.bounce {
  animation: bounceAnim 2s ease-in-out infinite;
}
@keyframes bounceAnim {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}
.hero-title {
  font-family: var(--font-title);
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1.2;
  color: var(--white);
}
.hero-title .highlight {
  color: var(--yellow);
  text-shadow: 0 0 20px rgba(255,230,109,0.5);
}
.hero-sub {
  margin-top: 12px;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.65);
  font-weight: 600;
}

/* ===== MENU GRID ===== */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  max-width: 600px;
  margin: 0 auto 40px;
}
.menu-card {
  background: var(--card-color, #FF6B6B);
  border: none;
  border-radius: var(--radius);
  padding: 28px 18px;
  cursor: pointer;
  color: var(--white);
  text-align: center;
  box-shadow: 0 8px 0 var(--card-shadow, #c0392b), 0 12px 24px rgba(0,0,0,0.3);
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
  overflow: hidden;
}
.menu-card::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 50%;
  height: 100%;
  background: rgba(255,255,255,0.15);
  transform: skewX(-20deg);
  transition: left 0.4s;
}
.menu-card:hover::after { left: 120%; }
.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 0 var(--card-shadow, #c0392b), 0 16px 30px rgba(0,0,0,0.35);
}
.menu-card:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 var(--card-shadow, #c0392b), 0 6px 14px rgba(0,0,0,0.3);
}
.card-emoji { font-size: 3rem; margin-bottom: 10px; }
.card-title {
  font-family: var(--font-title);
  font-size: 1.4rem;
  margin-bottom: 4px;
}
.card-desc { font-size: 0.85rem; opacity: 0.85; font-weight: 600; }

/* ===== BADGES ===== */
.badge-section {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}
.badge-section h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--yellow);
  margin-bottom: 14px;
}
.badges { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.badge-item {
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== GAME SCREEN ===== */
#gameScreen {
  padding: 72px 20px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.back-btn {
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.2);
  color: var(--white);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: 30px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.back-btn:hover { background: rgba(255,255,255,0.22); }
.game-info { flex: 1; text-align: center; }
.game-title-label {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--yellow);
  display: block;
  margin-bottom: 6px;
}
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.progress-bar {
  flex: 1;
  max-width: 180px;
  height: 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--green));
  border-radius: 10px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 10%;
}
#questionNum { font-size: 0.85rem; font-weight: 700; color: rgba(255,255,255,0.7); }
.lives { display: flex; gap: 2px; font-size: 1.2rem; }

/* ===== PANELS ===== */
.panel { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* ===== QUESTION CARD ===== */
.question-card {
  background: linear-gradient(135deg, #0f3460, #1a1a5e);
  border: 3px solid rgba(255,230,109,0.4);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.question-card.pop { animation: questionPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes questionPop {
  from { transform: scale(0.85); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}
.question-text {
  font-family: var(--font-title);
  font-size: clamp(2.4rem, 8vw, 4rem);
  color: var(--white);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ===== ANSWER GRID ===== */
.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 500px;
}
.answer-btn {
  background: linear-gradient(135deg, #1e3799, #0c2461);
  border: 3px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: var(--font-title);
  font-size: 1.8rem;
  padding: 18px 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
  box-shadow: 0 6px 0 rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}
.answer-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #2980b9, #1a5276);
  transform: translateY(-3px);
  box-shadow: 0 9px 0 rgba(0,0,0,0.3);
}
.answer-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}
.answer-btn.correct {
  background: linear-gradient(135deg, #00b894, #00cec9) !important;
  border-color: #55efc4 !important;
  animation: correctPulse 0.5s ease;
}
.answer-btn.wrong {
  background: linear-gradient(135deg, #d63031, #c0392b) !important;
  border-color: #ff7675 !important;
  animation: wrongShake 0.4s ease;
}
.answer-btn:disabled { cursor: not-allowed; }

@keyframes correctPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ===== FEEDBACK MSG ===== */
.feedback-msg {
  font-family: var(--font-title);
  font-size: 1.5rem;
  text-align: center;
  min-height: 2rem;
  transition: all 0.3s;
}
.feedback-correct { color: var(--green); text-shadow: 0 0 15px rgba(85,239,196,0.6); }
.feedback-wrong { color: var(--pink); }

/* ===== CLOCK ===== */
.clock-container {
  display: flex;
  justify-content: center;
  align-items: center;
}
#clockSvg {
  width: min(260px, 70vw);
  height: min(260px, 70vw);
  filter: drop-shadow(0 8px 24px rgba(255,107,107,0.4));
}
.clock-question {
  font-family: var(--font-title);
  font-size: 1.3rem;
  text-align: center;
  color: var(--yellow);
}

/* ===== STATS ===== */
.stats-card {
  background: linear-gradient(135deg, #0f3460, #1a1a5e);
  border: 3px solid rgba(162,155,254,0.4);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  text-align: center;
}
.stats-question {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--purple);
  margin-bottom: 14px;
}
.data-set {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.data-chip {
  background: rgba(162,155,254,0.2);
  border: 2px solid var(--purple);
  border-radius: 10px;
  padding: 10px 18px;
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--white);
  animation: chipPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes chipPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== RESULT SCREEN ===== */
#resultScreen {
  display: none;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 80px 20px 40px;
}
#resultScreen.active { display: flex; }
.result-container {
  background: linear-gradient(135deg, #0f3460, #1a1a5e);
  border: 3px solid rgba(255,230,109,0.3);
  border-radius: 28px;
  padding: 40px 28px;
  text-align: center;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.result-emoji { font-size: 5rem; margin-bottom: 12px; animation: bounceAnim 2s infinite; }
.result-title {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--yellow);
  margin-bottom: 24px;
}
.result-score { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px; }
.score-circle {
  background: rgba(255,230,109,0.15);
  border: 4px solid var(--yellow);
  border-radius: 50%;
  width: 90px;
  height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--yellow);
}
.score-circle small { font-size: 0.9rem; color: rgba(255,230,109,0.7); }
.score-stars { font-size: 2.2rem; letter-spacing: 4px; }
.result-msg {
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  margin-bottom: 16px;
  line-height: 1.5;
}
.result-badge {
  font-size: 1rem;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 24px;
  min-height: 1.5rem;
}
.result-btns { display: flex; gap: 14px; justify-content: center; }
.btn-retry, .btn-home {
  border: none;
  border-radius: 50px;
  padding: 14px 28px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 6px 0 rgba(0,0,0,0.25);
}
.btn-retry {
  background: linear-gradient(135deg, var(--teal), #00b894);
  color: #fff;
}
.btn-home {
  background: linear-gradient(135deg, var(--pink), #c0392b);
  color: #fff;
}
.btn-retry:hover, .btn-home:hover { transform: translateY(-3px); box-shadow: 0 9px 0 rgba(0,0,0,0.25); }
.btn-retry:active, .btn-home:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.25); }

/* ===== CONFETTI ===== */
#confettiContainer {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ===== LIVES EMPTY ===== */
.life-lost { filter: grayscale(1) opacity(0.3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .menu-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-emoji { font-size: 2.2rem; }
  .card-title { font-size: 1.1rem; }
  .answer-btn { font-size: 1.4rem; padding: 14px 8px; }
}
