.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.modal.open {
  display: flex;
}

.modal-content {
  margin: 30px auto;
  width: 95%;
  max-width: 1000px;
  position: relative;
  padding-bottom: 50px;
}

.close-modal {
  position: fixed;
  right: 25px;
  top: 15px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
  text-shadow: 0 0 10px rgba(0,0,0,0.8);
  transition: 0.3s;
}

.close-modal:hover {
  color: #E50914;
  transform: scale(1.2);
}

.player-loader-state {
  text-align: center;
  margin-top: 100px;
  font-size: 1.2rem;
  color: #888;
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  width: 100%;
  margin-bottom: 20px;
}

.video-wrapper iframe,
.video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.main-video-player {
  width: 100%;
  height: auto;
  max-height: 60vh;
  display: block;
}

.video-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #ccc;
  font-size: 1.1rem;
}

.player-details {
  background: #16171b;
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
}

.player-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 15px;
}

.player-description {
  color: #ccc;
  margin-bottom: 25px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.action-buttons {
  margin-bottom: 20px;
}

.fav-action-btn {
  background: transparent;
  border: 1px solid #E50914;
  color: #E50914;
  padding: 8px 20px;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  transition: 0.3s;
  display: inline-block;
}

.fav-action-btn:hover {
  background: rgba(229, 9, 20, 0.1);
}

.fav-action-btn.saved {
  background: #666;
  border-color: #666;
  color: #fff;
}

.ep-label {
  color: #E50914;
  margin-bottom: 15px;
  font-weight: bold;
  font-size: 1.1rem;
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 5px;
}

.ep-btn {
  display: block;
  background: #25262c;
  color: #ccc;
  padding: 10px 0;
  text-align: center;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #333;
  transition: 0.3s;
}

.ep-btn:hover, .ep-btn.active {
  background: #E50914;
  color: #fff;
  border-color: #E50914;
}

@media (max-width: 768px) {
  .video-wrapper {
    padding-bottom: 56.25%;
  }
  .player-title {
    font-size: 1.2rem;
  }
  .episode-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .fav-action-btn {
    width: 100%;
    text-align: center;
  }
}

/* =========================================
   AD OVERLAY (POPUP GLOBAL)
   ========================================= */

/* Container Utama: Menempel di Body, menutupi SEMUA (termasuk modal) */
#global-ad-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    z-index: 2147483647; /* Paling atas di dunia web */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Kunci Scroll Modal & Body saat iklan aktif */
body.ad-active {
    overflow: hidden !important;
}

/* Wrapper Iframe */
.ad-iframe-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    position: relative;
    z-index: 2147483648;
}

/* RESET TOTAL untuk Iframe Iklan */
/* Menggunakan ID spesifik agar menang melawan style video player */
#global-ad-overlay iframe {
    position: static !important; /* Matikan absolute */
    width: 300px !important;     /* Lebar standar iklan */
    height: 250px !important;    /* Tinggi standar iklan */
    max-width: 90vw;
    border: none !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Tombol Lanjutkan */
.ad-continue-btn {
    display: none;
    background: #E50914;
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(229, 9, 20, 0.4);
    transition: transform 0.2s;
    margin-top: 15px;
    z-index: 2147483648;
}

.ad-continue-btn:hover {
    transform: scale(1.05);
    background: #f40612;
}

.ad-status-text {
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    font-family: sans-serif;
    margin-bottom: 10px;
}