/* =========================================================================
   CINEMA ADS & BANNER STYLESHEET
   Giữ nguyên 100% cấu trúc banner cũ, cân đối thẩm mỹ & co giãn chuẩn Mobile
   ========================================================================= */

:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --border-subtle: #262933;
  --bg-surface: #1c1e24;
  --accent-gold: #f59e0b;
}

/* 1. TELEGRAM NOTICE BAR (Đầu trang) */
#telegram-notice-bar {
  background: linear-gradient(90deg, #0284c7, #0369a1);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 6px 16px;
  display: none;
}

#telegram-notice-bar a {
  color: #fef08a;
  font-weight: 700;
  text-decoration: underline;
  margin-left: 6px;
}

/* 2. CHUẨN BANNER CHUNG (CONTAINER & MULTI-BANNER GRID) */
.ad-banner-slot {
  width: 100%;
  margin: 12px auto;
  display: none;
  text-align: center;
  overflow: hidden;
}

/* HỆ THỐNG GRID TỰ ĐỘNG CÂN ĐỐI 1, 2, 3, HOẶC 4 BANNER */
.ad-banner-grid {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
}

/* 1 Banner: Căn giữa, chiều rộng tối đa đẹp mắt */
.ad-banner-grid.grid-cols-1 {
  grid-template-columns: 1fr;
  max-width: 760px;
}

/* 2 Banner: Chia đôi 50% - 50% cân đối hoàn hảo */
.ad-banner-grid.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
  max-width: 1060px;
}

/* 3 Banner: Chia 3 cân xứng 33.3% */
.ad-banner-grid.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
  max-width: 1240px;
}

/* 4 Banner: 4 cột đồng đều 25% */
.ad-banner-grid.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 100%;
}

.ad-banner-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  line-height: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ad-banner-inner:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  border-color: rgba(99, 102, 241, 0.4);
}

.ad-link-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 0;
}

.ad-link-wrap.no-link {
  cursor: default !important;
  pointer-events: auto;
}

.ad-img-responsive {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 110px;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.ad-badge-label {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.75);
  color: rgba(255, 255, 255, 0.85);
  font-size: 9.5px;
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 2;
  line-height: 1.3;
}

/* TOP BANNER (Lên tới 4 banner) */
#ad-top-banner {
  max-width: 100%;
  margin: 14px auto;
}

/* CAT BANNER (Lên tới 4 banner) */
#ad-cat-banner {
  max-width: 100%;
  margin: 10px 0 16px 0;
}

/* UNDERPLAY BANNER (Lên tới 4 banner) */
#ad-player-banner {
  max-width: 100%;
  margin: 12px 0 16px 0;
}

/* SIDEBAR BANNER (300x250) */
#ad-sidebar-banner {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  display: none;
}

#ad-sidebar-banner .ad-banner-inner {
  width: 100%;
}

#ad-sidebar-banner .ad-img-responsive {
  width: 100%;
}

/* 5. STICKY BOTTOM BANNER (Dính đáy màn hình - Lên tới 4 banner) */
#ad-bottom-sticky {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  max-width: 1100px;
  width: 96%;
  background: rgba(15, 17, 26, 0.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -6px 25px rgba(0, 0, 0, 0.7);
  display: none;
  padding: 8px 14px;
  text-align: center;
}

#ad-bottom-sticky .ad-img-responsive {
  max-height: 75px;
}

/* Responsive co giãn cho di động & máy tính bảng */
@media (max-width: 900px) {
  .ad-banner-grid.grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .ad-banner-grid.grid-cols-3,
  .ad-banner-grid.grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .ad-banner-grid.grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  #ad-bottom-sticky {
    width: 100%;
    border-radius: 0;
    padding: 6px 8px;
  }
  #ad-bottom-sticky .ad-img-responsive {
    max-height: 60px;
  }
}

@media (max-width: 480px) {
  .ad-banner-grid.grid-cols-3,
  .ad-banner-grid.grid-cols-4 {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.sticky-close-btn {
  position: absolute;
  top: -14px;
  right: 12px;
  background: #dc2626;
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  cursor: pointer;
  z-index: 10;
  border: 1px solid rgba(255,255,255,0.3);
}

/* 6. POPUP BANNER MODAL (Hỗ trợ 2-3 Banner Xếp Ngang, 4 Banner Ô Vuông 2x2) */
#ad-popup-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeInModal 0.25s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.popup-modal-content {
  position: relative;
  max-width: 100%;
  width: auto;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-container {
  position: relative;
  width: 100%;
  margin: 0 auto;
}

/* Kích thước tối đa theo cấu hình số lượng banner */
.popup-container.popup-grid-1 {
  max-width: 440px;
}
.popup-container.popup-grid-2 {
  max-width: 760px;
}
.popup-container.popup-grid-3 {
  max-width: 980px;
}
.popup-container.popup-grid-4 {
  max-width: 580px;
}

/* Grid Layout */
.popup-grid {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
}

/* 1 Banner */
.popup-grid.popup-grid-1 {
  grid-template-columns: 1fr;
}

/* 2 Banner: Xếp ngang */
.popup-grid.popup-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* 3 Banner: Xếp ngang */
.popup-grid.popup-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* 4 Banner: 4 ô vuông trong 1 ô vuông lớn (2x2) */
.popup-grid.popup-grid-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.popup-item {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #14171e;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}
.popup-item:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
}

.popup-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.popup-item-custom {
  aspect-ratio: auto;
  line-height: normal;
}

/* Nút đóng tròn nền trắng, dấu X màu đỏ ở góc trên bên phải */
.popup-close-btn {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff;
  color: #dc2626;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.popup-close-btn:hover {
  transform: scale(1.15);
  background: #fef2f2;
  color: #b91c1c;
}

/* Responsive Mobile */
@media (max-width: 768px) {
  .popup-grid {
    gap: 8px;
  }
  .popup-container.popup-grid-1 { max-width: 90vw; }
  .popup-container.popup-grid-2 { max-width: 94vw; }
  .popup-container.popup-grid-3 { max-width: 96vw; }
  .popup-container.popup-grid-4 { max-width: 92vw; }
  .popup-close-btn {
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
}
@media (max-width: 480px) {
  .popup-grid {
    gap: 6px;
  }
  .popup-close-btn {
    top: -10px;
    right: -10px;
    width: 26px;
    height: 26px;
    font-size: 13px;
  }
  .popup-item {
    border-radius: 6px;
  }
}

/* 7. PRE-ROLL IN-PLAYER AD */
.preroll-ad-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.preroll-header {
  height: 44px;
  background: rgba(18, 20, 26, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.preroll-badge {
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-skip-preroll {
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  transition: all 0.2s;
}

.btn-skip-preroll.disabled {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* =========================================================================
   HỆ THỐNG GIFTCODE GAME (HỘP QUÀ RƠI & POPUP NHẬN THƯỞNG)
   ========================================================================= */
@keyframes giftDropIn {
  0% {
    transform: translateY(-300px) rotate(-15deg);
    opacity: 0;
  }
  60% {
    transform: translateY(20px) rotate(10deg);
    opacity: 1;
  }
  80% {
    transform: translateY(-10px) rotate(-5deg);
  }
  100% {
    transform: translateY(0) rotate(0);
    opacity: 1;
  }
}

@keyframes giftWiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  15% { transform: rotate(-10deg) scale(1.05); }
  30% { transform: rotate(10deg) scale(1.05); }
  45% { transform: rotate(-6deg) scale(1.03); }
  60% { transform: rotate(6deg) scale(1.03); }
  75% { transform: rotate(0deg) scale(1); }
}

@keyframes giftPulseGlow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.4), 0 0 30px rgba(245, 158, 11, 0.2);
  }
  50% {
    box-shadow: 0 0 25px rgba(234, 179, 8, 0.8), 0 0 50px rgba(245, 158, 11, 0.5);
  }
}

.giftcode-drop-box {
  position: fixed;
  right: 24px;
  bottom: 90px;
  z-index: 9999;
  cursor: pointer;
  animation: giftDropIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  user-select: none;
  touch-action: manipulation;
}

.giftcode-box-inner {
  position: relative;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fef08a;
  animation: giftPulseGlow 2s infinite, giftWiggle 3.5s infinite 1s;
  transition: transform 0.2s ease;
}

.giftcode-box-inner:hover {
  transform: scale(1.12);
}

.giftcode-icon-emoji {
  font-size: 38px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

.giftcode-badge-label {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #f59e0b, #eab308);
  color: #000;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  border: 1px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.giftcode-close-bubble {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #181924;
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.giftcode-close-bubble:hover {
  background: #ef4444;
  color: #fff;
}

/* MODAL NHẬN GIFTCODE */
.giftcode-modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.giftcode-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.giftcode-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, #181a26, #0e1017);
  border: 2px solid #f59e0b;
  border-radius: 20px;
  padding: 30px 24px 26px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.9), 0 0 40px rgba(245, 158, 11, 0.25);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.giftcode-modal-overlay.active .giftcode-card {
  transform: scale(1);
}

.giftcode-card-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.giftcode-card-close:hover {
  background: #ef4444;
  color: #fff;
}

.giftcode-card-badge {
  display: inline-block;
  background: linear-gradient(90deg, #f59e0b, #eab308);
  color: #000;
  font-size: 12px;
  font-weight: 900;
  padding: 4px 16px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.giftcode-card-title {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.giftcode-card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.giftcode-box-display {
  background: #12141f;
  border: 1px dashed rgba(245, 158, 11, 0.5);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.giftcode-code-text {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fef08a;
  font-family: monospace;
  margin-bottom: 10px;
  text-shadow: 0 0 15px rgba(254, 240, 138, 0.4);
}

.btn-copy-code {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-copy-code:hover {
  background: #f59e0b;
  color: #000;
}

.btn-giftcode-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(90deg, #10b981, #059669);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}
.btn-giftcode-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.6);
}

@media (max-width: 768px) {
  .giftcode-drop-box {
    right: 14px;
    bottom: 80px;
  }
  .giftcode-box-inner {
    width: 60px;
    height: 60px;
    border-radius: 14px;
  }
  .giftcode-icon-emoji {
    font-size: 30px;
  }
}
