/* ================= EngGo — giao diện (Duolingo-style) ================= */
:root {
  --green: #58cc02; --green-d: #4aa802;
  --red: #ff4b4b; --red-d: #e33;
  --blue: #1cb0f6; --gray: #e5e5e5; --gray-d: #afafaf;
  --ink: #3c3c3c; --muted: #777; --bg: #fff;
  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  overscroll-behavior: none;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
b { font-weight: 800; }

/* ---------- Nút chung (hiệu ứng 3D) ---------- */
.btn {
  border: none; border-radius: 16px; font-family: var(--font);
  font-weight: 800; font-size: 17px; color: #fff; cursor: pointer;
  padding: 14px 18px; letter-spacing: .4px; text-transform: uppercase;
  transition: filter .1s, transform .05s; box-shadow: 0 4px 0 rgba(0,0,0,.2);
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn.big { width: 100%; }
.btn.green { background: var(--green); box-shadow: 0 4px 0 var(--green-d); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-d); }
.btn.gray { background: var(--gray); color: var(--gray-d); box-shadow: 0 4px 0 #d0d0d0; cursor: not-allowed; }

/* ---------- Thanh trên trang chủ ---------- */
.topbar {
  display: flex; gap: 8px; justify-content: space-around;
  padding: 14px 12px; position: sticky; top: 0; background: #fff;
  border-bottom: 2px solid #f0f0f0; z-index: 5;
}
.stat { font-size: 15px; color: var(--muted); display: flex; align-items: baseline; gap: 5px; }
.stat b { font-size: 19px; color: var(--ink); }
.stat span { font-size: 12px; }

/* ---------- Trang chủ / lộ trình ---------- */
.home { padding: 16px 18px 40px; }
.brand { display: flex; align-items: center; gap: 12px; margin: 6px 0 22px; }
.brand .logo { font-size: 46px; }
.brand h1 { margin: 0; font-size: 30px; color: var(--green); }
.brand p { margin: 2px 0 0; color: var(--muted); font-weight: 600; }

.unit { margin-bottom: 26px; }
.unit-head {
  background: var(--green); color: #fff; font-weight: 800; font-size: 17px;
  padding: 12px 18px; border-radius: 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 3px 0 rgba(0,0,0,.12);
}
.unit .uicon { font-size: 22px; }
.level-head {
  font-size: 13px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  color: #b06a00; background: #fff3d6; border: 2px dashed #ffc800;
  padding: 8px 14px; border-radius: 12px; margin: 8px 0 14px; text-align: center;
}
.path { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.node-cell { display: flex; align-items: center; gap: 12px; }
.node {
  width: 66px; height: 66px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 24px; font-weight: 800; color: #fff; background: var(--c, var(--green));
  box-shadow: 0 6px 0 rgba(0,0,0,.18); transition: transform .05s;
}
.node:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.node.done { background: #ffc800; box-shadow: 0 6px 0 #e0a800; }
.node.locked { background: #e5e5e5; color: #b0b0b0; box-shadow: 0 6px 0 #d0d0d0; cursor: default; }
.node-tip { font-weight: 700; color: var(--muted); font-size: 14px; }
.home-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.5; }

/* ---------- Màn chơi bài ---------- */
.lesson-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.quit { background: none; border: none; font-size: 22px; color: var(--gray-d); cursor: pointer; }
.progress { flex: 1; height: 16px; background: var(--gray); border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 10px; transition: width .3s; }
.hearts { color: var(--red); font-weight: 800; font-size: 16px; white-space: nowrap; }

.lesson-body { padding: 8px 18px; flex: 1; }
.q-prompt { font-size: 22px; font-weight: 800; margin: 6px 0 18px; }
.q-word { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 800; margin-bottom: 18px; }
.q-hint { color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.q-sentence { font-size: 21px; font-weight: 700; margin-bottom: 18px; line-height: 1.5; }
.q-sentence .blank { color: var(--blue); letter-spacing: 2px; }

.speaker, .listen-big {
  border: 2px solid var(--gray); background: var(--blue); color: #fff;
  border-radius: 12px; cursor: pointer; font-size: 18px; padding: 6px 12px;
  box-shadow: 0 3px 0 #1690cf;
}
.listen-big { display: block; font-size: 40px; padding: 20px 26px; margin: 0 auto 22px; border-radius: 20px; }
.listen-big:active, .speaker:active { transform: translateY(2px); box-shadow: 0 1px 0 #1690cf; }

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  text-align: left; padding: 15px 18px; font-size: 17px; font-weight: 700;
  border: 2px solid var(--gray); border-bottom-width: 4px; border-radius: 14px;
  background: #fff; color: var(--ink); cursor: pointer; font-family: var(--font);
}
.option.sel { border-color: var(--blue); background: #ddf4ff; color: #1487c9; }

/* xếp từ */
.build-answer {
  min-height: 56px; border-bottom: 2px solid var(--gray); margin-bottom: 22px;
  display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 10px;
}
.bank-label { color: var(--muted); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.build-bank { display: flex; flex-wrap: wrap; gap: 10px; }
.tile {
  padding: 11px 15px; font-size: 16px; font-weight: 700; font-family: var(--font);
  border: 2px solid var(--gray); border-bottom-width: 4px; border-radius: 12px;
  background: #fff; color: var(--ink); cursor: pointer;
}
.tile:active { transform: translateY(1px); }

/* ghép cặp */
.match { display: flex; gap: 14px; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.match-item {
  padding: 15px 10px; font-size: 16px; font-weight: 700; font-family: var(--font);
  border: 2px solid var(--gray); border-bottom-width: 4px; border-radius: 14px;
  background: #fff; color: var(--ink); cursor: pointer;
}
.match-item.picked { border-color: var(--blue); background: #ddf4ff; }
.match-item.wrong { border-color: var(--red); background: #ffdfe0; }
.match-item.gone { visibility: hidden; }

/* footer + phản hồi */
.footer { padding: 16px 18px 24px; position: sticky; bottom: 0; background: #fff; }
.feedback { padding: 18px; border-radius: 18px 18px 0 0; position: sticky; bottom: 0; }
.feedback.ok { background: #d7ffb8; }
.feedback.bad { background: #ffdfe0; }
.fb-title { font-weight: 800; font-size: 18px; margin-bottom: 4px; }
.feedback.ok .fb-title { color: #58a700; }
.feedback.bad .fb-title { color: #ea2b2b; }
.fb-answer { font-weight: 800; font-size: 17px; margin-bottom: 12px; color: #333; }
.feedback .btn { margin-top: 10px; }

/* kết quả */
.result { padding: 40px 22px; text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.result-emoji { font-size: 70px; }
.result h2 { font-size: 26px; margin: 10px 0 18px; }
.result-stats { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
.rs { background: #fff8dc; border: 2px solid #ffc800; border-radius: 14px; padding: 12px 16px; min-width: 78px; }
.rs b { display: block; font-size: 20px; color: #d69a00; }
.rs span { font-size: 12px; color: var(--muted); }
.result-note { color: var(--muted); font-weight: 700; margin-bottom: 22px; }
.result .btn { margin-top: 10px; }

/* gõ từ */
.type-input {
  width: 100%; padding: 15px 16px; font-size: 19px; font-family: var(--font); font-weight: 700;
  border: 2px solid var(--gray); border-bottom-width: 4px; border-radius: 14px; color: var(--ink);
  outline: none;
}
.type-input:focus { border-color: var(--blue); }

/* đọc hiểu */
.passage {
  background: #f7f7f7; border: 2px solid var(--gray); border-radius: 14px;
  padding: 14px 16px; font-size: 16px; line-height: 1.6; color: #444; margin-bottom: 16px;
}
.passage .speaker { margin-top: 10px; }
.q-question { font-size: 18px; font-weight: 800; margin-bottom: 14px; }

/* màn mẹo ngữ pháp */
.tip-screen { padding: 40px 24px; text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.tip-emoji { font-size: 60px; }
.tip-title { font-size: 22px; font-weight: 800; margin: 8px 0 14px; color: var(--green); }
.tip-text {
  background: #eafcd8; border: 2px solid var(--green); border-radius: 16px;
  padding: 18px; font-size: 17px; line-height: 1.6; font-weight: 700; color: #3f6d00; margin-bottom: 26px;
}

/* nút cài đặt + màn Thầy Robot */
.gear { background: none; border: none; font-size: 22px; cursor: pointer; padding: 0 4px; }
.set-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 2px solid #f0f0f0; }
.set-title { font-size: 19px; font-weight: 800; }
.settings { padding: 18px; }
.robot-hero { text-align: center; margin-bottom: 20px; }
.robot-hero .robot {
  font-size: 60px; width: 96px; height: 96px; line-height: 96px; margin: 0 auto 10px;
  background: #eef6ff; border: 3px solid var(--blue); border-radius: 50%;
}
.robot-hero p { color: var(--muted); font-weight: 600; font-size: 14px; line-height: 1.5; margin: 0; }
.set-label { font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--gray-d); margin: 18px 0 10px; }
.voice-list { display: flex; flex-direction: column; gap: 10px; }
.voice-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; font-family: var(--font); background: #fff; cursor: pointer;
  border: 2px solid var(--gray); border-bottom-width: 4px; border-radius: 14px;
}
.voice-item.sel { border-color: var(--blue); background: #ddf4ff; }
.voice-item .vn { font-weight: 800; font-size: 16px; color: var(--ink); }
.voice-item .vl { font-size: 14px; font-weight: 700; color: var(--muted); }
.speed-row { display: flex; align-items: center; gap: 12px; }
.speed-ic { font-size: 20px; }
.speed { flex: 1; accent-color: var(--green); height: 6px; }
.speed-valwrap { text-align: center; margin: 8px 0 18px; }
.speed-val { font-weight: 800; color: var(--green); font-size: 16px; }
.set-empty { background: #fff3d6; border: 2px solid #ffc800; border-radius: 14px; padding: 16px; font-weight: 600; color: #7a5b00; line-height: 1.6; }
.vchips { display: flex; gap: 8px; margin-bottom: 12px; }
.vchip { flex: 1; padding: 9px 8px; font-family: var(--font); font-weight: 800; font-size: 14px;
  border: 2px solid var(--gray); border-radius: 12px; background: #fff; color: var(--muted); cursor: pointer; }
.vchip.on { border-color: var(--blue); background: #ddf4ff; color: #1487c9; }
.vmeta { display: flex; align-items: center; gap: 8px; }
.vg { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 20px; }
.vg-f { background: #ffe3f1; color: #c2408a; }
.vg-m { background: #dcecff; color: #2b6fca; }
.voice-guide { background: #eafcd8; border: 2px solid var(--green); border-radius: 14px; padding: 14px 16px; margin-top: 20px; font-size: 14px; line-height: 1.55; color: #3f6d00; }
.voice-guide .vg-step { margin-top: 8px; font-weight: 600; }
.voice-guide .vg-note { margin-top: 10px; font-weight: 600; color: #5a7d1a; }

/* pinyin (tiếng Hoa) */
.py { display: block; font-size: 13px; color: #1cb0f6; font-weight: 700; margin-top: 2px; line-height: 1.15; }
.q-word > span { display: inline-block; }
.option .py, .tile .py, .match-item .py { color: #1487c9; }

/* chọn ngôn ngữ */
.lang-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-bottom: 14px;
  padding: 16px 18px; font-family: var(--font); cursor: pointer; background: #fff;
  border: 2px solid var(--gray); border-bottom-width: 4px; border-radius: 16px;
}
.lang-btn.sel { border-color: var(--green); background: #eafcd8; }
.lang-btn .lf { font-size: 34px; }
.lang-btn .ln { font-size: 19px; font-weight: 800; color: var(--ink); flex: 1; text-align: left; }
.lang-btn .lc { color: var(--green); font-size: 22px; font-weight: 800; }

@media (min-width: 480px) { .node { width: 72px; height: 72px; } }
