:root {
  --ink: #1c2430;
  --muted: #5b6573;
  --paper: #f7f1e6;
  --card: #fffdf8;
  --line: #e6dccb;
  --a: #e06a4a;
  --a-soft: #fde8e1;
  --b: #2f8f6b;
  --b-soft: #e3f4eb;
  --c: #2b6cb0;
  --c-soft: #e4eefb;
  --d: #c9891a;
  --d-soft: #f8ecd2;
  --shadow: 0 10px 28px rgba(48, 36, 20, 0.1);
  --radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
}

body {
  font-family: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -10%, #ffe7c2 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #d7ecff 0%, transparent 50%),
    var(--paper);
  line-height: 1.45;
}

button, a.btn {
  font-family: inherit;
  cursor: pointer;
}

[hidden] { display: none !important; }

.app {
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 8px;
  z-index: 5;
}

.bar-link {
  text-decoration: none;
  color: #5b5346;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stars {
  font-weight: 800;
  background: var(--d-soft);
  color: #8a5d0c;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 14px;
}

.dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  flex: 1;
}

.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e6dccb;
}

.dots span.is-on { background: var(--c); }
.dots span.is-done { background: var(--b); }

.stage {
  flex: 1;
  display: grid;
  margin-top: 18px;
}

.screen {
  grid-area: 1 / 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 28px 32px;
  display: none;
}

.screen.is-on { display: block; animation: rise 0.35s ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.eyebrow, .step-tag, .codes {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8a5a18;
}

.step-tag {
  display: inline-block;
  background: var(--d-soft);
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 10px;
}

h1, h2 {
  font-family: Nunito, "Be Vietnam Pro", sans-serif;
  line-height: 1.15;
}

h1 { font-size: clamp(28px, 5vw, 42px); margin: 10px 0 18px; }
h2 { font-size: clamp(24px, 4vw, 32px); margin-bottom: 8px; }

.lead, .prompt {
  color: var(--muted);
  font-size: 18px;
  max-width: 42ch;
  margin-bottom: 18px;
}

.prompt b { color: var(--ink); }

.heroes {
  display: flex;
  gap: 18px;
  margin: 8px 0 18px;
}

.hero-card {
  text-align: center;
  font-weight: 800;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 800;
  font-size: 16px;
  text-decoration: none;
  color: inherit;
}

.btn.big { padding: 16px 28px; font-size: 18px; }
.btn.primary { background: var(--c); color: #fff; }
.btn.ghost { background: #fff; border: 2px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.codes { margin-top: 16px; color: var(--muted); }

.choice-row, .compare, .baskets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.scene, .compare-card, .basket {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  font-weight: 700;
  color: var(--ink);
}

.scene { display: grid; gap: 10px; transition: transform 0.15s ease, border-color 0.15s ease; }
.scene:hover { transform: translateY(-3px); }
.scene.is-right { border-color: var(--b); background: var(--b-soft); }
.scene.is-wrong { border-color: var(--a); background: var(--a-soft); }

.scene-art, .avatar {
  width: 100%;
  aspect-ratio: 1.2;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}

.avatar {
  width: 140px;
  height: 140px;
  aspect-ratio: auto;
  margin: 0 auto 8px;
}

.avatar.kid, .scene-art.kid-cry, .take-icon.kid-mini {
  background: linear-gradient(#ffe7c2, #ffd7a8);
}

.avatar.robot, .scene-art.robot-tear, .take-icon.robot-mini {
  background: linear-gradient(#dce7f5, #c5d4e8);
}

.kid::before, .kid-cry::before, .kid-mini::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  background: #f7c9a3;
  border-radius: 50%;
  box-shadow: inset 0 -8px 0 #e8b089;
}

.kid::after, .kid-cry::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 52%;
  width: 28px;
  height: 14px;
  margin-left: -14px;
  border: 3px solid #7a3d2a;
  border-top: none;
  border-radius: 0 0 16px 16px;
}

.kid-cry::after {
  height: 10px;
  border-radius: 16px 16px 4px 4px;
  border-bottom: none;
  border-top: 3px solid #7a3d2a;
  top: 58%;
}

.kid-cry {
  background-image:
    radial-gradient(circle at 38% 58%, #6ec4ff 6px, transparent 7px),
    radial-gradient(circle at 62% 62%, #6ec4ff 5px, transparent 6px);
}

.robot::before, .robot-tear::before, .robot-mini::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 32%;
  width: 78px;
  height: 70px;
  margin-left: -39px;
  background: #8ea3bb;
  border-radius: 16px;
  box-shadow: 0 -14px 0 -8px #6d829a;
}

.robot::after, .robot-tear::after {
  content: "◡";
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
}

.robot.is-off::after { content: "–"; opacity: 0.35; }

.robot-tear {
  background-image: radial-gradient(circle at 62% 68%, #6ec4ff 7px, transparent 8px);
}

.has-heart::after {
  content: "❤";
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  color: var(--a);
  font-size: 22px;
  animation: beat 0.9s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: translateX(-50%) scale(1); }
  30% { transform: translateX(-50%) scale(1.2); }
}

.kid.has-heart::after { content: "❤"; border: none; width: auto; height: auto; background: none; box-shadow: none; }

.face-grid, .face-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px 0 16px;
}

.face-row { grid-template-columns: repeat(6, 1fr); }
.face-row.compact { grid-template-columns: repeat(3, 1fr); }

.face-btn {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 10px 6px 12px;
  display: grid;
  gap: 6px;
  justify-items: center;
  font-weight: 800;
  color: var(--ink);
}

.face-btn.is-seen, .face-btn.is-right { border-color: var(--b); background: var(--b-soft); }
.face-btn.is-wrong { animation: shake 0.35s ease; }
.face-btn.is-picked { border-color: var(--c); background: var(--c-soft); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.emoji-face {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  position: relative;
  background: #ffd56a;
}

.emoji-face.vui { background: #ffd56a; }
.emoji-face.buon { background: #9ec7ea; }
.emoji-face.gian { background: #f3a394; }
.emoji-face.so { background: #d7c4f0; }
.emoji-face.ngacnhien { background: #f8c56b; }
.emoji-face.binhthuong { background: #e7d7b8; }

.emoji-face::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 22px;
  height: 8px;
  background:
    radial-gradient(circle at 6px 4px, #3a2a1a 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 6px) 4px, #3a2a1a 4px, transparent 5px);
}

.emoji-face.vui::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  height: 12px;
  border: 3px solid #3a2a1a;
  border-top: none;
  border-radius: 0 0 16px 16px;
}

.emoji-face.buon::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 10px;
  height: 12px;
  border: 3px solid #3a2a1a;
  border-bottom: none;
  border-radius: 16px 16px 0 0;
}

.emoji-face.gian::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 16px;
  height: 4px;
  background: #3a2a1a;
  border-radius: 4px;
}

.emoji-face.so::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 14px;
  height: 16px;
  margin-left: -7px;
  border: 3px solid #3a2a1a;
  border-radius: 50%;
}

.emoji-face.ngacnhien::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: #3a2a1a;
  border-radius: 50%;
}

.emoji-face.binhthuong::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  height: 3px;
  background: #3a2a1a;
  border-radius: 4px;
}

.hint { color: var(--muted); font-size: 14px; }

.sit-card {
  background: var(--c-soft);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.sit-text { font-size: 22px; font-weight: 800; }
.sit-count { color: var(--muted); font-size: 13px; font-weight: 700; margin-top: 4px; }

.feedback {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 700;
}

.feedback.ok { background: var(--b-soft); color: #1d6a4d; }
.feedback.no { background: var(--a-soft); color: #9a3a22; }

.sort-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 72px;
  margin-bottom: 14px;
}

.sort-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-card.is-selected { border-color: var(--c); box-shadow: 0 0 0 3px var(--c-soft); }
.sort-card .mini { font-size: 22px; }

.basket {
  min-height: 160px;
  text-align: left;
}

.basket span { display: block; color: var(--muted); font-weight: 600; font-size: 13px; margin: 4px 0 8px; }
.basket.yes { background: var(--b-soft); }
.basket.no { background: var(--a-soft); }
.basket-items { display: flex; flex-wrap: wrap; gap: 6px; }
.basket-items .sort-card { pointer-events: none; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
}

.chip {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
}

.chip.is-on { background: var(--c); color: #fff; border-color: var(--c); }

.sentence {
  background: var(--d-soft);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}

.takeaways {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.takeaways li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
}

.take-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}

.kid-mini::before,
.robot-mini::before {
  width: 38px;
  height: 36px;
  margin-left: -19px;
  top: 24%;
}

.robot-mini::before {
  border-radius: 10px;
  box-shadow: 0 -8px 0 -5px #6d829a;
}

.chant {
  font-family: Nunito, sans-serif;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  text-align: center;
  background: var(--b-soft);
  color: #1d6a4d;
  border-radius: 18px;
  padding: 16px;
  margin: 8px 0 10px;
}

.home-task { text-align: center; color: var(--muted); margin-bottom: 16px; }

.subprompt { font-weight: 800; margin-top: 8px; }

.opt-grid {
  display: grid;
  gap: 10px;
  margin: 8px 0 16px;
}

.opt {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 800;
  text-align: left;
  color: var(--ink);
}

.opt.is-right { border-color: var(--b); background: var(--b-soft); }
.opt.is-wrong { border-color: var(--a); background: var(--a-soft); }

.baskets.three { grid-template-columns: 1fr 1fr 1fr; }
.basket.mid { background: var(--c-soft); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 8px 0 16px;
}

.pick-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 14px 10px;
  font-weight: 800;
  display: grid;
  gap: 6px;
  justify-items: center;
  color: var(--ink);
}

.pick-card.is-seen, .pick-card.is-right, .pick-card.is-on {
  border-color: var(--b);
  background: var(--b-soft);
}

.pick-card .big { font-size: 36px; line-height: 1; }

.robot-stage {
  background: var(--c-soft);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  margin-bottom: 12px;
  min-height: 120px;
  font-size: 22px;
  font-weight: 800;
}

@media (max-width: 700px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .choice-row, .compare, .baskets, .face-row { grid-template-columns: 1fr; }
  .face-grid, .face-row.compact { grid-template-columns: repeat(2, 1fr); }
  .baskets.three { grid-template-columns: 1fr; }
  .bar { border-radius: 18px; flex-wrap: wrap; }
  .screen { padding: 20px 16px 24px; }
  .avatar { width: 110px; height: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen.is-on, .has-heart::after, .face-btn.is-wrong { animation: none; }
}
