/* ==========================================================
   HÁI LỘC ĐẦU XUÂN 2027 — giao diện
   ========================================================== */
:root {
  --red-950: #3a0204;
  --red-900: #5c0508;
  --red-800: #7d0a0d;
  --red-700: #a00d14;
  --red-600: #c8102e;
  --red-500: #e0283d;
  --gold-200: #fff4c7;
  --gold-300: #ffe9a3;
  --gold-400: #ffd966;
  --gold-500: #f7c331;
  --gold-600: #dfa300;
  --gold-700: #a87400;
  --cream: #fff8e7;
  --paper: #fffaf0;
  --ink: #4a1a0c;
  --radius: 20px;
  --shadow: 0 12px 32px rgba(30, 0, 0, 0.45);
  --font: "Be Vietnam Pro", system-ui, sans-serif;
  --script: "Playfair Display", Georgia, serif;
  --gold-grad: linear-gradient(180deg, #fff6c4 0%, #ffd86b 38%, #f2b01e 62%, #c98a00 100%);
  --gold-line: linear-gradient(90deg, transparent, #ffd966 20%, #fff1b8 50%, #ffd966 80%, transparent);
  --cloud: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='110' viewBox='0 0 160 110'%3E%3Cg fill='none' stroke='%23ffd56a' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M18 70c-8 0-14-6-14-13s6-13 14-13c2-10 11-17 22-17 8 0 15 4 19 11 3-2 7-3 11-3 11 0 20 9 20 20 8 1 14 7 14 15H18z'/%3E%3Cpath d='M34 70c0-6 5-11 11-11s11 5 11 11'/%3E%3Cpath d='M44 59c0-4 3-7 7-7'/%3E%3Cpath d='M66 70c0-7 6-13 13-13'/%3E%3Ccircle cx='130' cy='28' r='6'/%3E%3Cpath d='M130 22c6-6 16-2 16 6'/%3E%3C/g%3E%3C/svg%3E");
  --mai: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-12 -12 24 24'%3E%3Cg fill='%23ffd43b' stroke='%23e8a100' stroke-width='.4'%3E%3Cellipse cy='-6' rx='4.2' ry='5.6'/%3E%3Cellipse cy='-6' rx='4.2' ry='5.6' transform='rotate(72)'/%3E%3Cellipse cy='-6' rx='4.2' ry='5.6' transform='rotate(144)'/%3E%3Cellipse cy='-6' rx='4.2' ry='5.6' transform='rotate(216)'/%3E%3Cellipse cy='-6' rx='4.2' ry='5.6' transform='rotate(288)'/%3E%3C/g%3E%3Ccircle r='2' fill='%23ea580c'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--cream);
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 35%, rgba(255, 120, 60, 0.28), transparent 70%),
    radial-gradient(ellipse at 50% 40%, #c8121f 0%, #9a0a12 45%, #5c0508 85%, #3a0204 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* hoa văn mây vàng */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.09;
  background-image: var(--cloud), var(--cloud);
  background-size: 160px 110px;
  background-position: 0 0, 80px 55px;
}
body::after { /* viền tối mép màn hình */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  box-shadow: inset 0 0 160px 40px rgba(20, 0, 0, 0.55);
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#petals { position: fixed; inset: 0; pointer-events: none; z-index: 3; }

.corner-branch {
  position: fixed; top: 0; z-index: 1; width: clamp(170px, 30vw, 340px); height: auto; pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}
.corner-branch.left { left: 0; }
.corner-branch.right { right: 0; transform: scaleX(-1); }
body:not(.on-welcome) .corner-branch { opacity: 0.55; width: clamp(130px, 22vw, 260px); }

.screen { display: none; position: relative; z-index: 2; min-height: 100dvh; }
.screen.active { display: flex; animation: fadeIn 0.6s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- nút ---------- */
.btn {
  position: relative; border: 0; border-radius: 999px; padding: 12px 24px; font-weight: 800; font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s; overflow: hidden;
}
.btn:active { transform: translateY(2px) scale(0.98); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn:disabled { filter: grayscale(0.5); opacity: 0.7; }
.btn-gold {
  background: var(--gold-grad); color: var(--red-800);
  box-shadow: 0 4px 0 var(--gold-700), 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-gold::after { /* ánh sáng lướt */
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: skewX(-20deg); animation: shine 3.2s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost {
  background: rgba(60, 0, 0, 0.35); color: var(--gold-200); border: 1.5px solid rgba(255, 217, 102, 0.65);
  box-shadow: inset 0 0 12px rgba(255, 200, 80, 0.12);
}
.btn-ghost:hover { background: rgba(255, 217, 102, 0.15); }
.btn-big { font-size: 1.3rem; padding: 17px 40px; animation: pulse 2s infinite; }
.btn-sm { padding: 9px 16px; font-size: 0.9rem; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 5px 0 var(--gold-700), 0 0 0 0 rgba(255, 217, 102, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
  50% { box-shadow: 0 5px 0 var(--gold-700), 0 0 0 16px rgba(255, 217, 102, 0), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
}

/* ---------- tiêu đề vàng ---------- */
.gold-text, .title, .tab-title {
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- MÀN CHÀO ---------- */
#welcome { align-items: center; justify-content: center; text-align: center; padding: 28px 20px; overflow: hidden; }
#fireworks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.frame { position: absolute; inset: 14px; pointer-events: none; z-index: 1; border: 2px solid rgba(255, 217, 102, 0.55); border-radius: 22px; }
.frame::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(255, 217, 102, 0.3); border-radius: 17px; }
.frame i { position: absolute; width: 34px; height: 34px; background: var(--mai) center / contain no-repeat; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4)); }
.frame i:nth-child(1) { left: -14px; top: -14px; } .frame i:nth-child(2) { right: -14px; top: -14px; }
.frame i:nth-child(3) { left: -14px; bottom: -14px; } .frame i:nth-child(4) { right: -14px; bottom: -14px; }

.welcome-inner { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 600px; }
.welcome-inner::before { /* hào quang sau chữ */
  content: ""; position: absolute; left: 50%; top: 30%; width: 560px; height: 560px; translate: -50% -50%; z-index: -1;
  background: radial-gradient(circle, rgba(255, 200, 80, 0.28), transparent 60%);
}
.room-name {
  margin: 0; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; font-size: 0.8rem;
  color: var(--gold-300); padding: 7px 22px; position: relative;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.3) 15%, rgba(0, 0, 0, 0.3) 85%, transparent);
}
.room-name::before, .room-name::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: var(--gold-line); }
.room-name::before { top: 0; } .room-name::after { bottom: 0; }
.title {
  font-family: var(--script); font-size: clamp(3.4rem, 14vw, 6.6rem); line-height: 1; margin: 6px 0 0;
  filter: drop-shadow(0 3px 0 #6b0a0a) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 30px rgba(255, 190, 60, 0.35));
}
.subtitle { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--gold-300); letter-spacing: 0.06em; display: flex; align-items: center; gap: 12px; }
.subtitle::before, .subtitle::after { content: ""; width: 46px; height: 1.5px; background: var(--gold-line); }
.hint { margin: 0; font-size: 0.85rem; opacity: 0.75; }

.countdown { margin: 14px 0 8px; }
.cd-label { margin: 0 0 10px; font-size: 0.82rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-300); }
.cd-boxes { display: flex; gap: 10px; justify-content: center; }
.cd-boxes div {
  position: relative; min-width: 72px; padding: 12px 6px 9px; border-radius: 14px;
  background: linear-gradient(180deg, #b10f1c, #6e0509);
  border: 2px solid var(--gold-500);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), inset 0 0 0 3px rgba(110, 5, 9, 1), inset 0 0 0 4px rgba(255, 217, 102, 0.4);
}
.cd-boxes b {
  display: block; font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; font-weight: 800;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cd-boxes small { font-size: 0.7rem; color: var(--gold-300); letter-spacing: 0.05em; }
.countdown.done .cd-boxes { display: none; }
.countdown.done .cd-label { font-family: var(--script); font-size: 2.2rem; text-transform: none; letter-spacing: 0; color: var(--gold-400); }

/* đèn lồng */
.lanterns { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.lantern { position: absolute; top: 0; width: 70px; transform-origin: top center; animation: swing 3.6s ease-in-out infinite; }
.lantern::before { content: ""; display: block; width: 2px; height: var(--rope, 40px); margin: 0 auto; background: var(--gold-500); }
.lantern span {
  position: relative; display: grid; place-items: center; width: 70px; height: 62px; border-radius: 50% / 46%;
  background:
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(120, 0, 0, 0.35) 9px 11px),
    radial-gradient(circle at 50% 42%, #ffb199 0%, #ff4b3e 28%, #c8102e 62%, #6e0509 100%);
  font-family: var(--script); font-size: 1.35rem; color: var(--gold-300); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 36px 6px rgba(255, 90, 50, 0.55);
}
.lantern span::before, .lantern span::after {
  content: ""; position: absolute; left: 50%; width: 34px; height: 8px; translate: -50% 0; border-radius: 3px; background: var(--gold-grad);
}
.lantern span::before { top: -4px; } .lantern span::after { bottom: -4px; }
.lantern::after { /* tua */
  content: ""; display: block; width: 10px; height: 28px; margin: 2px auto 0;
  background: repeating-linear-gradient(90deg, #ffcf40 0 1.5px, #c8102e 1.5px 3px); border-radius: 0 0 4px 4px;
}
.l1 { left: 15%; --rope: 34px; }
.l2 { right: 16%; --rope: 64px; animation-delay: -1.2s; }
.l3 { right: 30%; --rope: 14px; animation-delay: -2.1s; scale: 0.72; }
@media (max-width: 640px) { .l3 { display: none; } .lantern { scale: 0.72; } .l1 { left: 8%; } .l2 { right: 8%; } }
@keyframes swing { 0%, 100% { rotate: -6deg; } 50% { rotate: 6deg; } }

/* ---------- THẺ / FORM ---------- */
#profile { align-items: center; justify-content: center; padding: 20px; }
.card {
  position: relative; background: var(--paper); color: var(--ink); border-radius: 22px; padding: 30px 24px 24px;
  width: 100%; max-width: 430px;
  border: 3px solid var(--gold-500);
  box-shadow: var(--shadow), inset 0 0 0 6px var(--paper), inset 0 0 0 7.5px var(--red-600);
  background-image:
    var(--mai), var(--mai),
    radial-gradient(circle at 0 0, rgba(255, 201, 40, 0.18), transparent 35%),
    radial-gradient(circle at 100% 100%, rgba(255, 183, 197, 0.22), transparent 40%);
  background-repeat: no-repeat;
  background-size: 30px, 22px, auto, auto;
  background-position: 12px 12px, calc(100% - 14px) 14px, 0 0, 0 0;
}
.card h2 { margin: 0 0 18px; text-align: center; color: var(--red-700); font-size: 1.45rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-weight: 700; font-size: 0.88rem; color: #7a2e14; }
.field input, textarea {
  font: inherit; font-weight: 500; font-size: 1rem; padding: 13px 15px; border-radius: 14px;
  border: 2px solid #ecd3a4; background: #fff; color: var(--ink); width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, textarea:focus { outline: none; border-color: var(--red-600); box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.14); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.avatars button {
  font-size: 1.65rem; aspect-ratio: 1; border-radius: 14px; border: 2px solid #f0dcb4; background: linear-gradient(#fff, #fff4e0);
  display: grid; place-items: center; padding: 0; transition: transform 0.12s, box-shadow 0.12s;
}
.avatars button:hover { transform: translateY(-2px); }
.avatars button[aria-checked="true"] {
  border-color: var(--red-600); background: linear-gradient(#fff0f0, #ffd9d9); transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15), 0 6px 12px rgba(200, 16, 46, 0.25);
}
.form-error { color: var(--red-600); min-height: 1.2em; margin: 0 0 10px; font-size: 0.9rem; font-weight: 600; }
.profile-card .btn { width: 100%; }

/* ---------- TRANG CHÍNH ---------- */
#main { flex-direction: column; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: linear-gradient(180deg, rgba(70, 3, 6, 0.92), rgba(70, 3, 6, 0.75)); backdrop-filter: blur(10px);
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px; background: var(--gold-line); }
.brand { display: flex; gap: 8px; align-items: center; color: var(--gold-300); font-size: 1.02rem; }
.brand b { font-weight: 800; letter-spacing: 0.02em; }
.user-chip {
  display: flex; align-items: center; gap: 7px; border: 1.5px solid rgba(255, 217, 102, 0.6);
  background: rgba(0, 0, 0, 0.25); color: var(--gold-200); padding: 4px 14px 4px 5px; border-radius: 999px; font-weight: 700;
  max-width: 55vw;
}
.user-chip #meAvatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--gold-grad); font-size: 1.1rem; }
.user-chip #meName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tab { display: none; padding: 18px 16px 28px; max-width: 720px; width: 100%; margin: 0 auto; }
.tab.active { display: block; animation: fadeIn 0.4s ease; }
.tab-title {
  font-family: var(--script); font-size: clamp(2.3rem, 9vw, 3.2rem); text-align: center; margin: 6px 0 4px; line-height: 1.15;
  filter: drop-shadow(0 2px 0 #6b0a0a) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4));
}
.tab-sub {
  text-align: center; margin: 0 auto 14px; color: var(--gold-200); font-weight: 600; display: flex; align-items: center;
  justify-content: center; gap: 10px; max-width: 560px;
}
.tab-sub::before, .tab-sub::after { content: ""; flex: 0 0 36px; height: 1.5px; background: var(--gold-line); }

.panel {
  position: relative; border-radius: 22px; padding: 16px;
  background: linear-gradient(180deg, rgba(110, 6, 10, 0.6), rgba(60, 2, 5, 0.6));
  border: 1.5px solid rgba(255, 217, 102, 0.5);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), inset 0 0 30px rgba(255, 190, 60, 0.08);
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
  padding: 8px max(10px, calc(50% - 190px)) calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(80, 4, 7, 0.94), rgba(45, 1, 3, 0.98)); backdrop-filter: blur(10px);
}
.bottom-nav::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1.5px; background: var(--gold-line); }
.bottom-nav button {
  background: none; border: 0; color: rgba(255, 240, 210, 0.65); padding: 6px 2px; font-size: 0.74rem; font-weight: 700; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: background 0.2s, color 0.2s;
}
.bottom-nav button span { font-size: 1.35rem; transition: transform 0.2s; }
.bottom-nav button.active { color: var(--red-800); background: var(--gold-grad); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35); }
.bottom-nav button.active span { transform: scale(1.1); }

/* ---------- CÂY MAI ---------- */
.tree-wrap { position: relative; width: min(100%, 480px); aspect-ratio: 4 / 5; margin: 0 auto 8%; container-type: inline-size; }
.tree-wrap::before { /* hào quang */
  content: ""; position: absolute; inset: -6% -10% 10%; z-index: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 110, 0.35) 0%, rgba(255, 170, 60, 0.12) 40%, transparent 68%);
}
.tree { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: 1; filter: drop-shadow(0 6px 8px rgba(40, 0, 0, 0.45)); }
.flower { transform-box: fill-box; transform-origin: center; animation: bloom 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) backwards; }
@keyframes bloom { from { transform: scale(0) rotate(-40deg); } }

.pot { position: absolute; bottom: -9%; left: 50%; translate: -50% 0; width: 42%; z-index: 2; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.5)); }
.pot-rim { height: 4.2cqw; border-radius: 1.2cqw; background: linear-gradient(180deg, #ffe58a, #d69a00); border: 2px solid #8a5a00; }
.pot-body {
  margin: -1px 6% 0; height: 13cqw; border-radius: 0 0 46% 46% / 0 0 60% 60%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.25), transparent 25%, rgba(255, 255, 255, 0.25) 45%, transparent 60%, rgba(0, 0, 0, 0.25)),
    linear-gradient(180deg, #d0121f, #8e0a10);
  border: 2px solid #8a5a00; border-top: 0; display: grid; place-items: center;
}
.pot-body span {
  font-family: var(--script); font-size: 5.4cqw; padding: 0 3cqw; border-top: 1.5px solid var(--gold-500); border-bottom: 1.5px solid var(--gold-500);
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.3;
}

.envelopes { position: absolute; inset: 0; z-index: 3; }
.hang {
  position: absolute; display: flex; flex-direction: column; align-items: center; transform-origin: top center; translate: -50% 0;
  animation: swing var(--dur, 3s) ease-in-out infinite; animation-delay: var(--delay, 0s);
}
.hang .string { width: 1.5px; height: var(--str, 18px); background: linear-gradient(var(--gold-300), var(--gold-600)); }
.mini-env {
  position: relative; width: 8.6cqw; aspect-ratio: 0.66; padding: 0; border: 0; border-radius: 0.9cqw;
  background:
    radial-gradient(circle at 50% 120%, rgba(255, 200, 80, 0.25), transparent 50%),
    linear-gradient(165deg, #ff4d4d 0%, #d4142a 45%, #9a0b14 100%);
  box-shadow: 0 0.8cqw 1.6cqw rgba(30, 0, 0, 0.5), inset 0 0 0 0.45cqw #f2b01e, inset 0 0 0 0.75cqw #b00d22, inset 0 0 0 0.95cqw rgba(255, 217, 102, 0.6);
  transition: transform 0.18s, filter 0.18s, box-shadow 0.18s;
}
.mini-env::before { /* nắp */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 36%; border-radius: 0.9cqw 0.9cqw 0 0;
  background: linear-gradient(180deg, #e3283c, #b30f22); clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 1px 0 #f2b01e);
}
.mini-env .seal {
  position: absolute; left: 50%; top: 27%; translate: -50% 0; width: 4.4cqw; aspect-ratio: 1; border-radius: 50%;
  background: var(--gold-grad); display: grid; place-items: center; font-family: var(--script); font-size: 1.9cqw; color: var(--red-700);
  box-shadow: 0 0.3cqw 0.6cqw rgba(0, 0, 0, 0.35), inset 0 0 0 0.3cqw rgba(160, 13, 20, 0.5);
}
.tassel { display: block; width: 1.3cqw; height: 4.2cqw; margin-top: -0.2cqw; border-radius: 0 0 0.4cqw 0.4cqw;
  background: linear-gradient(#f7c331 0 22%, transparent 22%), repeating-linear-gradient(90deg, #e0283d 0 1px, #a00d14 1px 2px);
}
.mini-env:hover, .mini-env:focus-visible { transform: scale(1.14); filter: brightness(1.12); box-shadow: 0 0 2.6cqw rgba(255, 215, 90, 0.85), inset 0 0 0 0.45cqw #f2b01e, inset 0 0 0 0.75cqw #b00d22; }
.mini-env:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.mini-env.opened { filter: grayscale(0.55) brightness(0.75); }
.mini-env.opened .seal, .mini-env.mine .seal { font-size: 0; }
.mini-env.opened .seal::after, .mini-env.mine .seal::after { content: "✓"; font-family: var(--font); font-weight: 800; font-size: 2.2cqw; }
.mini-env.mine { filter: none; transform: scale(1.12); box-shadow: 0 0 0 0.5cqw #fff, 0 0 3cqw var(--gold-400), inset 0 0 0 0.45cqw #f2b01e; }
.envelopes.disabled .mini-env { pointer-events: none; }
.envelopes.disabled .mini-env:not(.mine):not(.opened) { filter: grayscale(0.4) brightness(0.85); }

/* ---------- MODAL MỞ BAO ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 45%, rgba(120, 10, 10, 0.97), rgba(20, 0, 0, 0.99)); overflow-y: auto;
  animation: fadeIn 0.3s ease; backdrop-filter: blur(4px);
}
.rays {
  position: fixed; left: 50%; top: 45%; width: 160vmax; height: 160vmax; translate: -50% -50%; pointer-events: none; opacity: 0.35;
  background: repeating-conic-gradient(from 0deg, rgba(255, 215, 100, 0.55) 0 6deg, transparent 6deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 45%); mask: radial-gradient(circle, #000 0%, transparent 45%);
  animation: rot 30s linear infinite;
}
@keyframes rot { to { rotate: 360deg; } }
#fxCanvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.modal-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 430px; }
.draw-msg { margin: 0; font-weight: 800; font-size: 1.1rem; color: var(--gold-300); min-height: 1.4em; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); }

.big-env { position: relative; width: 200px; height: 286px; margin-top: 70px; perspective: 900px; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.55)); }
.big-env.shake { animation: shake 0.45s ease-in-out infinite; }
@keyframes shake {
  0%, 100% { transform: rotate(0) scale(1); }
  20% { transform: rotate(-7deg) scale(1.03); }
  40% { transform: rotate(6deg) scale(1.05); }
  60% { transform: rotate(-4deg) scale(1.03); }
  80% { transform: rotate(3deg) scale(1.02); }
}
.env-back, .env-front { position: absolute; left: 0; right: 0; border-radius: 14px; }
.env-back { top: 0; bottom: 0; background: linear-gradient(170deg, #9a0b14, #5c0508); box-shadow: inset 0 0 0 4px #c98a00; }
.env-front {
  bottom: 0; height: 68%; z-index: 3; border-radius: 0 0 14px 14px;
  background: var(--cloud) center / 120px no-repeat, linear-gradient(165deg, #ff4d4d, #d4142a 45%, #9a0b14);
  box-shadow: inset 0 0 0 4px #f2b01e, inset 0 0 0 8px #b00d22, inset 0 0 0 9.5px rgba(255, 217, 102, 0.6);
  display: grid; place-items: center;
}
.env-seal {
  width: 88px; height: 88px; border-radius: 50%; background: var(--gold-grad); display: grid; place-items: center;
  font-family: var(--script); font-size: 2.4rem; color: var(--red-700); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border: 3px double var(--red-700); margin-top: 18px;
}
.env-flap {
  position: absolute; top: 0; left: 0; right: 0; height: 44%; z-index: 4; transform-origin: top center;
  background: linear-gradient(180deg, #e3283c, #b30f22); clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 14px 14px 0 0; transition: transform 0.6s ease, z-index 0s 0.3s;
}
.big-env.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.env-money {
  position: absolute; left: 9%; right: 9%; top: 7%; height: 80%; z-index: 2; border-radius: 10px;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.25) 0 6px, transparent 6px 12px), linear-gradient(135deg, #fff6d5, #ffd86b);
  border: 2px solid var(--gold-600); display: grid; place-items: center; text-align: center; color: var(--red-700); font-weight: 800;
  font-size: 1.5rem; padding: 8px; align-content: start; padding-top: 22px;
  transition: transform 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) 0.4s;
}
.big-env.open .env-money { transform: translateY(-62%); }
.em-wish { display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1; }
.em-wish b { font-family: var(--script); font-style: italic; font-size: 1.75rem; font-weight: 700;
  background: linear-gradient(180deg, #c8141c, #7a0a0e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.em-wish small { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold-700, #9a6b00); }

/* thẻ kết quả */
.rcard {
  position: relative; width: 100%; background: var(--paper); color: var(--ink); border-radius: 22px; padding: 0 22px 18px;
  text-align: center; border: 3px solid var(--gold-500); overflow: hidden;
  box-shadow: var(--shadow), inset 0 0 0 6px var(--paper), inset 0 0 0 7.5px var(--red-600);
  background-image: var(--mai), var(--mai), var(--mai), radial-gradient(circle at 50% 40%, #fffdf6, #fff3d6);
  background-repeat: no-repeat;
  background-size: 34px, 24px, 28px, auto;
  background-position: 12px calc(100% - 12px), 44px calc(100% - 10px), calc(100% - 14px) calc(100% - 14px), 0 0;
  animation: pop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.rcard .rc-top {
  margin: 0 -22px 6px; padding: 11px 10px 10px; font-size: 0.76rem; letter-spacing: 0.2em; text-transform: uppercase; font-weight: 800;
  color: var(--gold-300); background: linear-gradient(180deg, #d4142a, #9a0b14); border-bottom: 3px solid var(--gold-500);
}
.rcard .rc-who { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 12px 0 4px; font-weight: 800; font-size: 1.2rem; }
.rcard .rc-who span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font-size: 1.7rem; background: var(--gold-grad); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--gold-500); }
.rcard .rc-label {
  display: inline-block; margin: 8px 0 0; padding: 4px 14px; border-radius: 999px; background: linear-gradient(180deg, #e0283d, #a00d14);
  color: var(--gold-200); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; box-shadow: 0 3px 8px rgba(160, 13, 20, 0.35);
}
.rcard .rc-amount {
  font-size: clamp(2.7rem, 13vw, 3.8rem); font-weight: 800; line-height: 1.1; margin: 6px 0 2px; letter-spacing: -0.02em;
  background: linear-gradient(180deg, #e0283d, #8e0a10); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #ffd966);
}
.rcard .rc-troll { font-size: 1.25rem; font-weight: 800; color: var(--red-700); margin: 12px 0; }
.rcard .rc-wish {
  position: relative; font-family: var(--script); font-size: 1.55rem; line-height: 1.35; color: #8a1c10; margin: 10px 6px 14px; padding: 12px 6px 0;
}
.rcard .rc-wish::before { content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 1.5px; background: linear-gradient(90deg, transparent, #e0a400, transparent); }
.rcard .rc-foot { font-size: 0.74rem; color: #9a6b4a; border-top: 1px dashed #dcb985; padding-top: 9px; }
.rcard.jackpot { animation: pop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1), glow 1.4s ease-in-out 0.6s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px #fff3b0, 0 0 50px 14px rgba(255, 215, 0, 0.7), inset 0 0 0 6px var(--paper), inset 0 0 0 7.5px var(--red-600); } }
.rc-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

#myResult { max-width: 430px; margin: 10px auto 0; }

/* ---------- BẢNG VÀNG ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 22px; }
.stats div {
  text-align: center; padding: 14px 4px 12px; border-radius: 16px;
  background: linear-gradient(180deg, #b10f1c, #6e0509); border: 2px solid var(--gold-500);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 0 0 3px #6e0509, inset 0 0 0 4px rgba(255, 217, 102, 0.35);
}
.stats b { display: block; font-size: 1.35rem; font-weight: 800; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats small { font-size: 0.72rem; color: var(--gold-300); }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 10px auto 24px; max-width: 440px; }
.podium:empty { display: none; }
.podium .pod { flex: 1; max-width: 140px; text-align: center; }
.podium .pod .av {
  display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 6px; border-radius: 50%; font-size: 2rem; position: relative;
  background: var(--paper); box-shadow: 0 0 0 3px var(--gold-500), 0 6px 14px rgba(0, 0, 0, 0.4);
}
.podium .p1 .av { width: 70px; height: 70px; font-size: 2.4rem; }
.podium .p1 .av::before { content: "👑"; position: absolute; top: -24px; font-size: 1.5rem; }
.podium .pod .nm { font-weight: 800; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--gold-200); }
.podium .pod .am { color: var(--gold-400); font-weight: 800; font-size: 0.92rem; }
.podium .pod .base {
  margin-top: 8px; border-radius: 12px 12px 4px 4px; color: var(--red-800); font-weight: 800; font-size: 1.6rem;
  display: grid; place-items: center; background: var(--gold-grad);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.12), inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 8px 18px rgba(0, 0, 0, 0.35);
}
.podium .p2 .base { background: linear-gradient(180deg, #ffffff, #d9dde3 50%, #a9b0ba); }
.podium .p3 .base { background: linear-gradient(180deg, #ffe0c2, #e0a070 50%, #a8683c); }
.podium .p1 .base { height: 96px; } .podium .p2 .base { height: 68px; } .podium .p3 .base { height: 50px; }
.podium .p1 { order: 2; } .podium .p2 { order: 1; } .podium .p3 { order: 3; }

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.board li {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; border-radius: 16px;
  background: linear-gradient(90deg, #fffaf0, #fff1d6); color: var(--ink); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border-left: 5px solid var(--red-600);
}
.board li.me { border-left-color: var(--gold-500); box-shadow: 0 0 0 2px var(--gold-400), 0 4px 16px rgba(255, 200, 60, 0.35); }
.board .av { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--gold-grad); font-size: 1.45rem; }
.board .nm { font-weight: 800; }
.board .ws { font-size: 0.8rem; color: #8a5a40; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .am { font-weight: 800; color: var(--red-700); text-align: right; font-size: 1.02rem; }
.board .tm { font-size: 0.7rem; color: #a07a5a; text-align: right; }
.empty { text-align: center; color: var(--gold-200); padding: 24px; opacity: 0.9; }

/* ---------- KHÁC ---------- */
.music-btn {
  position: fixed; right: 14px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60; width: 50px; height: 50px;
  border-radius: 50%; border: 2px solid var(--gold-500); font-size: 1.3rem;
  background: radial-gradient(circle at 35% 30%, #d4142a, #6e0509); box-shadow: var(--shadow), 0 0 0 4px rgba(255, 217, 102, 0.18);
}
.music-btn.playing { animation: spin 6s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
body.on-welcome .music-btn { bottom: 26px; right: 26px; }
.toast {
  position: fixed; left: 50%; top: 16px; z-index: 200; transform: translate(-50%, calc(-100% - 40px)); visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), visibility 0s 0.35s;
  background: var(--paper); color: var(--ink); padding: 11px 20px; border-radius: 999px; font-weight: 700;
  box-shadow: var(--shadow), 0 0 0 2px var(--gold-500); max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.mode-badge {
  position: fixed; left: 10px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30; font-size: 0.68rem; font-weight: 700;
  background: rgba(0, 0, 0, 0.45); color: var(--gold-300); padding: 4px 10px; border-radius: 999px; pointer-events: none;
}
body.on-welcome .mode-badge { bottom: 26px; left: 26px; }

@media (max-width: 480px) {
  .cd-boxes div { min-width: 62px; }
  .cd-boxes b { font-size: 1.6rem; }
  .tab { padding: 14px 12px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}

/* ==========================================================
   TRÌNH PHÁT NHẠC
   ========================================================== */
.player {
  position: fixed; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: 2px; padding: 5px 6px 5px 5px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(150, 10, 18, 0.95), rgba(70, 3, 6, 0.95));
  border: 1.5px solid var(--gold-500); box-shadow: var(--shadow), 0 0 0 4px rgba(255, 217, 102, 0.12);
  backdrop-filter: blur(8px); animation: fadeIn 0.5s ease;
}
body.on-welcome .player { bottom: 24px; right: 24px; }
.pl-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--gold-300);
  display: grid; place-items: center; padding: 0; transition: background 0.15s, transform 0.15s;
}
.pl-btn:hover { background: rgba(255, 217, 102, 0.15); }
.pl-btn:active { transform: scale(0.92); }
.pl-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pl-btn svg { width: 17px; height: 17px; fill: currentColor; }
.pl-main { width: 42px; height: 42px; background: var(--gold-grad); color: var(--red-800); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35); }
.pl-main:hover { background: var(--gold-grad); filter: brightness(1.08); }
.pl-main svg { width: 20px; height: 20px; }
.pl-main .ic-play, .player:not(.playing) .ic-pause { display: none; }
.player:not(.playing) .ic-play { display: block; }
.pl-info { display: flex; align-items: center; gap: 8px; padding: 0 4px 0 8px; }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.eq i { width: 3px; height: 4px; border-radius: 2px; background: var(--gold-400); animation: eq 0.7s ease-in-out infinite alternate paused; }
.eq i:nth-child(2) { animation-delay: -0.3s; animation-duration: 0.55s; }
.eq i:nth-child(3) { animation-delay: -0.5s; animation-duration: 0.8s; }
.eq i:nth-child(4) { animation-delay: -0.15s; animation-duration: 0.6s; }
.player.playing .eq i { animation-play-state: running; }
@keyframes eq { to { height: 16px; } }
.pl-text { display: flex; flex-direction: column; min-width: 0; max-width: 150px; line-height: 1.2; }
.pl-text small { font-size: 0.6rem; color: var(--gold-300); opacity: 0.75; text-transform: uppercase; letter-spacing: 0.12em; }
.pl-text span { font-size: 0.82rem; font-weight: 700; color: var(--gold-200); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  #plPrev { display: none; }
  .pl-text { max-width: 96px; }
  .tab-sub::before, .tab-sub::after { display: none; }
}

/* ==========================================================
   DÂY PHÁO (bấm để đốt)
   ========================================================== */
.phao {
  position: absolute; top: 64px; z-index: 3; width: 46px; padding: 0 0 4px; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; transform-origin: top center;
  background: linear-gradient(var(--gold-500), var(--gold-500)) center top / 2px calc(100% - 40px) no-repeat;
  animation: swing 4.2s ease-in-out infinite; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.4));
}
.phao::before { content: ""; width: 2px; height: 30px; background: var(--gold-500); }
.phao.left { left: 4%; }
.phao.right { right: 4%; animation-delay: -2s; }
.phao i {
  display: block; width: 11px; height: 25px; margin-top: -7px; border-radius: 3px;
  background: linear-gradient(90deg, #6e0509, #d4142a 35%, #ff7a6b 52%, #b00d22 75%, #6e0509);
  box-shadow: inset 0 3px 0 var(--gold-500), inset 0 -3px 0 var(--gold-500);
}
.phao i:nth-child(odd) { rotate: 40deg; translate: -7px 0; }
.phao i:nth-child(even) { rotate: -40deg; translate: 7px 0; }
.phao b {
  position: relative; isolation: isolate; width: 46px; height: 46px; margin-top: 6px; display: grid; place-items: center;
  font-family: var(--script); font-size: 1rem; color: var(--gold-300); font-weight: 700;
}
.phao b::before {
  content: ""; position: absolute; inset: 7px; z-index: -1; rotate: 45deg; border-radius: 4px;
  background: linear-gradient(135deg, #e0283d, #8e0a10); border: 2px solid var(--gold-500);
}
.phao:hover i { filter: brightness(1.2); }
.phao:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 8px; }
.phao.boom { animation-play-state: paused; }
.phao.boom i, .phao.boom b { animation: crack 0.5s ease-out var(--d, 0s) forwards; }
.phao.boom b { --d: 1.3s; --dx: 0px; --dy: -10px; }
@keyframes crack {
  0% { filter: brightness(1); }
  30% { filter: brightness(3) drop-shadow(0 0 10px #ffd966); scale: 1.7; }
  100% { translate: var(--dx) var(--dy); rotate: 200deg; opacity: 0; scale: 0.3; }
}
@media (max-width: 640px) {
  .phao { top: 46px; scale: 0.72; }
  .phao.left { left: 1%; } .phao.right { right: 1%; }
  .l1 { left: 18%; } .l2 { right: 18%; }
}

/* ==========================================================
   MƯA ĐỒNG XU
   ========================================================== */
.coin {
  position: fixed; top: -50px; z-index: 150; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff6c4, #f7c331 45%, #c98a00 80%, #8a5a00);
  box-shadow: inset 0 0 0 2px #a87400, 0 3px 5px rgba(0, 0, 0, 0.4);
  animation-name: coinFall, coinSpin; animation-timing-function: cubic-bezier(0.45, 0, 0.8, 1), linear;
  animation-iteration-count: 1, infinite; animation-fill-mode: forwards, none;
}
.coin::after { content: ""; position: absolute; inset: 34%; background: #7d0a0d; border: 1.5px solid #a87400; }
@keyframes coinFall { to { top: 110vh; } }
@keyframes coinSpin { to { transform: rotateY(360deg); } }

/* ==========================================================
   BẢNG VÀNG TRỐNG
   ========================================================== */
.board li.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 10px;
  background: none; box-shadow: none; border: 0; color: var(--gold-200); text-align: center;
}
.empty-state b { font-size: 1.15rem; margin-top: 10px; }
.empty-state span { opacity: 0.85; }
.es-env {
  position: relative; width: 66px; height: 92px; border-radius: 8px; transform-origin: top center; animation: swing 3s ease-in-out infinite;
  background: linear-gradient(165deg, #ff4d4d, #d4142a 45%, #9a0b14);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4), inset 0 0 0 3px #f2b01e, inset 0 0 0 6px #b00d22;
}
.es-env::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 36%; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #e3283c, #b30f22); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.es-env::after {
  content: "Lộc"; position: absolute; left: 50%; top: 28%; translate: -50% 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold-grad); display: grid; place-items: center; font-family: var(--script); color: var(--red-700); font-size: 0.85rem;
}

/* ==========================================================
   NHẬN LỘC
   ========================================================== */
#payoutBox:empty { display: none; }
.payout { margin-top: 18px; padding: 18px 16px; }
.payout h3 { margin: 0 0 4px; text-align: center; font-size: 1.15rem; color: var(--gold-200); }
.po-amt { color: var(--gold-400); white-space: nowrap; }
.po-sub { margin: 0 0 14px; text-align: center; font-size: 0.82rem; color: var(--gold-300); opacity: 0.85; }
.po-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.po-choice {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 14px 8px 12px; border-radius: 16px;
  background: rgba(255, 248, 231, 0.06); border: 2px solid rgba(255, 217, 102, 0.35); color: var(--cream);
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.po-choice span { font-size: 1.9rem; }
.po-choice b { font-size: 0.95rem; }
.po-choice small { font-size: 0.72rem; opacity: 0.75; text-align: center; }
.po-choice:hover { transform: translateY(-2px); border-color: var(--gold-400); }
.po-choice[aria-checked="true"] {
  background: var(--paper); color: var(--ink); border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(255, 217, 102, 0.35), 0 8px 18px rgba(0, 0, 0, 0.3);
}
.payout .field { color: var(--gold-200); }
.payout select { font: inherit; font-size: 1rem; padding: 12px 14px; border-radius: 14px; border: 2px solid #ecd3a4; background: #fff; color: var(--ink); width: 100%; }
.payout select:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(255, 217, 102, 0.3); }
.payout textarea { min-height: 64px; resize: vertical; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); }
.seg button { border: 0; border-radius: 999px; padding: 9px 6px; font-weight: 700; font-size: 0.85rem; background: none; color: var(--gold-200); }
.seg button.on { background: var(--gold-grad); color: var(--red-800); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 150px; padding: 16px;
  border: 2px dashed rgba(255, 217, 102, 0.6); border-radius: 16px; cursor: pointer; text-align: center; background: rgba(0, 0, 0, 0.18);
}
.drop:hover { background: rgba(255, 217, 102, 0.08); }
.drop-img { max-width: 220px; max-height: 260px; border-radius: 10px; background: #fff; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35); }
.drop-txt { font-weight: 600; color: var(--gold-200); }
.po-hint { font-size: 0.78rem; color: var(--gold-300); opacity: 0.8; margin: 8px 0 0; text-align: center; }
.payout .form-error { color: #ffd0d0; text-align: center; }
.po-actions { display: flex; gap: 10px; justify-content: center; }
.po-actions .btn-gold { min-width: 180px; }
.po-status { margin: 10px 0 12px; padding: 10px 12px; border-radius: 12px; font-weight: 700; font-size: 0.9rem; text-align: center; }
.po-status.wait { background: rgba(255, 217, 102, 0.14); color: var(--gold-200); }
.po-status.paid { background: #d3f9d8; color: #2b8a3e; }
.po-sum {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px;
  background: var(--paper); color: var(--ink);
}
.po-sum .po-ic { font-size: 1.8rem; }
.po-sum div { flex: 1; min-width: 0; }
.po-sum b { display: block; }
.po-sum small { display: block; color: #8a5a40; word-break: break-word; }
.po-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid #e0c48a; }
.payout > .btn { display: block; margin: 0 auto; }

/* ==========================================================
   TINH CHỈNH GIAO DIỆN — gọn & sang hơn
   ========================================================== */
.title, .tab-title, .rc-wish, .countdown.done .cd-label, .pot-body span { font-style: italic; }
.title { font-size: clamp(2.7rem, 12vw, 5.6rem); line-height: 1.05; letter-spacing: -0.01em; }
.tab-title { font-size: clamp(1.9rem, 7.5vw, 2.6rem); letter-spacing: -0.01em; }
.rcard .rc-wish { font-size: 1.12rem; line-height: 1.55; }
.lantern span { font-size: 1.05rem; }
.pot-body span { font-size: 4.2cqw; }
.mini-env .seal { font-size: 1.55cqw; font-weight: 700; }
.env-seal { font-size: 1.8rem; font-weight: 700; }
.es-env::after { font-size: 0.7rem; font-weight: 700; }
.phao b { font-size: 0.78rem; }
.brand b { font-family: var(--script); font-style: italic; font-size: 1.1rem; }
.subtitle { font-size: 1rem; letter-spacing: 0.12em; text-transform: uppercase; }

/* hoa rơi nằm sau nội dung, nhẹ hơn */
#petals { z-index: 1; opacity: 0.85; }
body:not(.on-welcome) #petals { opacity: 0.45; }

/* nhãn chế độ thử: chỉ hiện ở màn chào, góc trên */
.mode-badge, body.on-welcome .mode-badge { white-space: nowrap; top: 10px; bottom: auto; left: 50%; translate: -50% 0; z-index: 5; }
body:not(.on-welcome) .mode-badge { display: none; }

/* màn chào trên điện thoại: bớt chi tiết */
@media (max-width: 640px) {
  .frame, .lanterns { display: none; }
  .corner-branch { width: 150px; }
  .phao { top: 70px; scale: 0.62; }
  .welcome-inner { gap: 12px; }
  .cd-boxes { gap: 8px; }
  .cd-boxes div { min-width: 64px; padding: 10px 4px 8px; }
}

/* thanh tab nổi dạng viên thuốc */
.bottom-nav {
  left: 50%; right: auto; translate: -50% 0; bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(340px, calc(100% - 28px)); padding: 6px; border-radius: 999px;
  border: 1.5px solid rgba(255, 217, 102, 0.55);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.bottom-nav::before { display: none; }
.bottom-nav button { flex-direction: row; justify-content: center; gap: 8px; padding: 10px 6px; font-size: 0.9rem; border-radius: 999px; }
.bottom-nav button span { font-size: 1.15rem; }
.bottom-nav button.active span { transform: none; }
#main { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

/* trình phát gọn khi ở trang chính */
.player { bottom: calc(80px + env(safe-area-inset-bottom)); }
body:not(.on-welcome) .player .pl-text, body:not(.on-welcome) #plPrev { display: none; }
body:not(.on-welcome) .player .pl-info { padding: 0 6px; }
body.on-welcome .player { left: 50%; right: auto; translate: -50% 0; bottom: 22px; }

/* bao đã mở / bị khoá: mờ đi thay vì xám xịt */
.mini-env.opened, .envelopes.disabled .mini-env:not(.mine):not(.opened) { filter: none; opacity: 0.45; }

/* khung nhạc Spotify / YouTube */
.music-dock {
  position: fixed; right: 12px; bottom: calc(138px + env(safe-area-inset-bottom)); z-index: 61;
  width: min(340px, calc(100% - 24px)); border-radius: 18px; overflow: hidden;
  background: linear-gradient(180deg, #7d0a0d, #3a0204); border: 1.5px solid var(--gold-500); box-shadow: var(--shadow);
  transform: translateY(12px); opacity: 0; pointer-events: none; transition: transform 0.25s, opacity 0.25s;
}
.music-dock.open { transform: none; opacity: 1; pointer-events: auto; }
body.on-welcome .music-dock { left: 50%; right: auto; translate: -50% 0; bottom: 84px; }
.md-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 14px; color: var(--gold-200); font-weight: 700; font-size: 0.85rem; }
.md-body { padding: 0 8px 8px; }
.music-dock[data-src="youtube"] #mdEmbed { aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; }
.music-dock[data-src="spotify"] #mdEmbed iframe { border-radius: 12px; display: block; }
#mdEmbed iframe { width: 100%; height: 100%; border: 0; }
/* thu nhỏ: vẫn phát, chỉ ẩn khung */
.music-dock:not(.open) { visibility: hidden; }

/* ==========================================================
   RUNG CÂY & THẺ CÀO
   ========================================================== */
.shake-row { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: -4px 0 6px; }
.shake-row small { color: var(--gold-300); font-size: 0.8rem; min-height: 1em; }
#btnShake { animation: nudge 2.6s ease-in-out infinite; }
@keyframes nudge { 0%, 80%, 100% { rotate: 0deg; } 84% { rotate: -4deg; } 88% { rotate: 4deg; } 92% { rotate: -3deg; } 96% { rotate: 2deg; } }
.tree-wrap.shaking .tree, .tree-wrap.shaking .envelopes { transform-origin: 50% 95%; animation: treeShake 0.16s ease-in-out 6; }
@keyframes treeShake { 0%, 100% { rotate: 0deg; } 25% { rotate: -2.2deg; } 75% { rotate: 2.2deg; } }
.hang.falling { animation: envFall 0.75s cubic-bezier(0.5, 0, 0.9, 0.6) forwards; z-index: 5; }
@keyframes envFall {
  0% { translate: -50% 0; rotate: 0deg; }
  20% { translate: -50% -10px; rotate: -12deg; }
  100% { translate: -50% 70cqw; rotate: 40deg; opacity: 0; }
}
.rc-prize { position: relative; padding: 4px 0 2px; margin: 2px 0; min-height: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rc-prize:has(canvas.scratch) { min-height: 100px; margin: 14px 0 8px; }
canvas.scratch {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 16px; touch-action: none; cursor: grab;
  box-shadow: 0 4px 12px rgba(150, 90, 0, 0.25), 0 0 0 1px rgba(200, 145, 40, 0.6);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.scratch-shine {
  position: absolute; inset: 0; border-radius: 16px; pointer-events: none; overflow: hidden;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.6) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%; animation: foilShine 2.8s ease-in-out infinite;
}
@keyframes foilShine { 0% { background-position: 130% 0; } 60%, 100% { background-position: -130% 0; } }
.scratch-hint {
  position: absolute; left: 50%; bottom: -18px; font-size: 1.5rem; pointer-events: none; z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45)); animation: swipeHint 1.8s ease-in-out infinite;
}
@keyframes swipeHint {
  0% { translate: -70px 0; rotate: -10deg; opacity: 0; } 15% { opacity: 1; }
  50% { translate: 50px -6px; rotate: 8deg; } 85% { opacity: 1; } 100% { translate: -70px 0; rotate: -10deg; opacity: 0; }
}
.rc-prize.scratching .scratch-shine, .rc-prize.scratching .scratch-hint, .rc-prize.scratched .scratch-shine { display: none; }
.link-btn {
  background: none; border: 0; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 0.85rem; font-weight: 600;
  color: var(--gold-300); opacity: 0.8; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { opacity: 1; }
canvas.scratch:active { cursor: grabbing; }
canvas.scratch.done { opacity: 0; transform: scale(1.06); pointer-events: none; }

#drawResult { -webkit-user-select: none; user-select: none; }

.scratch-hint { display: none; }

/* chặn tràn ngang trên điện thoại (cánh hoa, hiệu ứng bay ra ngoài mép) */
html { overflow-x: hidden; }
.modal { overflow-x: hidden; }
#main { padding-bottom: calc(170px + env(safe-area-inset-bottom, 0px)) !important; }

/* cây quất */
.fruit { transform-box: fill-box; transform-origin: center; animation: bloom 0.8s cubic-bezier(0.3, 1.5, 0.5, 1) backwards; }
.tree { filter: drop-shadow(0 10px 18px rgba(30, 0, 0, 0.45)); }

/* ==========================================================
   TRANH CÂY ĐÀO MÀU NƯỚC
   ========================================================== */
.tree-wrap { aspect-ratio: 995 / 1000; width: min(100%, 560px); margin: 0 auto 10px; }
.tree-wrap::before { inset: 4% 2% 18%; background: radial-gradient(circle, rgba(255, 214, 160, 0.32) 0%, rgba(255, 170, 120, 0.12) 45%, transparent 70%); }
.tree-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 1; user-select: none; -webkit-user-drag: none;
  filter: drop-shadow(0 18px 22px rgba(40, 0, 0, 0.45)); }
.pot { display: none; }
.corner-branch { display: none; }
body::before { opacity: 0.05; }
/* bao lì xì kiểu thẻ đỏ vẽ tay, giống các bao trong tranh */
.hang .string { width: 1px; background: #d9a53c; }
.mini-env {
  width: 6.4cqw; aspect-ratio: 0.62; border-radius: 0.45cqw;
  background:
    radial-gradient(120% 80% at 30% 20%, rgba(255, 120, 100, 0.35), transparent 60%),
    radial-gradient(90% 70% at 80% 90%, rgba(110, 0, 10, 0.35), transparent 70%),
    #c8161d;
  box-shadow: 0 0.5cqw 1.1cqw rgba(60, 0, 0, 0.35), inset 0 0 0 0.3cqw #c8161d, inset 0 0 0 0.45cqw #e8b84a;
}
.mini-env::before { display: none; }
.mini-env .seal {
  top: 50%; translate: -50% -50%; width: auto; aspect-ratio: auto; border-radius: 0; background: none; box-shadow: none;
  font-family: var(--script); font-style: italic; font-weight: 700; font-size: 2.2cqw; color: #f6d27a; text-shadow: 0 0.1cqw 0 rgba(90, 0, 0, 0.6);
}
.tassel { width: 0.9cqw; height: 3.6cqw; background: linear-gradient(#e8b84a 0 24%, transparent 24%), repeating-linear-gradient(90deg, #e8b84a 0 1px, #b8862a 1px 2px); }
.mini-env:hover, .mini-env:focus-visible { transform: scale(1.12) rotate(-3deg); filter: none;
  box-shadow: 0 0 2.2cqw rgba(255, 220, 150, 0.8), inset 0 0 0 0.3cqw #c8161d, inset 0 0 0 0.45cqw #f2c862; }
.mini-env.mine { box-shadow: 0 0 0 0.4cqw #fff6dc, 0 0 2.6cqw rgba(255, 220, 150, 0.9), inset 0 0 0 0.3cqw #c8161d, inset 0 0 0 0.45cqw #e8b84a; }
.tree-wrap:not(.ready) .envelopes, .tree-wrap:not(.ready) .tree-img { opacity: 0; }
.tree-wrap.ready .tree-img { animation: fadeIn 0.7s ease; }
.tree-wrap.ready .envelopes { animation: fadeIn 0.7s ease 0.15s backwards; }

/* ==========================================================
   PHONG CÁCH MÀU NƯỚC — đè lên các kiểu cũ
   Bảng màu: đỏ giấy #8f1b1b · đỏ son #a3201f · kem giấy #fbf3e4
             vàng mực #e6bf6a · vàng đậm #b88a3a · hồng đào #e98fa0
   ========================================================== */
:root {
  --paper: #fbf3e4;
  --ink: #4a2a1c;
  --ink-red: #a3201f;
  --cream-ink: #f6e7c8;
  --gold-ink: #e6bf6a;
  --gold-deep: #b88a3a;
  --grain: url("../img/grain.webp");
  --wash: url("../img/wash.webp");
  --gold-grad: linear-gradient(180deg, #efcf86, #e2b55c);
}
body {
  color: var(--cream-ink);
  background:
    radial-gradient(55% 40% at 28% 18%, rgba(205, 70, 58, 0.55), transparent 70%),
    radial-gradient(45% 38% at 82% 72%, rgba(105, 12, 18, 0.65), transparent 72%),
    radial-gradient(40% 30% at 70% 15%, rgba(190, 60, 70, 0.35), transparent 70%),
    radial-gradient(80% 70% at 50% 45%, #a3201f, #7d1618 68%, #551012);
  background-attachment: fixed;
}
body::before { /* vân giấy + loang màu (ảnh dựng sẵn, nhẹ) */
  opacity: 1;
  background-image: var(--grain), var(--wash);
  background-size: 256px 256px, cover; background-position: 0 0, center; background-repeat: repeat, no-repeat;
}
body::after { box-shadow: inset 0 0 140px 30px rgba(40, 0, 4, 0.45); }

/* chữ: vàng mực, không bóng kim loại */
.gold-text, .title, .tab-title {
  background: none; -webkit-background-clip: border-box; background-clip: border-box; color: #f1d38e;
  filter: drop-shadow(0 2px 0 rgba(70, 0, 6, 0.35)) drop-shadow(0 6px 16px rgba(40, 0, 4, 0.35));
}
.subtitle, .cd-label, .room-name, .brand, .tab-sub, .hint, .draw-msg, .shake-row small, .stats small, .podium .pod .nm, .empty { color: var(--cream-ink); }
.subtitle::before, .subtitle::after, .tab-sub::before, .tab-sub::after, .room-name::before, .room-name::after, .topbar::after, .bottom-nav::before {
  background: linear-gradient(90deg, transparent, rgba(230, 191, 106, 0.7), transparent);
}
.room-name { background: none; }
.welcome-inner::before { background: radial-gradient(circle, rgba(255, 200, 150, 0.16), transparent 62%); }
.draw-msg { text-shadow: 0 2px 6px rgba(40, 0, 4, 0.5); }

/* nút vàng lì */
.btn-gold {
  background: var(--grain), #e8c272; color: #7a1414; text-shadow: none;
  box-shadow: 0 3px 0 var(--gold-deep), 0 10px 22px rgba(40, 0, 4, 0.3);
}
.btn-gold::after { display: none; }
.btn-gold:hover { filter: brightness(1.04); }
.btn-big { animation: none; }
.btn-ghost { background: rgba(255, 240, 220, 0.06); color: var(--cream-ink); border: 1px solid rgba(246, 231, 200, 0.55); box-shadow: none; }
.btn-ghost:hover { background: rgba(255, 240, 220, 0.14); }
.bottom-nav button.active, .seg button.on { background: var(--grain), #e8c272; color: #7a1414; box-shadow: 0 2px 0 var(--gold-deep); }

/* MÀN CHÀO: cành đào từ tranh thay đèn lồng */
.lanterns, .frame i { display: none; }
.frame { border: 1px solid rgba(230, 191, 106, 0.35); }
.frame::before { border-color: rgba(230, 191, 106, 0.18); }
#welcome::before, #welcome::after {
  content: ""; position: absolute; top: 0; z-index: 1; pointer-events: none;
  width: min(46vw, 500px); aspect-ratio: 475 / 340;
  background: url("../img/canh-dao.webp") top left / contain no-repeat;
  -webkit-mask: linear-gradient(to bottom, #000 50%, transparent 96%);
  mask: linear-gradient(to bottom, #000 50%, transparent 96%);
  filter: drop-shadow(0 10px 14px rgba(40, 0, 4, 0.35));
}
#welcome::before { left: 0; }
#welcome::after { right: 0; transform: scaleX(-1); }
.cd-boxes div {
  background: var(--grain), var(--paper); border: 0; border-radius: 12px;
  box-shadow: 0 8px 18px rgba(40, 0, 4, 0.32), inset 0 0 0 4px var(--paper), inset 0 0 0 5px rgba(163, 32, 31, 0.28);
}
.cd-boxes b { background: none; color: var(--ink-red); -webkit-background-clip: border-box; background-clip: border-box; font-family: var(--script); font-weight: 700; }
.cd-boxes small { color: #8a5a3c; }
.countdown.done .cd-label { color: #f1d38e; }

/* THIỆP GIẤY */
.card, .rcard {
  border: 0;
  background: var(--grain), radial-gradient(90% 60% at 100% 100%, rgba(233, 143, 160, 0.16), transparent 60%), radial-gradient(70% 50% at 0 0, rgba(230, 191, 106, 0.18), transparent 60%), var(--paper);
  background-size: 256px 256px, auto, auto, auto; background-repeat: repeat, no-repeat, no-repeat, no-repeat; background-position: 0 0, 0 0, 0 0, 0 0;
  box-shadow: 0 16px 36px rgba(40, 0, 4, 0.42), inset 0 0 0 7px var(--paper), inset 0 0 0 8px rgba(163, 32, 31, 0.32);
}
.card h2 { color: var(--ink-red); font-family: var(--script); font-style: italic; }
.rcard .rc-top {
  background: var(--grain), radial-gradient(80% 140% at 20% 0, #c4372d, transparent 70%), #a3201f;
  color: #f6e3b4; border-bottom: 1px solid #d8ad5a; letter-spacing: 0.18em;
}
.rcard .rc-who span { background: #f3e1bd; box-shadow: 0 0 0 2px #fff8ec, 0 0 0 3px #d9b36a; }
.rcard .rc-label { background: #a3201f; color: #f8e6bd; box-shadow: none; }
.rcard .rc-amount { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: var(--ink-red); filter: none; font-family: var(--script); }
.rcard .rc-wish::before { background: linear-gradient(90deg, transparent, #d4a24c, transparent); height: 1px; }
.field input, textarea { border: 1.5px solid #e3cfa6; background: #fffdf7; }
.avatars button[aria-checked="true"] { box-shadow: 0 0 0 2px var(--ink-red); }

/* BẢNG VÀNG */
.stats div { background: var(--grain), var(--paper); border: 0; box-shadow: 0 8px 18px rgba(40, 0, 4, 0.3), inset 0 0 0 4px var(--paper), inset 0 0 0 5px rgba(163, 32, 31, 0.25); }
.stats b { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: var(--ink-red); font-family: var(--script); }
.stats small { color: #8a5a3c; }
.podium .pod .av { background: var(--paper); box-shadow: 0 0 0 2px #d9b36a, 0 6px 14px rgba(40, 0, 4, 0.35); }
.podium .pod .am { color: #f1d38e; }
.podium .pod .base { background: var(--grain), #e3b95e; color: #7a1414; box-shadow: 0 8px 18px rgba(40, 0, 4, 0.3); }
.podium .p2 .base { background: var(--grain), #ddd6c8; }
.podium .p3 .base { background: var(--grain), #d9a57a; }
.board li { background: var(--grain), var(--paper); border-left: 4px solid var(--ink-red); box-shadow: 0 4px 12px rgba(40, 0, 4, 0.25); }
.board li.me { border-left-color: var(--gold-deep); box-shadow: 0 0 0 2px #e6bf6a, 0 4px 14px rgba(40, 0, 4, 0.3); }
.board .av { background: #f3e1bd; }

/* KHUNG MỞ BAO */
.rays { opacity: 0.16; }
.env-back { background: #8e1618; box-shadow: inset 0 0 0 3px #c9a04e; }
.env-front {
  background: var(--grain), radial-gradient(120% 80% at 30% 15%, rgba(230, 110, 95, 0.4), transparent 60%), #b81c1f;
  box-shadow: inset 0 0 0 5px #b81c1f, inset 0 0 0 6.5px #e6bf6a;
}
.env-flap { background: var(--grain), #c8261f; }
.env-seal { background: none; border: 0; box-shadow: none; color: #f1d38e; font-style: italic; font-size: 2.8rem; text-shadow: 0 2px 0 rgba(70, 0, 6, 0.45); }
.env-money { background: var(--grain), #f7ecd4; border: 1px solid #d9b36a; }

/* thanh trên, thanh dưới, trình phát */
.topbar { background: linear-gradient(180deg, rgba(70, 10, 12, 0.55), rgba(70, 10, 12, 0)); }
.user-chip { background: rgba(255, 240, 220, 0.08); color: var(--cream-ink); border: 1px solid rgba(246, 231, 200, 0.35); }
.user-chip #meAvatar { background: #f3e1bd; }
.bottom-nav { background: linear-gradient(180deg, rgba(85, 16, 18, 0.92), rgba(55, 8, 10, 0.97)); }
.panel { background: rgba(60, 8, 10, 0.38); border: 1px solid rgba(246, 231, 200, 0.28); box-shadow: 0 12px 28px rgba(40, 0, 4, 0.3); }

/* bỏ pháo ở góc: đã có cành đào */
.phao { display: none !important; }
/* tia sáng mềm như loang màu, không sọc cứng */
.modal .rays {
  opacity: 0.5 !important;
  background: radial-gradient(circle at 50% 45%, rgba(246, 205, 120, 0.22), rgba(246, 205, 120, 0.06) 35%, transparent 65%) !important;
}

/* ===== NHIỀU KIỂU BAO LÌ XÌ ===== */
.mini-env {
  --edge: #c8161d; --line: #e8b84a; --ink: #f6d27a; --base: #c8161d;
  background:
    radial-gradient(120% 80% at 30% 20%, rgba(255, 255, 255, 0.16), transparent 60%),
    radial-gradient(90% 70% at 80% 90%, rgba(80, 0, 10, 0.28), transparent 70%),
    var(--pat, none), var(--base);
  box-shadow: 0 0.5cqw 1.1cqw rgba(60, 0, 0, 0.35), inset 0 0 0 0.3cqw var(--edge), inset 0 0 0 0.45cqw var(--line);
}
.mini-env .seal { color: var(--ink); }
.mini-env:hover, .mini-env:focus-visible {
  box-shadow: 0 0 2.2cqw rgba(255, 220, 150, 0.8), inset 0 0 0 0.3cqw var(--edge), inset 0 0 0 0.45cqw var(--line);
}
.mini-env.mine { box-shadow: 0 0 0 0.4cqw #fff6dc, 0 0 2.6cqw rgba(255, 220, 150, 0.9), inset 0 0 0 0.3cqw var(--edge), inset 0 0 0 0.45cqw var(--line); }

/* 1 · vàng nhũ, chữ đỏ */
.v1 .mini-env { --base: #e2b65a; --edge: #e2b65a; --line: #a3201f; --ink: #a3201f; }
.v1 .tassel { background: linear-gradient(#a3201f 0 24%, transparent 24%), repeating-linear-gradient(90deg, #c8161d 0 1px, #8a0f14 1px 2px); }
.v1 .mini-env .seal { text-shadow: none; }
/* 2 · hồng đào, hoa nhí */
.v2 .mini-env { --base: #e8838f; --edge: #e8838f; --line: #fff0e6; --ink: #8f1420;
  --pat: radial-gradient(circle at 25% 22%, #fff3ec 0 0.35cqw, transparent 0.4cqw), radial-gradient(circle at 75% 78%, #fff3ec 0 0.35cqw, transparent 0.4cqw), radial-gradient(circle at 78% 18%, rgba(255, 243, 236, 0.7) 0 0.22cqw, transparent 0.26cqw); }
.v2 .mini-env .seal { text-shadow: 0 0 0.4cqw rgba(255, 240, 230, 0.8); }
/* 3 · đỏ thẫm, ấn tròn vàng */
.v3 .mini-env { --base: #8e1017; --edge: #8e1017; --line: #d6a24a; --ink: #8e1017; }
.v3 .mini-env .seal { width: 4.4cqw; height: 4.4cqw; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #f8dd96, #d6a24a); font-size: 2cqw; text-shadow: none; box-shadow: 0 0 0 0.25cqw #8e1017, 0 0 0 0.4cqw #d6a24a; }
/* 4 · đỏ, nắp tam giác vàng */
.v4 .mini-env::before { display: block; content: ""; position: absolute; inset: 0 0 auto 0; height: 38%;
  background: linear-gradient(#d9a13d, #c48a2a); clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 0.45cqw 0.45cqw 0 0; }
.v4 .mini-env .seal { top: 64%; }
/* 5 · bao ngang */
.v5 .mini-env { width: 9.6cqw; aspect-ratio: 1.45; --base: #b5121b;
  --pat: repeating-linear-gradient(90deg, transparent 0 1.6cqw, rgba(232, 184, 74, 0.22) 1.6cqw 1.75cqw); }
/* 6 · trắng ngà, viền đỏ, chữ đỏ */
.v6 .mini-env { --base: #fbf0dc; --edge: #fbf0dc; --line: #c8161d; --ink: #c8161d; }
.v6 .mini-env .seal { text-shadow: none; }
.v6 .tassel { background: linear-gradient(#c8161d 0 24%, transparent 24%), repeating-linear-gradient(90deg, #c8161d 0 1px, #8a0f14 1px 2px); }
/* 7 · đỏ, hoạ tiết mây vàng */
.v7 .mini-env { --base: #c41a22;
  --pat: radial-gradient(circle at 50% 100%, transparent 0.9cqw, rgba(242, 200, 98, 0.45) 0.95cqw 1.1cqw, transparent 1.15cqw) 0 0 / 2.2cqw 1.6cqw; }
.v7 .mini-env .seal { background: #c41a22; padding: 0.2cqw 0.5cqw; border-radius: 0.3cqw; }
.v5 .mini-env .seal { font-size: 1.9cqw; white-space: nowrap; }
.mini-env .seal { white-space: nowrap; }

/* ===== CÁCH TREO BAO: nút buộc trên cành, dây thừng đỏ-vàng, lắc nhẹ lệch nhịp ===== */
.hang {
  animation: hangSwing var(--dur, 3.6s) ease-in-out infinite; animation-delay: var(--delay, 0s);
  filter: drop-shadow(0 0.7cqw 0.6cqw rgba(50, 0, 6, 0.38));
}
@keyframes hangSwing { 0%, 100% { rotate: calc(var(--amp, 3deg) * -1); } 50% { rotate: var(--amp, 3deg); } }
.hang .knot { display: block; width: 0.9cqw; height: 0.9cqw; border-radius: 50%; margin-bottom: -0.25cqw; position: relative; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #ffe7a8, #d39a33 60%, #8a5a14); box-shadow: 0 0 0 0.12cqw rgba(90, 40, 0, 0.35); }
.hang .string { width: 0.26cqw; height: var(--str, 2cqw);
  background: repeating-linear-gradient(160deg, #c8161d 0 0.25cqw, #e8b84a 0.25cqw 0.4cqw); border-radius: 0.2cqw; }
.mini-env { width: 6.6cqw; rotate: var(--tilt, 0deg); scale: var(--s, 1); transform-origin: 50% 0; }
.v5 .mini-env { width: 10cqw; }
/* khoen treo nhỏ ở mép trên bao */
.hang .string::after { content: ""; display: block; width: 1cqw; height: 0.7cqw; margin: 0 0 0 -0.37cqw; translate: 0 calc(var(--str, 2cqw) - 0.3cqw);
  border: 0.2cqw solid #e8b84a; border-bottom: 0; border-radius: 1cqw 1cqw 0 0; }
.hang .string { position: relative; }
.hang .string::after { position: absolute; left: 50%; top: 0; margin: 0; translate: -50% calc(var(--str, 2cqw) - 0.55cqw); }
/* tua rua: nút + sợi tua */
.tassel { position: relative; width: 1cqw; height: 3.4cqw; margin-top: -0.1cqw; rotate: var(--tilt, 0deg); transform-origin: 50% 0;
  background: radial-gradient(circle at 50% 0.45cqw, #f3cf78 0 0.42cqw, transparent 0.46cqw),
              linear-gradient(transparent 0 0.8cqw, #000 0.8cqw) 0 0 / 100% 100% no-repeat;
  -webkit-mask: none; mask: none; }
.tassel { background:
  radial-gradient(circle at 50% 0.45cqw, #f3cf78 0 0.42cqw, transparent 0.46cqw),
  linear-gradient(90deg, transparent 0 15%, #d9a53c 15% 85%, transparent 85%) 0 0.85cqw / 100% 0.35cqw no-repeat,
  repeating-linear-gradient(90deg, #c8161d 0 0.12cqw, #8a0f14 0.12cqw 0.22cqw) 0 1.2cqw / 100% 100% no-repeat;
  border-radius: 0 0 0.35cqw 0.35cqw; }
.v1 .tassel, .v6 .tassel { background:
  radial-gradient(circle at 50% 0.45cqw, #c8161d 0 0.42cqw, transparent 0.46cqw),
  linear-gradient(90deg, transparent 0 15%, #a3201f 15% 85%, transparent 85%) 0 0.85cqw / 100% 0.35cqw no-repeat,
  repeating-linear-gradient(90deg, #e8b84a 0 0.12cqw, #b8862a 0.12cqw 0.22cqw) 0 1.2cqw / 100% 100% no-repeat; }
.mini-env:hover, .mini-env:focus-visible { transform: scale(1.12); }
.hang:has(.mini-env:hover) { animation-play-state: paused; z-index: 4; }
@media (prefers-reduced-motion: reduce) { .hang { animation: none; } }

/* ===== PHÁO HOA NỀN TRANG CHÍNH ===== */
#skyFx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0.85;
  -webkit-mask: linear-gradient(#000 0 55%, transparent 85%); mask: linear-gradient(#000 0 55%, transparent 85%); }
#main > .tab { position: relative; z-index: 1; }

/* Playfair mặc định dùng số kiểu cổ (so le) → dùng số thẳng hàng */
html { font-variant-numeric: lining-nums; }
.cd-boxes b { font-variant-numeric: lining-nums tabular-nums; font-style: normal; }

/* ===== hẹn giờ mở bốc ===== */
.open-cd { font-variant-numeric: tabular-nums; color: #ffd36b; }

/* ===== bảng vàng: người vừa bốc ===== */
.board li.fresh { animation: freshIn 1.2s cubic-bezier(.2, .9, .3, 1.3), freshGlow 6s ease; }
.board li.jack .am { color: #b8860b; text-shadow: 0 0 10px rgba(255, 210, 90, 0.8); }
@keyframes freshIn { from { transform: translateX(-24px) scale(0.96); opacity: 0; } }
@keyframes freshGlow { 0%, 30% { box-shadow: 0 0 0 3px #ffd36b, 0 6px 22px rgba(255, 200, 60, 0.55); } 100% { box-shadow: none; } }

/* ===== chế độ nhẹ (máy yếu) ===== */
body.lite *, body.lite *::before, body.lite *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
body.lite #skyFx { display: none; }
body.lite .hang { animation-duration: 6s; }
body.lite .rcard.jackpot, body.lite .rays { animation: none !important; }

/* ===== BAO LÌ XÌ LỚN (khung mở bao) — cùng kiểu với bao đã bấm ===== */
.modal .big-env {
  --base: #c8161d; --dark: #8e0f14; --line: #e8b84a; --ink: #f6d27a; --flap: var(--base); --pat: none;
  width: 214px; height: 304px; filter: drop-shadow(0 22px 34px rgba(30, 0, 0, 0.6));
}
.modal .big-env .env-back, .modal .big-env .env-front { border-radius: 16px; }
.modal .big-env .env-back {
  background: linear-gradient(170deg, var(--dark), color-mix(in srgb, var(--dark) 70%, #000));
  box-shadow: inset 0 0 0 3px var(--line);
}
.modal .big-env .env-front {
  height: 70%; border-radius: 0 0 16px 16px; display: block;
  background:
    radial-gradient(120% 70% at 25% 10%, rgba(255, 255, 255, 0.22), transparent 55%),
    radial-gradient(90% 60% at 80% 100%, rgba(60, 0, 8, 0.28), transparent 70%),
    var(--pat), var(--grain), var(--base);
  background-size: auto, auto, var(--pat-size, auto), auto, auto;
  box-shadow: inset 0 0 0 7px var(--base), inset 0 0 0 8.5px var(--line), inset 0 0 0 12px var(--base), inset 0 0 0 13px color-mix(in srgb, var(--line) 60%, transparent),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
/* chữ chính trong ấn tròn */
.modal .big-env .env-seal {
  position: absolute; left: 50%; top: 52%; translate: -50% -50%; margin: 0;
  min-width: 104px; height: 104px; padding: 0 14px; border-radius: 52px; display: grid; place-items: center;
  font-family: var(--script); font-style: italic; font-weight: 700; font-size: 2.5rem; line-height: 1; white-space: nowrap;
  color: var(--ink); background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--base) 85%, #fff), var(--base) 70%);
  border: 2px solid var(--line); box-shadow: 0 0 0 5px var(--base), 0 0 0 6.5px color-mix(in srgb, var(--line) 55%, transparent), 0 6px 14px rgba(40, 0, 0, 0.25);
  text-shadow: 0 2px 0 rgba(60, 0, 6, 0.35);
}
.modal .big-env .env-year {
  position: absolute; left: 0; right: 0; bottom: 20px; text-align: center;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--line); opacity: 0.9;
}
/* hoa văn 4 góc */
.env-corner { position: absolute; width: 22px; height: 22px; border: 2px solid var(--line); opacity: 0.85; }
.env-corner.tl { left: 18px; top: 18px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.env-corner.tr { right: 18px; top: 18px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.env-corner.bl { left: 18px; bottom: 18px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.env-corner.br { right: 18px; bottom: 18px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.env-corner::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.env-corner.tl::after { left: 4px; top: 4px; } .env-corner.tr::after { right: 4px; top: 4px; }
.env-corner.bl::after { left: 4px; bottom: 4px; } .env-corner.br::after { right: 4px; bottom: 4px; }
/* nắp: cùng màu, viền vàng theo chữ V */
.modal .big-env .env-flap {
  height: 46%; border-radius: 16px 16px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 60%),
    var(--grain), var(--flap);
  filter: drop-shadow(0 3px 0 var(--line));
}
/* khuy tròn ở mũi nắp */
.env-clasp {
  position: absolute; left: 50%; top: 46%; z-index: 5; width: 30px; height: 30px; translate: -50% -55%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff4c4, #e8b84a 45%, #a8741c);
  box-shadow: 0 2px 5px rgba(40, 0, 0, 0.45), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  transition: opacity 0.25s;
}
.env-clasp::after { content: "✿"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; color: #9a1418; }
.big-env.open .env-clasp { opacity: 0; }
.modal .big-env .env-money { left: 10%; right: 10%; top: 31%; height: 66%; }
.modal .big-env.open .env-money { transform: translateY(-88%); }

/* 8 kiểu — khớp với bao trên cây */
.big-env.bv1 { --base: #e2b65a; --dark: #a77d2a; --line: #a3201f; --ink: #a3201f; }
.big-env.bv1 .env-seal { text-shadow: none; }
.big-env.bv2 { --base: #e8838f; --dark: #b4505d; --line: #fff0e6; --ink: #8f1420;
  --pat: radial-gradient(circle, #fff3ec 0 3px, transparent 3.5px), radial-gradient(circle, rgba(255, 243, 236, 0.6) 0 2px, transparent 2.5px);
  --pat-size: 34px 34px, 22px 22px; }
.big-env.bv2 .env-seal { text-shadow: 0 0 6px rgba(255, 240, 230, 0.9); }
.big-env.bv3 { --base: #8e1017; --dark: #5c0508; --line: #d6a24a; --ink: #8e1017; }
.big-env.bv3 .env-seal { background: radial-gradient(circle at 35% 30%, #fbe7ae, #d6a24a); text-shadow: none; border-color: #8e1017; }
.big-env.bv4 { --flap: linear-gradient(#e2ad48, #c48a2a); }
.big-env.bv5 { width: 300px; height: 214px; --base: #b5121b; --dark: #7a0a10;
  --pat: repeating-linear-gradient(90deg, transparent 0 26px, rgba(232, 184, 74, 0.2) 26px 29px); }
.big-env.bv5 .env-seal { top: 50%; min-width: 0; height: 74px; font-size: 2rem; border-radius: 37px; }
.big-env.bv5 .env-year { bottom: 14px; }
.big-env.bv6 { --base: #fbf0dc; --dark: #d9c6a2; --line: #c8161d; --ink: #c8161d; }
.big-env.bv6 .env-seal { text-shadow: none; }
.big-env.bv7 { --base: #c41a22; --dark: #85090f;
  --pat: radial-gradient(circle at 50% 100%, transparent 13px, rgba(242, 200, 98, 0.4) 14px 16px, transparent 17px);
  --pat-size: 34px 24px; }
.big-env.bv7 .env-seal { border-radius: 10px; min-width: 0; height: auto; padding: 14px 18px; }

/* ===== bao lớn v2: thanh lịch hơn ===== */
.modal .big-env { --fill: linear-gradient(180deg, #fff4c8 0%, #f3c65c 48%, #b97f1f 100%); }
/* nắp: mũi mềm, viền vàng mảnh bên dưới */
.modal .big-env .env-flap, .modal .big-env .env-flap-line {
  clip-path: polygon(0 0, 100% 0, 100% 12%, 55% 93%, 50% 100%, 45% 93%, 0 12%);
  border-radius: 16px 16px 0 0; filter: none;
}
.modal .big-env .env-flap {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, 0.08)), var(--grain), var(--flap);
}
.env-flap-line {
  position: absolute; top: 0; left: 0; right: 0; height: calc(46% + 3px); z-index: 4; transform-origin: top center;
  background: var(--line); transition: transform 0.6s ease, z-index 0s 0.3s;
}
.big-env.open .env-flap-line { transform: rotateX(180deg); z-index: 1; }
/* chữ: vàng nhũ, không vòng tròn */
.modal .big-env .env-seal {
  top: 57%; min-width: 0; height: auto; padding: 0 4px 6px; border: 0; border-radius: 0; box-shadow: none;
  font-size: 3.2rem; letter-spacing: 0.01em;
  background: var(--fill); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 2px 0 rgba(70, 0, 8, 0.35)) drop-shadow(0 0 10px rgba(255, 210, 120, 0.25));
}
/* dòng nhỏ có gạch hai bên */
.modal .big-env .env-year {
  bottom: 22px; font-size: 0.6rem; letter-spacing: 0.3em; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.modal .big-env .env-year::before, .modal .big-env .env-year::after { content: ""; width: 20px; height: 1px; background: currentColor; opacity: 0.8; }
/* góc: mảnh, không chấm */
.modal .big-env .env-corner { width: 14px; height: 14px; border-width: 1.5px; opacity: 0.75; }
.modal .big-env .env-corner::after { display: none; }
.modal .big-env .env-corner.tl, .modal .big-env .env-corner.tr { top: 16px; }
.modal .big-env .env-corner.bl, .modal .big-env .env-corner.br { bottom: 16px; }
.modal .big-env .env-corner.tl, .modal .big-env .env-corner.bl { left: 16px; }
.modal .big-env .env-corner.tr, .modal .big-env .env-corner.br { right: 16px; }
/* cành đào nhỏ góc dưới */
.env-sprig {
  position: absolute; right: 6px; bottom: 6px; width: 58%; aspect-ratio: 1.35; pointer-events: none;
  background: url("../img/canh-dao.webp") top left / contain no-repeat; rotate: 180deg; opacity: 0.95;
  -webkit-mask: linear-gradient(315deg, transparent 0, #000 30%); mask: linear-gradient(315deg, transparent 0, #000 30%);
}
/* ánh sáng lướt qua mặt bao */
.modal .big-env .env-front { overflow: hidden; }
.modal .big-env .env-front::after {
  content: ""; position: absolute; inset: -20% -60%; pointer-events: none;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.22) 50%, transparent 58%);
  animation: envShine 3.2s ease-in-out infinite; translate: -60% 0;
}
@keyframes envShine { 0%, 35% { translate: -60% 0; } 75%, 100% { translate: 60% 0; } }
@media (prefers-reduced-motion: reduce) { .modal .big-env .env-front::after { animation: none; opacity: 0; } }
/* khuy nhỏ, gọn hơn */
.modal .big-env .env-clasp { width: 26px; height: 26px; }
.modal .big-env .env-clasp::after { font-size: 13px; }

/* màu chữ theo từng kiểu */
.big-env.bv1 { --fill: linear-gradient(180deg, #c8302a, #7d0e12); }
.big-env.bv2 { --fill: linear-gradient(180deg, #b4243a, #6e0c18); }
.big-env.bv3 { --fill: linear-gradient(180deg, #fff1bf, #e2b04e 50%, #a8741c); }
.big-env.bv6 { --fill: linear-gradient(180deg, #d42a2a, #8a0f14); }
.big-env.bv1 .env-seal, .big-env.bv2 .env-seal, .big-env.bv6 .env-seal { filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.5)); }
.big-env.bv3 .env-seal, .big-env.bv7 .env-seal { background: var(--fill); -webkit-background-clip: text; background-clip: text; border: 0; box-shadow: none; padding: 0 4px 6px; }
.big-env.bv5 .env-seal { font-size: 2.7rem; top: 55%; height: auto; }
.big-env.bv5 .env-sprig { width: 38%; }
.big-env.bv6 .env-sprig, .big-env.bv1 .env-sprig { opacity: 0.85; }
/* sửa: chữ không bị cắt, cành đào không đè chữ */
.modal .big-env .env-seal { left: 0; right: 0; width: auto; translate: 0 -50%; text-align: center; top: 50%; display: block; }
.big-env.bv5 .env-seal { top: 48%; }
.modal .big-env .env-year { display: none; }
.modal .big-env .env-sprig { width: 44%; right: 4px; bottom: 4px; }
.big-env.bv5 .env-sprig { width: 30%; }

/* ===== HỘP HỎI TỰ VẼ (thay confirm/prompt) ===== */
dialog.ask { border: 0; padding: 0; background: transparent; max-width: min(400px, 92vw); width: 100%; }
dialog.ask::backdrop { background: rgba(40, 4, 6, 0.6); backdrop-filter: blur(2px); }
.ask-in {
  margin: 0; padding: 22px 20px 18px; border-radius: 18px; text-align: center; color: #4a1a12;
  background: var(--grain, none), #fbf3e2; border: 1.5px solid #e6bf6a; box-shadow: 0 20px 50px rgba(30, 0, 0, 0.5);
  animation: askIn 0.22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes askIn { from { transform: translateY(12px) scale(0.96); opacity: 0; } }
.ask-in h3 { margin: 0 0 8px; font-family: var(--script, Georgia, serif); font-style: italic; font-size: 1.35rem; color: #8f1015; }
.ask-in p { margin: 0 0 14px; line-height: 1.45; font-size: 0.95rem; }
.ask-type { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; font-size: 0.85rem; }
.ask-type input, .ask-in textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1.5px solid #d9b36a; background: #fff;
  font: inherit; font-size: 1rem; text-align: center; color: #4a1a12;
}
.ask-in textarea { text-align: left; font-size: 0.85rem; resize: none; margin-bottom: 14px; }
.ask-btns { display: flex; gap: 10px; justify-content: center; }
.ask-btns .btn { min-width: 110px; }
.ask-btns .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.ask-btns .btn-red { background: #b3121a; color: #fff; border: 0; box-shadow: 0 3px 0 #6e0a0e; }
.ask-btns .btn-line { background: #fff; color: #8f1015; border: 2px solid #c8161d; }

/* ===== bao lớn: mặt trong + mặt sau nắp khi mở ===== */
.modal .big-env .env-back {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.38), transparent 30%),
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--line) 16%, transparent) 0 1.5px, transparent 1.5px 10px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--line) 16%, transparent) 0 1.5px, transparent 1.5px 10px),
    linear-gradient(180deg, color-mix(in srgb, var(--dark) 75%, #000), var(--dark));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 45%, transparent), inset 0 12px 20px rgba(0, 0, 0, 0.35);
}
/* lật nắp lên thì thấy mặt trong của nắp: tối hơn, có vân lót giống thân bao */
.modal .big-env.open .env-flap {
  background:
    linear-gradient(0deg, rgba(0, 0, 0, 0.3), transparent 45%),
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--line) 16%, transparent) 0 1.5px, transparent 1.5px 10px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--line) 16%, transparent) 0 1.5px, transparent 1.5px 10px),
    var(--dark);
  transition: transform 0.6s ease, z-index 0s 0.3s, background 0s 0.3s;
}
/* miệng bao: viền sáng mảnh ở mép trên mặt trước */
.modal .big-env .env-front::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 1;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--line) 80%, #fff), transparent);
}
