:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2a1a12;
  --muted: #7a6455;
  --red: #d7262e;
  --red-dark: #a8161d;
  --gold: #f4b41a;
  --line: #f0e0c8;
  --ok: #1f8a4c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--red); color: #fff;
}
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 800; }
.fb { font-weight: 600; opacity: .9; font-size: 14px; }
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px; }

.hero { text-align: center; padding: 8px 0 4px; }
.hero-bot { width: 120px; height: auto; }
.kicker { margin: 4px 0 0; color: var(--red); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
h1 { font-size: 26px; line-height: 1.25; margin: 6px 0 8px; font-weight: 800; }
.lead { color: var(--muted); margin: 0 0 16px; }

.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.amt {
  border: 2px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 14px 4px; font: inherit; font-weight: 800; font-size: 17px; color: var(--ink); cursor: pointer;
}
.amt.on { border-color: var(--red); background: #ffefe6; color: var(--red-dark); }
.amt:disabled { opacity: .35; cursor: default; }

.btn {
  display: inline-flex; justify-content: center; align-items: center; text-align: center;
  border: 0; border-radius: 12px; padding: 14px 16px; font: inherit; font-weight: 800;
  cursor: pointer; text-decoration: none; min-height: 50px;
}
.btn.main { width: 100%; background: var(--red); color: #fff; font-size: 17px; box-shadow: 0 4px 0 var(--red-dark); }
.btn.main:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--red-dark); }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); flex: 1; font-weight: 600; }
.row-btns { display: flex; gap: 8px; margin: 12px 0; }

.challenges { margin-top: 28px; }
.challenges h2 { font-size: 18px; margin: 0 0 10px; }
.ch {
  display: block; background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; color: var(--ink); text-decoration: none;
}
.ch b { display: block; }
.ch span { color: var(--muted); font-size: 14px; }

.budget-bar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 12px; text-align: center;
}
.budget-bar .lbl { display: block; font-size: 12px; opacity: .7; }
.budget-bar b { font-size: 16px; }
.budget-bar b.zero { color: #7be3a3; }
.rule { background: #fff2c9; border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0 0; }

.cats { margin-top: 12px; }
.cat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.cat.locked { opacity: .45; }
.cat-head { display: flex; align-items: center; gap: 8px; }
.cat-ico { font-size: 22px; width: 28px; text-align: center; }
.cat-name { flex: 1; font-weight: 600; font-size: 15px; }
.cat-pct { color: var(--muted); font-size: 13px; min-width: 38px; text-align: right; }
.cat-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.cat-row input[type=range] { flex: 1; accent-color: var(--red); height: 28px; }
.cat-num { width: 112px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: #fffdf8; }
.cat-num input { width: 100%; border: 0; background: transparent; font: inherit; font-weight: 600; padding: 8px 0; text-align: right; min-width: 0; }
.cat-num small { color: var(--muted); margin-left: 4px; }

.sticky-go { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 16px 0 8px; }
.warn { color: var(--red-dark); font-weight: 600; font-size: 14px; margin: 0 0 8px; text-align: center; }

#card { width: 100%; height: auto; border-radius: 14px; box-shadow: 0 6px 24px rgba(80, 30, 0, .15); display: block; }
.follow { text-align: center; color: var(--muted); font-size: 14px; }
.follow a { color: var(--red); font-weight: 600; }

.foot { max-width: 560px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: 12px; text-align: center; }

/* vé số */
.ticket {
  background: linear-gradient(135deg, #fff3c4, #ffd76a); border: 3px dashed var(--red);
  border-radius: 18px; padding: 12px; box-shadow: 0 8px 20px rgba(160, 60, 0, .18);
}
.ticket-top { display: flex; justify-content: space-between; font-weight: 800; color: var(--red-dark); font-size: 14px; letter-spacing: .04em; }
.ticket-bot { font-size: 12px; color: var(--red-dark); text-align: center; margin-top: 8px; }
.scratch { position: relative; height: 150px; margin-top: 10px; border-radius: 12px; overflow: hidden; background: #fff; }
.prize { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.prize small { font-weight: 800; color: var(--muted); letter-spacing: .1em; }
.prize b { font-size: 48px; font-weight: 800; color: var(--red); line-height: 1.1; }
#scratch-cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; transition: opacity .5s; }
.hint { text-align: center; color: var(--muted); font-weight: 600; margin: 10px 0 14px; }
.link { display: block; margin: 10px auto; background: none; border: 0; color: var(--red); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
#after-scratch .amounts { margin-top: 8px; }
.pop { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* mascot khi chia tiền */
.buddy { display: flex; align-items: flex-end; gap: 6px; margin-top: 10px; }
.buddy img { width: 64px; height: auto; flex: none; }
.bubble {
  position: relative; flex: 1; margin: 0 0 18px; background: #fff; border: 2px solid var(--ink);
  border-radius: 14px; padding: 8px 12px; font-weight: 600; font-size: 15px;
}
.bubble::before { content: ""; position: absolute; left: -10px; bottom: 10px; border: 8px solid transparent; border-right-color: var(--ink); }

/* trò khác */
.more { margin-top: 28px; }
.more h2 { font-size: 18px; margin: 0 0 4px; }
.more .sub { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.game { display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; color: var(--ink); text-decoration: none; }
.game .gi { font-size: 30px; }
.game b { display: block; }
.game span { color: var(--muted); font-size: 13px; }
.game .go { margin-left: auto; color: var(--red); font-weight: 800; font-size: 13px; white-space: nowrap; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

.row-btns .btn { flex: 1; width: auto; }
.ticket, .scratch, .prize { user-select: none; -webkit-user-select: none; }
