:root {
  /* Colors sampled directly from the logo file (Logo/202606 Logo Bruco-tagline.png)
     so this matches the real brand green instead of an approximated one. */
  --forest: #455a31;
  --olive: #688146;
  --mustard: #cfa639;
  --mustard-light: #e0b93a;
  --cream: #f4efe2;
  --cream-dark: #e8dfc9;
  --ink: #455a31;
  --white: #ffffff;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(69, 90, 49, 0.12);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 12px 20px;
  position: relative;
  overflow-x: hidden;
  /* light brand-tone wash instead of flat cream */
  background: radial-gradient(circle at 15% 10%, #f6f1e2 0%, #eef0e0 45%, #e9ecd9 100%);
}

/* ---- Decorative background doodles (subtle, behind the card) ---- */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.bg-decor img {
  position: absolute;
  opacity: 0.13;
  filter: saturate(0.85);
}
.bg-decor .d-bean1   { width: 120px; top: -30px; left: -30px; transform: rotate(-12deg); }
.bg-decor .d-bean2   { width: 90px;  bottom: 6%; left: -20px; transform: rotate(20deg); }
.bg-decor .d-flower  { width: 150px; top: 8%; right: -40px; transform: rotate(8deg); }
.bg-decor .d-mugs    { width: 130px; bottom: -30px; right: -20px; transform: rotate(-6deg); }
.bg-decor .d-burst1  { width: 70px;  top: 42%; left: 4%; transform: rotate(-20deg); opacity: 0.10; }
.bg-decor .d-burst2  { width: 60px;  top: 20%; right: 8%; transform: rotate(35deg); opacity: 0.10; }

/* Only the Welcome screen keeps the boxed "card" look. */
.welcome-card {
  width: 100%;
  max-width: 480px;
  background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #fbf8f0 55%, #f5efdf 100%);
  border: 1px solid rgba(69, 90, 49, 0.07);
  border-radius: 28px;
  box-shadow: 0 20px 50px -12px rgba(69, 90, 49, 0.18), 0 2px 8px rgba(69, 90, 49, 0.05);
  overflow: hidden;
  position: relative;
  z-index: 1;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

/* Everything after Welcome runs card-free, directly on the page — wider, so
   answer options get more breathing room (learned from the Bruvi reference). */
.open-area {
  width: 100%;
  max-width: 680px;
  position: relative;
  z-index: 1;
}

/* faint watermark so the welcome card isn't a flat empty block */
.app-watermark {
  position: absolute;
  width: 280px;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-6deg);
  opacity: 0.035;
  pointer-events: none;
  z-index: 0;
}

/* Header / progress — now sits above both the card and the open area */
.topbar {
  width: 100%;
  max-width: 680px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 4px;
  position: relative;
  z-index: 1;
}


.progress-cup {
  width: 34px;
  height: 34px;
  position: relative;
}
.progress-cup svg { width: 100%; height: 100%; }
.progress-cup .fill {
  transition: stroke-dashoffset 0.5s ease;
}

.screen {
  display: none;
  flex-direction: column;
  animation: fadeIn 0.4s ease;
}
.screen.active { display: flex; }
.welcome-card .screen { flex: 1; padding: 32px 28px 28px; position: relative; z-index: 1; }
.open-area .screen { padding: 4px 6px 4px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Welcome */
#screen-welcome { align-items: center; text-align: center; justify-content: center; }
#screen-welcome .bean {
  width: 100px;
  margin-bottom: 18px;
}
#screen-welcome h1 {
  font-size: 1.6rem;
  color: var(--forest);
  margin: 0 0 10px;
  line-height: 1.3;
}
#screen-welcome p {
  color: #5b5b4f;
  font-size: 0.95rem;
  margin: 0 0 28px;
  line-height: 1.5;
}
.tagline {
  font-family: 'Brush Script MT', cursive;
  color: var(--mustard);
  font-size: 1.1rem;
  margin-top: -6px;
  margin-bottom: 24px;
}

.btn-primary {
  background: linear-gradient(135deg, #3a4a2c 0%, #566b3a 100%);
  color: #faf6ec;
  border: none;
  padding: 14px 28px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 20px -6px rgba(44, 58, 31, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  width: 100%;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 22px -6px rgba(44, 58, 31, 0.4); }
.btn-primary:active { transform: translateY(0) scale(0.98); box-shadow: 0 4px 10px -4px rgba(44, 58, 31, 0.3); }

.btn-secondary {
  background: transparent;
  color: var(--olive);
  border: 1.5px solid rgba(44, 58, 31, 0.16);
  padding: 9px 28px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 2px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.btn-secondary:hover { background: rgba(44, 58, 31, 0.05); border-color: rgba(44, 58, 31, 0.28); }

.btn-small {
  background: transparent;
  color: var(--forest);
  border: 1.5px solid rgba(44, 58, 31, 0.18);
  padding: 6.5px 15px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-small:hover { background: rgba(44, 58, 31, 0.06); border-color: rgba(44, 58, 31, 0.3); }
.btn-small.ghost {
  color: var(--olive);
  border-color: var(--cream-dark);
}

/* Question screens */
.q-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 6px;
}
.q-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mustard);
  font-weight: 700;
}
.back-link {
  font-size: 0.78rem;
  color: #8a8a7a;
  cursor: pointer;
  font-weight: 600;
}
.back-link:hover { color: var(--forest); }

.q-title {
  font-size: 1.35rem;
  color: var(--forest);
  margin: 0 0 22px;
  line-height: 1.35;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Unselected = solid dark card w/ white content; selected = inverts to white
   w/ dark content — same high-contrast pattern as the Bruvi quiz reference. */
.option-card {
  background: var(--forest);
  border: 2px solid var(--forest);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  user-select: none;
}
.option-card .icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff; /* for hand-drawn SVG icons (Câu 1) using currentColor — emoji ignore this */
  transition: background 0.15s ease, color 0.15s ease;
}
.option-card .label { font-size: 0.88rem; font-weight: 700; color: var(--cream); line-height: 1.3; }

/* Hover previews the same white "selected" look — chosen state just makes it stick */
.option-card:hover,
.option-card.selected {
  background: var(--white);
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(44, 58, 31, 0.12);
  transform: translateY(-2px);
}
.option-card:hover .icon,
.option-card.selected .icon { background: var(--mustard-light); color: var(--forest); }
.option-card:hover .label,
.option-card.selected .label { color: var(--forest); }
.option-card.selected .label { color: var(--forest); }

/* Loading */
#screen-loading { align-items: center; justify-content: center; text-align: center; }
.brew-anim {
  width: 70px;
  height: 70px;
  margin-bottom: 20px;
  animation: spin 1.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#screen-loading p { color: var(--forest); font-weight: 600; }

/* Result */
#screen-result { align-items: center; text-align: center; padding-top: 2px; }
/* Gu (tên kết quả) đứng đầu — cào để lộ, giờ chỉ chứa badge+tag, không còn
   ảnh sản phẩm bên trong (ảnh chuyển xuống danh sách sản phẩm gợi ý bên
   dưới, mỗi Gu có thể gợi ý nhiều sản phẩm nên không còn hợp lý để nhét 1
   ảnh đại diện vào đây nữa). Card ngắn lại tương ứng (aspect-ratio rộng hơn). */
/* 2 giai đoạn rõ ràng: lúc CÀO thì card giữ nguyên kích thước lớn ban đầu
   (trải nghiệm cào phải đã tay) — cào xong thì tự CO LẠI (animate) thành 1
   dải kết quả gọn, nhường khoảng trống đó lại cho danh sách sản phẩm bên
   dưới. Dùng chiều cao cố định (px) thay vì aspect-ratio để 2 trạng thái
   chuyển động mượt qua lại được. */
.scratch-wrap {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 300px;
  flex-shrink: 0; /* stop the parent flex column from squashing this to fit */
  border-radius: var(--radius);
  overflow: hidden;
  margin: 2px auto 4px;
  box-shadow: var(--shadow);
  transition: height 0.5s ease 0.15s, box-shadow 0.6s ease;
}
.scratch-wrap.revealed { height: 130px; box-shadow: none; }
.scratch-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.result-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--white);
  transition: background-color 0.6s ease;
}
.result-reveal.bg-hidden { background: transparent; }
.gu-badge {
  display: inline-block;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--forest);
  background: var(--mustard-light);
  padding: 8px 20px;
  border-radius: 999px;
  margin-bottom: 8px;
  line-height: 1.3;
}
.gu-tag {
  font-size: 0.85rem;
  color: #6b6b5c;
  font-weight: 600;
  line-height: 1.4;
}
.result-info {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
  width: 100%;
  flex-shrink: 0;
}
.result-info.revealed {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Mặc định "chưa active" (xám, mờ) — chỉ sáng lên đúng màu vàng gold khi
   SĐT hợp lệ + đã tick checkbox (xem updateClaimBtnState() trong script.js). */
.btn-gold {
  background: var(--cream-dark);
  color: #a39c88;
  border: none;
  padding: 7px 24px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  box-shadow: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.25s ease, color 0.25s ease;
}
.btn-gold.active {
  background: linear-gradient(135deg, var(--mustard) 0%, var(--mustard-light) 100%);
  color: var(--forest);
  box-shadow: 0 8px 18px -6px rgba(201, 162, 39, 0.45);
}
.btn-gold.active:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-gold.active:active { transform: translateY(0) scale(0.98); }

.product-links-heading {
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  color: #6b6b5c;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
/* Luôn 1 hàng duy nhất, không xuống hàng, không ép cuộn ngang — nếu 4 sản
   phẩm không đủ chỗ thì cứ tràn ra ngoài lề (bị viewport cắt bớt ở màn hẹp,
   chấp nhận đánh đổi này để ảnh luôn to + không cần thao tác cuộn gì thêm). */
.product-links {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}
.product-card {
  flex: 0 0 260px;
  width: 260px;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.product-card:hover { border-color: var(--olive); transform: translateY(-1px); }
.product-card:active { transform: translateY(0) scale(0.98); }
/* Ảnh gốc là hình vuông (900×900) — dùng đúng tỉ lệ 1:1 để hiện full ảnh,
   không ép tỉ lệ dọc/ngang khác khiến object-fit:cover cắt mất 2 bên. */
.product-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--cream);
}
.product-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* "Mua ngay" overlay — hiện khi hover cả card (desktop); trên mobile không
   có hover, nhưng cả card vẫn là link nên vẫn bấm mua được bình thường. */
.product-buy-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(69, 90, 49, 0.82);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.product-card:hover .product-buy-overlay { opacity: 1; }
.product-buy-overlay span {
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  text-align: center;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
/* Lead capture card — single consolidated CTA card, swaps to .code-reveal once claimed */
.lead-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--cream);
  border-radius: 16px;
  padding: 5px 10px;
  text-align: left;
  box-sizing: border-box;
  margin-bottom: 3px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-bottom: 4px;
  cursor: pointer;
}
.consent-row input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--olive);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.consent-row span {
  font-size: 0.72rem;
  color: #6b6b5c;
  line-height: 1.4;
}
.consent-row.invalid span { color: #c0392b; }
.lead-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--forest);
  margin-bottom: 2px;
  text-align: center;
}
.lead-subtext {
  font-size: 0.72rem;
  color: #6b6b5c;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.3;
}
.lead-input {
  width: 100%;
  padding: 6px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--cream-dark);
  background: var(--white);
  font-size: 0.84rem;
  margin-bottom: 4px;
  font-family: inherit;
  color: var(--ink);
  box-sizing: border-box;
}
.lead-input:focus { outline: none; border-color: var(--olive); }

.field-error {
  font-size: 0.72rem;
  color: #c0392b;
  text-align: left;
  margin: -4px 0 10px;
  line-height: 1.4;
}

.code-reveal {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fbf6e3;
  border: 1.5px dashed var(--mustard);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  text-align: center;
  box-sizing: border-box;
}
.code-label {
  font-size: 0.72rem;
  color: #8a712a;
  font-weight: 600;
  margin-bottom: 6px;
}
.code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.code-value {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--forest);
}
.copy-btn {
  background: var(--white);
  border: 1.5px solid var(--mustard);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--forest);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.2s ease;
}
.copy-btn:hover { background: var(--cream); transform: translateY(-1px); }
.copy-btn:active { transform: translateY(0) scale(0.96); }
.copy-btn.copied { border-color: var(--olive); color: var(--olive); }

.lang-toggle {
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  color: var(--forest);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.lang-toggle:hover { border-color: var(--olive); transform: translateY(-1px); }

