:root {
  --ink: #1E3A5F;
  --ink-soft: #486581;
  --paper: #FFFFFF;
  --cream: #FFFDF5;
  --blue: #38A1FF;
  --blue-dark: #1B75D0;
  --orange: #FF9F43;
  --orange-dark: #D97706;
  --pink: #FF6B9D;
  --pink-dark: #D63B70;
  --green: #38D36E;
  --green-dark: #1E9E4B;
  --yellow: #FFD93D;
  --yellow-dark: #D99A00;
  --purple: #9B6BFF;
  --purple-dark: #6D3EDB;
  --border: #1E3A5F;
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-card: 0 10px 0 rgba(30, 58, 95, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: #87D8FA;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .combined-word, .sandbox-big-word, .celebration-title, .celebration-word-pill {
  font-family: 'Baloo 2', 'Quicksand', cursive, sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: inherit;
}

button:focus-visible {
  outline: 4px solid #FFD93D;
  outline-offset: 3px;
}

/* =================================================== */
/* STORYBOOK ANIMATED BACKGROUND                       */
/* =================================================== */
.world-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sky-scene {
  width: 100%;
  height: 100%;
  display: block;
}

.sun-rays {
  animation: spinSlow 28s linear infinite;
}

.cloud-1 {
  animation: driftCloud 36s ease-in-out infinite alternate;
}

.cloud-2 {
  animation: driftCloud 44s ease-in-out infinite alternate-reverse;
}

.cloud-3 {
  animation: driftCloud 30s ease-in-out infinite alternate;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes driftCloud {
  from { transform: translateX(-28px); }
  to { transform: translateX(48px); }
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 120;
}

/* =================================================== */
/* APP SHELL & TOP HEADER                              */
/* =================================================== */
.app-shell {
  position: relative;
  z-index: 10;
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 20px 44px;
}

.top-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 4px solid var(--border);
  border-radius: 26px;
  padding: 12px 18px;
  box-shadow: 0 8px 0 rgba(30, 58, 95, 0.16);
}

.top-bar-row1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #FFF3C4;
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 42px;
  height: 42px;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.1;
  color: var(--ink);
}

.brand-text p {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--orange-dark);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
  border-top: 2.5px dashed #CFE4F7;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 16px;
  border: 3px solid var(--border);
  background: #F4F9FF;
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.mode-tab:hover {
  transform: translateY(-2px);
  background: #FFF9DC;
}

.mode-tab:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border);
}

.mode-tab.active {
  background: var(--yellow);
  color: var(--ink);
  transform: translateY(1px);
  box-shadow: 0 3px 0 var(--border);
}

.tab-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.12s ease;
}

.pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border);
}

.pill-btn.muted {
  background: #E2E8F0;
  color: #64748B;
}

.btn-svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 3px solid var(--border);
  background: #FFF2B2;
  font-family: 'Baloo 2', cursive;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.15s ease;
}

.star-counter:hover {
  transform: scale(1.05);
}

.star-counter.bump {
  animation: popBounce 0.45s ease;
}

.star-svg {
  width: 26px;
  height: 26px;
}

.profile-btn {
  background: #E8F5FF;
  padding: 6px 14px 6px 8px;
}

.profile-btn:hover {
  background: #D6EEFF;
}

.profile-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-mini-avatar svg {
  width: 26px;
  height: 26px;
}

/* Profile Manager Modal */
.profile-modal-card {
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.profile-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 20px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  box-shadow: 0 4px 0 var(--border);
}

.profile-row-card.is-active {
  background: #EBFBEE;
  border-color: var(--green-dark);
}

.profile-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.profile-row-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #FFF9DB;
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-row-avatar svg {
  width: 48px;
  height: 48px;
}

.profile-row-info {
  min-width: 0;
}

.profile-row-name {
  font-family: 'Baloo 2', cursive;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.15;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.active-kid-tag {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--green);
  color: #0B3D1D;
  border: 2px solid var(--border);
}

.profile-row-stats {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
}

.profile-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.small-pill-btn {
  padding: 7px 12px;
  border-radius: 12px;
  border: 2.5px solid var(--border);
  background: #FFFFFF;
  font-weight: 800;
  font-size: 0.86rem;
  box-shadow: 0 3px 0 var(--border);
}

.small-pill-btn.select-btn {
  background: var(--blue);
  color: #FFFFFF;
}

.small-pill-btn.delete-btn {
  background: #FFE5E5;
  color: #B91C1C;
}

.add-profile-form {
  background: #F4F9FF;
  border: 3px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.add-profile-form h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.add-profile-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.profile-text-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 3px solid var(--border);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: #FFFFFF;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-choice-btn {
  padding: 8px 4px;
  border-radius: 14px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 3px 0 var(--border);
}

.avatar-choice-btn.selected {
  background: var(--yellow);
  transform: translateY(-2px);
}

.avatar-choice-btn svg {
  width: 42px;
  height: 42px;
}

.avatar-choice-btn span {
  font-size: 0.72rem;
  font-weight: 800;
}

.profile-backup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.import-label {
  cursor: pointer;
}

.backup-status {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--green-dark);
}

/* =================================================== */
/* MASCOT COACH BAR                                    */
/* =================================================== */
.mascot-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 18px 0 16px;
}

.mascot-avatar-wrap {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  cursor: pointer;
  filter: drop-shadow(0 6px 0 rgba(30, 58, 95, 0.18));
  transition: transform 0.2s ease;
}

.mascot-avatar-wrap:hover {
  transform: scale(1.06) rotate(-2deg);
}

.mascot-avatar-wrap svg {
  width: 100%;
  height: 100%;
}

.mascot-bob {
  animation: mascotBob 2.6s ease-in-out infinite;
}

.mascot-cheer {
  animation: mascotJump 0.55s ease-in-out infinite alternate;
}

.mascot-wobble {
  animation: wobbleSoft 0.45s ease;
}

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

@keyframes mascotJump {
  0% { transform: translateY(0px) rotate(-4deg) scale(1); }
  100% { transform: translateY(-16px) rotate(4deg) scale(1.06); }
}

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

.speech-bubble {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--paper);
  border: 4px solid var(--border);
  border-radius: 24px;
  padding: 14px 20px;
  box-shadow: 0 7px 0 rgba(30, 58, 95, 0.14);
}

.speech-bubble::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 16px solid var(--border);
}

.speech-bubble::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-right: 13px solid var(--paper);
}

.speech-bubble p {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
}

.mini-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #EBF7FF;
  border: 3px solid var(--border);
  font-weight: 700;
  font-size: 0.92rem;
  flex-shrink: 0;
  box-shadow: 0 4px 0 var(--border);
}

.mini-audio-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border);
}

/* =================================================== */
/* COMMON CARDS & TACTILE CARTOON BUTTONS              */
/* =================================================== */
.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
  animation: fadeSlideUp 0.25s ease;
}

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

.card {
  background: var(--cream);
  border: 4px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 18px;
  border: 3px solid var(--border);
  font-weight: 800;
  font-size: 1.02rem;
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
}

.action-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--border);
}

.btn-big {
  font-size: 1.15rem;
  padding: 12px 26px;
}

.btn-blue { background: var(--blue); color: #FFFFFF; }
.btn-green { background: var(--green); color: #0B3D1D; }
.btn-yellow { background: var(--yellow); color: var(--ink); }
.btn-purple { background: var(--purple); color: #FFFFFF; }
.btn-ghost { background: #FFFFFF; color: var(--ink); }
.btn-mic { background: #FF5E7E; color: #FFFFFF; }

.btn-mic.recording {
  background: #E11D48;
  animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 5px 0 var(--border), 0 0 0 0 rgba(225, 29, 72, 0.55); }
  50% { box-shadow: 0 5px 0 var(--border), 0 0 0 12px rgba(225, 29, 72, 0); }
}

/* AI Reading Grader Feedback Box */
.ai-grade-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 3px solid var(--border);
  background: #F4F9FF;
  text-align: left;
  animation: fadeSlideUp 0.2s ease;
}

.ai-grade-box.listening {
  background: #FFF0F6;
  border-color: #E11D48;
}

.ai-grade-box.passed {
  background: #EBFBEE;
  border-color: var(--green-dark);
}

.ai-grade-box.retry {
  background: #FFF9DB;
  border-color: var(--orange-dark);
}

.ai-grade-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
}

.ai-score-pill {
  padding: 4px 12px;
  border-radius: 999px;
  border: 2.5px solid var(--border);
  background: var(--yellow);
  font-family: 'Baloo 2', cursive;
  font-size: 1.05rem;
  font-weight: 800;
}

.ai-score-pill.good {
  background: #69DB7C;
  color: #0B3D1D;
}

.ai-wave-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}

.ai-wave-bars span {
  width: 4px;
  background: #E11D48;
  border-radius: 99px;
  animation: waveBounce 0.7s ease-in-out infinite alternate;
}

.ai-wave-bars span:nth-child(1) { height: 7px; animation-delay: 0s; }
.ai-wave-bars span:nth-child(2) { height: 16px; animation-delay: 0.15s; }
.ai-wave-bars span:nth-child(3) { height: 11px; animation-delay: 0.3s; }
.ai-wave-bars span:nth-child(4) { height: 18px; animation-delay: 0.45s; }

@keyframes waveBounce {
  from { transform: scaleY(0.35); }
  to { transform: scaleY(1); }
}

.ai-heard-line {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.ai-word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-word-chip {
  padding: 4px 12px;
  border-radius: 12px;
  border: 2.5px solid var(--border);
  font-family: 'Baloo 2', cursive;
  font-size: 1.15rem;
  font-weight: 800;
}

.ai-word-chip.ok {
  background: #B2F2BB;
  color: #0B3D1D;
}

.ai-word-chip.miss {
  background: #FFD8A8;
  color: #9A3412;
  cursor: pointer;
}

/* =================================================== */
/* MODE 1: GHÉP ĐÁNH VẦN                               */
/* =================================================== */
.level-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.level-chip {
  padding: 10px 18px;
  border-radius: 999px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-weight: 800;
  font-size: 0.98rem;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.12s ease, background 0.12s ease;
}

.level-chip.active {
  background: var(--orange);
  color: #FFFFFF;
}

.level-chip:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border);
}

.build-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.picture-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-label {
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
}

.progress-track {
  flex: 1;
  height: 16px;
  background: #E2EEF9;
  border: 3px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38D36E, #FFD93D);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.cartoon-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: radial-gradient(circle at 50% 40%, #FFFFFF 0%, #E6F7FF 100%);
  border: 4px solid var(--border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: hidden;
  position: relative;
}

.cartoon-frame svg {
  width: 100%;
  height: 100%;
  max-height: 250px;
  animation: gentleFloat 3.4s ease-in-out infinite;
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}

.picture-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.assembly-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.assembly-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.color-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-dot {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid var(--border);
}

.dot-onset { background: #D6EEFF; color: #0B4F8C; }
.dot-rime { background: #FFE6C7; color: #9A4A00; }
.dot-tone { background: #FFD6E6; color: #991B4D; }

.result-stage {
  background: #FFFFFF;
  border: 4px solid var(--border);
  border-radius: 24px;
  padding: 16px;
  margin-bottom: 16px;
}

.slots-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.letter-slot {
  min-width: 88px;
  height: 92px;
  border-radius: 20px;
  border: 4px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  transition: transform 0.16s ease, background 0.16s ease, border-style 0.16s ease;
}

.letter-slot.filled {
  border-style: solid;
  box-shadow: 0 5px 0 var(--border);
}

.letter-slot.pulse-step {
  transform: scale(1.14);
  box-shadow: 0 0 0 6px #FFD93D, 0 5px 0 var(--border);
}

.slot-onset { background: #E8F5FF; }
.slot-onset.filled { background: #64B8FF; color: #FFFFFF; }
.slot-rime { background: #FFF2E0; }
.slot-rime.filled { background: #FFA94D; color: #FFFFFF; }
.slot-tone { background: #FFEAF2; }
.slot-tone.filled { background: #FF7AA8; color: #FFFFFF; }

.slot-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  opacity: 0.85;
}

.slot-value {
  font-family: 'Baloo 2', cursive;
  font-size: 2.1rem;
  line-height: 1.05;
  font-weight: 800;
}

.plus-sign, .equals-sign {
  font-family: 'Baloo 2', cursive;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.combined-word-box {
  min-width: 146px;
  height: 92px;
  padding: 0 22px;
  border-radius: 22px;
  border: 4px solid var(--border);
  background: #FFF9CC;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 var(--border);
  transition: transform 0.2s ease, background 0.2s ease;
}

.combined-word-box.pulse-step {
  transform: scale(1.12);
  background: #9BF6A8;
}

.combined-word-box.shake-wrong {
  animation: shakeX 0.4s ease;
  background: #FFE0E0;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.combined-word {
  font-size: 2.7rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}

.spelling-breakdown {
  margin-top: 12px;
  text-align: center;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink-soft);
  min-height: 28px;
}

.trays-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tray {
  border-radius: 20px;
  border: 3px solid var(--border);
  padding: 12px 14px;
}

.tray-onset { background: #EBF7FF; }
.tray-rime { background: #FFF4E5; }
.tray-tone { background: #FFF0F6; }

.tray-title {
  font-weight: 800;
  font-size: 0.92rem;
  margin-bottom: 8px;
  color: var(--ink);
}

.tile-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.letter-tile {
  min-width: 62px;
  min-height: 56px;
  padding: 6px 14px;
  border-radius: 16px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-family: 'Baloo 2', cursive;
  font-size: 1.65rem;
  font-weight: 800;
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

.letter-tile:hover {
  transform: translateY(-3px);
}

.letter-tile:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--border);
}

.letter-tile.selected-onset {
  background: var(--blue);
  color: #FFFFFF;
}

.letter-tile.selected-rime {
  background: var(--orange);
  color: #FFFFFF;
}

.letter-tile.selected-tone {
  background: var(--pink);
  color: #FFFFFF;
}

.tone-tile-label {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
}

.assembly-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* =================================================== */
/* MODE 2: XƯỞNG GHÉP CHỮ TỰ DO                        */
/* =================================================== */
.sandbox-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start;
}

.sandbox-stage-card h2 {
  margin: 0 0 4px;
  font-size: 1.55rem;
}

.sandbox-sub {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-weight: 700;
}

.sandbox-display {
  background: #FFFFFF;
  border: 4px solid var(--border);
  border-radius: 24px;
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}

.sandbox-art-slot {
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.sandbox-art-slot svg {
  max-height: 165px;
  max-width: 100%;
  animation: popBounce 0.4s ease;
}

.sandbox-big-word {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1.05;
  color: var(--ink);
}

.sandbox-spell-formula {
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--purple-dark);
}

.sandbox-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sandbox-group {
  margin-bottom: 16px;
}

.sandbox-group:last-child {
  margin-bottom: 0;
}

.sandbox-group h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-blue, .badge-orange, .badge-pink {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: 999px;
  border: 2px solid var(--border);
}

.badge-blue { background: #D6EEFF; }
.badge-orange { background: #FFE6C7; }
.badge-pink { background: #FFD6E6; }

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sb-chip {
  min-width: 52px;
  height: 48px;
  padding: 0 12px;
  border-radius: 14px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-family: 'Baloo 2', cursive;
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.1s ease, background 0.1s ease;
}

.sb-chip:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--border);
}

.sb-chip.active-onset { background: var(--blue); color: #FFFFFF; }
.sb-chip.active-rime { background: var(--orange); color: #FFFFFF; }
.sb-chip.active-tone { background: var(--pink); color: #FFFFFF; }

.tone-grid .sb-chip {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.98rem;
  padding: 0 14px;
}

/* =================================================== */
/* MODE 3: ĐỌC LƯU LOÁT & TÌM TRANH                    */
/* =================================================== */
.reading-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.reading-top h2 {
  margin: 0;
  font-size: 1.5rem;
}

.reading-sub {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.reading-progress {
  background: var(--yellow);
  border: 3px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--border);
}

.reading-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reading-score-pill {
  background: #D3F9D8;
  border: 3px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: 0 4px 0 var(--border);
}

.chip-score-badge {
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #B2F2BB;
  color: #0B3D1D;
  border: 2px solid var(--border);
  font-size: 0.78rem;
  font-weight: 800;
}

.sentence-stage {
  background: #FFFFFF;
  border: 4px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  text-align: center;
  margin-bottom: 20px;
}

.sentence-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.word-pill {
  padding: 10px 20px;
  border-radius: 18px;
  border: 3px solid var(--border);
  background: #F0F9FF;
  font-family: 'Baloo 2', cursive;
  font-size: 2.1rem;
  font-weight: 800;
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.14s ease, background 0.14s ease;
}

.word-pill:hover {
  transform: translateY(-3px);
  background: #FFF2B2;
}

.word-pill.speaking {
  transform: scale(1.12);
  background: #FFD93D;
}

.sentence-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.picture-choices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.pic-choice-card {
  background: #FFFFFF;
  border: 4px solid var(--border);
  border-radius: 24px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 7px 0 var(--border);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.pic-choice-card:hover {
  transform: translateY(-4px);
  background: #FFFDF0;
}

.pic-choice-card:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--border);
}

.pic-choice-card svg {
  width: 100%;
  height: 170px;
}

.pic-choice-card.wrong-try {
  animation: shakeX 0.4s ease;
  background: #FFE5E5;
}

.pic-choice-caption {
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink-soft);
}

/* =================================================== */
/* CELEBRATION SHOW OVERLAY                            */
/* =================================================== */
.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 42, 74, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.celebration-stage {
  position: relative;
  width: 100%;
  max-width: 540px;
  background: #FFFDF2;
  border: 5px solid var(--border);
  border-radius: 36px;
  padding: 28px 26px 26px;
  text-align: center;
  box-shadow: 0 14px 0 rgba(30, 58, 95, 0.35);
  overflow: hidden;
  animation: popBounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sunburst-bg {
  position: absolute;
  inset: -40%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 217, 61, 0.22) 0deg 15deg,
    rgba(255, 255, 255, 0) 15deg 30deg
  );
  animation: spinSlow 18s linear infinite;
  pointer-events: none;
}

.floating-balloons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.balloon {
  position: absolute;
  bottom: -60px;
  width: 34px;
  height: 42px;
  border-radius: 50% 50% 48% 48%;
  border: 3px solid var(--border);
  animation: riseBalloon 3.2s ease-out forwards;
}

.balloon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 28px;
  background: var(--border);
}

.b1 { left: 8%; background: #FF6B9D; animation-delay: 0s; }
.b2 { left: 22%; background: #38A1FF; animation-delay: 0.25s; }
.b3 { right: 20%; background: #38D36E; animation-delay: 0.15s; }
.b4 { right: 8%; background: #FF9F43; animation-delay: 0.35s; }

@keyframes riseBalloon {
  0% { transform: translateY(0) rotate(-4deg); opacity: 1; }
  100% { transform: translateY(-480px) rotate(6deg); opacity: 0.2; }
}

.celebration-mascot {
  position: relative;
  z-index: 2;
  width: 170px;
  height: 170px;
  margin: 0 auto 6px;
}

.celebration-mascot svg {
  width: 100%;
  height: 100%;
}

.celebration-stars {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.c-star {
  width: 44px;
  height: 44px;
  animation: starPop 0.5s ease both;
}

.s1 { animation-delay: 0.08s; }
.s2 { width: 54px; height: 54px; transform: translateY(-6px); animation-delay: 0.2s; }
.s3 { animation-delay: 0.32s; }

@keyframes starPop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.2) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.celebration-title {
  position: relative;
  z-index: 2;
  margin: 0 0 10px;
  font-size: 2rem;
  color: #D9480F;
}

.celebration-word-pill {
  position: relative;
  z-index: 2;
  display: inline-block;
  padding: 6px 28px;
  border-radius: 999px;
  background: var(--yellow);
  border: 4px solid var(--border);
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 5px 0 var(--border);
  margin-bottom: 8px;
}

.celebration-spell-text {
  position: relative;
  z-index: 2;
  margin: 0 0 18px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
}

.celebration-actions {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* =================================================== */
/* TROPHY MODAL                                        */
/* =================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(20, 42, 74, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  background: #FFFDF5;
  border: 5px solid var(--border);
  border-radius: 30px;
  padding: 24px;
  box-shadow: 0 12px 0 rgba(30, 58, 95, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.6rem;
}

.close-modal-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: #FFE5E5;
  font-weight: 800;
  font-size: 1.1rem;
}

.modal-sub {
  margin: 0 0 16px;
  font-weight: 700;
  color: var(--ink-soft);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.sticker-card {
  background: #FFFFFF;
  border: 3px solid var(--border);
  border-radius: 20px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 4px 0 var(--border);
}

.sticker-card.locked {
  background: #EDF2F7;
  opacity: 0.65;
  filter: grayscale(0.85);
}

.sticker-card svg {
  width: 72px;
  height: 72px;
}

.sticker-name {
  font-weight: 800;
  font-size: 0.9rem;
  margin-top: 4px;
}

.sticker-req {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--orange-dark);
}

@keyframes popBounce {
  0% { transform: scale(0.7); opacity: 0; }
  65% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* =================================================== */
/* MODE 4: KHO 14 BÀI HỌC VẦN GHÉP TOÀN DIỆN LỚP 1     */
/* =================================================== */
.lesson-picker-card {
  margin-bottom: 18px;
  padding: 18px 20px;
}

.lesson-picker-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.lesson-picker-top h2 {
  margin: 0 0 2px;
  font-size: 1.4rem;
}

.lesson-picker-sub {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.lesson-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  padding: 7px 14px;
  border-radius: 999px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 3px 0 var(--border);
  transition: transform 0.1s ease, background 0.1s ease;
}

.cat-pill.active {
  background: var(--purple);
  color: #FFFFFF;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.lesson-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 18px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  text-align: left;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.12s ease, background 0.12s ease;
}

.lesson-btn:hover {
  transform: translateY(-2px);
  background: #FFF9DC;
}

.lesson-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border);
}

.lesson-btn.active {
  background: var(--orange);
  color: #FFFFFF;
}

.lesson-btn.active .lesson-num {
  color: #FFF3B0;
}

.lesson-num {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.lesson-rimes {
  font-family: 'Baloo 2', cursive;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.15;
}

.lesson-done-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #0B3D1D;
  border: 2px solid var(--border);
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hat-guide-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.hat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 22px;
  border: 4px solid var(--border);
  background: #FFFFFF;
  text-align: left;
  box-shadow: 0 6px 0 var(--border);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.hat-card:hover {
  transform: translateY(-3px);
}

.hat-card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--border);
}

.hat-a { background: #EBF7FF; }
.hat-aw { background: #FFF4E5; }
.hat-aa { background: #FFF0F6; }

.hat-visual {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
}

.hat-visual svg {
  width: 100%;
  height: 100%;
}

.hat-info strong {
  display: block;
  font-family: 'Baloo 2', cursive;
  font-size: 1.55rem;
  line-height: 1.1;
  color: var(--ink);
}

.hat-info span {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.focus-grid {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 20px;
  align-items: start;
}

.focus-stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.step-node {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 3px solid var(--border);
  background: #EDF2F7;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.step-node .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2.5px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', cursive;
  font-size: 0.95rem;
  color: var(--ink);
  flex-shrink: 0;
}

.step-node.active {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--border);
}

.step-node.done {
  background: #B2F2BB;
  color: #0B3D1D;
}

.step-node.done .step-num {
  background: var(--green);
  color: #0B3D1D;
}

.focus-score-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.score-pill-info,
.mistake-pill-info {
  font-size: 0.84rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  border: 2.5px solid var(--border);
}

.score-pill-info {
  background: #FFF3BF;
  color: #8F4D00;
}

.mistake-pill-info {
  background: #F1F5F9;
  color: var(--ink-soft);
}

.mistake-pill-info.warn {
  background: #FFE3E3;
  color: #C92A2A;
  animation: shakeX 0.4s ease;
}

.step3-mic-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 0 3px 0 var(--border);
  background: #CBD5E1;
  color: #475569;
}

.focus-step-badge {
  margin-top: 14px;
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--yellow);
  border: 3px solid var(--border);
  font-weight: 800;
  font-size: 0.95rem;
}

.loupe-stage {
  margin: 14px 0;
  background: radial-gradient(circle at 50% 45%, #FFFFFF 0%, #FFF9DB 100%);
  border: 4px solid var(--border);
  border-radius: 26px;
  padding: 22px 16px;
  text-align: center;
  position: relative;
}

.loupe-word-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Baloo 2', cursive;
  font-size: 4.3rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 2px;
}

.w-onset {
  color: var(--blue-dark);
}

.w-rime-lens {
  position: relative;
  display: inline-block;
  padding: 4px 20px;
  border-radius: 24px;
  background: #FFE066;
  border: 4px solid #D9480F;
  color: #B91C1C;
  box-shadow: 0 0 0 6px rgba(255, 217, 61, 0.45);
  animation: lensPulse 1.8s ease-in-out infinite;
}

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

.loupe-context-chip {
  margin-top: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.two-beat-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.beat-pill {
  padding: 10px 14px;
  border-radius: 16px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-size: 0.96rem;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease;
}

.beat-pill.active-beat {
  transform: scale(1.04);
  background: #FFF3B0;
  box-shadow: 0 0 0 4px #FFD93D;
}

.focus-question-box {
  background: #FFFFFF;
  border: 3px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
}

.focus-q-title {
  font-weight: 800;
  font-size: 1.02rem;
  margin-bottom: 12px;
  text-align: center;
}

.focus-rime-buttons,
.focus-word-quiz {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.focus-choice-btn {
  padding: 14px 10px;
  border-radius: 20px;
  border: 4px solid var(--border);
  background: #F4F9FF;
  font-family: 'Baloo 2', cursive;
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 6px 0 var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.focus-choice-btn:hover {
  transform: translateY(-3px);
  background: #FFF9DC;
}

.focus-choice-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--border);
}

.focus-choice-btn.wrong-try {
  animation: shakeX 0.4s ease;
  background: #FFE0E0;
}

.focus-choice-btn.correct-hit {
  background: #9BF6A8;
}

.focus-choice-sub {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.focus-blend-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.focus-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.contrast-header h2 {
  margin: 0 0 4px;
  font-size: 1.38rem;
}

.contrast-header p {
  margin: 0 0 14px;
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

.contrast-onset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.contrast-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.contrast-word-card {
  border-radius: 20px;
  border: 4px solid var(--border);
  padding: 14px 8px;
  text-align: center;
  box-shadow: 0 6px 0 var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 0.14s ease;
}

.contrast-word-card:hover {
  transform: translateY(-3px);
}

.contrast-word-card:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--border);
}

.contrast-word-card.c-0 { background: #D6EEFF; }
.contrast-word-card.c-1 { background: #FFE6C7; }
.contrast-word-card.c-2 { background: #FFD6E6; }

.contrast-big {
  font-family: 'Baloo 2', cursive;
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}

.contrast-spell {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.contrast-hat-tag {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid var(--border);
}

.contrast-tip-box {
  background: #FFF9DB;
  border: 3px dashed var(--orange-dark);
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
}

/* =================================================== */
/* MODE 5: LỘ TRÌNH TIẾNG VIỆT LỚP 1 (8 CHƯƠNG)        */
/* =================================================== */
.curriculum-map-card {
  margin-bottom: 18px;
  padding: 18px 20px;
}

.curriculum-map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.curriculum-map-head h2 {
  margin: 0 0 2px;
  font-size: 1.42rem;
}

.curriculum-map-sub {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.curriculum-progress-pill {
  padding: 8px 16px;
  border-radius: 999px;
  background: #D3F9D8;
  border: 3px solid var(--border);
  font-weight: 800;
  box-shadow: 0 4px 0 var(--border);
}

.chapter-roadmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.chapter-pill-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 11px 14px;
  border-radius: 18px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  text-align: left;
  box-shadow: 0 4px 0 var(--border);
  transition: transform 0.12s ease, background 0.12s ease;
}

.chapter-pill-btn:hover {
  transform: translateY(-2px);
  background: #FFF9DC;
}

.chapter-pill-btn.active {
  background: var(--blue);
  color: #FFFFFF;
}

.chapter-pill-btn.active .ch-meta {
  color: #E0F2FE;
}

.ch-meta {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--orange-dark);
}

.ch-name {
  font-family: 'Baloo 2', cursive;
  font-size: 1.04rem;
  font-weight: 800;
  line-height: 1.2;
}

.curriculum-workspace {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 20px;
  align-items: start;
}

.chapter-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.chapter-title-row h2 {
  margin: 0;
  font-size: 1.45rem;
}

.chapter-badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--yellow);
  border: 3px solid var(--border);
  font-weight: 800;
  font-size: 0.86rem;
}

.chapter-summary {
  margin: 0 0 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.chapter-rule-banner {
  background: #FFF0F6;
  border: 3px dashed var(--pink-dark);
  border-radius: 18px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 800;
  color: #991B4D;
}

.chapter-section-block {
  margin-bottom: 16px;
}

.chapter-section-block:last-child {
  margin-bottom: 0;
}

.chapter-section-block h3 {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

.study-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.study-tile {
  padding: 10px 8px;
  border-radius: 16px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  box-shadow: 0 4px 0 var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.12s ease, background 0.12s ease;
}

.study-tile:hover {
  transform: translateY(-3px);
  background: #FFF9DB;
}

.study-tile:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border);
}

.study-tile-main {
  font-family: 'Baloo 2', cursive;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}

.study-tile-sub {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--orange-dark);
}

.passage-card {
  background: #FFFFFF;
  border: 3px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
}

.passage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.passage-header h4 {
  margin: 0;
  font-family: 'Baloo 2', cursive;
  font-size: 1.25rem;
  color: var(--blue-dark);
}

.passage-line-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: #F4F9FF;
  border: 2px solid transparent;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.45;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.passage-line-btn:hover {
  background: #FFF3B0;
  border-color: var(--border);
}

.chapter-quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.chapter-quiz-head h3 {
  margin: 0;
  font-size: 1.28rem;
}

.quiz-step-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--yellow);
  border: 3px solid var(--border);
  font-weight: 800;
  font-size: 0.86rem;
}

.chapter-quiz-prompt-box {
  background: #FFFFFF;
  border: 3px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
}

.chapter-quiz-prompt-box p {
  margin: 0 0 10px;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.4;
}

.chapter-quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.quiz-opt-btn {
  width: 100%;
  padding: 12px 16px;
  border-radius: 16px;
  border: 3px solid var(--border);
  background: #FFFFFF;
  font-family: 'Baloo 2', cursive;
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.12s ease, background 0.12s ease;
}

.quiz-opt-btn:hover {
  transform: translateY(-2px);
  background: #FFF9DC;
}

.quiz-opt-btn.wrong-try {
  animation: shakeX 0.4s ease;
  background: #FFE0E0;
}

.quiz-opt-btn.correct-hit {
  background: #9BF6A8;
}

.chapter-quiz-feedback {
  background: #EBF7FF;
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink);
}

/* SGK Tiếng Việt 1 Tập 1 (83 Lessons) Controls */
.sgk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.sgk-search-input {
  min-width: 240px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 3px solid var(--border);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  background: #FFFFFF;
}

.sgk-lesson-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
  padding: 4px 6px 8px 2px;
}

.sgk-target-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sgk-target-chip {
  min-width: 74px;
  padding: 10px 18px;
  border-radius: 18px;
  border: 3.5px solid var(--border);
  background: #FFF3BF;
  font-family: 'Baloo 2', cursive;
  font-size: 1.9rem;
  font-weight: 800;
  color: #B91C1C;
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.12s ease, background 0.12s ease;
}

.sgk-target-chip:hover {
  transform: translateY(-3px);
  background: #FFE066;
}

.sgk-sentence-text {
  margin: 0 0 12px;
  font-family: 'Baloo 2', cursive;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.sgk-sentence-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sgk-step2-mic {
  margin-bottom: 14px;
}

.sgk-nav-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

/* =================================================== */
/* RESPONSIVE                                          */
/* =================================================== */
@media (max-width: 980px) {
  .top-bar {
    border-radius: 24px;
  }

  .mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .focus-stepper {
    grid-template-columns: 1fr;
  }

  .build-grid,
  .sandbox-grid,
  .focus-grid,
  .hat-guide-bar,
  .curriculum-workspace {
    grid-template-columns: 1fr;
  }

  .picture-choices-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .mascot-bar {
    flex-direction: column;
    text-align: center;
  }

  .speech-bubble {
    flex-direction: column;
  }

  .speech-bubble::before,
  .speech-bubble::after {
    display: none;
  }

  .combined-word {
    font-size: 2.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
