:root {
  --pink: #ff6fa5;
  --purple: #8c5cf5;
  --blue: #4dc9ff;
  --teal: #22d3aa;
  --yellow: #ffce3d;
  --orange: #ff9a3d;
  --red: #ff5c5c;
  --green: #3ddc84;
  --dark: #2d2350;
  --card-radius: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Rubik', 'Fredoka', sans-serif;
  background: linear-gradient(160deg, #fff2d6 0%, #ffe0f0 45%, #dcefff 100%);
  color: var(--dark);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
#bg-decor::before, #bg-decor::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  opacity: .35;
  filter: blur(2px);
}
#bg-decor::before {
  width: 260px; height: 260px;
  background: var(--yellow);
  top: -80px; right: -60px;
  animation: floaty 7s ease-in-out infinite;
}
#bg-decor::after {
  width: 200px; height: 200px;
  background: var(--blue);
  bottom: -60px; left: -50px;
  animation: floaty 9s ease-in-out infinite reverse;
}

.deco-shape {
  position: absolute;
  font-size: 2.2rem;
  opacity: .5;
  animation: floaty 6s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-25px) rotate(8deg); }
}

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 14px;
}
.screen.active {
  display: flex;
  animation: screenIn .45s cubic-bezier(.22,1.1,.4,1);
}

@keyframes screenIn {
  from { opacity: 0; transform: scale(.94) translateY(14px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 2.1rem;
  color: var(--purple);
  text-shadow: 2px 2px 0 #fff, 4px 4px 10px rgba(140,92,245,.25);
  margin: 0;
}
.subtitle {
  font-size: 1.1rem;
  color: var(--dark);
  opacity: .75;
  margin: 0 0 10px;
}

.mascot {
  font-size: 5.5rem;
  line-height: 1;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.15));
}
.bounce-idle {
  animation: bounce 2.2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}
.mascot.happy {
  animation: happyPop .6s ease;
}
@keyframes happyPop {
  0% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.3) rotate(-10deg); }
  60% { transform: scale(1.15) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
.mascot.sad {
  animation: sadShake .5s ease;
}
@keyframes sadShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-10px) rotate(-6deg); }
  40% { transform: translateX(10px) rotate(6deg); }
  60% { transform: translateX(-8px) rotate(-4deg); }
  80% { transform: translateX(8px) rotate(4deg); }
}

.speech-bubble {
  background: #fff;
  border: 3px solid var(--purple);
  border-radius: 20px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 1rem;
  color: var(--purple);
  position: relative;
  max-width: 320px;
  transition: all .25s ease;
}

/* buttons */
.big-btn {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  border: none;
  border-radius: 999px;
  padding: 18px 44px;
  cursor: pointer;
  box-shadow: 0 8px 0 #c93f8c, 0 14px 20px rgba(140,92,245,.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.big-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #c93f8c, 0 6px 10px rgba(140,92,245,.35);
}
.big-btn.glow {
  animation: glowPulse 1.8s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 8px 0 #c93f8c, 0 14px 20px rgba(140,92,245,.35); }
  50% { box-shadow: 0 8px 0 #c93f8c, 0 14px 34px rgba(255,111,165,.6); }
}

.small-btn {
  font-family: 'Rubik', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: var(--purple);
  background: #fff;
  border: 2px solid #e6d9ff;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform .12s ease;
}
.small-btn:active { transform: scale(.95); }

.back-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--purple);
  background: #fff;
  border: 2px solid #e6d9ff;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  z-index: 5;
}
.back-btn.small {
  position: static;
  padding: 8px 12px;
  font-size: 1.1rem;
}

/* choice grids */
.choice-grid {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
}
.choice-grid.two { grid-template-columns: 1fr 1fr; }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice-grid.four { grid-template-columns: 1fr 1fr; }

.choice-card {
  background: #fff;
  border: none;
  border-radius: var(--card-radius);
  padding: 22px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 6px 0 #e4d6ff, 0 10px 18px rgba(140,92,245,.18);
  transition: transform .12s ease, box-shadow .12s ease;
}
.choice-card:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #e4d6ff, 0 4px 10px rgba(140,92,245,.18);
}
.choice-card:nth-child(4n+1) { border-bottom: 6px solid var(--pink); }
.choice-card:nth-child(4n+2) { border-bottom: 6px solid var(--blue); }
.choice-card:nth-child(4n+3) { border-bottom: 6px solid var(--teal); }
.choice-card:nth-child(4n+4) { border-bottom: 6px solid var(--orange); }

.choice-emoji { font-size: 2.4rem; }
.choice-label { font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 1.15rem; color: var(--dark); }
.choice-sub { font-size: .8rem; opacity: .6; }
.choice-stars { font-size: .9rem; }

/* game screen */
#screen-game { justify-content: flex-start; padding-top: 18px; }

.game-topbar {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.progress-dots {
  display: flex;
  gap: 6px;
}
.progress-dots .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #e6d9ff;
  transition: background .2s ease, transform .2s ease;
}
.progress-dots .dot.done { background: var(--teal); }
.progress-dots .dot.current { background: var(--purple); transform: scale(1.3); }

.score-pill {
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  color: var(--orange);
  box-shadow: 0 3px 0 #f1e2ff;
}

#screen-game .mascot { font-size: 3.6rem; margin-top: 4px; }

.problem-card {
  direction: ltr;
  background: #fff;
  border-radius: var(--card-radius);
  padding: 22px 30px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'Fredoka', sans-serif;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--dark);
  box-shadow: 0 8px 0 #e4d6ff, 0 14px 22px rgba(140,92,245,.2);
  margin: 10px 0 18px;
}
.op-symbol { color: var(--pink); }
.eq { color: var(--purple); }
.qmark { font-size: 2rem; }

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}
.answer-btn {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 22px 10px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.answer-btn:active { transform: scale(.94); }
.ans1 { background: linear-gradient(135deg, #ff8fb3, var(--red)); box-shadow: 0 6px 0 #c93f5c; }
.ans2 { background: linear-gradient(135deg, #7fd7ff, var(--blue)); box-shadow: 0 6px 0 #2688b8; }
.ans3 { background: linear-gradient(135deg, #6be8c4, var(--teal)); box-shadow: 0 6px 0 #159b78; }
.ans4 { background: linear-gradient(135deg, #ffd97f, var(--orange)); box-shadow: 0 6px 0 #c96f1a; }

.answer-btn { position: relative; }

.answer-btn.correct {
  animation: correctPop .5s ease;
  filter: brightness(1.15);
  outline: 4px solid var(--green);
  outline-offset: 3px;
}
.answer-btn.wrong {
  animation: wrongShake .5s ease;
  filter: brightness(.8) grayscale(.3);
  outline: 4px solid var(--red);
  outline-offset: 3px;
}
.answer-btn.dim { opacity: .5; pointer-events: none; }

.badge {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
  animation: badgePop .35s ease;
}
.answer-btn.correct .badge { color: var(--green); }
.answer-btn.wrong .badge { color: var(--red); }

@keyframes badgePop {
  0% { transform: scale(0); }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes correctPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); }
  100% { transform: scale(1.05); }
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

/* results screen */
.results-stars {
  font-size: 3rem;
  animation: starsIn .6s ease;
}
@keyframes starsIn {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.2) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.results-detail {
  font-size: 1.1rem;
  opacity: .75;
}
.results-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* confetti */
#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  opacity: .9;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to {
    transform: translateY(110vh) rotate(540deg);
    opacity: .2;
  }
}

@media (max-width: 420px) {
  .title { font-size: 1.6rem; }
  .mascot { font-size: 4rem; }
  .problem-card { font-size: 2rem; padding: 16px 20px; gap: 10px; }
  .answer-btn { font-size: 1.4rem; padding: 18px 8px; }
  .big-btn { font-size: 1.15rem; padding: 14px 34px; }
}
