@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --purple:       #9B59B6;
  --purple-light: #C39BD3;
  --purple-pale:  #f5eeff;
  --coral:        #FF6B6B;
  --yellow:       #FFD93D;
  --green:        #6BCB77;
  --blue:         #4D96FF;
  --orange:       #FF922B;
  --pink:         #FF8FAB;
  --teal:         #38D9A9;
  --card:         #ffffff;
  --text:         #2d2044;
  --muted:        #7a6890;
  --radius-lg:    24px;
  --radius-md:    16px;
  --radius-sm:    12px;
  --shadow:       0 4px 20px rgba(155, 89, 182, 0.13);
  --shadow-lg:    0 8px 32px rgba(155, 89, 182, 0.18);
}

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

body {
  font-family: 'Nunito', 'Arial Rounded MT Bold', Arial, sans-serif;
  background: var(--purple-pale);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

button { font-family: inherit; }

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════
   CONFETTI CANVAS
═══════════════════════════════════════ */
#confetti-canvas {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ═══════════════════════════════════════
   HOME SCREEN
═══════════════════════════════════════ */
.home-screen {
  max-width: 580px;
  margin: 0 auto;
  padding: 28px 18px 40px;
  width: 100%;
}

.home-header {
  text-align: center;
  position: relative;
  margin-bottom: 6px;
}

.home-title {
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 900;
  line-height: 1.2;
  background: linear-gradient(135deg, #9B59B6, #FF6B6B, #FF922B);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.earnings-pill {
  display: inline-block;
  background: linear-gradient(135deg, #FFD93D, #FF922B);
  color: white;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 9px 22px;
  border-radius: 999px;
  margin-bottom: 4px;
  box-shadow: 0 3px 10px rgba(255, 146, 43, 0.4);
  letter-spacing: 0.02em;
}

.honeydo-pill {
  display: inline-block;
  background: linear-gradient(135deg, #6BCB77, #38D9A9);
  color: white;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 9px 22px;
  border-radius: 999px;
  margin-bottom: 4px;
  box-shadow: 0 3px 10px rgba(56,217,169,0.4);
  letter-spacing: 0.02em;
}

.daily-pill {
  display: inline-block;
  background: linear-gradient(135deg, #48CAE4, #4D96FF);
  color: white;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 4px;
  box-shadow: 0 2px 8px rgba(77,150,255,0.3);
}
.daily-pill.daily-done {
  background: linear-gradient(135deg, #6BCB77, #38D9A9);
  box-shadow: 0 2px 8px rgba(107,203,119,0.35);
}

.cap-block {
  background: linear-gradient(135deg, #eafaf1, #d5f5e3) !important;
  border-color: #82e0aa !important;
}

.gear-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: white;
  border: 2px solid #e0d0f0;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, background 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.gear-btn:hover { transform: rotate(45deg); background: #f0e8ff; }

.home-sub {
  text-align: center;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 700;
  margin: 14px 0 20px;
}

.back-to-eleanor {
  display: block;
  text-align: center;
  margin-top: 22px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.back-to-eleanor:hover { opacity: 1; }

.category-grid {
  display: grid;
  gap: 13px;
}

.cat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  border: none;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 14px rgba(0,0,0,0.11);
  transition: transform 0.17s cubic-bezier(.34,1.56,.64,1), box-shadow 0.17s;
  color: white;
  position: relative;
  overflow: hidden;
}
.cat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity 0.2s;
}
.cat-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 10px 28px rgba(0,0,0,0.16); }
.cat-card:hover::after { opacity: 1; }
.cat-card:active { transform: translateY(0) scale(0.99); }

.cat-0 { background: linear-gradient(135deg, #FF6B6B 0%, #FF8FAB 100%); }
.cat-1 { background: linear-gradient(135deg, #4D96FF 0%, #48CAE4 100%); }
.cat-2 { background: linear-gradient(135deg, #6BCB77 0%, #38D9A9 100%); }
.cat-3 { background: linear-gradient(135deg, #FF922B 0%, #FFD93D 100%); }
.cat-4 { background: linear-gradient(135deg, #9B59B6 0%, #C39BD3 100%); }

.cat-emoji { font-size: 2rem; flex-shrink: 0; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.15)); }
.cat-info  { flex: 1; min-width: 0; }
.cat-name  { font-size: 1.15rem; font-weight: 800; display: block; }
.cat-count { font-size: 0.82rem; opacity: 0.88; font-weight: 600; display: block; margin-top: 2px; }
.cat-arrow { font-size: 1.2rem; opacity: 0.7; flex-shrink: 0; }

/* ═══════════════════════════════════════
   QUIZ SCREEN
═══════════════════════════════════════ */
.quiz-screen {
  max-width: 580px;
  margin: 0 auto;
  padding: 18px 18px 36px;
  width: 100%;
}

.quiz-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.home-btn {
  background: white;
  border: 2px solid #e0d0f0;
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  padding: 8px 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
  line-height: 1;
}
.home-btn:hover { background: #f0e8ff; transform: scale(1.05); }

.progress-wrap { flex: 1; }
.progress-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.progress-track {
  background: #e0d0f0;
  border-radius: 999px;
  height: 11px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--coral), var(--orange));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
  min-width: 6px;
}

.score-chip {
  background: white;
  border: 2px solid #e0d0f0;
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  font-weight: 900;
  font-size: 0.92rem;
  color: var(--purple);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
  white-space: nowrap;
}

.question-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 30px 24px 24px;
  box-shadow: var(--shadow-lg);
}

.question-text {
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 26px;
  text-align: center;
  min-height: 2.5em;
}

/* Number input */
.num-input-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}
.ans-input {
  font-family: inherit;
  font-size: 2.2rem;
  font-weight: 900;
  width: 150px;
  text-align: center;
  border: 3px solid #d0b0f0;
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--purple);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}
.ans-input::-webkit-outer-spin-button,
.ans-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ans-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(155,89,182,0.18);
}
.ans-input:disabled { background: #f8f5ff; color: #aaa; }

/* Multiple choice */
.choices-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-bottom: 22px;
}

.choice-btn {
  font-size: 1.05rem;
  font-weight: 800;
  border: 3px solid #e0d0f0;
  border-radius: var(--radius-md);
  padding: 15px 10px;
  background: white;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(.34,1.56,.64,1);
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--purple);
  background: #f5eeff;
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(155,89,182,0.18);
}
.choice-btn.selected {
  border-color: var(--purple);
  background: #ede0ff;
  color: var(--purple);
  transform: scale(1.03);
}
.choice-btn.correct-highlight {
  border-color: #27ae60;
  background: #eafaf1;
  color: #1a7a42;
}
.choice-btn.wrong-highlight {
  border-color: #e0b8b8;
  background: #fef9e7;
  color: #8a6000;
}
.choice-btn:disabled { cursor: default; transform: none !important; }

/* Check button */
.check-btn {
  display: block;
  width: 100%;
  font-size: 1.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--purple), #a66cc4);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 5px 16px rgba(155,89,182,0.4);
  letter-spacing: 0.02em;
}
.check-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(155,89,182,0.45);
}
.check-btn:active:not(:disabled) { transform: translateY(0); }
.check-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Feedback */
.feedback-box {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  animation: feedbackIn 0.25s cubic-bezier(.34,1.56,.64,1);
}
.feedback-box.hidden { display: none; }
.fb-correct {
  background: linear-gradient(135deg, #eafaf1, #d5f5e3);
  color: #1a7a42;
  border: 2px solid #82e0aa;
}
.fb-wrong {
  background: linear-gradient(135deg, #fef9e7, #fdebd0);
  color: #7d5a00;
  border: 2px solid #f9e09a;
}

@keyframes feedbackIn {
  from { opacity: 0; transform: scale(0.9) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ═══════════════════════════════════════
   RESULTS SCREEN
═══════════════════════════════════════ */
.results-screen {
  max-width: 500px;
  margin: 0 auto;
  padding: 28px 18px 40px;
  width: 100%;
}

.results-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 36px 26px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border-top: 8px solid;
  animation: cardIn 0.4s cubic-bezier(.34,1.56,.64,1);
}
.results-pass { border-top-color: var(--green); }
.results-fail { border-top-color: var(--purple-light); }

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.results-trophy { font-size: 4rem; margin-bottom: 8px; line-height: 1; }
.results-cat {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 22px;
}

.score-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.score-big { font-size: 3.5rem; font-weight: 900; color: var(--purple); line-height: 1; }
.score-sep { font-size: 1.1rem; color: var(--muted); font-weight: 700; }

.pct-badge {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 900;
  padding: 6px 24px;
  border-radius: 999px;
  margin-bottom: 22px;
  letter-spacing: 0.03em;
}
.pct-pass { background: #eafaf1; color: #1a7a42; border: 2px solid #82e0aa; }
.pct-fail { background: #f5eeff; color: var(--purple); border: 2px solid var(--purple-light); }

.earned-block {
  background: linear-gradient(135deg, #eafaf1, #d5f5e3);
  border: 2px solid #82e0aa;
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 26px;
  font-size: 1.05rem;
  line-height: 1.6;
}
.balance-line { margin-top: 6px; font-size: 0.95rem; color: var(--muted); }

.try-block {
  background: #f5eeff;
  border: 2px solid var(--purple-light);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 26px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
}

.results-btns {
  display: flex;
  gap: 12px;
}

.btn-try {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 3px solid var(--purple);
  background: white;
  color: var(--purple);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.btn-try:hover { background: #f0e8ff; transform: scale(1.02); }

.btn-home {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--purple), #a66cc4);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(155,89,182,0.38);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-home:hover { transform: translateY(-2px); box-shadow: 0 7px 20px rgba(155,89,182,0.45); }

/* ═══════════════════════════════════════
   PARENT SCREEN
═══════════════════════════════════════ */
.parent-screen {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 18px 48px;
  width: 100%;
}

.parent-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.parent-lock-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--purple);
  margin-bottom: 6px;
  text-align: center;
}
.parent-lock-sub {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 18px;
}

.pin-input {
  font-family: inherit;
  font-size: 1.8rem;
  letter-spacing: 0.4em;
  width: 100%;
  text-align: center;
  border: 3px solid #d0b0f0;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  outline: none;
  transition: border-color 0.2s;
}
.pin-input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(155,89,182,0.18); }

.pin-error {
  text-align: center;
  color: #c0392b;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 10px;
  padding: 10px;
  background: #fdf2f2;
  border-radius: var(--radius-sm);
}

.pin-btns {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn-cancel {
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 2px solid #ddd;
  background: white;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s;
}
.btn-cancel:hover { background: #f5f5f5; }

.btn-verify {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--purple);
  color: white;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-verify:hover { opacity: 0.88; }

/* Dashboard */
.parent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.parent-header h2 {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--purple);
}

.parent-balance {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 2px solid #FFD93D;
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 18px;
  color: #7d5a00;
}

.parent-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn-danger {
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  border: 2px solid #e8b8b8;
  background: white;
  color: #c0392b;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #fdf2f2; }

.btn-pin-change {
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  border: 2px solid #d0b0f0;
  background: white;
  color: var(--purple);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-pin-change:hover { background: #f5eeff; }

.change-pin-wrap {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: #f8f0ff;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  animation: feedbackIn 0.2s ease;
}
.change-pin-wrap input { font-size: 1.2rem; letter-spacing: 0.25em; margin: 0; }
.pin-msg { font-size: 0.9rem; font-weight: 700; padding: 8px 12px; border-radius: 8px; }
.pin-msg-ok  { background: #eafaf1; color: #1a7a42; }
.pin-msg-err { background: #fef9e7; color: #7d5a00; }

.history-heading {
  font-size: 1rem;
  font-weight: 900;
  color: var(--purple);
  margin-bottom: 12px;
  padding-top: 4px;
  border-top: 2px solid #f0e8ff;
  padding-top: 16px;
}
.no-history { color: var(--muted); font-size: 0.95rem; text-align: center; padding: 16px; }

.history-table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 420px;
}
.history-table th {
  background: #f0e8ff;
  color: var(--purple);
  font-weight: 800;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}
.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0e8ff;
  vertical-align: middle;
}
.row-pass td:nth-child(4) { color: #1a7a42; font-weight: 700; }
.row-fail td:nth-child(4) { color: var(--muted); }

/* ═══════════════════════════════════════
   UTILITY
═══════════════════════════════════════ */
.hidden { display: none !important; }

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
@media (max-width: 400px) {
  .home-screen, .quiz-screen, .results-screen, .parent-screen {
    padding-left: 12px;
    padding-right: 12px;
  }
  .question-card { padding: 22px 16px 18px; }
  .choice-btn { font-size: 0.95rem; padding: 12px 8px; }
  .score-big { font-size: 2.8rem; }
  .results-btns { flex-direction: column; }
}

@media (min-width: 580px) {
  .home-screen, .quiz-screen, .results-screen, .parent-screen {
    padding-top: 36px;
  }
}
