:root {
  --green: #7CA541; --green-2: #9BC85E; --green-d: #4E8F2A;
  --purple: #5B449B; --purple-2: #8E6BE0; --purple-d: #2C1C58;
  --navy: #120a2e; --ink: #1b1238;
  --gold: #FFD23F; --gold-2: #FFF1B8; --pink: #E64980; --orange: #F08A24;
  --txt: #ffffff; --muted: #c4bce6; --card: rgba(255, 255, 255, .07); --bd: rgba(255, 255, 255, .16);
  --ok: #51cf66; --bad: #ff6b6b;
  --t0: #7CA541; --t1: #8E6BE0; --t2: #F08A24;
  --font: 'Be Vietnam Pro', system-ui, 'Segoe UI', Arial, sans-serif;
  --display: 'Baloo 2', 'Be Vietnam Pro', system-ui, sans-serif;
  --r: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--txt); background: var(--navy);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }
.hidden { display: none !important; }

.bg {
  position: fixed; inset: 0; z-index: -2; overflow: hidden;
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(124, 165, 65, .34), transparent 60%),
    radial-gradient(900px 700px at 105% 10%, rgba(142, 107, 224, .45), transparent 60%),
    radial-gradient(1000px 800px at 50% 120%, rgba(230, 73, 128, .22), transparent 60%),
    linear-gradient(180deg, #1d1145 0%, #120a2e 60%, #0b0620 100%);
}
.bg::before {
  content: ""; position: absolute; left: 50%; top: 36%; width: 220vmax; height: 220vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, .045) 0deg 6deg, transparent 6deg 18deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 42%); mask-image: radial-gradient(circle, #000 0%, transparent 42%);
  animation: bgspin 140s linear infinite;
}
@keyframes bgspin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.petals { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.petal {
  position: absolute; top: -40px; width: 16px; height: 12px; background: var(--c);
  border-radius: 12px 0 12px 0; opacity: .85; transform: scale(var(--s));
  animation: fall var(--d) linear infinite; animation-delay: var(--dl);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .06);
}
@keyframes fall {
  0% { transform: translate(0, -5vh) rotate(0) scale(var(--s)); }
  50% { transform: translate(var(--x), 50vh) rotate(200deg) scale(var(--s)); }
  100% { transform: translate(calc(var(--x) * -.5), 110vh) rotate(420deg) scale(var(--s)); }
}

.display { font-family: var(--display); font-weight: 800; letter-spacing: .01em; line-height: 1; }
.gold-text {
  background: linear-gradient(180deg, #fffbe6 0%, #FFD23F 52%, #c98b00 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .25));
}
.ribbon {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; border-radius: 999px;
  background: linear-gradient(90deg, #E64980, #F783AC); color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 18px rgba(230, 73, 128, .35);
}

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .08); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-weight: 700; font-size: 15px; transition: transform .12s, background .15s, border-color .15s, filter .15s;
  user-select: none; touch-action: manipulation;
}
.btn:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .35; cursor: not-allowed; filter: grayscale(.4); transform: none; }
.btn.primary { background: linear-gradient(180deg, #ffe27a, #f2b400); color: #2a1a00; border-color: #fff0b0; box-shadow: 0 6px 0 #a87a00, 0 10px 24px rgba(255, 210, 63, .3); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:active { box-shadow: 0 3px 0 #a87a00; transform: translateY(3px); }
.btn.green { background: linear-gradient(180deg, #9BC85E, #6a9a34); border-color: #c5e59a; box-shadow: 0 6px 0 #3f6d17; }
.btn.green:active { box-shadow: 0 3px 0 #3f6d17; transform: translateY(3px); }
.btn.red { background: linear-gradient(180deg, #ff7b8a, #d6334a); border-color: #ffb3bd; box-shadow: 0 6px 0 #8f1a2a; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 19px; padding: 14px 30px; }
.btn.xl { font-size: clamp(20px, 2vw, 28px); padding: 16px 40px; }
.btn.sm { font-size: 13px; padding: 7px 13px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--bd); background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: var(--gold); }

input[type=text], input[type=password], input[type=tel], select, textarea {
  width: 100%; background: rgba(0, 0, 0, .28); color: #fff; border: 1.5px solid var(--bd); border-radius: 12px;
  padding: 11px 13px; font: inherit; font-size: 15px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 63, .2); }
select option { background: #241552; }
input[type=checkbox] { accent-color: var(--gold); width: 17px; height: 17px; }

.card { background: var(--card); border: 1px solid var(--bd); border-radius: var(--r); padding: 18px; backdrop-filter: blur(6px); }

/* ---------- Thú nhồi bông ---------- */
.mascot { position: relative; display: inline-flex; flex-direction: column; align-items: center; width: var(--mw, 110px); user-select: none; }
.mascot .m-fig { width: 100%; aspect-ratio: 120/150; transform-origin: 50% 95%; animation: bop 1000ms cubic-bezier(.45, 0, .55, 1) infinite; animation-delay: var(--sync, 0ms); will-change: transform; }
.mascot .m-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mascot .m-head { transform-origin: 60px 80px; animation: headbob 1000ms ease-in-out infinite; animation-delay: var(--sync, 0ms); }
.mascot .m-arm-l { transform-origin: 34px 96px; animation: armL 1000ms ease-in-out infinite; animation-delay: var(--sync, 0ms); }
.mascot .m-arm-r { transform-origin: 86px 96px; animation: armR 1000ms ease-in-out infinite; animation-delay: var(--sync, 0ms); }
.mascot .m-bow { animation: bow 500ms ease-in-out infinite; animation-delay: var(--sync, 0ms); transform-box: fill-box; transform-origin: center; }
.mascot .m-shadow { transform-origin: 60px 144px; animation: shadow 500ms ease-in-out infinite; animation-delay: var(--sync, 0ms); }
.m-tag {
  position: relative; z-index: 2; max-width: 150%; margin-bottom: -6%; padding: 3px 10px 4px; border-radius: 999px;
  background: var(--tagc, #E64980); color: #fff; font-weight: 800; font-size: calc(var(--mw, 110px) * .13 + 3px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
  border: 2px solid rgba(255, 255, 255, .7);
}
.m-tag span { display: block; overflow: hidden; text-overflow: ellipsis; }
@keyframes bop {
  0%, 100% { transform: translateY(0) rotate(-5deg) scale(1, 1); }
  12% { transform: translateY(0) rotate(-5deg) scale(1.06, .93); }
  25% { transform: translateY(-11%) rotate(0deg) scale(.97, 1.04); }
  50% { transform: translateY(0) rotate(5deg) scale(1, 1); }
  62% { transform: translateY(0) rotate(5deg) scale(1.06, .93); }
  75% { transform: translateY(-11%) rotate(0deg) scale(.97, 1.04); }
}
@keyframes headbob { 0%, 100% { transform: rotate(4deg); } 50% { transform: rotate(-4deg); } }
@keyframes armL { 0%, 100% { transform: rotate(10deg); } 50% { transform: rotate(-35deg); } }
@keyframes armR { 0%, 100% { transform: rotate(35deg); } 50% { transform: rotate(-10deg); } }
@keyframes bow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12) rotate(-6deg); } }
@keyframes shadow { 0%, 100% { transform: scale(1); } 50% { transform: scale(.8); } }
/* Di chuột / chạm: tăng động hơn */
.mascot:hover .m-fig, .mascot.hyper .m-fig { animation: crazy 380ms ease-in-out infinite; }
.mascot:hover .m-head, .mascot.hyper .m-head { animation: crazyhead 190ms ease-in-out infinite; }
.mascot:hover .m-arm-l, .mascot.hyper .m-arm-l { animation: armL 190ms ease-in-out infinite; }
.mascot:hover .m-arm-r, .mascot.hyper .m-arm-r { animation: armR 190ms ease-in-out infinite; }
.mascot:hover { z-index: 5; }
@keyframes crazy {
  0%, 100% { transform: translateY(0) rotate(-14deg) scale(1.08); }
  25% { transform: translateY(-22%) rotate(0deg) scale(1.12, 1.02); }
  50% { transform: translateY(0) rotate(14deg) scale(1.08); }
  75% { transform: translateY(-22%) rotate(0deg) scale(1.12, 1.02); }
}
@keyframes crazyhead { 0%, 100% { transform: rotate(12deg); } 50% { transform: rotate(-12deg); } }
.mascot.jump .m-fig { animation: jump 760ms cubic-bezier(.3, .7, .4, 1) 1; }
@keyframes jump { 0% { transform: scale(1.1, .85); } 30% { transform: translateY(-55%) rotate(-180deg) scale(1); } 60% { transform: translateY(-40%) rotate(-360deg); } 100% { transform: translateY(0) rotate(-360deg) scale(1); } }
.mascot.pop-in { animation: popin .6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes popin { from { transform: scale(0) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.mascot.off { opacity: .45; filter: grayscale(.6); }
.mascot.off .m-fig, .mascot.off .m-head, .mascot.off .m-arm-l, .mascot.off .m-arm-r { animation-play-state: paused; }
.mascot .crown { position: absolute; top: -18%; left: 50%; transform: translateX(-50%); font-size: calc(var(--mw, 110px) * .3); filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .4)); animation: crown 1s ease-in-out infinite; z-index: 3; }
@keyframes crown { 50% { transform: translateX(-50%) translateY(-6px) rotate(6deg); } }

/* ---------- Bảng ô chữ ---------- */
.board {
  --cw: 50px; --gap: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--gap);
  padding: 12px; border-radius: 20px; border: 2px solid rgba(255, 255, 255, .25);
  background: radial-gradient(ellipse at 50% 40%, rgba(91, 68, 155, .55), rgba(18, 10, 46, .85));
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .5), 0 0 24px rgba(142, 107, 224, .25);
}
.brow { display: flex; gap: var(--gap); }
.cell { width: var(--cw); height: calc(var(--cw) * 1.18); perspective: 700px; }
.cell .ci { position: relative; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.3, 1.3, .5, 1); transform-style: preserve-3d; }
.cell.open .ci { transform: rotateY(180deg); }
.cell.sym .ci { transition: none; }
.cell .f, .cell .b { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--cw) * .16); display: flex; align-items: center; justify-content: center; }
.cell .f { background: linear-gradient(180deg, #8E6BE0, #4a2f99); border: 2px solid #c9b8ff; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .2), inset 0 0 12px rgba(0, 0, 0, .3); }
.cell .f::after { content: ""; width: 34%; height: 34%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .35), transparent 70%); }
.cell .b { background: linear-gradient(180deg, #ffffff, #efe9ff); color: #2C1C58; transform: rotateY(180deg); font-family: var(--display); font-weight: 800; font-size: calc(var(--cw) * .66); border: 2px solid var(--gold); line-height: 1; padding-top: 6%; }
.cell.sym .b { background: transparent; border-color: transparent; color: var(--gold); }
.cell.gap { visibility: hidden; }
.cell.flash .b { animation: flash .45s 3; }
@keyframes flash { 50% { background: #FFF1B8; box-shadow: 0 0 22px var(--gold); } }
.cell.pick { cursor: pointer; }
.cell.pick .f { animation: pick .6s infinite alternate; border-color: #ff9fd0; }
@keyframes pick { to { box-shadow: 0 0 18px #ff5fb8; filter: brightness(1.35); } }

/* ---------- Vòng quay ---------- */
.wheel-box { position: relative; aspect-ratio: 1; }
.wheel-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 30px rgba(255, 210, 63, .28)); }
.wtxt { paint-order: stroke; stroke: rgba(0, 0, 0, .3); stroke-width: 3px; font-family: var(--display); }
.bulb { fill: #FFF1B8; }
.wheel-box .bulb.b1 { animation: bl 1.6s steps(2) infinite; }
.wheel-box .bulb.b2 { animation: bl 1.6s steps(2) infinite .8s; }
.wheel-box.spinning .bulb.b1 { animation-duration: .24s; }
.wheel-box.spinning .bulb.b2 { animation-duration: .24s; animation-delay: .12s; }
@keyframes bl { 50% { fill: #6b5200; } }

/* ---------- Lớp hiệu ứng ---------- */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; }
#fx-fire { z-index: 5; }
.float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.float-emoji { position: absolute; font-size: 40px; animation: floatup 2.2s ease-out forwards; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .35)); }
@keyframes floatup { 0% { transform: translate(-50%, 0) scale(.4); opacity: 0; } 15% { opacity: 1; transform: translate(-50%, -30px) scale(1.15); } 100% { transform: translate(calc(-50% + var(--dx)), -260px) scale(.9); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; background: rgba(20, 12, 50, .95); border: 1px solid var(--bd); padding: 10px 18px; border-radius: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: toastin .25s; max-width: 92vw; text-align: center; }
.toast.err { border-color: #ff8a8a; }
@keyframes toastin { from { transform: translate(-50%, 20px); opacity: 0; } }
.netbar { position: fixed; top: 0; left: 0; right: 0; z-index: 130; text-align: center; padding: 6px; font-size: 13px; font-weight: 700; background: #d6334a; color: #fff; transform: translateY(-100%); transition: transform .25s; }
.netbar.show { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .mascot .m-fig, .mascot .m-head, .mascot .m-arm-l, .mascot .m-arm-r, .mascot .m-bow, .bg::before { animation-duration: 2.5s !important; }
}
