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

:root {
  --bg-gradient-start: #fef9ef;
  --bg-gradient-end: #e0f7fa;
  --panel-bg: rgba(255, 255, 255, 0.75);
  --panel-border: rgba(255, 182, 73, 0.2);
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --theme-blue: #54a0ff;
  --theme-red: #ff6b6b;
  --theme-yellow: #feca57;
  --theme-green: #48dbfb;
  --theme-orange: #ff9f43;
  --theme-purple: #a29bfe;
  --theme-pink: #fd79a8;
  --success-color: #00b894;
  --error-color: #d63031;
  --font-title: 'Fredoka One', cursive;
  --font-body: 'Nunito', sans-serif;
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-big: 0 20px 60px rgba(0, 0, 0, 0.12);
}

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

body {
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-title);
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px;
  border: 2px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mascot {
  font-size: 2rem;
  animation: wiggle 2s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.app-title-group h1 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--theme-red), var(--theme-yellow), var(--theme-blue), var(--theme-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.app-title-group p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Topic Tabs ── */
.topic-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.topic-tab {
  padding: 8px 16px;
  border-radius: 50px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.topic-tab:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.topic-tab.active {
  background: linear-gradient(135deg, var(--theme-yellow), var(--theme-orange));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 15px rgba(254, 202, 87, 0.4);
}

.topic-tab .tab-emoji {
  margin-right: 4px;
}

/* ── Star Counter ── */
.star-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #fff5d6, #ffeaa7);
  padding: 6px 14px;
  border-radius: 50px;
  border: 2px solid rgba(254, 202, 87, 0.4);
  font-family: var(--font-title);
  font-size: 1rem;
  color: #e17055;
}

.star-icon {
  color: #fdcb6e;
  font-size: 1.2rem;
}

#star-count {
  font-size: 1.1rem;
  min-width: 20px;
  text-align: center;
}

/* ── Main Layout ── */
.main-area {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  flex: 1;
}

@media (max-width: 700px) {
  .main-area {
    grid-template-columns: 1fr;
  }
}

/* ── Lesson Area ── */
.lesson-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lesson-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 24px;
  border: 2px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  padding: 24px;
  text-align: center;
}

.lesson-card .lesson-icon {
  font-size: 4.5rem;
  margin-bottom: 8px;
  display: block;
}

.lesson-card h2 {
  font-size: 2.1rem;
  margin-bottom: 4px;
}

.lesson-card .lesson-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 600;
}

.lesson-card .lesson-prompt {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.lesson-card .lesson-hint {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Big Interactive Display ── */
.big-display {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px;
  min-height: 300px;
}

.big-number {
  font-family: var(--font-title);
  font-size: 9rem;
  color: var(--theme-blue);
  text-shadow: 4px 4px 0 rgba(84, 160, 255, 0.2);
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Large, bare emoji for countable items — no small circle background.
   The emoji itself IS the cow/star/fish at full size, which is much
   easier for a preschooler to see, recognize and tap. */
.count-dot {
  width: clamp(110px, 24vw, 160px);
  height: clamp(110px, 24vw, 160px);
  border-radius: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(4.5rem, 13vw, 7rem);
  line-height: 1;
  cursor: pointer;
  animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transition: all 0.2s ease;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15));
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.count-dot:hover {
  transform: scale(1.08);
}

.count-dot.tapped {
  transform: scale(0.85);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15)) grayscale(0.4);
}

.big-shape {
  font-size: 9rem;
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.big-shape:hover {
  transform: scale(1.1);
}

.color-swatch {
  width: clamp(120px, 24vw, 160px);
  height: clamp(120px, 24vw, 160px);
  border-radius: 24px;
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 4px solid rgba(255,255,255,0.5);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.color-swatch:hover {
  transform: scale(1.1);
}

/* ── Interactive Buttons (big touch targets) ── */
.big-btn-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin: 12px 0;
  width: 100%;
}

.big-btn {
  min-width: clamp(120px, 26vw, 170px);
  height: clamp(120px, 26vw, 170px);
  border-radius: 24px;
  border: 4px solid rgba(255,255,255,0.4);
  font-family: var(--font-title);
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.big-btn:active {
  transform: scale(0.92);
}

.big-btn.correct-highlight {
  box-shadow: 0 0 0 6px var(--success-color), 0 0 30px rgba(0, 184, 148, 0.3);
  animation: celebratePulse 0.6s ease;
}

.big-btn.wrong-highlight {
  box-shadow: 0 0 0 6px var(--error-color), 0 0 30px rgba(214, 48, 49, 0.2);
  animation: shake 0.4s ease;
}

@keyframes celebratePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.big-btn.tiny {
  height: clamp(90px, 18vw, 110px);
  min-width: clamp(90px, 18vw, 110px);
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  padding: 0 16px;
}

/* ── Color buttons for sorting ── */
.color-sort-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 16px 0;
}

.color-drop-zone {
  width: clamp(150px, 32vw, 220px);
  min-height: 190px;
  border-radius: 24px;
  border: 4px dashed rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px;
  gap: 10px;
  transition: all 0.2s ease;
  background: rgba(255,255,255,0.3);
}

.color-drop-zone.drag-over {
  border-color: var(--theme-blue);
  background: rgba(84, 160, 255, 0.1);
}

.color-drop-zone .zone-label {
  font-family: var(--font-title);
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-chip {
  width: clamp(72px, 16vw, 92px);
  height: clamp(72px, 16vw, 92px);
  border-radius: 18px;
  border: 3px solid rgba(255,255,255,0.6);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-chip:hover {
  transform: scale(1.1);
}

.color-chip:active {
  transform: scale(0.9);
}

/* ── Matching Game ── */
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 16px 0;
}

.match-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.match-item {
  padding: clamp(20px, 4.5vw, 30px) clamp(22px, 5.5vw, 34px);
  border-radius: 20px;
  border: 4px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.6);
  font-family: var(--font-title);
  font-size: clamp(1.7rem, 4.6vw, 2.5rem);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.match-item:active {
  transform: scale(0.95);
}

.match-item.selected {
  border-color: var(--theme-blue);
  background: rgba(84, 160, 255, 0.15);
  box-shadow: 0 0 0 4px rgba(84, 160, 255, 0.3);
}

.match-item.matched {
  border-color: var(--success-color);
  background: rgba(0, 184, 148, 0.1);
  opacity: 0.7;
  pointer-events: none;
}

/* ── Progress / Feedback ── */
.feedback-box {
  padding: 18px 24px;
  border-radius: 16px;
  font-family: var(--font-title);
  font-size: 1.4rem;
  text-align: center;
  margin-top: 12px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.feedback-box.correct {
  background: rgba(0, 184, 148, 0.12);
  border: 2px solid var(--success-color);
  color: #00a381;
}

.feedback-box.incorrect {
  background: rgba(214, 48, 49, 0.08);
  border: 2px solid var(--error-color);
  color: #c0392b;
}

.feedback-box .feedback-emoji {
  font-size: 2.1rem;
  margin-right: 8px;
}

/* ── Next / Generate buttons ── */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.btn-next, .btn-generate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 18px 40px;
  border-radius: 50px;
  border: none;
  font-family: var(--font-title);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
}

.btn-next {
  background: linear-gradient(135deg, var(--theme-yellow), var(--theme-orange));
  color: #fff;
  box-shadow: 0 4px 15px rgba(254, 202, 87, 0.4);
}

.btn-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(254, 202, 87, 0.5);
}

.btn-next:active {
  transform: scale(0.97);
}

.btn-generate {
  background: linear-gradient(135deg, var(--theme-purple), var(--theme-pink));
  color: #fff;
  box-shadow: 0 4px 15px rgba(162, 155, 254, 0.4);
}

.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(162, 155, 254, 0.5);
}

.btn-generate:active {
  transform: scale(0.97);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: wait;
  transform: none;
}

/* ── Activity Area (right side / secondary) ── */
.activity-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 2px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
  padding: 20px;
}

.activity-card h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.activity-card .activity-icon {
  font-size: 1.7rem;
}

.activity-card p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ── Song / Audio card ── */
.song-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.song-card:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateX(4px);
}

.song-card .song-icon {
  font-size: 2.4rem;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--theme-pink), var(--theme-purple));
  border-radius: 14px;
  color: #fff;
}

.song-card .song-info {
  flex: 1;
}

.song-card .song-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
}

.song-card .song-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── AI Generated Badge ── */
.ai-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 3px 10px;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--theme-purple), var(--theme-pink));
  color: #fff;
  font-family: var(--font-title);
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 8px;
}

.ai-thinking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.ai-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(162, 155, 254, 0.2);
  border-top-color: var(--theme-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Celebration Overlay ── */
.celebration-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.celebration-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.celebration-content {
  background: #fff;
  border-radius: 32px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow-big);
  animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  max-width: 400px;
  width: 90%;
}

.celebration-content h2 {
  font-size: 2rem;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--theme-yellow), var(--theme-orange), var(--theme-red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.celebration-content p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.celebration-stars {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: float 2s ease-in-out infinite;
}

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

.btn-celebrate {
  padding: 14px 40px;
  border-radius: 50px;
  border: none;
  background: linear-gradient(135deg, var(--theme-yellow), var(--theme-orange));
  color: #fff;
  font-family: var(--font-title);
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(254, 202, 87, 0.4);
}

.btn-celebrate:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(254, 202, 87, 0.5);
}

/* ── Confetti canvas ── */
#confetti-canvas {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 999;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .app-container {
    padding: 8px 10px;
  }

  .app-header {
    padding: 10px 14px;
    gap: 8px;
  }

  .app-title-group h1 {
    font-size: 1.15rem;
  }

  .mascot {
    font-size: 1.5rem;
  }

  .topic-tab {
    padding: 6px 12px;
    font-size: 0.75rem;
  }

  .lesson-card {
    padding: 16px;
  }

  .lesson-card .lesson-icon {
    font-size: 3.6rem;
  }

  .lesson-card h2 {
    font-size: 1.6rem;
  }

  .big-number {
    font-size: 6rem;
  }

  .match-item {
    min-height: 72px;
  }

  .celebration-content {
    padding: 28px 20px;
  }

  .celebration-content h2 {
    font-size: 1.5rem;
  }
}

/* ── Print friendly ── */
@media print {
  .app-header, .celebration-overlay, #confetti-canvas {
    display: none !important;
  }
}
