/* ===== Tiếng Anh lớp 2 — giao diện cho bé ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #fff7ed;
  --card: #ffffff;
  --ink: #3a2c1a;
  --muted: #9a8b78;
  --line: #f0e3d4;
  --pink: #fbeaf0;   --pink-d: #c0436c;
  --amber: #faeeda;  --amber-d: #b6730f;
  --teal: #e1f5ee;   --teal-d: #0f7a5d;
  --blue: #e6f1fb;   --blue-d: #1f6fc0;
  --green: #1d9e75;
  --radius: 22px;
}
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Baloo 2", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }

/* Hình động (Noto animated emoji) + fallback emoji thường — cỡ theo font-size chỗ đặt */
.emo, .emo-fb { display: inline-block; line-height: 1; }
.emo-img { width: 1em; height: 1em; object-fit: contain; vertical-align: -0.12em; }

/* --- Nút bấm chung --- */
button { font-family: inherit; cursor: pointer; border: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green); color: #fff; font-weight: 700; font-size: 19px;
  padding: 14px 22px; border-radius: 999px; transition: transform .08s ease, filter .15s;
  box-shadow: 0 4px 0 rgba(0,0,0,.08);
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.big { width: 100%; font-size: 22px; padding: 18px; }

/* --- Thanh đầu trang --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--pink); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
}
.topbar .hello { font-size: 14px; color: var(--pink-d); }
.topbar .title { font-size: 24px; font-weight: 800; color: #7a1f3d; line-height: 1.1; }
.topbar .name-edit { cursor: pointer; text-decoration: underline dotted; }
.starcount { background: #fff; color: var(--amber-d); font-weight: 800; padding: 8px 14px; border-radius: 999px; white-space: nowrap; font-size: 17px; }
.backbtn { background: #fff; border: 2px solid var(--line); color: var(--ink); font-weight: 700; padding: 8px 16px; border-radius: 999px; font-size: 16px; }

/* --- Chọn giọng đọc --- */
.voice-pick { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 18px; flex-wrap: wrap; }
.voice-pick span { color: var(--muted); font-size: 15px; }
.voice-pick button { background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 8px 18px; font-size: 16px; font-weight: 700; color: var(--ink); transition: transform .08s; }
.voice-pick button:active { transform: scale(.96); }
.voice-pick button.on { background: var(--green); color: #fff; border-color: var(--green); }

/* --- Lưới chọn Unit --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.unit-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 12px; text-align: center;
  border: 3px solid var(--line); transition: transform .1s; position: relative; overflow: hidden;
}
.unit-card.open { cursor: pointer; }
.unit-card.open:active { transform: scale(.97); }
.unit-card .uemoji { font-size: 52px; line-height: 1; }
.unit-card .uname { font-weight: 800; margin-top: 6px; font-size: 17px; }
.unit-card .uno { font-size: 13px; color: var(--muted); }
.unit-card .ustars { font-size: 18px; margin-top: 6px; letter-spacing: 2px; }
.unit-card.locked { opacity: .55; }
.unit-card.locked .lockmsg { font-size: 13px; color: var(--muted); margin-top: 4px; }
.unit-card.c0 { background: var(--amber); }
.unit-card.c1 { background: var(--teal); }
.unit-card.c2 { background: var(--blue); }

/* --- Menu hoạt động trong 1 unit --- */
.unit-head { text-align: center; margin: 8px 0 20px; }
.unit-head .big-emoji { font-size: 64px; }
.unit-head h2 { margin: 4px 0 0; font-size: 26px; }
.unit-head .sub { color: var(--muted); font-size: 16px; }
.act-list { display: flex; flex-direction: column; gap: 12px; }
.act-row {
  display: flex; align-items: center; gap: 14px; background: #fff; border: 3px solid var(--line);
  border-radius: 18px; padding: 14px 16px; cursor: pointer; transition: transform .08s;
}
.act-row:active { transform: scale(.98); }
.act-row .ico { font-size: 32px; width: 44px; text-align: center; }
.act-row .lbl { font-weight: 700; font-size: 19px; flex: 1; }
.act-row .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.act-row .check { font-size: 24px; color: var(--green); width: 30px; text-align: center; }

/* --- Khu chơi 1 hoạt động --- */
.stage { text-align: center; }
.progress-dots { display: flex; gap: 8px; justify-content: center; margin: 4px 0 18px; }
.progress-dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.progress-dots span.on { background: var(--green); }

/* Thẻ từ */
.flashcard {
  background: var(--amber); border-radius: var(--radius); padding: 30px 16px; margin: 0 auto; max-width: 420px;
}
.flashcard .fc-emoji { font-size: 120px; line-height: 1; }
.flashcard .fc-word { font-size: 44px; font-weight: 800; margin-top: 8px; }
.flashcard .fc-ipa { font-size: 21px; font-weight: 700; color: var(--teal-d); margin-top: 2px; }
.flashcard .fc-vi { font-size: 20px; color: var(--amber-d); margin-top: 4px; }
.sound-btn {
  margin: 18px auto 0; background: var(--green); color: #fff; font-size: 22px; font-weight: 700;
  padding: 14px 26px; border-radius: 999px; display: inline-flex; gap: 10px; box-shadow: 0 4px 0 rgba(0,0,0,.08);
}
.sound-btn:active { transform: translateY(2px); }
.nav-row { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }

/* Nghe & chọn / Đánh vần */
.question-prompt { font-size: 20px; color: var(--muted); margin-bottom: 6px; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 460px; margin: 12px auto 0; }
.opt {
  background: #fff; border: 3px solid var(--line); border-radius: 20px; padding: 18px 8px;
  font-size: 60px; transition: transform .08s, border-color .15s, background .15s;
}
.opt:active { transform: scale(.96); }
.opt.right { border-color: var(--green); background: #e9faf2; }
.opt.wrong { border-color: #e36; background: #fdeef2; animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.letters { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.letter-btn {
  width: 64px; height: 64px; border-radius: 16px; background: #fff; border: 3px solid var(--line);
  font-size: 30px; font-weight: 800; color: var(--ink);
}
.letter-btn:active { transform: scale(.95); }
.letter-btn.used { opacity: .4; }
.word-blanks { font-size: 46px; font-weight: 800; letter-spacing: 4px; margin-top: 10px; }
.word-blanks .blank { color: var(--green); border-bottom: 5px solid var(--green); padding: 0 4px; }

/* Mẫu câu */
.sentence-box { background: var(--blue); border-radius: var(--radius); padding: 22px 18px; max-width: 480px; margin: 0 auto; text-align: center; }
.sentence-box .en { font-size: 28px; font-weight: 800; }
.sentence-box .vi { font-size: 18px; color: var(--blue-d); margin-top: 4px; }
.sentence-list { display: flex; flex-direction: column; gap: 14px; }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.mini-btn { background: var(--green); color: #fff; font-weight: 700; font-size: 17px; padding: 10px 18px; border-radius: 999px; box-shadow: 0 4px 0 rgba(0,0,0,.08); }
.mini-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.mini-btn.mic { background: #d8553a; }
.mini-btn.listening { animation: pulse .9s ease-in-out infinite; }
.mini-btn:disabled { background: #c3bdb3; box-shadow: none; cursor: default; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.09); } }
.say-result { margin-top: 14px; min-height: 6px; }
.say-hint { color: var(--blue-d); font-size: 15px; }
.score-big { font-size: 48px; font-weight: 800; line-height: 1; }
.score-msg { font-size: 19px; font-weight: 800; margin-top: 2px; }
.score-heard { color: #6b6256; font-size: 14px; margin-top: 6px; font-style: italic; }

/* Khen ngợi / kết quả */
.praise { font-size: 26px; font-weight: 800; color: var(--green); margin: 14px 0; min-height: 34px; }
.result-emoji { font-size: 90px; }
.result-score { font-size: 24px; margin: 10px 0; }

/* Nhân vật + màn giới thiệu chủ đề */
.mascot { font-size: 74px; display: inline-block; animation: bob 1.6s ease-in-out infinite; }
.mascot.big { font-size: 96px; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-14px) rotate(4deg); } }
.bubble { background: #fff; border: 3px solid var(--line); border-radius: 18px; padding: 10px 18px; display: inline-block; font-weight: 700; margin: 4px 0 14px; }
.intro { text-align: center; padding-top: 6px; }
.intro-emoji { font-size: 92px; animation: bob 2.4s ease-in-out infinite; }
.intro h2 { margin: 8px 0 2px; font-size: 28px; }
.intro .sub { color: var(--muted); font-size: 16px; }
.phonics-chip { display: inline-block; margin-top: 12px; background: var(--amber); color: var(--amber-d); font-weight: 800; padding: 8px 18px; border-radius: 999px; font-size: 17px; }

/* Hiệu ứng hiện ra (nảy nhẹ) */
.pop-in { animation: popin .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes popin { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Badge khen ngợi / động viên bay lên */
.praise-pop {
  position: fixed; left: 50%; top: 36%; transform: translate(-50%,-50%); z-index: 60;
  background: #fff; border: 4px solid var(--green); color: var(--green); font-weight: 800;
  font-size: 34px; padding: 14px 30px; border-radius: 26px; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); animation: popjoy 1.25s ease forwards;
}
.praise-pop.soft { border-color: var(--amber-d); color: var(--amber-d); }
@keyframes popjoy {
  0%   { transform: translate(-50%,-50%) scale(.3);  opacity: 0; }
  18%  { transform: translate(-50%,-50%) scale(1.18); opacity: 1; }
  68%  { transform: translate(-50%,-52%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-86%) scale(.92); opacity: 0; }
}

/* Thẻ từ: emoji nhún nhẹ cho vui */
.flashcard .fc-emoji { animation: bob 2.6s ease-in-out infinite; }

/* Pháo bông */
#fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti { position: absolute; font-size: 26px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); opacity: .9; } }

@media (max-width: 480px) {
  body { font-size: 17px; }
  .flashcard .fc-emoji { font-size: 96px; }
  .flashcard .fc-word { font-size: 36px; }
  .opt { font-size: 48px; }
}
