/* Thiết lập chung cho màn hình cảm ứng Điện thoại / iPad */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background-color: #FFF8E7;
  color: #3D2C2E;
  font-family: "Quicksand", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

/* Khung ứng dụng chính */
.app-shell {
  min-height: 100dvh;
  max-width: 960px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 12px) 16px env(safe-area-inset-bottom, 20px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Thanh hiển thị tổng Sao trên cùng */
.top-bar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background-color: #FFFFFF;
  border: 4px solid #F3E5C8;
  border-radius: 28px;
  box-shadow: 0 6px 0 #EBD7B0;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-badge {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.app-title {
  font-size: clamp(1.15rem, 3.5vw, 1.5rem);
  font-weight: 800;
  color: #4A3531;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background-color: #FFF3B0;
  border: 3px solid #FFFFFF;
  border-radius: 999px;
  box-shadow: 0 4px 0 #F2C94C;
  flex-shrink: 0;
}

.star-icon {
  font-size: 1.85rem;
  line-height: 1;
}

.star-value {
  font-size: 1.65rem;
  font-weight: 900;
  color: #8A5300;
  line-height: 1;
}

/* Vùng nội dung chính */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 0 28px;
}

.welcome-card {
  width: 100%;
  max-width: 460px;
  padding: 36px 24px;
  background-color: #FFFFFF;
  border: 5px solid #F3E5C8;
  border-radius: 36px;
  box-shadow: 0 10px 0 #EBD7B0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.welcome-emoji {
  font-size: 4.5rem;
  line-height: 1;
}

.welcome-heading {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  color: #4A3531;
}

/* Nút bấm khổng lồ cho tay bé 4 tuổi */
.big-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 220px;
  min-height: 84px;
  padding: 18px 32px;
  font-family: inherit;
  font-size: 1.4rem;
  font-weight: 800;
  border: 4px solid #FFFFFF;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.big-btn--primary {
  background-color: #FF8A65;
  color: #FFFFFF;
  box-shadow: 0 8px 0 #D96543, 0 12px 20px rgba(74, 53, 49, 0.12);
}

.big-btn:active {
  transform: translateY(5px);
}

.big-btn--primary:active {
  box-shadow: 0 3px 0 #D96543, 0 5px 10px rgba(74, 53, 49, 0.12);
}

.is-hidden {
  display: none !important;
}

/* Nút Quay lại trên thanh đầu trang */
.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  font-size: 1.7rem;
  background-color: #FFF3B0;
  border: 3px solid #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 4px 0 #E5C158;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.back-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #E5C158;
}

/* Khung màn hình chung */
.screen-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-heading {
  margin: 0;
  text-align: center;
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  font-weight: 800;
  color: #4A3531;
}

/* Lưới 20 thẻ Chủ đề lớn */
.topics-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (min-width: 680px) {
  .topics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (min-width: 900px) {
  .topics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.topic-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 156px;
  padding: 18px 12px;
  background-color: var(--card-tint, #FFE8CC);
  border: 5px solid #FFFFFF;
  border-radius: 30px;
  box-shadow: 0 8px 0 #E5D4B3, 0 10px 18px rgba(74, 53, 49, 0.08);
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.topic-card:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #E5D4B3, 0 5px 10px rgba(74, 53, 49, 0.08);
}

.topic-icon {
  font-size: 3.2rem;
  line-height: 1;
}

.topic-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #3D2C2E;
  line-height: 1.25;
}

.topic-progress {
  padding: 5px 12px;
  background-color: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #7A5C48;
}

/* Màn hình Bản đồ 10 Gói nhỏ */
.map-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background-color: var(--card-tint, #FFE8CC);
  border: 5px solid #FFFFFF;
  border-radius: 30px;
  box-shadow: 0 7px 0 #E5D4B3;
}

.map-banner-icon {
  font-size: 3.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.map-banner-title {
  margin: 0 0 4px;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  font-weight: 800;
  color: #3D2C2E;
}

.map-banner-sub {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #6E5246;
}

.packs-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (min-width: 720px) {
  .packs-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.pack-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 132px;
  padding: 16px 14px;
  border: 5px solid #FFFFFF;
  border-radius: 28px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.pack-card.is-unlocked {
  background-color: #DDF7E3;
  box-shadow: 0 8px 0 #9ED4AA, 0 10px 16px rgba(74, 53, 49, 0.08);
}

.pack-card.is-unlocked:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #9ED4AA;
}

.pack-card.is-locked {
  background-color: #EFE8DA;
  box-shadow: 0 8px 0 #D5C8B2;
  color: #8E7F74;
}

.pack-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pack-number {
  font-size: 1.2rem;
  font-weight: 900;
  color: inherit;
}

.pack-status-icon {
  font-size: 1.65rem;
  line-height: 1;
}

.pack-label {
  font-size: 1rem;
  font-weight: 800;
}

.pack-progress-track {
  width: 100%;
  height: 12px;
  background-color: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  overflow: hidden;
}

.pack-progress-fill {
  height: 100%;
  background-color: #4CAF50;
  border-radius: 999px;
}

/* Hiệu ứng rung nhẹ khi chạm vào gói bị khóa */
@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-2deg); }
  40% { transform: translateX(7px) rotate(2deg); }
  60% { transform: translateX(-5px) rotate(-1deg); }
  80% { transform: translateX(5px) rotate(1deg); }
}

.pack-card.is-shaking {
  animation: lock-shake 0.35s ease;
}

.pack-preview-desc {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #6E5246;
  line-height: 1.45;
}

/* Dòng kiểm chứng dữ liệu góc dưới Trang chủ */
.data-verify-footer {
  align-self: center;
  margin-top: 8px;
  padding: 8px 18px;
  background-color: #FFFFFF;
  border: 3px solid #F3E5C8;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #6E5246;
  text-align: center;
}

/* ===== Lưới 5 thẻ hình từ vựng ===== */
.word-cards-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (min-width: 720px) {
  .word-cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }
}

.word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 12px 18px;
  background-color: #FFFFFF;
  border: 5px solid #F3E5C8;
  border-radius: 30px;
  box-shadow: 0 8px 0 #EBD7B0, 0 12px 20px rgba(74, 53, 49, 0.08);
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.word-card:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #EBD7B0, 0 5px 10px rgba(74, 53, 49, 0.08);
}

/* Vùng ảnh thẻ hình */
.word-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #FFF8E7;
  border: 4px solid #F3E5C8;
  border-radius: 22px;
  overflow: hidden;
}

.word-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.word-card-img.is-loaded {
  opacity: 1;
}

.word-card-img.is-hidden {
  display: none;
}

/* Hình dự phòng: emoji nét to trên nền kem trơn */
.word-card-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  line-height: 1;
  background-color: #FFF8E7;
}

.word-card-fallback.is-hidden {
  display: none;
}

/* Tên từ tiếng Anh */
.word-card-en {
  font-size: 1.35rem;
  font-weight: 900;
  color: #4A3531;
  line-height: 1.2;
}

/* Nghĩa tiếng Việt */
.word-card-vi {
  font-size: 1.05rem;
  font-weight: 700;
  color: #7A5C48;
  line-height: 1.25;
}

/* Nút nghe phát âm */
.word-card-speak {
  font-size: 1.8rem;
  line-height: 1;
  padding: 6px;
}

/* Hiệu ứng nảy vui mắt khi chạm nghe phát âm */
@keyframes card-bounce {
  0% { transform: scale(1); }
  25% { transform: scale(1.08); }
  50% { transform: scale(0.95); }
  75% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.word-card.is-bouncing {
  animation: card-bounce 0.4s ease;
}

/* ===== Trò chơi 1: Lật thẻ Ú Òa - Hộp quà rung rinh ===== */
.gift-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (min-width: 720px) {
  .gift-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }
}

.gift-slot {
  position: relative;
  min-height: 200px;
}

/* Hộp quà rung lắc mời gọi */
.gift-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 200px;
  padding: 20px 16px;
  background-color: var(--gift-color, #FF8A65);
  border: 6px solid #FFFFFF;
  border-radius: 30px;
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.12),
    0 12px 20px rgba(0, 0, 0, 0.08),
    inset 0 -4px 0 rgba(0, 0, 0, 0.1);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  animation: gift-wiggle 1.2s ease-in-out infinite;
  animation-delay: var(--wiggle-delay, 0s);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gift-box:active {
  transform: scale(0.93);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}

.gift-box-emoji {
  font-size: 4rem;
  line-height: 1;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.15));
}

.gift-box-label {
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFFFFF;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Hiệu ứng rung lắc hộp quà */
@keyframes gift-wiggle {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-4deg) scale(1.03); }
  30% { transform: rotate(4deg) scale(1.03); }
  45% { transform: rotate(-3deg); }
  60% { transform: rotate(3deg); }
  75% { transform: rotate(-1deg); }
  90% { transform: rotate(1deg); }
}

/* Hiệu ứng bung nắp quà */
.gift-box.is-opened {
  animation: gift-burst 0.45s ease forwards;
  pointer-events: none;
}

@keyframes gift-burst {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(1.2) rotate(5deg); opacity: 1; }
  60% { transform: scale(1.3) rotate(-3deg); opacity: 0.7; }
  100% { transform: scale(0.3) rotate(10deg); opacity: 0; }
}

/* Thẻ ảnh bật ra sau khi mở quà */
.gift-revealed-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

/* Hiệu ứng bật lên vui mắt */
@keyframes pop-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

.is-pop-in {
  animation: pop-in 0.45s ease forwards;
}

/* Nút chuyển trò tiếp theo */
.next-step-btn {
  align-self: center;
  margin-top: 12px;
}


/* ============================
   TRÒ CHƠI 2: ĐỌC THEO HÔ BIẾN
   ============================ */

.speak-game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 16px 32px;
  max-width: 420px;
  margin: 0 auto;
}

/* Vùng thẻ ảnh khổng lồ */
.speak-card-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.speak-big-img-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 32px;
  border: 6px solid #FFFFFF;
  background: #FFFFFF;
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.08),
    0 12px 24px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.speak-big-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 26px;
  display: block;
}

.speak-big-img.is-hidden {
  display: none;
}

.speak-big-fallback {
  font-size: 6rem;
  line-height: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.speak-big-fallback.is-hidden {
  display: none;
}

/* Từ tiếng Anh to rõ */
.speak-word-en {
  font-size: 2.2rem;
  font-weight: 900;
  color: #E65100;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  letter-spacing: 1px;
}

/* Từ tiếng Việt nhỏ hơn */
.speak-word-vi {
  font-size: 1.15rem;
  font-weight: 700;
  color: #6D4C41;
  text-align: center;
}

/* Hàng sao thưởng */
.speak-star-row {
  font-size: 1.5rem;
  min-height: 2rem;
  text-align: center;
}

/* Chỉ dẫn cho bé */
.speak-instruction {
  font-size: 1.05rem;
  font-weight: 700;
  color: #5D4037;
  text-align: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
}

/* Nút Micro khổng lồ */
.speak-mic-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 6px solid #FFFFFF;
  background: linear-gradient(145deg, #66BB6A, #43A047);
  box-shadow:
    0 8px 0 #2E7D32,
    0 12px 20px rgba(0, 0, 0, 0.15);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: mic-pulse 2s ease-in-out infinite;
}

.speak-mic-btn:active {
  transform: scale(0.92) translateY(4px);
  box-shadow: 0 4px 0 #2E7D32, 0 6px 10px rgba(0, 0, 0, 0.1);
}

.speak-mic-icon {
  font-size: 3.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.speak-mic-label {
  font-size: 1rem;
  font-weight: 800;
  color: #FFFFFF;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  text-align: center;
  line-height: 1.2;
}

/* Nhấp nháy xanh-đỏ khi đang thu âm */
.speak-mic-btn.is-recording {
  background: linear-gradient(145deg, #EF5350, #D32F2F);
  box-shadow:
    0 8px 0 #B71C1C,
    0 12px 20px rgba(0, 0, 0, 0.15);
  animation: mic-recording-pulse 0.6s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes mic-recording-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 0 #B71C1C, 0 0 0 0 rgba(239, 83, 80, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 8px 0 #B71C1C, 0 0 0 20px rgba(239, 83, 80, 0); }
}

/* Nút nghe mẫu lại (phụ) */
.big-btn--secondary {
  background: linear-gradient(145deg, #90CAF9, #42A5F5) !important;
  box-shadow:
    0 6px 0 #1565C0,
    0 10px 16px rgba(0, 0, 0, 0.1) !important;
}

.big-btn--secondary:active {
  box-shadow: 0 3px 0 #1565C0 !important;
}

.speak-listen-btn {
  font-size: 1.1rem;
  min-height: 52px;
  width: 100%;
  max-width: 300px;
}

/* Nhân vật nhảy tưng tưng ăn mừng */
.speak-big-img-wrap.is-celebrating {
  animation: celebrate-bounce 0.8s ease;
}

@keyframes celebrate-bounce {
  0% { transform: translateY(0) scale(1); }
  15% { transform: translateY(-24px) scale(1.08) rotate(-3deg); }
  30% { transform: translateY(0) scale(0.95); }
  45% { transform: translateY(-16px) scale(1.05) rotate(3deg); }
  60% { transform: translateY(0) scale(0.97); }
  75% { transform: translateY(-8px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}


/* ============================
   TRÒ CHƠI 3: ĐỐ VUI TÌM BẠN
   ============================ */

.quiz-game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 32px;
  max-width: 420px;
  margin: 0 auto;
}

/* Câu hỏi "Where is the ...?" */
.quiz-question {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #4E342E;
  line-height: 1.4;
  cursor: pointer;
}

.quiz-question-word {
  color: #E65100;
  font-size: 1.8rem;
  text-decoration: underline wavy #FFB74D;
  text-underline-offset: 6px;
}

.quiz-hint-vi {
  font-size: 1.05rem;
  font-weight: 700;
  color: #8D6E63;
  text-align: center;
}

.quiz-mastery-bar {
  font-size: 1.15rem;
  font-weight: 800;
  color: #E65100;
  background: #FFF3E0;
  border: 2px solid #FFB74D;
  padding: 5px 16px;
  border-radius: 20px;
  text-align: center;
}

.quiz-progress {
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFFFFF;
  background: #AB47BC;
  padding: 4px 16px;
  border-radius: 20px;
}

/* Lưới 3 thẻ ảnh */
.quiz-choices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  position: relative;
}

/* Thẻ lựa chọn */
.quiz-choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 12px;
  background: #FFFFFF;
  border: 4px solid #E0E0E0;
  border-radius: 22px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.06), 0 6px 12px rgba(0,0,0,0.06);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.quiz-choice-card:active {
  transform: scale(0.95);
}

/* Chạm đúng — viền xanh lá + phóng to nhẹ */
.quiz-choice-card.is-correct {
  border-color: #43A047;
  background: #E8F5E9;
  transform: scale(1.06);
  box-shadow: 0 6px 0 #2E7D32, 0 10px 20px rgba(67,160,71,0.25);
  animation: correct-bounce 0.5s ease;
}

@keyframes correct-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(0.97); }
  100% { transform: scale(1.06); }
}

/* Chạm sai — lắc nhẹ + viền đỏ */
.quiz-choice-card.is-wrong {
  border-color: #EF5350;
  background: #FFEBEE;
  animation: wrong-shake 0.45s ease;
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px) rotate(-2deg); }
  30% { transform: translateX(8px) rotate(2deg); }
  45% { transform: translateX(-6px) rotate(-1deg); }
  60% { transform: translateX(6px) rotate(1deg); }
  75% { transform: translateX(-3px); }
}

/* Ảnh trong thẻ quiz */
.quiz-choice-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #FFF8E7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-choice-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  display: block;
}

.quiz-choice-img.is-hidden {
  display: none;
}

.quiz-choice-fallback {
  font-size: 3rem;
  line-height: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.quiz-choice-fallback.is-hidden {
  display: none;
}

.quiz-choice-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: #5D4037;
  text-align: center;
  word-break: break-word;
}

/* Pháo giấy nhỏ */
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--confetti-color, #FFD93D);
  left: var(--confetti-left, 50%);
  top: 40%;
  border-radius: 2px;
  pointer-events: none;
  animation: confetti-fall 1s ease forwards;
  animation-delay: var(--confetti-delay, 0s);
  transform: rotate(var(--confetti-rotate, 0deg));
  z-index: 10;
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(120px) rotate(360deg) scale(0.5); }
}


/* ============================
   MÀN ÔN LẠI + HOÀN THÀNH GÓI
   ============================ */

/* Màn ôn lại */
.retry-screen {
  text-align: center;
}

.retry-desc {
  font-size: 1.1rem;
  font-weight: 700;
  color: #5D4037;
  line-height: 1.5;
}

.retry-word-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}

.retry-word-tag {
  display: inline-block;
  padding: 6px 14px;
  background: #FFF3E0;
  border: 2px solid #FFB74D;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 700;
  color: #E65100;
}

/* Màn hoàn thành gói */
.pack-complete-screen {
  text-align: center;
}

.complete-emoji {
  font-size: 5rem;
  line-height: 1;
  animation: celebrate-bounce 0.8s ease;
}

.complete-desc {
  font-size: 1.15rem;
  font-weight: 700;
  color: #5D4037;
  line-height: 1.5;
}

.complete-unlock-msg {
  font-size: 1.3rem;
  font-weight: 900;
  color: #2E7D32;
  animation: pop-in 0.5s ease forwards;
}

/* Gói đã thuộc hết */
.pack-card.is-mastered {
  border-color: #66BB6A;
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
}

/* Pháo hoa to toàn màn hình */
.big-confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.big-confetti-piece {
  position: absolute;
  width: var(--confetti-size, 10px);
  height: var(--confetti-size, 10px);
  background: var(--confetti-color, #FFD93D);
  left: var(--confetti-left, 50%);
  top: -20px;
  border-radius: 3px;
  animation: big-confetti-fall 2s ease forwards;
  animation-delay: var(--confetti-delay, 0s);
  transform: rotate(var(--confetti-rotate, 0deg));
}

@keyframes big-confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}


/* ============================
   SỔ NHÃN DÁN + GÓC BA MẸ
   ============================ */

/* Cụm bên phải thanh đầu trang: Tổng Sao + nút Ba Mẹ */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.top-parent-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: linear-gradient(145deg, #E1BEE7, #BA68C8);
  color: #FFFFFF;
  border: 3px solid #FFFFFF;
  border-radius: 999px;
  box-shadow: 0 4px 0 #7B1FA2;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.15s ease, background 0.2s ease;
}

.top-parent-btn.is-holding {
  background: linear-gradient(145deg, #FFB74D, #F57C00);
  box-shadow: 0 2px 0 #E65100;
  animation: hold-shrink 3s linear forwards;
}

.top-parent-label {
  white-space: nowrap;
}

/* Nút mở Sổ Nhãn Dán ngay đầu Trang chủ */
.home-sticker-banner {
  width: 100%;
  min-height: 68px !important;
  font-size: 1.25rem !important;
  color: #4E342E !important;
}

.big-btn--sticker {
  background: linear-gradient(145deg, #FFE082, #FFB300) !important;
  color: #4E342E !important;
  box-shadow: 0 6px 0 #FF8F00, 0 10px 16px rgba(0,0,0,0.1) !important;
}

.big-btn--sticker:active {
  box-shadow: 0 3px 0 #FF8F00 !important;
}

@keyframes hold-shrink {
  0% { transform: scale(1); }
  100% { transform: scale(0.9); }
}

/* === Hộp Bóc Nhãn Dán Mới khi hoàn thành gói === */
.sticker-peel-box {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 6px 0;
}

.sticker-peel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  background: #FFFDE7;
  border: 5px dashed #FFB300;
  border-radius: 28px;
  box-shadow: 0 8px 0 #FFA000, 0 12px 20px rgba(0,0,0,0.1);
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s ease, border-style 0.2s ease;
}

.sticker-peel-btn.is-unpeeled {
  animation: gift-wiggle 1.3s ease-in-out infinite;
}

.sticker-peel-btn.is-peeled {
  border-style: solid;
  border-color: #66BB6A;
  background: #FFFFFF;
  box-shadow: 0 6px 0 #43A047;
  animation: pop-in 0.45s ease forwards;
}

.sticker-peel-img-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  border-radius: 24px;
  border: 5px solid #FFFFFF;
  background: #FFF8E7;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-peel-emoji {
  font-size: 4rem;
  line-height: 1;
}

.sticker-peel-caption {
  font-size: 1.05rem;
  font-weight: 900;
  color: #E65100;
}

/* === Sổ Nhãn Dán === */
.sticker-book-screen {
  text-align: center;
}

.sticker-count {
  font-size: 1.15rem;
  font-weight: 800;
  color: #E65100;
  margin-bottom: 8px;
}

.sticker-topics-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.sticker-topic-box {
  background: var(--card-tint, #FFFFFF);
  border: 4px solid #FFFFFF;
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.06);
}

.sticker-topic-header {
  font-size: 1.1rem;
  font-weight: 900;
  color: #4A3531;
  text-align: left;
  margin-bottom: 10px;
  padding-left: 4px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
}

@media (max-width: 520px) {
  .sticker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sticker-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 18px;
  border: 3px solid #E0E0E0;
  background: #FFFFFF;
  font-family: inherit;
  transition: transform 0.2s ease;
}

.sticker-cell.is-earned {
  border-color: #FFB300;
  background: #FFFDE7;
  cursor: pointer;
  touch-action: manipulation;
  animation: sticker-shine 2.4s ease-in-out infinite;
}

.sticker-cell.is-locked {
  opacity: 0.55;
}

@keyframes sticker-shine {
  0%, 100% { box-shadow: 0 3px 0 rgba(255,179,0,0.35); }
  50% { box-shadow: 0 3px 0 rgba(255,179,0,0.35), 0 0 10px 2px rgba(255,213,79,0.5); }
}

.sticker-img-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 14px;
  border: 3px solid #FFFFFF;
  background: #FFF8E7;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sticker-img.is-hidden {
  display: none;
}

.sticker-icon {
  font-size: 2rem;
  line-height: 1;
}

.sticker-icon.is-hidden {
  display: none;
}

.sticker-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #5D4037;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
}

/* === Góc Ba Mẹ === */
.parent-dashboard-screen {
  text-align: center;
}

.parent-stats-box {
  display: flex;
  gap: 10px;
  width: 100%;
  margin: 8px 0;
}

.parent-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: #FFFFFF;
  border-radius: 20px;
  border: 3px solid #E0E0E0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.parent-stat-num {
  font-size: 2rem;
  font-weight: 900;
  color: #E65100;
}

.parent-stat-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #5D4037;
}

.parent-total-stars {
  font-size: 1.15rem;
  font-weight: 800;
  color: #E65100;
  margin: 6px 0;
}

.parent-progress-pct {
  font-size: 1.1rem;
  font-weight: 800;
  color: #2E7D32;
  margin-bottom: 12px;
}

.parent-speed-section {
  width: 100%;
  padding: 16px;
  background: #FFFFFF;
  border-radius: 20px;
  border: 3px solid #E0E0E0;
  margin-bottom: 12px;
}

.parent-speed-label {
  font-size: 1.05rem;
  font-weight: 800;
  color: #5D4037;
  margin-bottom: 10px;
}

.parent-speed-toggle {
  display: flex;
  gap: 10px;
}

.speed-btn {
  flex: 1;
  padding: 12px;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: inherit;
  border: 3px solid #E0E0E0;
  border-radius: 16px;
  background: #F5F5F5;
  color: #5D4037;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.speed-btn.is-active {
  border-color: #43A047;
  background: #E8F5E9;
  color: #2E7D32;
  box-shadow: 0 3px 0 #2E7D32;
}

.parent-topic-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  text-align: left;
}

.parent-topic-row {
  padding: 8px 12px;
  background: #FFF8E7;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #4A3531;
}

.parent-reset-btn {
  width: 100%;
  background: #FFEBEE;
  border-color: #EF9A9A;
  color: #C62828;
}

.parent-reset-btn.is-confirming {
  background: #D32F2F;
  border-color: #B71C1C;
  color: #FFFFFF;
}
