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

:root {
  --purple:   #7c3aed;
  --purple-l: #a78bfa;
  --pink:     #ec4899;
  --yellow:   #fbbf24;
  --green:    #10b981;
  --red:      #ef4444;
  --blue:     #3b82f6;
  --bg:       #0f0a1e;
  --card:     #1e1340;
  --text:     #f3e8ff;
  --ghost-white: #e0d7ff;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── NAV ──────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--purple);
}

.nav-logo {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--purple-l);
  letter-spacing: 0.05em;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 700;
  transition: color 0.2s;
}

nav a:hover { color: var(--yellow); }

/* ── HERO SECTION ─────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 1rem 3rem;
  background: radial-gradient(ellipse at 50% 30%, #2d1b69 0%, #0f0a1e 70%);
  overflow: hidden;
}

.hero-content { position: relative; z-index: 2; }

.hero h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple-l), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.tagline {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: #c4b5fd;
  line-height: 1.6;
  margin-bottom: 2.5rem;
}

.ghost-label {
  font-size: 0.95rem;
  color: #a78bfa;
  margin-top: 1.5rem;
  line-height: 1.6;
  font-style: italic;
}

.cta-btn {
  display: inline-block;
  margin-top: 2rem;
  padding: 1rem 2.5rem;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 800;
  border-radius: 50px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5);
}

.cta-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.7);
}

/* ── FLOATING STARS ───────────────────────────────────── */
.star {
  position: absolute;
  font-size: 1.8rem;
  animation: float-star 4s ease-in-out infinite;
  z-index: 1;
  user-select: none;
}
.s1 { top: 15%; left: 8%;  animation-delay: 0s;    animation-duration: 5s; }
.s2 { top: 25%; right: 10%; animation-delay: 1s;   animation-duration: 4s; }
.s3 { top: 60%; left: 5%;  animation-delay: 2s;    animation-duration: 6s; }
.s4 { top: 70%; right: 7%; animation-delay: 0.5s;  animation-duration: 4.5s; }
.s5 { top: 40%; left: 85%; animation-delay: 1.5s;  animation-duration: 5.5s; }

@keyframes float-star {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-18px) rotate(20deg); }
}

/* ── GHOST ────────────────────────────────────────────── */
.ghost-wrapper, .game-ghost-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin: 1.5rem auto;
}

.ghost, .game-ghost {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: float-ghost 3s ease-in-out infinite;
  cursor: default;
  user-select: none;
}

.ghost-body {
  width: 90px;
  height: 100px;
  background: var(--ghost-white);
  border-radius: 50px 50px 0 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ghost-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: -8px;
}

.ghost-eye {
  width: 14px;
  height: 14px;
  background: var(--purple);
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.ghost-face {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 60px;
  padding-top: 28px;
}

.ghost-mouth {
  width: 28px;
  height: 14px;
  border-radius: 0 0 14px 14px;
  border: 3px solid var(--purple);
  border-top: none;
  margin-top: -4px;
  flex-basis: 100%;
  margin-left: auto;
  margin-right: auto;
  transition: all 0.3s ease;
}

/* Ghost mood classes */
.ghost.happy .ghost-mouth,
.game-ghost.happy .ghost-mouth {
  border-color: var(--green);
  transform: scaleX(1.2);
}

.ghost.sad .ghost-mouth,
.game-ghost.sad .ghost-mouth {
  border-radius: 14px 14px 0 0;
  border-bottom: none;
  border-top: 3px solid var(--red);
  border-color: var(--red);
  margin-top: 4px;
}

.ghost.happy .ghost-eye,
.game-ghost.happy .ghost-eye {
  background: var(--green);
  transform: scaleY(0.6); /* squinted happy eyes */
}

.ghost.sad .ghost-eye,
.game-ghost.sad .ghost-eye {
  background: var(--red);
}

.ghost-tail {
  display: flex;
  flex-direction: row;
  width: 90px;
}

.ghost-bump {
  flex: 1;
  height: 20px;
  background: var(--ghost-white);
  border-radius: 0 0 50% 50%;
}

.ghost-shadow {
  width: 70px;
  height: 12px;
  background: rgba(124, 58, 237, 0.3);
  border-radius: 50%;
  animation: shadow-pulse 3s ease-in-out infinite;
}

@keyframes float-ghost {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-14px); }
}

@keyframes shadow-pulse {
  0%, 100% { transform: scaleX(1);   opacity: 0.5; }
  50%       { transform: scaleX(0.8); opacity: 0.2; }
}

/* Happy ghost bounce */
@keyframes bounce-happy {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25%       { transform: translateY(-20px) rotate(-8deg); }
  75%       { transform: translateY(-20px) rotate(8deg); }
}

.game-ghost.happy { animation: bounce-happy 0.6s ease 2; }

/* Sad ghost shake */
@keyframes shake-sad {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-8px); }
  80%       { transform: translateX(8px); }
}

.game-ghost.sad { animation: shake-sad 0.5s ease; }

/* ── PLAY SECTION ─────────────────────────────────────── */
.play-section {
  min-height: 100vh;
  padding: 5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse at 50% 80%, #1e1340 0%, #0f0a1e 70%);
}

.play-section h2 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 900;
  color: var(--yellow);
  margin-bottom: 0.75rem;
  text-align: center;
}

.play-intro {
  font-size: 1rem;
  color: #c4b5fd;
  max-width: 520px;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* ── GAME CONTAINER ───────────────────────────────────── */
.game-container {
  background: var(--card);
  border: 2px solid var(--purple);
  border-radius: 24px;
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 0 40px rgba(124, 58, 237, 0.3);
}

/* Ghost speech bubble */
.ghost-speech {
  background: var(--purple);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  position: relative;
  text-align: center;
  margin-top: 0.5rem;
}

.ghost-speech::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: var(--purple);
}

/* ── SCOREBOARD ───────────────────────────────────────── */
.scoreboard {
  display: flex;
  gap: 1.5rem;
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(124, 58, 237, 0.2);
  border: 1px solid var(--purple);
  border-radius: 12px;
  padding: 0.5rem 1.5rem;
}

.score-label {
  font-size: 0.8rem;
  color: var(--purple-l);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-num {
  font-size: 2rem;
  font-weight: 900;
  color: var(--yellow);
}

/* ── PROBLEM ──────────────────────────────────────────── */
.problem-area {
  width: 100%;
}

.problem-box {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--purple-l);
  border-radius: 16px;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  color: #fff;
}

.problem-box .equals { color: var(--purple-l); }
.problem-box .question-mark { color: var(--yellow); }

/* ── ANSWER CHOICES ───────────────────────────────────── */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

.choice-btn {
  padding: 1rem;
  font-size: 1.6rem;
  font-weight: 900;
  border: 3px solid var(--purple);
  border-radius: 16px;
  background: rgba(124, 58, 237, 0.15);
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.choice-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: rgba(124, 58, 237, 0.4);
  border-color: var(--pink);
}

.choice-btn.correct {
  background: rgba(16, 185, 129, 0.3);
  border-color: var(--green);
  color: var(--green);
}

.choice-btn.wrong {
  background: rgba(239, 68, 68, 0.3);
  border-color: var(--red);
  color: var(--red);
}

.choice-btn:disabled { cursor: default; }

/* ── FEEDBACK ─────────────────────────────────────────── */
.feedback {
  font-size: 1.3rem;
  font-weight: 800;
  min-height: 2rem;
  text-align: center;
  transition: all 0.3s;
}

.feedback.correct { color: var(--green); }
.feedback.wrong   { color: var(--red); }

/* ── BUTTONS ──────────────────────────────────────────── */
.start-btn, .next-btn {
  padding: 0.9rem 2.5rem;
  font-size: 1.1rem;
  font-weight: 800;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.next-btn {
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

.start-btn:hover, .next-btn:hover {
  transform: translateY(-2px) scale(1.04);
}

/* ── GAME STATES ──────────────────────────────────────── */
.problem-box.flash-correct {
  animation: flash-green 0.4s ease;
}

.problem-box.flash-wrong {
  animation: flash-red 0.4s ease;
}

@keyframes flash-green {
  0%, 100% { background: rgba(255,255,255,0.05); }
  50%       { background: rgba(16, 185, 129, 0.25); }
}

@keyframes flash-red {
  0%, 100% { background: rgba(255,255,255,0.05); }
  50%       { background: rgba(239, 68, 68, 0.25); }
}

/* ── FOOTER ───────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem;
  color: #6b4fa0;
  font-size: 0.9rem;
  border-top: 1px solid #2d1b69;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 480px) {
  .game-container { padding: 1.25rem; }
  .problem-box { gap: 0.5rem; padding: 1rem; }
  .choice-btn { padding: 0.75rem; font-size: 1.3rem; }
}
