:root {
  --bg1: #fff6e9;
  --bg2: #e8f8f5;
  --ink: #1a535c;
  --muted: #5c7a7f;
  --coral: #ff6b6b;
  --teal: #4ecdc4;
  --sun: #ffe66d;
  --purple: #a29bfe;
  --green: #00b894;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(26, 83, 92, 0.12);
  --radius: 22px;
  /* Be Vietnam Pro hỗ trợ đủ dấu tiếng Việt (ô, ơ, ê...) — tránh lỗi glyph như Fredoka */
  --font-display: "Be Vietnam Pro", "Nunito", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #ffe8a3 0, transparent 35%),
    radial-gradient(circle at 90% 0%, #c5f6ef 0, transparent 40%),
    linear-gradient(165deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  /* line-height cao hơn để dấu thanh không bị cắt */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--coral); text-decoration: none; }
img { max-width: 100%; }

.container { width: min(1100px, 92%); margin: 0 auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 22px;
  font-weight: 800; font-family: var(--font-display); font-size: 1.05rem;
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 6px 0 rgba(0,0,0,.08);
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn-primary { background: var(--coral); color: #fff; }
.btn-teal { background: var(--teal); color: #083b40; }
.btn-sun { background: var(--sun); color: #5c4b00; }
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid #d9ecea; box-shadow: none; }
.btn-block { width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; gap: 10px; position: relative; z-index: 30;
  flex-wrap: nowrap;
}
.brand {
  font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
  color: var(--ink); display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.brand-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 42vw;
}
.brand-badge {
  width: 36px; height: 36px; border-radius: 12px; background: var(--coral);
  display: grid; place-items: center; color: #fff; font-size: 1.05rem; flex-shrink: 0;
}
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.stats-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: #fff; border-radius: 999px; padding: 8px 12px;
  font-weight: 800; font-size: .9rem; box-shadow: var(--shadow);
}
.pill-compact { padding: 6px 10px; font-size: .82rem; }
.menu-toggle {
  width: 42px; height: 42px; border: 0; border-radius: 14px;
  background: #fff; box-shadow: var(--shadow); font-size: 1.25rem;
  cursor: pointer; font-weight: 800; color: var(--ink);
}
.top-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; border-radius: 18px; box-shadow: var(--shadow);
  padding: 10px; min-width: 200px; display: flex; flex-direction: column; gap: 4px;
}
.top-menu[hidden] { display: none !important; }
.top-menu a, .top-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 12px 14px; border-radius: 12px; font: inherit; font-weight: 700;
  color: var(--ink); cursor: pointer; text-decoration: none;
}
.top-menu a:hover, .top-menu button:hover { background: #eefaf7; }
.top-menu-user {
  padding: 8px 14px 10px; font-weight: 800; color: var(--muted); font-size: .9rem;
  border-bottom: 1px solid #e8f0ef; margin-bottom: 4px;
}

/* Ẩn header khi làm bài để tối ưu không gian tương tác */
body.play-mode .brand-text { display: none; }
body.play-mode .pill-compact { display: none; }
body.play-mode .topbar { padding: 6px 0 4px; }
body.play-focus .topbar,
body.play-mode.play-focus #appTopbar { display: none !important; }
body.play-mode .container { width: min(720px, 96%); }

.play-shell { padding-top: 4px; }
.play-progress { margin-bottom: 10px; padding: 12px 14px !important; }
.play-progress-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-weight: 800; margin-bottom: 8px;
}
.play-back {
  width: 36px; height: 36px; border-radius: 12px; background: #eef6f5;
  display: grid; place-items: center; color: var(--ink); font-weight: 900;
}
.celebrate-card { text-align: center; padding: 28px 18px !important; }
.celebrate-actions {
  display: flex; flex-direction: column; gap: 10px; margin-top: 18px;
}
@media (min-width: 560px) {
  .celebrate-actions { flex-direction: row; justify-content: center; flex-wrap: wrap; }
}

/* Landing */
.hero {
  display: grid; gap: 28px; padding: 20px 0 40px;
  align-items: center;
}
@media (min-width: 860px) {
  .hero { grid-template-columns: 1.1fr .9fr; min-height: 78vh; }
}
.hero h1 {
  font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.25; margin: 8px 0 12px; font-weight: 800;
}
.hero .lead { font-size: 1.15rem; color: var(--muted); margin: 0 0 18px; }
.price-tag {
  display: inline-flex; align-items: baseline; gap: 8px;
  background: #fff; border-radius: 18px; padding: 10px 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.price-tag strong { font-size: 2rem; color: var(--coral); font-family: var(--font-display); }
.hero-visual {
  background: linear-gradient(145deg, #ff8e8e, #ffd93d 45%, #6bcB77);
  border-radius: 32px; min-height: 340px; position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-visual .fox {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 6rem; animation: bob 2.4s ease-in-out infinite;
}
.hero-visual .bubble {
  position: absolute; left: 18px; bottom: 18px; right: 18px;
  background: rgba(255,255,255,.92); border-radius: 18px; padding: 14px;
  font-weight: 700;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }

.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border-top: 1px solid #e5f2f0; padding: 10px 14px;
  display: flex; gap: 10px; justify-content: center; align-items: center;
}
.sticky-cta--dual { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
.sticky-trial {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #ffe66d, #ffb703);
  color: #5c4b00; text-decoration: none; font-weight: 800;
  border-radius: 18px; padding: 8px 12px; min-width: 118px;
  box-shadow: 0 6px 0 rgba(0,0,0,.08); line-height: 1.15; font-size: .82rem;
}
.sticky-trial__ico { font-size: 1.45rem; }
.sticky-trial__txt { text-align: left; }
.sticky-buy { flex: 1; max-width: 280px; }
@keyframes trialBlink {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 0 rgba(0,0,0,.08), 0 0 0 0 rgba(255,183,3,.55); }
  50% { transform: scale(1.06); box-shadow: 0 6px 0 rgba(0,0,0,.08), 0 0 0 10px rgba(255,183,3,0); }
}
.sticky-trial--pulse { animation: trialBlink 1.2s ease-in-out infinite; }
.demo-top {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.section { padding: 36px 0; }
.section h2 { font-family: var(--font-display); font-size: 1.8rem; margin: 0 0 8px; }
.section .sub { color: var(--muted); margin: 0 0 20px; }
.grid-3 { display: grid; gap: 14px; }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.feature { text-align: center; }
.feature .ico { font-size: 2.2rem; }

form label { display: block; font-weight: 700; margin: 10px 0 4px; font-size: .92rem; }
form input, form textarea, form select {
  width: 100%; padding: 12px 14px; border-radius: 14px;
  border: 2px solid #d7ebe8; font: inherit; background: #fff;
}
form input:focus, form textarea:focus { outline: none; border-color: var(--teal); }
.alert {
  padding: 12px 14px; border-radius: 12px; margin: 10px 0; font-weight: 700;
}
.alert-ok { background: #d8f5e7; color: #0b6b4f; }
.alert-err { background: #ffe3e3; color: #a61e1e; }
.alert-info { background: #e7f5ff; color: #1c7ed6; }

/* App path */
.path { display: flex; flex-direction: column; gap: 14px; padding: 10px 0 80px; }
.path-node {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  background: #fff; border-radius: 20px; padding: 14px; box-shadow: var(--shadow);
}
.path-node.locked { opacity: .55; filter: grayscale(.3); }
.path-dot {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  color: #fff; font-size: 1.5rem; font-weight: 800; font-family: var(--font-display);
}
.mastery-bar {
  height: 10px; background: #eef6f5; border-radius: 999px; overflow: hidden; margin-top: 6px;
}
.mastery-bar > span { display: block; height: 100%; background: var(--green); border-radius: inherit; }

/* Player */
.player-shell { max-width: 720px; margin: 0 auto; padding: 12px 0 40px; }
.prompt {
  font-family: var(--font-display); font-size: 1.4rem; text-align: center;
  margin: 12px 0 18px; line-height: 1.45; font-weight: 700;
}
.math-visual {
  text-align: center; font-size: 2.2rem; font-weight: 800;
  font-family: var(--font-display); margin: 10px 0; line-height: 1.4;
}
.compare-row {
  display: flex; justify-content: center; align-items: center; gap: 24px;
  font-size: 2.2rem; font-weight: 800; margin: 10px 0; line-height: 1.3;
}
.compare-row .vs { font-size: 1rem; color: var(--muted); }
.fill-input {
  font-size: 1.6rem; text-align: center; max-width: 160px; margin: 0 auto; display: block;
  padding: 12px; border-radius: 14px; border: 2px solid #d7ebe8; font-family: var(--font-display);
}
.items-row {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0;
}
.item-emoji {
  font-size: 2.4rem; cursor: pointer; user-select: none;
  transition: transform .12s ease;
}
.item-emoji.tapped { transform: scale(1.2); filter: drop-shadow(0 4px 0 rgba(0,0,0,.1)); }
.choices {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 12px;
}
.choice-btn {
  border: 0; border-radius: 18px; padding: 18px; font-size: 1.4rem;
  font-weight: 800; font-family: var(--font-display); background: #fff;
  box-shadow: var(--shadow); cursor: pointer; color: var(--ink);
}
.choice-btn:hover { background: #f3fffd; }
.choice-btn.correct { background: #b2f2bb; }
.choice-btn.wrong { background: #ffc9c9; }
.feedback { display: none !important; }
.fb-lock { overflow: hidden !important; }
.fb-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  background: rgba(18, 42, 48, .55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fbFade .2s ease;
}
.fb-modal {
  width: min(420px, 100%);
  max-height: min(78vh, 520px);
  overflow: auto;
  text-align: center;
  font-weight: 700;
  border-radius: 24px;
  padding: 28px 20px 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
  background: #fff;
}
.fb-modal.ok { background: #e8fbef; border: 4px solid #51cf66; }
.fb-modal.bad { background: #fff0f0; border: 4px solid #ff6b6b; }
.fb-modal .btn-next-q {
  margin-top: 18px; min-width: 200px; min-height: 52px; font-size: 1.15rem;
}
.feedback-msg {
  font-size: 1.2rem;
  line-height: 1.45;
  margin: 10px 0 4px;
  font-family: var(--font-display);
  color: var(--ink);
}
@keyframes fbFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.tts-btn {
  border: 0; background: var(--purple); color: #fff; border-radius: 999px;
  padding: 10px 14px; font-weight: 800; cursor: pointer;
}

.progress-ring {
  height: 14px; background: #e6f4f1; border-radius: 999px; overflow: hidden;
}
.progress-ring > i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); width: 0%; transition: width .3s; }

.admin-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.admin-table th, .admin-table td { padding: 10px 8px; border-bottom: 1px solid #e8f0ef; text-align: left; }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800;
}
.badge-pending { background: #fff3bf; color: #8a6d00; }
.badge-paid { background: #d3f9d8; color: #087f5b; }
.badge-cancel { background: #ffe3e3; color: #c92a2a; }

.chart-bars {
  display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 10px 0;
}
.chart-bars .bar {
  flex: 1; background: var(--teal); border-radius: 8px 8px 4px 4px; min-width: 8px;
  position: relative;
}
.chart-bars .bar span {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: .65rem; font-weight: 700; white-space: nowrap;
}

.drag-board { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.drag-col { min-height: 120px; background: #f7fffe; border: 2px dashed #bfe8e2; border-radius: 16px; padding: 10px; }
.chip {
  display: inline-block; margin: 6px; padding: 10px 14px; background: #fff;
  border-radius: 12px; box-shadow: var(--shadow); font-weight: 800; cursor: grab;
}

.order-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.order-item {
  width: 64px; height: 64px; border-radius: 16px; background: #fff;
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 800;
  box-shadow: var(--shadow); cursor: pointer; border: 3px solid transparent;
}
.order-item.selected { border-color: var(--coral); }

.footer-note { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 0 80px; }

.feedback-ico { font-size: 2rem; animation: popIn .35s ease; }
.qr-box { text-align: center; margin: 14px 0; }
.qr-box img {
  width: min(280px, 100%); border-radius: 16px; background: #fff;
  box-shadow: var(--shadow); border: 4px solid #fff;
}
.qr-caption { font-size: .9rem; color: var(--muted); margin-top: 8px; }

/* Motions */
@keyframes popIn {
  0% { transform: scale(.7); opacity: 0; }
  70% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes floatY {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes pulseSoft {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes shakeX {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes successPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.anim-pop { animation: popIn .4s ease both; }
.anim-float { animation: floatY 2.4s ease-in-out infinite; }
.anim-pulse { animation: pulseSoft 1.8s ease-in-out infinite; }
.anim-shake { animation: shakeX .45s ease; }
.anim-success { animation: successPop .45s ease; }
.btn, .choice-btn, .tts-btn, .order-item, .path-dot, .brand-badge {
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, filter .18s ease;
}
.btn:hover, .choice-btn:hover, .tts-btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.03);
}
.btn-bounce:active { transform: scale(.94) !important; }
.feature .ico { display: inline-block; animation: floatY 3s ease-in-out infinite; }
.feature:nth-child(2) .ico { animation-delay: .2s; }
.feature:nth-child(3) .ico { animation-delay: .4s; }
.path-node { transition: transform .2s ease, box-shadow .2s ease; }
.path-node:not(.locked):hover { transform: translateY(-3px); }
.path-dot { animation: popIn .5s ease both; }

/* Install app */
.install-modal {
  position: fixed; inset: 0; background: rgba(20,40,45,.55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.install-modal.show { display: flex; }
.install-modal__card {
  background: #fff; border-radius: 22px; padding: 22px; max-width: 400px; width: 100%;
  box-shadow: var(--shadow); position: relative; text-align: left;
}
.install-modal__card h3 { margin: 8px 0 10px; font-family: var(--font-display); line-height: 1.35; }
.install-modal__card ol { padding-left: 1.2rem; margin: 0 0 12px; }
.install-modal__card li { margin: 8px 0; line-height: 1.45; }
.install-modal__close {
  position: absolute; right: 12px; top: 8px; border: 0; background: transparent;
  font-size: 1.6rem; cursor: pointer; color: var(--muted);
}
.install-hint { color: var(--muted); font-size: .88rem; }
.ios-share { display: inline-block; transform: rotate(180deg); }
[data-install-app].install-ready { box-shadow: 0 0 0 3px rgba(78,205,196,.45), 0 6px 0 rgba(0,0,0,.08); }

h1,h2,h3,.brand,.pill,.btn,.choice-btn,.prompt,.path-dot {
  line-height: 1.35;
}
