/**
 * ============================================================================
 * CHỦ ĐỀ HALLOWEEN (ĐÊM MA MỊ, RỪNG CÂY KHÔ & BÍ NGÔ QUỶ)
 * ============================================================================
 * - Bối cảnh rừng đêm u ám, cành cây khô khẳng khiu vươn nhánh ma mị
 * - Đàn dơi đêm bay vút chéo từ vực thẳm dưới lên bầu trời u linh
 * - Bí ngô quỷ Jack-o'-Lantern với ánh lửa bập bùng ngự trị trên đỉnh khung
 * - TUÂN THỦ TUYỆT ĐỐI: 100% UI_Frames (Alpha Test, Open Beta, Top 1-2-3)
 *   GIỮ NGUYÊN MÀU GỐC TỰ NHIÊN, KHÔNG HUE-ROTATE BỆT MÀU!
 */

:root {
  --hw-bg-dark: #07030d;
  --hw-bg-mist: #130722;
  --hw-purple-primary: #a855f7;
  --hw-purple-glow: rgba(168, 85, 247, 0.6);
  --hw-pumpkin-orange: #ff6600;
  --hw-pumpkin-glow: rgba(255, 102, 0, 0.7);
  --hw-blood-red: #ef4444;
  --hw-witch-green: #10b981;
}

/* ==========================================================================
   1. BẦU KHÔNG KHÍ HẬU KỲ HALLOWEEN (TRĂNG TRÒN, NHÀ MA, RỪNG CÂY KHÔ & BÍ NGÔ)
   ========================================================================== */
body.theme-halloween {
  background-color: var(--hw-bg-dark) !important;
  color: #f3e8ff !important;
  position: relative;
  overflow-x: hidden;
}

/* Đảm bảo .unified-site-bg không che mất bối cảnh hậu kỳ */
body.theme-halloween .unified-site-bg {
  background-color: transparent !important;
  background-image: 
    radial-gradient(circle at 72% 20%, rgba(168, 85, 247, 0.15) 0%, transparent 60%),
    radial-gradient(circle at 18% 75%, rgba(255, 102, 0, 0.10) 0%, transparent 50%),
    radial-gradient(circle at 85% 75%, rgba(255, 102, 0, 0.10) 0%, transparent 50%) !important;
}

/* Khung hiển thị bối cảnh hậu kỳ Halloween cố định toàn màn hình (z-index: 0) */
.halloween-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  display: none;
  overflow: hidden;
}

body.theme-halloween .halloween-backdrop {
  display: block !important;
}

.halloween-backdrop-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Hiệu ứng nhấp nháy ánh nến ma quái trong cửa sổ ngôi nhà hoang */
@keyframes hwWindowFlicker {
  0%, 100% { opacity: 0.95; filter: drop-shadow(0 0 8px #ff6600); }
  22% { opacity: 0.70; filter: drop-shadow(0 0 4px #ea580c); }
  45% { opacity: 1.0; filter: drop-shadow(0 0 14px #fbbf24); }
  68% { opacity: 0.65; filter: drop-shadow(0 0 3px #c2410c); }
  85% { opacity: 0.88; filter: drop-shadow(0 0 10px #f97316); }
}

.hw-flicker-window {
  animation: hwWindowFlicker 3.0s ease-in-out infinite;
}

/* Lớp sương đêm dịu nhẹ */
body.theme-halloween::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.12;
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(18, 7, 34, 0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 100% 0%, rgba(18, 7, 34, 0.8) 0%, transparent 60%),
    linear-gradient(0deg, rgba(19, 7, 34, 0.6) 0%, transparent 30%);
  mix-blend-mode: multiply;
}

/* ==========================================================================
   2. ẨN HOÀN TOÀN DẢI BĂNG TUYẾT & CÀNH XUÂN CŨ
   ========================================================================== */
body.theme-halloween .icicle-ridge,
body.theme-halloween .milestone-snow-crest,
body.theme-halloween .master-rank-card .snow-crest,
body.theme-halloween .milestone-spring-garland,
body.theme-halloween .spring-crest,
body.theme-halloween .spring-roadmap-garland,
body.theme-halloween .milestone-autumn-garland,
body.theme-halloween .autumn-crest,
body.theme-halloween .autumn-roadmap-garland {
  display: none !important;
}

/* ==========================================================================
   3. GIỮ NGUYÊN 100% MÀU GỐC CỦA TẤT CẢ UI_FRAMES (KHÔNG HUE-ROTATE)
   ========================================================================== */
body.theme-halloween .milestone-box-frame,
body.theme-halloween .milestone-frame-img,
body.theme-halloween .master-rank-frame,
body.theme-halloween .banner-title-frame,
body.theme-halloween .header-divider,
body.theme-halloween .content-box-frame,
body.theme-halloween .ui-frame-box {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.95)) 
         drop-shadow(0 0 16px rgba(168, 85, 247, 0.35)) 
         drop-shadow(0 0 28px rgba(255, 102, 0, 0.3)) !important;
  opacity: 1 !important;
  transition: filter 0.3s ease;
}

body.theme-halloween .milestone-box:hover .milestone-box-frame {
  filter: brightness(1.1) 
         drop-shadow(0 12px 30px rgba(0, 0, 0, 0.98)) 
         drop-shadow(0 0 24px rgba(168, 85, 247, 0.55)) 
         drop-shadow(0 0 35px rgba(255, 102, 0, 0.5)) !important;
}

/* Khung vinh danh Top 1, 2, 3 giữ nguyên màu vàng kim, bạch kim và đồng */
body.theme-halloween .master-rank-card img {
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.95)) 
         drop-shadow(0 0 20px rgba(168, 85, 247, 0.4)) !important;
}

/* ==========================================================================
   4. BÍ NGÔ QUỶ & CÀNH CÂY KHÔ ÔM KHUNG ALPHA TEST & OPEN BETA
   ========================================================================== */
body.theme-halloween .milestone-box .milestone-halloween-garland,
body.theme-halloween .milestone-halloween-garland,
.milestone-box .milestone-halloween-garland {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  pointer-events: none !important;
  z-index: 7 !important;
  overflow: visible !important;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 16px rgba(255, 102, 0, 0.7));
}

body.theme-halloween .milestone-box:hover .milestone-halloween-garland {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.98)) drop-shadow(0 0 24px rgba(255, 102, 0, 0.95)) brightness(115%);
}

/* Hiệu ứng lửa bí ngô bập bùng ma quái (Flickering Flame) */
@keyframes pumpkinFlicker {
  0%, 100% {
    opacity: 0.95;
    filter: drop-shadow(0 0 8px #ff6600) drop-shadow(0 0 18px #ffaa00);
  }
  25% {
    opacity: 0.75;
    filter: drop-shadow(0 0 5px #ff4400) drop-shadow(0 0 12px #ff7700);
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 12px #ff8800) drop-shadow(0 0 24px #ffbb00) brightness(1.2);
  }
  75% {
    opacity: 0.85;
    filter: drop-shadow(0 0 6px #ff5500) drop-shadow(0 0 15px #ff8800);
  }
}

.halloween-flame-glow {
  animation: pumpkinFlicker 2.4s infinite ease-in-out;
}

/* Dơi bay lượn quanh viền bí ngô */
@keyframes batWingFlutter {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.45); }
}

.halloween-mini-bat {
  transform-origin: center;
  animation: batWingFlutter 0.3s infinite ease-in-out;
}

/* ==========================================================================
   5. VƯƠNG MIỆN CÁNH DƠI & BÍ NGÔ QUỶ CHO KHUNG TOP 1, 2, 3
   ========================================================================== */
body.theme-halloween .master-rank .halloween-crest,
body.theme-halloween .halloween-crest,
.master-rank .halloween-crest {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  pointer-events: none !important;
  z-index: 6 !important;
  overflow: visible !important;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 14px rgba(168, 85, 247, 0.65));
}

body.theme-halloween .master-rank:hover .halloween-crest {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.98)) drop-shadow(0 0 22px rgba(255, 102, 0, 0.9)) brightness(115%);
}

.halloween-crest--rank1 {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.95)) 
         drop-shadow(0 0 22px rgba(255, 102, 0, 0.85)) 
         drop-shadow(0 0 14px rgba(245, 158, 11, 0.9)) !important;
}

.halloween-crest--rank2 {
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.95)) 
         drop-shadow(0 0 18px rgba(168, 85, 247, 0.8)) !important;
}

.halloween-crest--rank3 {
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.95)) 
         drop-shadow(0 0 18px rgba(234, 88, 12, 0.8)) !important;
}

/* ==========================================================================
   6. CÀNH KHÔ & MẠNG NHỆN CHO THẺ LỘ TRÌNH (ROADMAP CARDS)
   ========================================================================== */
.halloween-roadmap-garland {
  position: absolute;
  top: -12px;
  left: 0;
  width: 100%;
  height: 38px;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.9));
}

body.theme-halloween .roadmap-card {
  background: linear-gradient(145deg, rgba(20, 8, 36, 0.9) 0%, rgba(9, 3, 16, 0.95) 100%) !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), inset 0 0 20px rgba(168, 85, 247, 0.1) !important;
}

body.theme-halloween .roadmap-card:hover {
  border-color: rgba(255, 102, 0, 0.75) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.95), 0 0 24px rgba(255, 102, 0, 0.35) !important;
}

body.theme-halloween .roadmap-badge {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.8) !important;
}

/* ==========================================================================
   7. KHỐI ĐẾM NGƯỢC (COUNTDOWN PODS) & NÚT BẤM (BUTTONS)
   ========================================================================== */
body.theme-halloween .countdown-pod {
  background: linear-gradient(180deg, rgba(28, 10, 48, 0.85) 0%, rgba(12, 4, 22, 0.95) 100%) !important;
  border: 1px solid rgba(168, 85, 247, 0.4) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.9), inset 0 0 12px rgba(168, 85, 247, 0.2) !important;
}

body.theme-halloween .countdown-val {
  color: #ff9900 !important;
  text-shadow: 0 0 14px rgba(255, 102, 0, 0.85), 0 0 24px rgba(255, 153, 0, 0.6) !important;
}

body.theme-halloween .countdown-label {
  color: #d8b4fe !important;
}

body.theme-halloween .btn-custom-action,
body.theme-halloween .btn-primary-winter {
  background: linear-gradient(135deg, #7c3aed 0%, #ff6600 100%) !important;
  border: 1px solid #ff9900 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 18px rgba(255, 102, 0, 0.5), 0 0 12px rgba(168, 85, 247, 0.6) !important;
}

body.theme-halloween .btn-custom-action:hover,
body.theme-halloween .btn-primary-winter:hover {
  background: linear-gradient(135deg, #ff6600 0%, #7c3aed 100%) !important;
  box-shadow: 0 6px 26px rgba(255, 102, 0, 0.8), 0 0 20px rgba(168, 85, 247, 0.9) !important;
  transform: translateY(-2px);
}

/* ==========================================================================
   8. BẢNG XẾP HẠNG & QUY TẮC SỰ KIỆN (TABLES & RULES)
   ========================================================================== */
body.theme-halloween .ranking-table-wrapper,
body.theme-halloween .event-rules-card {
  background: rgba(14, 6, 26, 0.92) !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.95), inset 0 0 30px rgba(168, 85, 247, 0.08) !important;
}

body.theme-halloween .ranking-table th {
  background: linear-gradient(180deg, rgba(38, 14, 68, 0.9) 0%, rgba(20, 8, 36, 0.9) 100%) !important;
  color: #ffaa00 !important;
  border-bottom: 2px solid rgba(255, 102, 0, 0.5) !important;
  text-shadow: 0 0 10px rgba(255, 102, 0, 0.6);
}

body.theme-halloween .ranking-table tr:hover td {
  background: rgba(168, 85, 247, 0.15) !important;
}

body.theme-halloween .ranking-rank-num.rank-1 {
  color: #ff9900 !important;
  text-shadow: 0 0 12px #ff6600 !important;
}

body.theme-halloween .ranking-rank-num.rank-2 {
  color: #d8b4fe !important;
  text-shadow: 0 0 12px #a855f7 !important;
}

body.theme-halloween .ranking-rank-num.rank-3 {
  color: #fb923c !important;
  text-shadow: 0 0 12px #ea580c !important;
}

/* ==========================================================================
   9. WIDGET ĐIỀU KHIỂN THỜI GIAN THỰC NỔI (#snowControlWrapper)
   ========================================================================== */
body.theme-halloween .snow-ctrl-pill {
  background: linear-gradient(135deg, rgba(30, 10, 52, 0.95) 0%, rgba(14, 5, 25, 0.95) 100%) !important;
  border: 1px solid #ff6600 !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.9), 0 0 14px rgba(255, 102, 0, 0.6) !important;
}

body.theme-halloween .snow-ctrl-pill:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.95), 0 0 22px rgba(168, 85, 247, 0.9) !important;
}

body.theme-halloween .snow-ctrl-title {
  color: #ff9900 !important;
  text-shadow: 0 0 10px rgba(255, 102, 0, 0.7);
}

body.theme-halloween .snow-ctrl-slider {
  accent-color: #ff6600 !important;
}

body.theme-halloween .snow-ctrl-item-val {
  color: #c084fc !important;
}

