:root {
  --pink: #ff6b9d;
  --orange: #ffa64d;
  --yellow: #ffd93d;
  --green: #4ecb71;
  --blue: #4da6ff;
  --purple: #a66bff;
  --red: #ff5c5c;
  --ink: #2d2a4a;
  --card: #ffffff;
  --bg1: #8ec5fc;
  --bg2: #e0c3fc;
  --shadow: 0 10px 0 rgba(0,0,0,0.08), 0 14px 24px rgba(45,42,74,0.12);
  --radius: 26px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Be Vietnam Pro', sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1), var(--bg2) 60%, #fcd5ea);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3, .title-font, button {
  font-family: 'Baloo 2', 'Be Vietnam Pro', sans-serif;
}

.bg-shapes {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.bg-shapes .shape {
  position: absolute;
  font-size: 2.6rem;
  opacity: 0.35;
  animation: float 9s ease-in-out infinite;
  filter: drop-shadow(0 6px 6px rgba(0,0,0,0.08));
}
.s1 { top: 8%; left: 6%; animation-delay: 0s; }
.s2 { top: 18%; right: 10%; animation-delay: 1.5s; font-size: 3.2rem; }
.s3 { bottom: 14%; left: 12%; animation-delay: 3s; }
.s4 { bottom: 22%; right: 8%; animation-delay: 2s; font-size: 3rem; }
.s5 { top: 48%; left: 2%; animation-delay: 4s; font-size: 3.4rem; }
.s6 { top: 60%; right: 4%; animation-delay: 1s; font-size: 3rem; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-26px) rotate(6deg); }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.mascot {
  font-size: 2.6rem;
  background: #fff;
  border-radius: 50%;
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform: translateY(0) rotate(0deg);} 50%{transform: translateY(-6px) rotate(-6deg);} }

.brand {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--ink);
  text-shadow: 2px 2px 0 #fff;
}
.brand small { display:block; font-family:'Be Vietnam Pro'; font-weight:600; font-size:0.85rem; color:#5b577a; }

/* ---------- Cards / screens ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  animation: pop 0.35s ease;
}
@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.center { text-align: center; }

/* ---------- Start screen ---------- */
.start-emoji { font-size: 5rem; margin-bottom: 6px; }
.start-title { font-size: 1.9rem; font-weight: 800; margin: 6px 0 4px; color: var(--purple); }
.start-sub { font-size: 1.05rem; color: #5b577a; margin-bottom: 22px; }

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 480px) { .option-grid { grid-template-columns: 1fr 1fr; } }

.len-btn {
  border: 3px solid transparent;
  background: linear-gradient(135deg, #fff, #f3f0ff);
  border-radius: 18px;
  padding: 18px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 0 #ddd6fb;
  transition: transform .12s ease, box-shadow .12s ease;
  color: var(--ink);
}
.len-btn .big { display:block; font-size:1.6rem; font-family:'Baloo 2'; }
.len-btn:hover { transform: translateY(-3px); }
.len-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #ddd6fb; }
.len-btn.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, #efe6ff, #fde6f3);
  box-shadow: 0 6px 0 var(--purple);
}

.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--orange));
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 16px 38px;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 7px 0 #d44e7e;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(5px); box-shadow: 0 2px 0 #d44e7e; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform:none; }

.btn-secondary {
  background: #fff;
  color: var(--purple);
  border: 3px solid var(--purple);
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease;
}
.btn-secondary:hover { transform: translateY(-2px); background: #f6f0ff; }

/* ---------- Progress ---------- */
.progress-wrap {
  margin-bottom: 18px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  color: #534f77;
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.progress-track {
  height: 20px;
  background: #ffffffaa;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.08);
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width .4s ease;
  position: relative;
}
.score-pill {
  display:inline-flex; align-items:center; gap:6px;
  background:#fff; border-radius:999px; padding:6px 14px;
  font-weight:800; box-shadow: var(--shadow); color: var(--orange);
}

/* ---------- Question ---------- */
.q-type-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f0e9ff;
  color: var(--purple);
  margin-bottom: 10px;
}
.q-text {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 20px;
  color: var(--ink);
}

/* single / multi choices */
.choice-list { display: flex; flex-direction: column; gap: 12px; }
.choice-btn {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f7f6ff;
  border: 3px solid #e8e4fb;
  border-radius: 18px;
  padding: 14px 18px;
  font-size: 1.05rem;
  font-family: 'Be Vietnam Pro';
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.choice-btn:hover { transform: translateX(4px); border-color: var(--blue); }
.choice-btn .letter {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #ccc4f0;
  display:flex; align-items:center; justify-content:center;
  font-weight: 800;
}
.choice-btn.selected { border-color: var(--purple); background: #efe6ff; }
.choice-btn.selected .letter { background: var(--purple); color:#fff; border-color: var(--purple); }
.choice-btn.correct { border-color: var(--green); background: #e5faec; }
.choice-btn.correct .letter { background: var(--green); color:#fff; border-color: var(--green); }
.choice-btn.wrong { border-color: var(--red); background: #ffecec; }
.choice-btn.wrong .letter { background: var(--red); color:#fff; border-color: var(--red); }
.choice-btn:disabled { cursor: default; }

/* grid category (co/khong, dung/sai) */
.grid-stmt-list { display:flex; flex-direction:column; gap: 16px; }
.grid-stmt {
  background: #f7f6ff;
  border-radius: 18px;
  padding: 14px 16px;
  border: 3px solid #e8e4fb;
}
.grid-stmt-text { font-weight: 600; margin-bottom: 10px; font-size: 1.02rem; }
.grid-choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.grid-chip {
  flex: 1;
  min-width: 90px;
  border: 3px solid #ccc4f0;
  background: #fff;
  border-radius: 14px;
  padding: 10px;
  font-weight: 700;
  font-family: 'Baloo 2';
  cursor: pointer;
  transition: transform .1s ease;
}
.grid-chip:hover { transform: translateY(-2px); }
.grid-chip.selected { background: var(--purple); border-color: var(--purple); color: #fff; }
.grid-chip.correct { background: var(--green); border-color: var(--green); color: #fff; }
.grid-chip.wrong { background: var(--red); border-color: var(--red); color: #fff; }
.grid-chip:disabled { cursor:default; }

/* drag match (matching + ordering) */
.dm-wrap { display:flex; flex-direction: column; gap: 18px; }
.dm-hint { font-size: 0.92rem; color:#6a6690; font-weight:600; background:#fff7e0; border-radius:14px; padding:10px 14px; }
.dm-slots { display:flex; flex-direction:column; gap:12px; }
.dm-slot {
  display:flex; align-items:center; gap:12px;
  background:#f7f6ff; border:3px dashed #ccc4f0; border-radius:16px;
  padding:12px 14px; min-height: 58px;
}
.dm-slot.over { border-color: var(--blue); background:#eaf4ff; }
.dm-slot.filled { border-style: solid; }
.dm-slot-label { flex: 1; font-weight:600; font-size: 0.98rem; }
.dm-slot-target {
  min-width: 150px;
  flex-shrink: 0;
  min-height: 44px;
  border-radius: 12px;
  background: #fff;
  border: 2px solid #ddd6fb;
  display:flex; align-items:center; justify-content:center;
  padding: 4px 8px;
}
.dm-pool {
  display:flex; flex-wrap:wrap; gap:10px;
  padding: 14px;
  background: #fff6ec;
  border-radius: 16px;
  min-height: 66px;
}
.dm-chip {
  touch-action: none;
  user-select: none;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #4a2e00;
  font-weight: 700;
  font-family: 'Baloo 2';
  padding: 10px 16px;
  border-radius: 14px;
  cursor: grab;
  box-shadow: 0 4px 0 #d98a1f;
  font-size: 0.96rem;
  line-height: 1.3;
}
.dm-chip.dragging { opacity: 0.35; }
.dm-chip.placed-correct { background: linear-gradient(135deg, #b9f3c9, var(--green)); color:#073b17; box-shadow: 0 4px 0 #2fa852; }
.dm-chip.placed-wrong { background: linear-gradient(135deg, #ffc2c2, var(--red)); color:#5c0b0b; box-shadow: 0 4px 0 #c43f3f; }
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%) rotate(-3deg) scale(1.05);
  opacity: 0.95;
}

/* text fallback */
.text-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 3px solid #ccc4f0;
  font-size: 1.05rem;
  font-family: 'Be Vietnam Pro';
}
.fallback-note { font-size: 0.85rem; color:#9a4b00; background:#fff3de; padding:8px 12px; border-radius:10px; margin-top:10px; }

/* feedback banner */
.feedback-banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  font-weight: 700;
  display:flex; align-items:center; gap:10px;
  animation: pop .25s ease;
}
.feedback-banner.ok { background:#e5faec; color:#1f7a3d; }
.feedback-banner.bad { background:#ffecec; color:#b23232; }

/* footer nav */
.nav-row {
  display:flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

/* ---------- Results ---------- */
.result-stars { font-size: 3.4rem; margin: 6px 0 10px; }
.result-score { font-size: 2.6rem; font-weight: 800; color: var(--purple); }
.result-sub { color:#5b577a; font-weight:600; margin-bottom: 14px; }
.result-stats-row { display:flex; justify-content:center; gap:12px; margin-bottom: 22px; flex-wrap: wrap; }
.result-stat-pill {
  font-weight: 800;
  font-family: 'Baloo 2';
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 1.05rem;
}
.result-stat-pill.ok { background:#e5faec; color:#1f7a3d; }
.result-stat-pill.bad { background:#ffecec; color:#b23232; }
.review-item {
  text-align:left;
  background:#f7f6ff;
  border-radius:16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border-left: 8px solid var(--green);
}
.review-item.wrong { border-left-color: var(--red); }
.review-q { font-weight:700; margin-bottom:6px; }
.review-line { font-size: 0.92rem; margin: 2px 0; }
.review-line.correct-ans { color:#1f7a3d; font-weight:700; }
.review-line.user-ans { color:#b23232; }

footer.credit {
  text-align:center;
  font-size: 0.8rem;
  color: #6a6690;
  margin-top: 30px;
  padding: 0 8px;
  line-height: 1.5;
}
footer.credit a { color: var(--purple); font-weight: 700; text-decoration: underline; }

@media (max-width: 480px) {
  .q-text { font-size: 1.1rem; }
  .card { padding: 20px 16px; }
  .dm-slot-target { min-width: 110px; }
}
