/* MathQuest styles — bright, chunky, kid-friendly */
:root {
  --sky-1: #7ec8ff;
  --sky-2: #b8e6ff;
  --sun: #ffd966;
  --coral: #ff7b6b;
  --grass: #6ed18a;
  --deep: #2b3a67;
  --ink: #1f2742;
  --paper: #fff8e7;
  --gold: #ffc83d;
  --shadow: 0 6px 0 rgba(0,0,0,0.15);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: "Comic Sans MS", "Chalkboard SE", "Baloo 2", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1), var(--sky-2));
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

/* HUD */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid rgba(0,0,0,0.08);
  z-index: 10;
}
.hud.hidden { display: none; }
.hud-stats { display: flex; gap: 16px; font-size: 22px; font-weight: 700; }
.stat { background: white; padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow); }
.icon-btn {
  background: white;
  border: none;
  font-size: 26px;
  width: 52px; height: 52px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }

/* Screens */
#screens { flex: 1; position: relative; overflow: hidden; }
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}
.screen.active { display: flex; }
.screen-title {
  text-align: center;
  font-size: 32px;
  margin: 8px 0 16px;
  color: var(--deep);
  text-shadow: 2px 2px 0 white;
}

/* Welcome */
.welcome-card {
  margin: auto;
  text-align: center;
  background: var(--paper);
  padding: 36px 28px;
  border-radius: 32px;
  box-shadow: var(--shadow);
  border: 4px solid white;
}
.big-mascot {
  font-size: 96px;
  animation: bounce 1.6s ease-in-out infinite;
}
.welcome-card h1 {
  font-size: 48px; margin: 8px 0; color: var(--coral);
}
.subtitle { font-size: 22px; margin: 0 0 24px; color: var(--deep); }

.primary-btn {
  background: var(--coral);
  color: white;
  border: none;
  font-size: 26px;
  font-weight: 700;
  padding: 16px 36px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #c84e40;
  cursor: pointer;
  font-family: inherit;
  margin: 8px;
}
.primary-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c84e40; }
.text-btn {
  background: transparent; border: none;
  color: var(--deep); font-size: 16px; cursor: pointer;
  text-decoration: underline; margin-top: 12px;
  font-family: inherit;
}

/* Island Map */
.island-map {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  padding: 8px;
}
.island-card {
  background: white;
  border-radius: 24px;
  padding: 20px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 4px solid white;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
}
.island-card:active { transform: scale(0.97); }
.island-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.island-emoji { font-size: 56px; display: block; margin-bottom: 6px; }
.island-name { font-size: 18px; font-weight: 700; margin: 4px 0; }
.island-stars { font-size: 18px; color: var(--gold); }
.island-bar {
  height: 8px; background: #eee; border-radius: 4px;
  overflow: hidden; margin-top: 8px;
}
.island-bar-fill {
  height: 100%; background: var(--grass);
  transition: width 0.4s;
}
.lock-icon {
  position: absolute; top: 8px; right: 10px;
  font-size: 22px;
}
.companion-display {
  text-align: center;
  font-size: 18px;
  padding: 12px;
  background: rgba(255,255,255,0.6);
  border-radius: 16px;
  margin-top: 8px;
}

/* Play */
.play-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.progress-bar {
  flex: 1; height: 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 8px; overflow: hidden;
  border: 2px solid white;
}
#progressFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--grass), #4eb86b);
  transition: width 0.4s;
}
.streak-dots { display: flex; gap: 4px; }
.streak-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: 2px solid white;
}
.streak-dot.correct { background: var(--grass); }
.streak-dot.wrong { background: var(--coral); }

.puzzle-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px;
}

.question-text {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  background: var(--paper);
  padding: 14px 24px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 3px solid white;
}

.tap-objects {
  display: flex; flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 480px;
}
.tap-object {
  font-size: 48px;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.15s;
  background: rgba(255,255,255,0.5);
  border-radius: 16px;
  min-width: 64px; min-height: 64px;
  display: flex; align-items: center; justify-content: center;
}
.tap-object.tapped {
  background: var(--gold);
  transform: scale(1.15);
}
.tap-object:active { transform: scale(0.92); }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 420px;
}
.choice-btn {
  background: white;
  border: 4px solid white;
  border-radius: 20px;
  padding: 20px;
  font-size: 36px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-family: inherit;
  min-height: 88px;
  display: flex; align-items: center; justify-content: center;
}
.choice-btn:active { transform: translateY(2px); }
.choice-btn.correct { background: var(--grass); color: white; animation: pop 0.4s; }
.choice-btn.wrong { background: var(--coral); color: white; animation: shake 0.4s; }
.choice-btn.faded { opacity: 0.3; pointer-events: none; }

.compare-piles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 520px;
}
.compare-pile {
  background: white;
  border: 4px solid white;
  border-radius: 20px;
  padding: 16px;
  min-height: 180px;
  display: flex; flex-wrap: wrap;
  align-content: center; justify-content: center;
  gap: 4px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 28px;
}
.compare-pile:active { transform: scale(0.97); }
.compare-pile.correct { background: var(--grass); }
.compare-pile.wrong { background: var(--coral); }

.confirm-btn {
  background: var(--gold);
  color: var(--ink);
  border: none;
  font-size: 22px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 999px;
  box-shadow: 0 5px 0 #c89a1f;
  cursor: pointer;
  font-family: inherit;
}
.confirm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.confirm-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #c89a1f; }

.pip-reaction {
  font-size: 64px;
  text-align: center;
  position: absolute;
  bottom: 20px; right: 20px;
  pointer-events: none;
  transition: transform 0.3s;
}
.pip-reaction.cheer { animation: cheer 0.6s; }
.pip-reaction.gasp { animation: gasp 0.4s; }

.feedback {
  position: absolute;
  top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 56px;
  font-weight: 900;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 4px 0 rgba(0,0,0,0.2);
}
.feedback.show { animation: feedbackPop 1s ease-out; }
.feedback.good { color: var(--grass); }
.feedback.bad { color: var(--coral); }

/* Reward Screen */
.reward-card {
  margin: auto;
  background: var(--paper);
  padding: 32px;
  border-radius: 32px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 4px solid white;
  max-width: 380px;
  width: 100%;
}
.reward-card h2 { font-size: 36px; color: var(--coral); margin: 0 0 16px; }
.reward-stars {
  font-size: 64px;
  letter-spacing: 8px;
  margin: 16px 0;
  min-height: 70px;
}
.reward-stars .star-empty { opacity: 0.2; }
.reward-stars .star-filled { animation: starPop 0.6s; display: inline-block; }
.reward-items {
  font-size: 20px;
  margin: 12px 0 24px;
}
.reward-items div { margin: 6px 0; }

/* Parent Dashboard */
.parent-content {
  background: var(--paper);
  padding: 20px;
  border-radius: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 3px solid white;
}
.parent-skill {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.parent-skill:last-child { border-bottom: none; }
.skill-rating {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
}
.skill-rating.mastered { background: var(--grass); color: white; }
.skill-rating.learning { background: var(--gold); color: var(--ink); }
.skill-rating.new { background: #ddd; color: #555; }

/* Animations */
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes pop {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
@keyframes cheer {
  0%,100% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.3) rotate(-15deg); }
  75% { transform: scale(1.3) rotate(15deg); }
}
@keyframes gasp {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}
@keyframes feedbackPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.4); }
  30% { opacity: 1; transform: translate(-50%,-50%) scale(1.2); }
  60% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1); }
}
@keyframes starPop {
  0% { transform: scale(0) rotate(-180deg); }
  60% { transform: scale(1.4) rotate(20deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Confetti dot */
.confetti {
  position: absolute;
  width: 10px; height: 14px;
  pointer-events: none;
  animation: confettiFall 1.6s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}
