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

:root {
  --shadow: 0 6px 24px rgba(0,0,0,0.13);
  --radius: 28px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #FFF9F0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: scale(0.97);
  overflow: hidden;
}
.screen.active {
  opacity: 1; pointer-events: all;
  transform: scale(1);
}

/* ===== HOME ===== */
#screen-home {
  background: linear-gradient(160deg, #FFF9F0 0%, #FFE8F4 100%);
  padding: 20px 16px 24px;
  overflow-y: auto;
}

.home-header {
  text-align: center;
  padding: 12px 0 20px;
}
.home-title {
  font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 900;
  color: #E91E8C;
  text-shadow: 3px 3px 0 rgba(233,30,140,0.15);
  letter-spacing: -0.5px;
}
.home-sub {
  font-size: clamp(1rem, 4vw, 1.3rem);
  color: #aaa;
  margin-top: 6px;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 500px;
  margin: 0 auto;
}

.cat-btn {
  background: linear-gradient(145deg, var(--c1), var(--c2));
  border: none;
  border-radius: var(--radius);
  padding: clamp(16px, 5vw, 24px) 12px;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  box-shadow: var(--shadow);
  transition: transform 0.13s ease, box-shadow 0.13s ease;
  color: white;
}
.cat-btn:active {
  transform: scale(0.91);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.cat-icon { font-size: clamp(2.5rem, 11vw, 3.8rem); line-height: 1; }
.cat-name { font-size: clamp(1.3rem, 5.5vw, 1.9rem); font-weight: 900; }
.cat-desc { font-size: clamp(0.7rem, 2.8vw, 0.9rem); opacity: 0.85; }

/* wide button spans both columns */
.cat-btn--wide {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 14px;
  padding: clamp(14px, 4vw, 20px) 12px;
}

/* ===== TOP BAR ===== */
.top-bar {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0;
  z-index: 10;
}
.icon-btn {
  background: rgba(0,0,0,0.09);
  border: none; border-radius: 50%;
  width: 46px; height: 46px;
  font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.icon-btn:active { background: rgba(0,0,0,0.2); }
.icon-btn.playing {
  background: #FF9800; color: white;
}
.top-title {
  font-size: clamp(1rem, 4.5vw, 1.4rem);
  font-weight: 800; color: #444;
  text-align: center; flex: 1;
  padding: 0 8px;
}

/* ===== LEARN CARD ===== */
#screen-learn { background: #F0F4FF; }

.learn-card {
  flex: 1; margin: 10px 12px;
  border-radius: 32px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer;
  position: relative; overflow: hidden;
  background: white;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, background 0.3s ease;
  gap: 10px; padding: 24px 20px 48px;
}
.learn-card:active { transform: scale(0.97); }

.card-main {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  line-height: 1.1; text-align: center;
}
.card-main.pop {
  animation: cardPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.card-label {
  font-size: clamp(1.8rem, 7.5vw, 3rem);
  font-weight: 900; color: #333;
  text-align: center; transition: color 0.3s;
}
.card-sub {
  font-size: clamp(0.95rem, 3.8vw, 1.4rem);
  color: #999; text-align: center;
}
.tap-hint {
  position: absolute; bottom: 14px;
  font-size: clamp(0.7rem, 2.8vw, 0.85rem);
  color: #ccc; pointer-events: none;
}

/* ===== CARD FOOTER ===== */
.card-footer {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 8px 18px 16px;
  flex-shrink: 0; gap: 12px;
}
.nav-btn {
  background: #3D3D3D; color: white;
  border: none; border-radius: 50%;
  width: clamp(52px, 14vw, 68px);
  height: clamp(52px, 14vw, 68px);
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  transition: transform 0.12s, background 0.12s;
  display: flex; align-items: center; justify-content: center;
}
.nav-btn:active { transform: scale(0.88); background: #666; }
.card-counter {
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 700; color: #aaa;
  flex: 1; text-align: center;
}

/* ===== PARTICLES ===== */
.particles {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.particle {
  position: absolute;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  animation: flyUp var(--dur, 0.9s) ease-out forwards;
  opacity: 1;
}
@keyframes flyUp {
  0%   { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-130px) scale(0.4) rotate(45deg); opacity: 0; }
}

/* ===== QUIZ ===== */
#screen-quiz {
  background: linear-gradient(160deg, #FFF9F0, #E8F5E9);
}
.quiz-score {
  font-size: 1.05rem; font-weight: 800;
  background: #FF9800; color: white;
  padding: 6px 16px; border-radius: 999px;
  flex-shrink: 0;
}
.quiz-question {
  text-align: center;
  padding: 18px 20px 8px;
  font-size: clamp(1.2rem, 5.5vw, 1.9rem);
  font-weight: 800; color: #333;
  flex-shrink: 0;
  line-height: 1.3;
}
.quiz-choices {
  flex: 1;
  display: flex; align-items: center;
  justify-content: center;
  gap: clamp(12px, 4vw, 24px);
  padding: 8px 16px;
}
.quiz-choice {
  flex: 1; max-width: 220px;
  aspect-ratio: 1;
  background: white;
  border: 4px solid #e5e5e5;
  border-radius: 28px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
  padding: 12px;
}
.quiz-choice:active { transform: scale(0.93); }
.quiz-choice.correct {
  border-color: #4CAF50; background: #E8F5E9;
  animation: bounce 0.45s ease;
}
.quiz-choice.wrong {
  border-color: #F44336; background: #FFEBEE;
  animation: shake 0.45s ease;
}
@keyframes bounce {
  0%,100% { transform: scale(1); }
  40%      { transform: scale(1.13); }
  70%      { transform: scale(0.96); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-10px); }
  40%     { transform: translateX(10px); }
  60%     { transform: translateX(-7px); }
  80%     { transform: translateX(7px); }
}

.quiz-feedback {
  text-align: center;
  font-size: clamp(1.3rem, 5.5vw, 1.9rem);
  font-weight: 900;
  min-height: 2.2em;
  padding: 4px 20px;
  flex-shrink: 0;
  line-height: 1.3;
}
.quiz-next-btn {
  display: block;
  margin: 8px auto 20px;
  background: #4CAF50; color: white;
  border: none; border-radius: 999px;
  padding: clamp(12px, 3.5vw, 16px) clamp(30px, 8vw, 48px);
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 16px rgba(76,175,80,0.38);
  transition: transform 0.12s;
  flex-shrink: 0;
}
.quiz-next-btn:active { transform: scale(0.94); }

/* ===== COLOUR SCREEN ===== */
#screen-colour {
  background: #FFF8FC;
}

.colour-top-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}

/* Tabs */
.colour-tabs {
  display: flex;
  padding: 8px 12px 0;
  gap: 8px;
  flex-shrink: 0;
}
.colour-tab {
  flex: 1;
  padding: 10px 4px;
  border: none;
  border-radius: 14px 14px 0 0;
  font-size: clamp(0.9rem, 3.8vw, 1.1rem);
  font-weight: 800;
  background: #e8e0f0;
  color: #888;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.colour-tab.active {
  background: white;
  color: #E91E63;
  box-shadow: 0 -3px 10px rgba(0,0,0,0.08);
}

/* Panels */
.colour-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border-radius: 0 0 0 0;
  margin: 0 12px;
  box-shadow: var(--shadow);
}
.colour-panel.active { display: flex; }

/* Paint panel */
.paint-scene-row {
  display: flex;
  justify-content: flex-start;
  gap: clamp(6px, 2.5vw, 14px);
  padding: 8px 12px;
  flex-shrink: 0;
  background: #fdf0f7;
  border-bottom: 2px solid #f0e0f0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.paint-scene-row::-webkit-scrollbar { display: none; }
.scene-btn {
  font-size: clamp(1.5rem, 6.5vw, 2.2rem);
  background: transparent;
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 4px 8px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
.scene-btn.active { border-color: #E91E63; background: #fff; }
.scene-btn:active { transform: scale(0.88); }

.paint-svg-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}
#paint-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Draw panel */
.draw-tools-row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 2.5vw, 12px);
  padding: 8px 12px;
  flex-shrink: 0;
  background: #fdf0f7;
  border-bottom: 2px solid #f0e0f0;
}
.draw-tool {
  font-size: clamp(1.4rem, 5.5vw, 2rem);
  background: transparent;
  border: 3px solid transparent;
  border-radius: 12px;
  padding: 3px 7px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.draw-tool.active { border-color: #E91E63; background: #fff; }
.draw-tool:active { transform: scale(0.88); }

#brush-size {
  flex: 1;
  accent-color: #E91E63;
  height: 6px;
  cursor: pointer;
}

#draw-canvas {
  flex: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

/* Palette */
.colour-palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 2.5vw, 10px);
  padding: clamp(8px, 3vw, 14px) clamp(10px, 4vw, 18px);
  background: #FFF8FC;
  flex-shrink: 0;
}
.palette-swatch {
  width: clamp(32px, 9vw, 46px);
  height: clamp(32px, 9vw, 46px);
  border-radius: 50%;
  border: 4px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.palette-swatch.selected {
  border-color: #333;
  transform: scale(1.22);
}
.palette-swatch:active { transform: scale(0.9); }

