:root {
  --cream: #FFF8E7;
  --sky: #4FB8E8;
  --marigold: #FFA630;
  --leaf: #4CAF6D;
  --berry: #E8506B;
  --ink: #2B2540;
  --paper: #FFFDF6;
  --gold: #F2C94C;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Mukta', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgba(43,37,64,0.08) 1.5px, transparent 0) 0 0/22px 22px,
    linear-gradient(160deg, #D9AF6E 0%, #C9A46A 60%, #BF9A5C 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--paper) 0%, #FFFBF2 100%);
  padding: 12px 20px;
  box-shadow: 0 4px 14px rgba(43,37,64,0.18);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo-badge { font-size: 1.6rem; transform: rotate(-12deg); display: inline-block; }
.topbar-title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--berry);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.star-pill {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--marigold));
  color: white;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
}
.btn-rewards {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--berry);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18);
  transition: transform 0.12s ease;
}
.btn-rewards:hover { transform: translateY(-2px); }
.btn-rewards:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,0.18); }

.corkboard {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px 100px;
}

/* ---------------- Screens ---------------- */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.tagline-center {
  text-align: center;
  color: var(--paper);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 4px 0 26px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ---------------- Wall of pinned charts ---------------- */
.wall {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px 24px;
}
.wall-small { grid-template-columns: repeat(4, 1fr); gap: 20px 16px; margin-bottom: 10px; }
@media (max-width: 700px) {
  .wall { grid-template-columns: 1fr; }
  .wall-small { grid-template-columns: repeat(2, 1fr); }
}

.section-heading {
  font-family: 'Baloo 2', sans-serif;
  color: var(--paper);
  font-size: 1.3rem;
  margin: 30px 0 16px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ---------------- Pehla Kadam prominent card ---------------- */
.pehla-kadam-card {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  background: linear-gradient(120deg, #FFD65C, #FFA630 55%, #FF7A59);
  border: none;
  border-radius: 22px;
  padding: 22px 26px;
  margin-bottom: 30px;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(0,0,0,0.18), 0 14px 24px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}
.pehla-kadam-card:hover { transform: translateY(-3px); }
.pehla-kadam-card:active { transform: translateY(3px); box-shadow: 0 4px 0 rgba(0,0,0,0.18); }
.pk-card-emoji { font-size: 3.4rem; animation: bob 2.4s ease-in-out infinite; }
.pk-card-text { display: flex; flex-direction: column; text-align: left; }
.pk-card-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 1.7rem; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.pk-card-sub { font-family: 'Mukta', sans-serif; font-weight: 600; font-size: 1rem; color: rgba(255,255,255,0.95); margin-top: 2px; }

/* ---------------- Pehla Kadam module screens ---------------- */
.pk-toggle {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 20px;
}
.pk-toggle-btn {
  font-size: 1.8rem;
  background: var(--paper);
  border: 3px solid transparent;
  border-radius: 18px;
  padding: 10px 26px;
  cursor: pointer;
  opacity: 0.55;
  box-shadow: 0 4px 0 rgba(43,37,64,0.15);
}
.pk-toggle-btn.active { opacity: 1; border-color: var(--marigold); }

.pk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 18px;
  max-width: 560px;
  margin: 0 auto;
}
.pk-blob {
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.18), 0 8px 14px rgba(0,0,0,0.15);
  transition: transform 0.12s ease;
}
.pk-blob:hover { transform: scale(1.06); }
.pk-blob.pk-shape-blob {
  background: var(--paper);
  font-size: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pk-bounce { animation: pkPop 0.4s ease; }
@keyframes pkPop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

.pk-progress { font-size: 1.6rem; text-align: center; margin-bottom: 16px; letter-spacing: 4px; }
.pk-celebrate { font-size: 3rem; text-align: center; margin-bottom: 10px; animation: pkPop 0.6s ease; }

#line-canvas {
  background: var(--cream);
  border-radius: 20px;
  border: 4px dashed var(--marigold);
  touch-action: none;
  cursor: crosshair;
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.chart-card {
  position: relative;
  border: none;
  cursor: pointer;
  background: var(--paper);
  border-radius: 14px;
  padding: 34px 20px 24px;
  text-align: center;
  font-family: 'Baloo 2', sans-serif;
  box-shadow: 0 8px 0 rgba(43,37,64,0.18), 0 10px 18px rgba(0,0,0,0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chart-card:hover { transform: translateY(-4px) rotate(0deg) !important; box-shadow: 0 12px 0 rgba(43,37,64,0.18), 0 16px 22px rgba(0,0,0,0.14); }
.chart-card:active { transform: translateY(2px) !important; box-shadow: 0 4px 0 rgba(43,37,64,0.18); }

.chart-1 { transform: rotate(-3deg); border-top: 8px solid var(--sky); }
.chart-2 { transform: rotate(2deg); border-top: 8px solid var(--marigold); }
.chart-3 { transform: rotate(-2deg); border-top: 8px solid var(--leaf); }
.chart-4 { transform: rotate(3deg); border-top: 8px solid var(--berry); }
.chart-mini { padding: 20px 10px 16px; }
.chart-mini .chart-emoji { font-size: 2.2rem; }
.chart-mini .chart-title { font-size: 1.05rem; }
.chart-5 { transform: rotate(-2deg); border-top: 6px solid var(--sky); }
.chart-6 { transform: rotate(2deg); border-top: 6px solid var(--berry); }
.chart-7 { transform: rotate(-1.5deg); border-top: 6px solid var(--leaf); }
.chart-8 { transform: rotate(1.5deg); border-top: 6px solid var(--marigold); }

.pin {
  position: absolute;
  top: -14px; left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.3));
}
.chart-emoji { display: block; font-size: 3rem; margin-bottom: 6px; }
.chart-title { display: block; font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.chart-sub { display: block; font-size: 0.95rem; color: var(--ink); opacity: 0.65; margin-top: 2px; }

.footer-note {
  text-align: center;
  color: var(--paper);
  margin-top: 36px;
  font-size: 0.95rem;
}

/* ---------------- Subject / minigame header ---------------- */
.subject-header {
  background: var(--paper);
  border-radius: 20px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 6px 0 rgba(43,37,64,0.15);
}
.btn-back {
  font-family: 'Mukta', sans-serif;
  font-weight: 600;
  border: none;
  background: var(--cream);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.95rem;
}
#subject-title, #minigame-title {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.8rem;
  margin: 12px 0 14px;
  color: var(--berry);
}
.rewards-total {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.1rem;
  color: var(--ink);
}
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tab-btn {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.05rem;
  border: none;
  background: var(--cream);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.tab-btn:hover { transform: translateY(-1px); }
.tab-btn.active { opacity: 1; background: var(--marigold); color: white; }

.panel { display: none; }
.panel.active { display: block; }

/* ---------------- Flashcard grid (Learn mode) ---------------- */
.flash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}
.flashcard {
  background: var(--paper);
  border: none;
  border-radius: 16px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43,37,64,0.15);
  transition: transform 0.12s ease;
}
.flashcard:hover { transform: translateY(-3px); }
.flashcard:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43,37,64,0.15); }
.flash-letter {
  display: block;
  font-family: 'Baloo 2', sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--sky);
  line-height: 1.1;
}
.flash-emoji { display: block; font-size: 2rem; margin: 4px 0; }
.flash-word { display: block; font-size: 0.9rem; font-weight: 600; opacity: 0.8; }

.category-block { margin-bottom: 26px; }
.category-title {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.3rem;
  color: var(--paper);
  background: var(--leaf);
  display: inline-block;
  padding: 6px 18px;
  border-radius: 999px;
  margin-bottom: 12px;
}

/* ---------------- Game area (Play mode) ---------------- */
.game-box {
  background: var(--paper);
  border-radius: 20px;
  padding: 26px;
  box-shadow: 0 6px 0 rgba(43,37,64,0.15);
  text-align: center;
}
.game-score {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--cream);
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.game-prompt {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 18px;
}
.game-display {
  font-size: 4.5rem;
  font-weight: 800;
  color: var(--berry);
  font-family: 'Baloo 2', sans-serif;
  margin-bottom: 22px;
}
.game-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 14px;
  max-width: 500px;
  margin: 0 auto;
}
.option-btn {
  font-size: 2.4rem;
  font-family: 'Baloo 2', sans-serif;
  background: var(--cream);
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 18px 8px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}
.option-btn:hover { transform: scale(1.05); }
.option-btn.correct { background: var(--leaf); border-color: var(--leaf); color: white; animation: pop 0.35s ease; }
.option-btn.wrong { background: var(--berry); border-color: var(--berry); color: white; animation: shake 0.35s ease; }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback-msg {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.4rem;
  min-height: 34px;
  margin-top: 16px;
}
.feedback-msg.win { color: var(--leaf); }
.feedback-msg.lose { color: var(--berry); }

.btn-primary {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--marigold), #FF8A00);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  cursor: pointer;
  margin-top: 18px;
  box-shadow: 0 5px 0 rgba(0,0,0,0.15);
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }

.btn-secondary {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1rem;
  background: var(--cream);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(43,37,64,0.12);
}
.btn-secondary:active { transform: translateY(2px); box-shadow: none; }

/* ---------------- Level picker ---------------- */
.level-options {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.level-btn {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  background: var(--cream);
  padding: 16px 26px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43,37,64,0.15);
  transition: transform 0.12s ease;
}
.level-btn:hover { transform: translateY(-3px); }
.level-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(43,37,64,0.15); }

/* ---------------- Memory game ---------------- */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1;
  background: var(--sky);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
}
.memory-card.flipped, .memory-card.matched {
  background: var(--paper);
  box-shadow: 0 3px 0 rgba(43,37,64,0.15);
}
.memory-card.matched { opacity: 0.55; cursor: default; }
.memory-card:not(.flipped):not(.matched):hover { transform: scale(1.05); }

/* ---------------- Tracing (Likho) ---------------- */
.trace-letter-label {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 14px;
}
#trace-canvas {
  background: var(--cream);
  border-radius: 16px;
  border: 3px dashed var(--marigold);
  touch-action: none;
  cursor: crosshair;
  max-width: 100%;
}
.trace-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---------------- Rewards page ---------------- */
.rewards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.badge-card {
  background: var(--paper);
  border-radius: 16px;
  padding: 20px 12px;
  text-align: center;
  box-shadow: 0 5px 0 rgba(43,37,64,0.15);
}
.badge-card.locked { opacity: 0.55; }
.badge-card.earned { background: linear-gradient(160deg, #FFFDF6, #FFF3D6); border: 2px solid var(--gold); }
.badge-emoji { display: block; font-size: 2.6rem; margin-bottom: 8px; }
.badge-name { display: block; font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 1rem; }
.badge-desc { display: block; font-size: 0.8rem; opacity: 0.7; margin-top: 4px; }

/* ---------------- Mascot ---------------- */
.mascot-wrap {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.mascot-emoji {
  font-size: 3.2rem;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.mascot-bubble {
  background: var(--paper);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: 'Baloo 2', sans-serif;
  font-size: 0.95rem;
  max-width: 220px;
  text-align: right;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.mascot-bubble.visible { opacity: 1; transform: translateY(0) scale(1); }

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Focus visibility for keyboard nav */
button:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .topbar-title { font-size: 1.1rem; }
  .btn-rewards { font-size: 0.8rem; padding: 7px 10px; }
  #subject-title, #minigame-title { font-size: 1.4rem; }
  .mascot-emoji { font-size: 2.4rem; }
  .mascot-bubble { max-width: 160px; font-size: 0.85rem; }
}
