/* ═══════════════════════════════════════════════════════════════════════════
   HALLOWEEN EVENT — lớp giao diện theo mùa
   ---------------------------------------------------------------------------
   • Toàn bộ nằm dưới `html.hw-on` (class do script trong <head> gắn vào) nên tắt là
     trả về giao diện gốc 100%.
   • NỀN GIỮ NGUYÊN như bản gốc (style.css) — chỉ đổi điểm nhấn + thêm trang trí, để
     site vẫn sạch và dễ đọc như trước.
   • File này nạp SAU style.css + app.css + home-redesign.css để thắng cascade.
   • Bật/tắt: nút 🎃 góc phải dưới, hoặc ?event=halloween / ?event=off.
   • Máy yếu (html.perf-low) và người bật "giảm chuyển động" sẽ không thấy animation.
   ═══════════════════════════════════════════════════════════════════════════ */

html.hw-on {
  /* Chỉ đổi ĐIỂM NHẤN (cam bí ngô) — không đụng tới --bg / --surface / --glass để nền
     và độ tương phản giữ y như bản gốc. */
  --hw-orange: #ff8a1f;
  --hw-orange-soft: #ffb066;
  --hw-amber: #ffcf8a;
  --hw-violet: #a855f7;

  --gold: #ff8a1f;
  --gold2: #ffa447;
  --gold3: #ffc07a;
  --gold-dim: rgba(255, 138, 31, 0.12);
  --gold-glow: rgba(255, 138, 31, 0.2);
  --accent: #ff8a1f;
  --border-gold: rgba(255, 138, 31, 0.34);
  --glow: 0 0 28px rgba(255, 138, 31, 0.18);
  --glow-lg: 0 0 52px rgba(255, 138, 31, 0.14);
  --glow-btn: 0 4px 20px rgba(255, 138, 31, 0.36);
}

/* ── Thanh trên + sidebar: giữ nền gốc, chỉ thêm hơi cam ở đường viền ───────── */
html.hw-on .top-nav {
  border-bottom-color: rgba(255, 138, 31, 0.16);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 138, 31, 0.14);
}

html.hw-on .top-nav .logo::after {
  content: "🎃";
  margin-left: 7px;
  font-size: 0.95rem;
  line-height: 1;
  filter: drop-shadow(0 0 7px rgba(255, 138, 31, 0.5));
}

html.hw-on .top-nav .nav-logo {
  box-shadow: 0 0 20px rgba(255, 138, 31, 0.42);
}

/* ── Nút bấm ──────────────────────────────────────────────────────────────── */
html.hw-on .btn-primary {
  background: linear-gradient(135deg, #ff9a35 0%, #ff7a18 48%, #e2570a 100%);
  box-shadow: 0 4px 20px rgba(255, 122, 24, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

html.hw-on .btn-primary:hover {
  background: linear-gradient(135deg, #ffb15a 0%, #ff8a1f 48%, #f0680e 100%);
  box-shadow: 0 8px 28px rgba(255, 122, 24, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

html.hw-on .btn-outline {
  background: rgba(168, 85, 247, 0.09);
  border-color: rgba(168, 85, 247, 0.36);
  color: var(--hw-orange-soft);
}

html.hw-on .btn-outline:hover {
  background: rgba(168, 85, 247, 0.16);
  border-color: rgba(255, 138, 31, 0.5);
  color: #fff;
}

/* ── Thẻ / khối nội dung: chỉ đổi màu hover cho có không khí lễ hội ───────── */
html.hw-on .stat-card:hover,
html.hw-on .feature-card:hover,
html.hw-on .step:hover,
html.hw-on .proof-card:hover {
  border-color: rgba(255, 138, 31, 0.38);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), 0 0 26px rgba(255, 138, 31, 0.14);
}

html.hw-on .section-heading h2 span,
html.hw-on #view-home .hero h1 span {
  background: linear-gradient(96deg, #ffd9ac, #ff9a35 42%, #ffb066);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html.hw-on .step-num,
html.hw-on #view-home .step-num {
  color: #431a00;
  background: radial-gradient(circle at 34% 28%, #ffc98a 0%, #ff9a35 46%, #f2710c 100%);
  box-shadow: 0 0 22px rgba(255, 138, 31, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ── Trang chủ ────────────────────────────────────────────────────────────── */
html.hw-on #view-home .hero-console {
  border-color: rgba(255, 138, 31, 0.18);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55), 0 0 46px rgba(255, 138, 31, 0.1);
}

html.hw-on #view-home .lp-badge svg {
  color: var(--hw-orange);
}

/* Dải số liệu: đường kẻ chia ô ánh cam thay vì xám */
html.hw-on #view-home .platform-bar {
  background: linear-gradient(180deg, rgba(255, 138, 31, 0.4), rgba(255, 255, 255, 0.08));
}

html.hw-on #view-home .trust-strip {
  border-color: rgba(255, 138, 31, 0.2);
}

/* Khối kêu gọi cuối trang */
html.hw-on #view-home .cta-block {
  border-color: rgba(255, 138, 31, 0.3);
  background:
    radial-gradient(ellipse 68% 130% at 50% 0%, rgba(255, 138, 31, 0.1), transparent 62%),
    #0b0c0e;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.5), 0 0 60px rgba(255, 138, 31, 0.08);
}

html.hw-on #view-home .cta-block h2::before {
  content: "🎃";
  margin-right: 10px;
  font-size: 0.86em;
  vertical-align: -2px;
  filter: drop-shadow(0 0 8px rgba(255, 138, 31, 0.5));
}

/* Chữ ký mùa lễ hội ở footer */
html.hw-on #view-home .site-footer::after {
  content: " · 🎃 Chúc mừng Halloween";
  color: rgba(255, 176, 102, 0.72);
}

/* Dải "Mùa Halloween" trong hero — chỉ hiện khi bật event */
.hw-ribbon {
  display: none;
  align-items: center;
  gap: 9px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 18px;
  padding: 8px 15px 8px 13px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffe9d2;
  background:
    linear-gradient(120deg, rgba(255, 138, 31, 0.16), rgba(124, 58, 237, 0.18)),
    rgba(12, 12, 16, 0.82);
  border: 1px solid rgba(255, 138, 31, 0.34);
  /* KHÔNG dùng backdrop-filter: nằm trong vùng cuộn nên trình duyệt phải làm mờ lại
     toàn bộ nền phía sau ở MỖI khung hình khi cuộn ⇒ đây là thủ phạm gây lag rõ nhất
     trên điện thoại. Nền đặc hơn một chút cho ra cùng cảm giác. */
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

html.hw-on .hw-ribbon { display: inline-flex; }

.hw-ribbon .hw-ribbon-pumpkin {
  --hw-dur: 3.8s;
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  color: #ff9a35;
  filter: drop-shadow(0 0 8px rgba(255, 138, 31, 0.5));
  animation: hwPumpkinBob var(--hw-dur) ease-in-out infinite;
  will-change: transform;
}

.hw-ribbon .hw-ribbon-pumpkin svg { width: 100%; height: 100%; display: block; }

.hw-ribbon em {
  font-style: normal;
  font-weight: 800;
  color: #ffc48a;
}

/* ── Trang trí: trăng, mạng nhện, dơi ─────────────────────────────────────── */
.hw-decor {
  position: fixed;
  inset: 0;
  /* z-index âm: nằm trên nền body nhưng dưới toàn bộ nội dung (nhiều khối nội dung
     không tạo stacking context nên để 0 thì dơi/mạng nhện sẽ đè lên chữ). */
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  /* Cô lập vùng vẽ: khi nội dung cuộn, trình duyệt không phải tính lại/vẽ lại lớp trang
     trí này. */
  contain: layout paint style;
  display: none;
}

html.hw-on .hw-decor { display: block; }

/* ── Bầu trời đêm: quầng sáng chân trời + sao + sương + vignette ────────────
   Đều là LỚP PHỦ TRONG SUỐT nằm trên nền gốc ⇒ màu nền vẫn y như bản cũ, chỉ có
   thêm chiều sâu (không đổi --bg, không đụng body). */
.hw-decor .hw-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 76% 44% at 50% 104%, rgba(255, 122, 24, 0.15), transparent 72%),
    radial-gradient(ellipse 58% 40% at 6% -8%, rgba(142, 84, 255, 0.13), transparent 70%),
    radial-gradient(ellipse 50% 36% at 97% 16%, rgba(255, 168, 92, 0.09), transparent 72%),
    linear-gradient(118deg, transparent 36%, rgba(142, 84, 255, 0.05) 52%, rgba(255, 160, 90, 0.035) 61%, transparent 76%);
}

/* Sao: 46 hạt nhỏ vẽ bằng box-shadow trên MỘT phần tử 2px (rẻ hơn 46 thẻ div) */
.hw-decor .hw-sky::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  box-shadow:
      58.2vw 40.5vh 0 0 rgba(255, 246, 232, 0.75),
      69.9vw 58.7vh 0 0 rgba(255, 246, 232, 0.63),
      52.1vw 11.8vh 0 0 rgba(255, 246, 232, 0.28),
      22.6vw 22.4vh 0 0 rgba(255, 246, 232, 0.8),
      71vw 52.4vh 0 0 rgba(255, 246, 232, 0.45),
      25.6vw 8.2vh 0 0 rgba(255, 246, 232, 0.74),
      85vw 65.5vh 0 0 rgba(255, 246, 232, 0.5),
      28.1vw 65.6vh 0 0 rgba(255, 246, 232, 0.28),
      76.6vw 75.1vh 0 0 rgba(255, 246, 232, 0.69),
      11.5vw 26.3vh 0 0 rgba(255, 246, 232, 0.61),
      5.6vw 21vh 0 0 rgba(255, 246, 232, 0.53),
      76.8vw 21.2vh 0 0 rgba(255, 246, 232, 0.53),
      0.3vw 45vh 0 0 rgba(255, 246, 232, 0.56),
      65.1vw 54.8vh 0 0 rgba(255, 246, 232, 0.72),
      81.3vw 17.9vh 0 0 rgba(255, 246, 232, 0.71),
      42.8vw 71.6vh 0 0 rgba(255, 246, 232, 0.33),
      84.6vw 22.6vh 0 0 rgba(255, 246, 232, 0.26),
      48.9vw 2vh 0 0 rgba(255, 246, 232, 0.33),
      93.7vw 18.8vh 0 0 rgba(255, 246, 232, 0.43),
      61.4vw 57.2vh 0 0 rgba(255, 246, 232, 0.57),
      80.7vw 47.4vh 0 0 rgba(255, 246, 232, 0.59),
      8.9vw 21vh 0 0 rgba(255, 246, 232, 0.29),
      90vw 76.1vh 0 0 rgba(255, 246, 232, 0.38),
      81.4vw 17.3vh 0 0 rgba(255, 246, 232, 0.48),
      7.2vw 2vh 0 0 rgba(255, 246, 232, 0.33),
      35.6vw 42.3vh 0 0 rgba(255, 246, 232, 0.8),
      42.4vw 29.6vh 0 0 rgba(255, 246, 232, 0.45),
      63vw 32.4vh 0 0 rgba(255, 246, 232, 0.26),
      75.7vw 33.7vh 0 0 rgba(255, 246, 232, 0.71),
      17.1vw 53.2vh 0 0 rgba(255, 246, 232, 0.54),
      76.4vw 49vh 0 0 rgba(255, 246, 232, 0.52),
      41.8vw 18.3vh 0 0 rgba(255, 246, 232, 0.26),
      32.9vw 42.1vh 0 0 rgba(255, 246, 232, 0.41),
      98.8vw 64.3vh 0 0 rgba(255, 246, 232, 0.58),
      9.9vw 74.4vh 0 0 rgba(255, 246, 232, 0.57),
      59.5vw 9.7vh 0 0 rgba(255, 246, 232, 0.3),
      83.1vw 52.2vh 0 0 rgba(255, 246, 232, 0.51),
      78vw 50.2vh 0 0 rgba(255, 246, 232, 0.73),
      33.7vw 10vh 0 0 rgba(255, 246, 232, 0.5),
      6.8vw 70.5vh 0 0 rgba(255, 246, 232, 0.44),
      70.8vw 39.6vh 0 0 rgba(255, 246, 232, 0.29),
      9.1vw 42vh 0 0 rgba(255, 246, 232, 0.5),
      95.1vw 2.3vh 0 0 rgba(255, 246, 232, 0.77),
      93.6vw 47.6vh 0 0 rgba(255, 246, 232, 0.59),
      52.4vw 35.9vh 0 0 rgba(255, 246, 232, 0.53),
      23.2vw 17.1vh 0 0 rgba(255, 246, 232, 0.3);
  animation: hwTwinkle 9s ease-in-out infinite alternate;
  /* Mỗi lớp sao tự lên một layer riêng: chỉ đổi opacity (composite) thay vì vẽ lại
     46 bóng đổ trải khắp màn hình ở mỗi khung hình. */
  will-change: opacity;
}

/* Vài "ngôi sao lớn" có quầng sáng, nhấp nháy chậm hơn ⇒ tạo chiều sâu */
.hw-decor .hw-sky::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  box-shadow:
      8.5vw 12vh 4px 0 rgba(255, 214, 160, 0.26),
      26vw 6vh 4px 0 rgba(255, 214, 160, 0.2),
      44vw 24vh 4px 0 rgba(255, 214, 160, 0.3),
      62vw 9vh 4px 0 rgba(255, 214, 160, 0.22),
      88vw 30vh 4px 0 rgba(255, 214, 160, 0.28),
      14vw 46vh 4px 0 rgba(255, 214, 160, 0.2),
      36vw 62vh 4px 0 rgba(255, 214, 160, 0.26),
      58vw 40vh 4px 0 rgba(255, 214, 160, 0.3),
      72vw 70vh 4px 0 rgba(255, 214, 160, 0.18),
      94vw 58vh 4px 0 rgba(255, 214, 160, 0.26),
      22vw 78vh 4px 0 rgba(255, 214, 160, 0.22),
      50vw 84vh 4px 0 rgba(255, 214, 160, 0.18);
  animation: hwTwinkle 13s ease-in-out infinite alternate-reverse;
}

/* Sương ấm ở chân trang — trôi rất chậm */
.hw-decor .hw-fog {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -12%;
  height: 52%;
  background:
    radial-gradient(ellipse 46% 58% at 18% 100%, rgba(255, 138, 31, 0.12), transparent 72%),
    radial-gradient(ellipse 52% 54% at 74% 100%, rgba(142, 84, 255, 0.11), transparent 74%);
  /* Bỏ `filter: blur(14px)`: gradient ở trên vốn đã mềm, blur chỉ tốn GPU (khối rộng 120%
     màn hình phải làm mờ lại mỗi khung hình). Nhìn gần như không khác. */
  animation: hwFogDrift 34s ease-in-out infinite alternate;
  will-change: transform;
}

/* Vignette: tối nhẹ 4 mép cho nội dung nổi hơn */
.hw-decor .hw-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 118% 92% at 50% 42%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.34) 100%);
}

@keyframes hwTwinkle {
  from { opacity: 0.42; }
  to   { opacity: 0.95; }
}

@keyframes hwFogDrift {
  from { transform: translate3d(-2%, 1%, 0) scale(1); }
  to   { transform: translate3d(3%, -2%, 0) scale(1.06); }
}

.hw-decor .hw-moon {
  position: absolute;
  top: 34px;
  right: 4vw;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 63% 63%, rgba(214, 176, 128, 0.55) 0 7px, rgba(214, 176, 128, 0) 8px),
    radial-gradient(circle at 39% 61%, rgba(214, 176, 128, 0.45) 0 4.5px, rgba(214, 176, 128, 0) 5.5px),
    radial-gradient(circle at 56% 34%, rgba(214, 176, 128, 0.38) 0 3px, rgba(214, 176, 128, 0) 4px),
    radial-gradient(circle at 72% 40%, rgba(214, 176, 128, 0.3) 0 2.4px, rgba(214, 176, 128, 0) 3.4px),
    radial-gradient(circle at 34% 30%, #fffdf7 0%, #fff1d8 38%, #ffdcaa 72%, #ffc98c 100%);
  box-shadow:
    0 0 0 1px rgba(255, 240, 214, 0.3),
    0 0 42px 8px rgba(255, 214, 160, 0.26),
    0 0 130px 38px rgba(255, 150, 60, 0.12);
  opacity: 0.82;
  animation: hwMoonGlow 8s ease-in-out infinite;
  will-change: opacity;
}

/* Mạng nhện: cùng một hình, xoay/lật cho bám đúng mép màn hình */
.hw-decor .hw-web {
  position: absolute;
  width: 150px;
  height: 150px;
  background: no-repeat top left / contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='%23efe3cf' stroke-opacity='.44' stroke-width='.75'%3E%3Cpath d='M0 0 100 100M0 0 100 44M0 0 44 100M0 0 100 14M0 0 14 100M0 0 78 100M0 0 100 78'/%3E%3Cpath d='M22 0Q18 18 0 22M44 0Q37 37 0 44M66 0Q56 56 0 66M88 0Q75 75 0 88M11 0Q9 9 0 11M33 0Q28 28 0 33'/%3E%3C/svg%3E");
}

/* Bốn góc màn hình — tơ nhện chỉ bám ở góc, không cắt ngang nội dung */
.hw-decor .hw-web-tr { top: 0; right: 0; width: 168px; height: 168px; transform: scaleX(-1); opacity: 0.55; }
.hw-decor .hw-web-tl { top: 0; left: 0; width: 150px; height: 150px; opacity: 0.45; }
.hw-decor .hw-web-br { bottom: 0; right: 0; width: 152px; height: 152px; transform: scale(-1, -1); opacity: 0.5; }
.hw-decor .hw-web-bl { bottom: 0; left: 0; width: 132px; height: 132px; transform: scaleY(-1); opacity: 0.42; }

/* Desktop: sidebar chiếm 256px bên trái nên "góc" của vùng nội dung mới là góc thật.
   Thu gọn sidebar (72px) thì tơ bám lại theo. */
html.hw-on.device-desktop .hw-decor .hw-web-tl,
html.hw-on.device-desktop .hw-decor .hw-web-bl { left: 256px; }
html.hw-on.device-desktop body.sidebar-collapsed .hw-decor .hw-web-tl,
html.hw-on.device-desktop body.sidebar-collapsed .hw-decor .hw-web-bl { left: 72px; }

/* Nhện treo ở tơ góc phải trên: thỉnh thoảng THU tơ (kéo mình lên) rồi NHẢ tơ
   (tụt xuống). Tơ co giãn bằng scaleY + nhện dịch lên bằng translateY (chỉ transform,
   không đụng layout) nên chạy mượt cả trên máy yếu. */
.hw-decor .hw-spider {
  --hw-thread: 68px;
  position: absolute;
  top: 118px;
  right: 116px;
  width: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(232, 220, 200, 0.55);
  transform-origin: top center;
  animation: hwSpiderSwing 9s ease-in-out infinite;
  will-change: transform;
}

.hw-decor .hw-spider-thread {
  --hw-dur: 13s;
  width: 1px;
  height: var(--hw-thread);
  transform-origin: top center;
  background: linear-gradient(to bottom, rgba(239, 227, 207, 0) 0%, rgba(239, 227, 207, 0.5) 100%);
  animation: hwSpiderThread var(--hw-dur) cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.hw-decor .hw-spider svg {
  --hw-dur: 13s;
  display: block;
  width: 22px;
  height: 22px;
  margin-top: -2px;
  animation: hwSpiderRise var(--hw-dur) cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes hwSpiderThread {
  0%, 10%   { transform: scaleY(1); }
  38%, 56%  { transform: scaleY(0.16); }
  88%, 100% { transform: scaleY(1); }
}

@keyframes hwSpiderRise {
  0%, 10%   { transform: translateY(0); }
  38%, 56%  { transform: translateY(calc(var(--hw-thread) * -0.84)); }
  88%, 100% { transform: translateY(0); }
}

/* Tàn lửa/đom đóm cam bay lên — điểm nhấn chuyển động rất nhẹ */
.hw-decor .hw-ember {
  position: absolute;
  bottom: -10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe3bd 0%, rgba(255, 138, 31, 0.85) 55%, rgba(255, 138, 31, 0) 78%);
  box-shadow: 0 0 12px rgba(255, 160, 70, 0.75);
  opacity: 0;
  animation: hwEmberRise 18s linear infinite;
  will-change: transform, opacity;
}

.hw-decor .hw-ember-1 { left: 8%; animation-duration: 16s; animation-delay: -1s; }
.hw-decor .hw-ember-2 { left: 22%; animation-duration: 21s; animation-delay: -7s; }
.hw-decor .hw-ember-3 { left: 41%; animation-duration: 19s; animation-delay: -13s; }
.hw-decor .hw-ember-4 { left: 58%; animation-duration: 23s; animation-delay: -4s; }
.hw-decor .hw-ember-5 { left: 74%; animation-duration: 17s; animation-delay: -10s; }
.hw-decor .hw-ember-6 { left: 88%; animation-duration: 25s; animation-delay: -16s; }

@keyframes hwEmberRise {
  0%   { transform: translate3d(0, 0, 0) scale(0.7); opacity: 0; }
  10%  { opacity: 0.85; }
  70%  { opacity: 0.5; }
  100% { transform: translate3d(18px, -88vh, 0) scale(1.15); opacity: 0; }
}

@keyframes hwSpiderSwing {
  0%, 100% { transform: rotate(-3.5deg); }
  50%      { transform: rotate(3.5deg); }
}

.hw-decor .hw-bat {
  --hw-dur: 24s;
  position: absolute;
  top: 12%;
  left: -14vw;
  width: 30px;
  color: rgba(232, 220, 200, 0.62);
  filter: drop-shadow(0 0 8px rgba(255, 170, 90, 0.22));
  animation: hwBatFly var(--hw-dur) linear infinite;
  /* Lên layer riêng: bộ lọc chỉ tính MỘT lần rồi di chuyển bằng composite. */
  will-change: transform;
}

.hw-decor .hw-bat svg { display: block; width: 100%; height: auto; overflow: visible; }

/* Vỗ cánh: xoay từng cánh quanh "vai" (toạ độ trong viewBox 48x24) */
.hw-decor .hw-bat .hw-bat-wing { --hw-dur: 0.58s; transform-box: view-box; }
.hw-decor .hw-bat .hw-bat-wing-l { transform-origin: 23px 10.5px; animation: hwWingL var(--hw-dur) ease-in-out infinite alternate; }
.hw-decor .hw-bat .hw-bat-wing-r { transform-origin: 25px 10.5px; animation: hwWingR var(--hw-dur) ease-in-out infinite alternate; }

@keyframes hwWingL {
  from { transform: rotate(-9deg); }
  to   { transform: rotate(11deg); }
}

@keyframes hwWingR {
  from { transform: rotate(9deg); }
  to   { transform: rotate(-11deg); }
}

.hw-decor .hw-bat-1 { --hw-dur: 26s; top: 14%; width: 26px; animation-delay: -3s; opacity: 0.72; }
.hw-decor .hw-bat-2 { --hw-dur: 32s; top: 30%; width: 34px; animation-delay: -14s; opacity: 0.6; }
.hw-decor .hw-bat-3 { --hw-dur: 22s; top: 56%; width: 24px; animation-delay: -8s; opacity: 0.5; }
.hw-decor .hw-bat-4 { --hw-dur: 36s; top: 72%; width: 30px; animation-delay: -20s; opacity: 0.5; }
.hw-decor .hw-bat-5 { --hw-dur: 28s; top: 44%; width: 22px; animation-delay: -25s; opacity: 0.42; }

/* Hai con bay ngược chiều (phải → trái) cho khung cảnh tự nhiên hơn */
.hw-decor .hw-bat-rev { animation-direction: reverse; }

@keyframes hwBatFly {
  0%   { transform: translate3d(0, 0, 0) rotate(-3deg) scale(0.94); }
  33%  { transform: translate3d(42vw, -5vh, 0) rotate(4deg) scale(1.04); }
  66%  { transform: translate3d(82vw, 4vh, 0) rotate(-2deg) scale(0.98); }
  100% { transform: translate3d(124vw, -2vh, 0) rotate(3deg) scale(0.94); }
}

@keyframes hwMoonGlow {
  /* Chỉ đổi opacity. Trước đây keyframes đổi cả box-shadow (3 lớp bóng lớn) ⇒ trình duyệt
     phải vẽ lại quầng sáng mỗi khung hình. Quầng tĩnh + opacity vẫn cho cảm giác "thở". */
  0%, 100% { opacity: 0.78; }
  50%      { opacity: 0.92; }
}

@keyframes hwPumpkinBob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-2px) rotate(4deg); }
}

/* ── Công tắc trong Hồ sơ: giao diện + nhạc Halloween ─────────────────────── */
.hw-event-box .hw-event-note {
  margin: 0 0 16px;
  color: var(--text3);
  font-size: .8rem;
  line-height: 1.65;
}

.hw-event-box .hw-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.hw-event-box .hw-switch-row:first-of-type { border-top: 0; padding-top: 0; }
.hw-event-box .hw-switch-row:last-of-type { padding-bottom: 0; }

.hw-switch-text { min-width: 0; }
.hw-switch-text strong { display: block; color: var(--text); font-size: .9rem; font-weight: 700; }
.hw-switch-text span { display: block; margin-top: 4px; color: var(--text3); font-size: .78rem; line-height: 1.6; }

.hw-switch {
  position: relative;
  flex-shrink: 0;
  width: 50px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.hw-switch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hw-switch:disabled { opacity: 0.4; cursor: not-allowed; }

.hw-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #9aa0aa;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.22s ease;
}

.hw-switch[aria-checked="true"] {
  background: linear-gradient(135deg, #ff9a35, #e2570a);
  border-color: rgba(255, 138, 31, 0.6);
  box-shadow: 0 0 16px rgba(255, 138, 31, 0.32);
}

.hw-switch[aria-checked="true"] .hw-switch-knob {
  transform: translateX(22px);
  background: #fff;
}

@media (max-width: 820px) {
  /* Điện thoại: GPU yếu nhất ⇒ bỏ hẳn sương mờ toàn màn hình và bớt tàn lửa.
     Vẫn giữ dơi + nhện + sao để còn "không khí" Halloween. */
  .hw-decor .hw-fog { display: none; }
  .hw-decor .hw-ember-2,
  .hw-decor .hw-ember-4,
  .hw-decor .hw-ember-6 { display: none; }
  .hw-decor .hw-bat-4,
  .hw-decor .hw-bat-5 { display: none; }
}

@media (max-width: 640px) {
  .hw-ribbon { font-size: 0.69rem; gap: 7px; padding: 7px 12px; margin-bottom: 14px; }
  .hw-ribbon .hw-ribbon-pumpkin { width: 16px; height: 16px; }
  .hw-decor .hw-moon { width: 62px; height: 62px; top: 14px; right: 8vw; opacity: 0.66; }
  .hw-decor .hw-web-tl { width: 96px; height: 96px; opacity: 0.38; }
  .hw-decor .hw-web-tr { width: 104px; height: 104px; opacity: 0.46; }
  .hw-decor .hw-web-bl { width: 88px; height: 88px; opacity: 0.36; }
  .hw-decor .hw-web-br { width: 100px; height: 100px; opacity: 0.42; }
  .hw-decor .hw-spider { --hw-thread: 44px; top: 80px; right: 66px; width: 16px; }
  .hw-decor .hw-spider svg { width: 16px; height: 16px; }
}

/* ── Máy yếu (html.perf-low) ────────────────────────────────────────────────
   app.css có luật `html.perf-low * { animation-duration:.001s!important; ... }` để dập
   MỌI animation nhằm đỡ tốn CPU — nên trên máy ≤ 4 nhân / ≤ 4GB RAM, dơi và nhện đứng
   im (đúng triệu chứng "animation không chạy").
   Trang trí Halloween chỉ dùng transform/opacity (rất nhẹ, trình duyệt chạy ở lớp
   composite) ⇒ bật lại riêng dơi + nhện + bí ngô ở ribbon. Các hiệu ứng nặng (sương mờ,
   sao nhấp nháy toàn màn hình, tàn lửa, quầng trăng) vẫn tắt cho máy yếu. */
html.perf-low.hw-on .hw-decor .hw-bat,
html.perf-low.hw-on .hw-decor .hw-bat .hw-bat-wing,
html.perf-low.hw-on .hw-decor .hw-spider,
html.perf-low.hw-on .hw-decor .hw-spider-thread,
html.perf-low.hw-on .hw-decor .hw-spider svg,
html.perf-low.hw-on .hw-ribbon .hw-ribbon-pumpkin {
  animation-duration: var(--hw-dur, 24s) !important;
  animation-iteration-count: infinite !important;
}

html.perf-low.hw-on .hw-decor .hw-moon,
html.perf-low.hw-on .hw-decor .hw-sky::before,
html.perf-low.hw-on .hw-decor .hw-sky::after,
html.perf-low.hw-on .hw-decor .hw-fog {
  animation: none !important;
}

/* Tàn lửa là thứ "động" rõ nhất ⇒ máy yếu ẩn hẳn cho nhẹ. */
html.perf-low.hw-on .hw-decor .hw-ember { display: none; }
html.perf-low.hw-on .hw-decor .hw-bat { opacity: 0.55; }
html.perf-low.hw-on .hw-decor .hw-sky::before,
html.perf-low.hw-on .hw-decor .hw-sky::after { opacity: 0.7; }

@media (prefers-reduced-motion: reduce) {
  .hw-decor .hw-bat,
  .hw-decor .hw-bat .hw-bat-wing,
  .hw-decor .hw-moon,
  .hw-decor .hw-spider,
  .hw-decor .hw-spider-thread,
  .hw-decor .hw-spider svg,
  .hw-decor .hw-sky::before,
  .hw-decor .hw-sky::after,
  .hw-decor .hw-fog,
  .hw-ribbon .hw-ribbon-pumpkin {
    animation-play-state: paused !important;
  }

  .hw-decor .hw-ember { display: none; }
}

/* Member tự bấm 🎃 để bật event ⇒ tôn trọng ý muốn đó: cho animation chạy lại kể cả khi
   Windows/điện thoại đang bật "giảm chuyển động" (chỉ những hiệu ứng nhẹ dưới đây). */
html.hw-motion .hw-decor .hw-bat,
html.hw-motion .hw-decor .hw-bat .hw-bat-wing,
html.hw-motion .hw-decor .hw-spider,
html.hw-motion .hw-decor .hw-spider-thread,
html.hw-motion .hw-decor .hw-spider svg,
html.hw-motion .hw-ribbon .hw-ribbon-pumpkin {
  animation-play-state: running !important;
  animation-duration: var(--hw-dur, 24s) !important;
  animation-iteration-count: infinite !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CANDY EXCHANGE — Kẹo Halloween (nằm trong trang "Làm nhiệm vụ")
   ═══════════════════════════════════════════════════════════════════════════ */

/* Khối đổi kẹo giờ nằm ngay dưới danh sách nhiệm vụ vượt link. */
.candy-earn-card {
  margin: 22px 0 4px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

/* Huy hiệu "+1 🍬" trên mỗi thẻ nhiệm vụ: luôn có trong HTML, chỉ hiện khi sự kiện bật
   (class `candy-on` do JS gắn) nên đổi trạng thái không phải vẽ lại danh sách. */
.task-candy-badge { display: none; }
html.candy-on .task-candy-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 800;
  color: #ffd9a8;
  background: rgba(255, 138, 31, 0.16);
  border: 1px solid rgba(255, 138, 31, 0.36);
  white-space: nowrap;
}

.candy-exchange-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, rgba(255,138,31,0.14) 0%, rgba(168,85,247,0.1) 100%);
  border: 1px solid rgba(255,138,31,0.28);
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 20px;
}

.candy-pumpkin-icon {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(255,138,31,0.55));
  animation: hw-pumpkin-bounce 3s ease-in-out infinite;
  will-change: transform;
}

@keyframes hw-pumpkin-bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

.candy-exchange-hero h2 { margin: 0 0 4px; font-size: 1.35rem; }
.candy-exchange-hero p { margin: 0; color: var(--text2); font-size: 0.88rem; }

.candy-balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}

.candy-balance-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.candy-balance-icon {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 8px rgba(255,138,31,0.4));
}

.candy-balance-label {
  font-size: 0.78rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.candy-balance-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--hw-orange, #ff8a1f);
  line-height: 1;
  text-shadow: 0 0 16px rgba(255,138,31,0.35);
}

.candy-balance-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.candy-rate-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,138,31,0.1);
  border: 1px solid rgba(255,138,31,0.22);
  border-radius: 8px;
  padding: 6px 12px;
}

.candy-rate-label {
  font-size: 0.78rem;
  color: var(--text2);
}

.candy-rate-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--hw-orange, #ff8a1f);
}

.candy-collected-info {
  color: var(--text3);
  font-size: 0.78rem;
}

.candy-exchange-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 18px;
}

.candy-form-head { margin-bottom: 16px; }
.candy-form-head h3 { margin: 0; font-size: 1.05rem; }

.candy-input-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.candy-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
}

.candy-preview-arrow {
  font-size: 1.4rem;
  color: var(--hw-orange, #ff8a1f);
  font-weight: 700;
}

.candy-preview-label {
  font-size: 0.72rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1px;
}

.candy-preview-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--hw-orange, #ff8a1f);
  text-shadow: 0 0 10px rgba(255,138,31,0.3);
}

.candy-hint {
  font-size: 0.76rem;
  color: var(--text3);
  margin: 10px 0 0;
  text-align: center;
}

.candy-history-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
}

.candy-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.candy-history-head h3 { margin: 0; font-size: 1rem; }

.candy-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.candy-history-empty {
  text-align: center;
  color: var(--text3);
  font-size: 0.85rem;
  padding: 24px 0;
}

.candy-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 0.85rem;
}

.candy-history-item .chi-candy {
  color: var(--hw-orange, #ff8a1f);
  font-weight: 700;
}

.candy-history-item .chi-reward {
  color: #4ade80;
  font-weight: 700;
}

.candy-history-item .chi-time {
  color: var(--text3);
  font-size: 0.76rem;
}

/* Nút đổi kẹo nổi bật hơn trong Halloween */
html.hw-on #candy-exchange-btn {
  background: linear-gradient(135deg, #ff8a1f 0%, #ff6b00 100%);
  border-color: #ff8a1f;
  box-shadow: 0 4px 18px rgba(255,138,31,0.4);
  font-weight: 700;
  letter-spacing: 0.02em;
}

html.hw-on #candy-exchange-btn:hover {
  background: linear-gradient(135deg, #ff9a3a 0%, #ff7a1a 100%);
  box-shadow: 0 6px 24px rgba(255,138,31,0.55);
  transform: translateY(-1px);
}

html.hw-on #candy-exchange-btn:active {
  transform: translateY(0);
}

/* Hàng kẹo trong Hồ sơ */
html.hw-on .hw-candy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px dashed rgba(255,138,31,0.25);
  margin-top: 12px;
  padding-top: 12px;
}

html.hw-on .hw-candy-row .hw-switch-text strong {
  color: var(--hw-orange, #ff8a1f);
}
