/* Thiết kế cho điện thoại trước: nút to, dễ chạm, không dựa vào hover. */
:root {
  --bg: #FFF8E7;
  --ink: #2B2D42;
  --muted: #6C6F80;
  --accent: #FF8C42;
  --focus-letter: #D9480F;
  --surface: #FFFFFF;
  --shadow: rgba(0, 0, 0, 0.08);
  --radius: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button, a {
  touch-action: manipulation; /* tắt double-tap zoom trên điện thoại */
}

[hidden] { display: none !important; }

.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Thanh trên cùng ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.back svg,
.ctrl svg {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back svg { width: 28px; height: 28px; }

.titles {
  flex: 1;
  min-width: 0;
}

.title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.counter {
  flex: none;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  padding: 6px 14px;
  border-radius: 999px;
}

.notice {
  margin: 0;
  padding: 12px 16px;
  background: #FFE3E3;
  border-radius: 16px;
  font-weight: 600;
}

/* ---------- Ô chọn lớp / chọn bài ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.08s, box-shadow 0.08s;
}

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

.tile.is-disabled { opacity: 0.45; }

.grade-tile {
  min-height: 112px;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.tile-big {
  font-size: 1.8rem;
  font-weight: 800;
}

.tile-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.unit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.unit-icon { font-size: 2.2rem; line-height: 1; }

.unit-letter {
  font-weight: 800;
  color: var(--focus-letter);
  background: #FFF0E0;
  padding: 2px 10px;
  border-radius: 999px;
}

.unit-number {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.unit-title {
  font-weight: 700;
  line-height: 1.25;
}

/* ---------- Sao và tiến độ ---------- */
.grade-stars {
  margin-top: 4px;
  font-weight: 800;
}

.unit-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
}

.unit-game {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.85rem;
}

.mini-stars { font-size: 1rem; letter-spacing: 0.02em; }

.review {
  padding: 12px 14px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--shadow);
}

.review-title {
  margin: 0 0 8px;
  font-weight: 800;
}

.review-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: #FFF0E0;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.review-picture { font-size: 1.5rem; line-height: 1; }

.review-picture.is-placeholder {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--focus-letter);
}

.new-best {
  margin: 0;
  font-weight: 800;
  color: var(--focus-letter);
  animation: pop 0.5s ease-out;
}

/* Nút dành cho phụ huynh ở cuối màn chọn lớp. */
.grades-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: auto;
}

.grades-footer .btn { font-size: 0.95rem; }

/* ---------- Màn hình "Giọng đọc" ---------- */
.settings-hint {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voice-row {
  display: flex;
  gap: 10px;
}

.voice-pick {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 16px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--shadow);
  text-align: left;
}

.voice-row.is-selected .voice-pick {
  border-color: var(--accent);
  background: #FFF0E0;
}

.voice-name {
  font-size: 1.05rem;
  font-weight: 800;
}

.voice-meta {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.voice-play {
  flex: none;
  width: 56px;
  border: none;
  border-radius: 18px;
  background: var(--accent);
  font-size: 1.3rem;
  box-shadow: 0 4px 0 var(--shadow);
}

.settings-help {
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--surface);
}

.settings-help summary {
  font-weight: 800;
  cursor: pointer;
}

.settings-help p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Thẻ flashcard ---------- */
/* Thẻ giãn theo chiều cao màn hình, tối đa 560px, và nằm giữa khi màn hình cao hơn. */
.card-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 320px;
}

.card {
  flex: 1;
  width: 100%;
  max-height: 560px;
  border: none;
  border-radius: var(--radius);
  background: var(--card-color, var(--surface));
  box-shadow: 0 10px 0 var(--shadow), 0 18px 30px var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y; /* để vuốt ngang được xử lý bằng code, không cuộn trang */
  transition: background-color 0.3s;
}

.card-picture {
  font-size: clamp(96px, 32vw, 168px);
  line-height: 1.1;
}

.card-picture img {
  display: block;
  width: min(60vw, 220px);
  height: auto;
}

/* Từ chưa có hình: hiện chữ cái của bài trong vòng tròn nét đứt. */
.card-picture.is-placeholder {
  width: 150px;
  height: 150px;
  border: 5px dashed rgba(43, 45, 66, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  font-weight: 800;
  color: rgba(43, 45, 66, 0.45);
}

.card-word {
  font-size: clamp(2.25rem, 12vw, 4rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.15;
}

.focus-letter {
  color: var(--focus-letter);
  text-decoration: underline;
  text-decoration-thickness: 4px;
  text-underline-offset: 6px;
}

.card-meaning {
  font-size: 1.3rem;
  font-weight: 600;
  color: rgba(43, 45, 66, 0.7);
}

.card.is-speaking { animation: bounce 0.5s ease-out; }
.card.enter-next  { animation: enter-next 0.3s ease-out; }
.card.enter-prev  { animation: enter-prev 0.3s ease-out; }

@keyframes bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.06); }
  60%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

@keyframes enter-next {
  from { transform: translateX(48px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes enter-prev {
  from { transform: translateX(-48px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ---------- Chấm tiến độ ---------- */
.dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  transition: width 0.25s, background-color 0.25s;
}

.dot.active {
  width: 26px;
  background: var(--accent);
}

/* ---------- Nút điều khiển ---------- */
.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.ctrl {
  height: 72px;
  border: none;
  border-radius: 22px;
  background: var(--surface);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s;
}

.ctrl:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--shadow);
}

.ctrl svg { width: 36px; height: 36px; }

.ctrl-speak { background: var(--accent); }

/* ---------- Nút chung ---------- */
/* Các nút dưới thẻ: hai nút một hàng; nút nào bị ẩn thì nút còn lại trong hàng giãn ra cho đủ chỗ. */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.card-actions .btn {
  flex: 1 1 40%;
  padding: 12px 10px;
  font-size: 1rem;
  white-space: nowrap;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 5px 0 var(--shadow);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.08s, box-shadow 0.08s;
}

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

.btn-primary { background: var(--accent); }

.btn-dashed {
  background: transparent;
  box-shadow: none;
  border: 2px dashed rgba(0, 0, 0, 0.15);
  color: var(--muted);
}

.btn-dashed:active { box-shadow: none; }

.btn-scene { background: #BDE0FE; }
.btn-mic { background: #CAFFBF; }
.btn-story { background: #FFC6FF; }

/* ---------- Truyện ---------- */
.story-head { text-align: center; }

.story-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
}

.story-title-vi {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.story-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.story-line {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 5px 0 var(--shadow);
  text-align: left;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

/* Câu đang được đọc: sáng lên và hơi phóng to để bé dõi theo. */
.story-line.is-reading {
  background: #FFF0E0;
  box-shadow: 0 0 0 4px var(--accent), 0 5px 0 var(--shadow);
  transform: scale(1.02);
}

.story-icon {
  font-size: 1.3rem;
  line-height: 1.6;
}

.story-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.story-en {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.45;
}

.story-vi {
  display: none;
  color: var(--muted);
  font-weight: 600;
}

.story-lines.show-vi .story-vi { display: block; }

.story-word {
  color: var(--focus-letter);
  font-weight: 800;
  white-space: nowrap; /* từ và hình của nó luôn nằm cùng một dòng */
}

.story-emoji {
  margin-left: 2px;
  font-size: 1.05em;
}

/* Chọn tốc độ đọc: ba nút liền nhau, nút đang chọn tô màu. */
.speed-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-label {
  flex: none;
  font-weight: 700;
  color: var(--muted);
}

.speed-option {
  flex: 1;
  min-height: 44px;
  padding: 6px 8px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.speed-option.is-selected {
  border-color: var(--accent);
  background: #FFF0E0;
  color: var(--focus-letter);
}

.story-actions {
  display: flex;
  gap: 12px;
}

.story-actions .btn {
  flex: 1;
  padding: 12px 10px;
  white-space: nowrap;
}

.story-note {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Nút bật/tắt nghĩa tiếng Việt nằm ở góc trên bên phải thẻ. */
.card-area { position: relative; }

.meaning-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  min-height: 40px;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ---------- Game đọc to ---------- */
.speak-play {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.speak-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 16px 16px;
  border-radius: var(--radius);
  background: #FFD6A5;
  box-shadow: 0 8px 0 var(--shadow);
}

.speak-card .card-picture { font-size: clamp(80px, 26vw, 128px); }
.speak-card .card-picture.is-placeholder { width: 120px; height: 120px; font-size: 64px; }

.speak-word {
  font-size: clamp(2.25rem, 11vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

/* "a " trong "a car": nhạt hơn để bé vẫn thấy rõ từ chính */
.speak-article {
  font-weight: 600;
  color: var(--muted);
}

.speak-model {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.95rem;
}

.mic-btn {
  width: 112px;
  height: 112px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: #2B9348;
  font-size: 3rem;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s, box-shadow 0.08s, background-color 0.2s;
}

.mic-btn:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

/* Đang nghe: nút đỏ với vòng sóng lan ra để bé biết là đang được nghe. */
.mic-btn.is-listening {
  background: #E63946;
  animation: mic-pulse 1s ease-out infinite;
}

.mic-btn.is-correct { background: #80ED99; }

@keyframes mic-pulse {
  0%   { box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), 0 0 0 0 rgba(230, 57, 70, 0.45); }
  100% { box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), 0 0 0 26px rgba(230, 57, 70, 0); }
}

.speak-feedback {
  min-height: 2.6em;
  margin: 0;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.speak-feedback.is-good { color: #2B9348; }
.speak-feedback.is-bad { color: var(--focus-letter); }

.speak-privacy {
  margin: auto 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- Game 3D ---------- */
.scene-stage {
  position: relative;
  flex: 1;
  min-height: 320px;
  border-radius: 24px;
  overflow: hidden;
  background: #FFE3CC;
  box-shadow: 0 6px 0 var(--shadow);
}

.scene-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.scene-bubble {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 10px 20px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--shadow);
  font-size: 1.4rem;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}

.scene-bubble.is-popping { animation: bubble-pop 0.35s ease-out; }

@keyframes bubble-pop {
  0%   { transform: translateX(-50%) scale(0.7); opacity: 0; }
  100% { transform: translateX(-50%) scale(1);   opacity: 1; }
}

/* Nhãn chữ trên đồ vật; vị trí left/top được code cập nhật theo khung hình 3D. */
.scene-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 14px;
  border-radius: 999px;
  background: #2B9348;
  color: #FFFFFF;
  font-size: 1.3rem;
  font-weight: 800;
  pointer-events: none;
}

.scene-label.is-wrong { background: #E85D04; }
.scene-label.is-popping { animation: label-pop 0.3s ease-out; }

@keyframes label-pop {
  0%   { transform: translate(-50%, -60%) scale(0.6); opacity: 0; }
  100% { transform: translate(-50%, -100%) scale(1);  opacity: 1; }
}

.scene-message {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 248, 231, 0.85);
}

.scene-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.scene-result-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.scene-result .result-title { font-size: 1.6rem; }
.scene-result .stars { font-size: 2.2rem; }

.scene-result-actions {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 8px;
}

.scene-result-actions .btn {
  padding: 10px 8px;
  font-size: 0.95rem;
}

/* ---------- Mini-game ---------- */
.progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s;
}

.game-play {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.listen-btn {
  width: 104px;
  height: 104px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  font-size: 3rem;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s, box-shadow 0.08s;
}

.listen-btn:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.listen-btn.is-speaking { animation: bounce 0.5s ease-out; }

.game-hint {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.options {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.option {
  aspect-ratio: 1;
  border: none;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--shadow);
  font-size: clamp(56px, 18vw, 88px);
  transition: opacity 0.2s, background-color 0.2s;
}

.option-picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.option-picture img {
  max-width: 75%;
  max-height: 75%;
}

.option.is-correct {
  background: #CAFFBF;
  box-shadow: 0 0 0 5px #2B9348, 0 6px 0 var(--shadow);
  animation: pop 0.4s ease-out;
}

.option.is-wrong {
  opacity: 0.35;
  cursor: default;
  animation: shake 0.4s;
}

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

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

.game-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.result-emoji {
  font-size: 96px;
  line-height: 1;
  animation: pop 0.6s ease-out;
}

.result-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
}

.stars {
  font-size: 3rem;
  letter-spacing: 0.1em;
}

.star { color: #FFB703; }
.star.is-empty { color: rgba(0, 0, 0, 0.15); }

.result-note {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.result-actions {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}

.back:focus-visible,
.tile:focus-visible,
.card:focus-visible,
.ctrl:focus-visible,
.btn:focus-visible,
.listen-btn:focus-visible,
.mic-btn:focus-visible,
.meaning-toggle:focus-visible,
.speed-option:focus-visible,
.voice-pick:focus-visible,
.voice-play:focus-visible,
.option:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .card.is-speaking,
  .card.enter-next,
  .card.enter-prev,
  .listen-btn.is-speaking,
  .option.is-correct,
  .option.is-wrong,
  .result-emoji,
  .scene-bubble.is-popping,
  .scene-label.is-popping,
  .new-best,
  .mic-btn.is-listening { animation: none; }
  .story-line { transition: none; }
  .story-line.is-reading { transform: none; }
}

/* ---------- Nuôi chim ---------- */

/* Ô "Chim của bé" ở đầu màn chọn lớp */
.bird-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, #FFF3C4, #FFE0B2);
  box-shadow: 0 6px 0 var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.08s, box-shadow 0.08s;
}

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

.bird-tile-emoji { font-size: 2.6rem; line-height: 1; }

.bird-tile-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.bird-tile-name { font-size: 1.25rem; font-weight: 800; }

.bird-tile-note { color: var(--muted); font-weight: 700; font-size: 0.95rem; }

.bird-tile-go { font-size: 2rem; font-weight: 800; color: var(--accent); }

/* Khung cảnh chim */
.bird-stage { background: #BDE6FF; }

.bird-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.bird-say-en { font-size: 1.4rem; font-weight: 800; }

.bird-say-vi { font-size: 0.85rem; font-weight: 700; color: var(--muted); }

/* Chim bằng emoji khi máy không chạy được 3D */
.bird-fallback {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 180px;
  height: 180px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  font-size: 110px;
  line-height: 1;
}

.bird-fallback.is-bouncing { animation: bounce 0.45s ease-out; }

/* Thông báo lên cấp, nổi giữa khung cảnh */
.bird-levelup {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: calc(100% - 32px);
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--shadow);
  text-align: center;
  animation: pop 0.5s ease-out;
  cursor: pointer;
}

.bird-levelup-title { font-size: 1.6rem; font-weight: 800; color: var(--focus-letter); }

.bird-levelup-news { font-weight: 700; }

/* Cấp, thanh lớn lên */
.bird-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bird-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bird-level { font-size: 1.2rem; font-weight: 800; }

.bird-rename {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 6px 4px;
}

.bird-meter {
  height: 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.bird-meter-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFD166, #FF9F1C);
  transition: width 0.3s;
}

.bird-note { margin: 0; color: var(--muted); font-weight: 700; }

.bird-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 12px 14px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--shadow);
}

.bird-name label { width: 100%; font-weight: 800; }

.bird-name input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 8px 14px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
}

.bird-name .btn { min-height: 48px; }

.bird-actions {
  display: flex;
  gap: 10px;
}

.bird-actions .btn { flex: 1; }

.bird-actions .btn:disabled { opacity: 0.5; }

.bird-hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.bird-hint.is-nudging { animation: bounce 0.45s ease-out; color: var(--focus-letter); }

/* "+3 🌾 hạt cho chim" ở màn kết quả game */
.seed-reward {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: #FFF3C4;
  color: #8A5A00;
  font-weight: 800;
  text-decoration: none;
  animation: pop 0.5s ease-out;
}

.scene-result .seed-reward { align-self: center; }

/* Hàng nút của chế độ thử (?test=1), chỉ người lớn dùng */
.bird-testbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 2px dashed #E63946;
  border-radius: 18px;
}

.bird-testbar-title { width: 100%; font-weight: 800; color: #E63946; font-size: 0.9rem; }

.bird-testbar .btn { flex: 1 1 40%; min-height: 44px; padding: 8px; font-size: 0.95rem; }

/* ---------- Tủ đồ của chim ---------- */
.btn-wardrobe { background: #F3E8FF; }
.btn-wardrobe:disabled { opacity: 0.6; box-shadow: none; }
.btn-wardrobe.has-new { background: #FFD6E8; animation: pop 0.5s ease-out; }

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

.wardrobe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wardrobe-title { margin: 0; font-size: 1.4rem; }

.wardrobe-done { min-height: 48px; padding: 8px 22px; }

.wardrobe-note { margin: 0; color: var(--muted); font-weight: 700; min-height: 1.3em; }

.wardrobe-slot { grid-column: 1 / -1; margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--muted); }

/* Hàng tab nhóm đồ: Đầu, Kính, Cổ, Áo, Giày, Quanh cây */
.wardrobe-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.wardrobe-tabs::-webkit-scrollbar { display: none; }

.wardrobe-tab {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 6px 2px 4px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--shadow);
  font-weight: 800;
  font-size: 0.75rem;
  line-height: 1.2;
}

.wardrobe-tab.is-current { border-color: var(--accent); background: #FFF3E6; }

.wardrobe-tab-icon { font-size: 1.4rem; line-height: 1.1; }

.wardrobe-tab-title { white-space: nowrap; }

.wardrobe-tab-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E63946;
}

.wardrobe-list { padding: 8px 2px 10px; }

.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Khi mở tủ: cả màn hình vừa một trang. Khung chim ở trên, danh sách đồ cuộn riêng ở dưới,
   nên kéo xem đồ mà chim vẫn luôn hiện. */
body.is-bird-wardrobe .app {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.is-bird-wardrobe #birdView { min-height: 0; gap: 10px; }

body.is-bird-wardrobe .bird-stage {
  flex: 0 0 auto;
  height: 40%;
  min-height: 190px;
}

body.is-bird-wardrobe .wardrobe {
  flex: 1;
  min-height: 0;
  gap: 8px;
}

body.is-bird-wardrobe .wardrobe-head .wardrobe-title { font-size: 1.2rem; }

body.is-bird-wardrobe .wardrobe-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.is-bird-wardrobe .wardrobe-item { padding: 8px 4px; }

body.is-bird-wardrobe .wardrobe-emoji { font-size: 1.8rem; }

.wardrobe-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--shadow);
}

.wardrobe-item.is-worn { border-color: var(--accent); background: #FFF3E6; }

.wardrobe-item.is-locked { opacity: 0.55; }

.wardrobe-emoji { font-size: 2rem; line-height: 1.1; }

.wardrobe-en { font-weight: 800; }

.wardrobe-vi { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-align: center; }

.wardrobe-new {
  position: absolute;
  top: -8px;
  right: -4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #E63946;
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 800;
}

/* Dòng thông báo dịp (Tết, Trung thu, Halloween…) trên màn nuôi chim */
.bird-event {
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  background: #FFF0F6;
  color: #9D174D;
  font-weight: 800;
  text-align: center;
}

.bird-event.is-done { background: #ECFDF3; color: #2B9348; }
