.video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
  touch-action: pan-y;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .video-container {
    /* Use -webkit-fill-available on iOS */
    height: -webkit-fill-available;
  }
}

/* Additional mobile viewport fixes */
@media screen and (max-width: 768px) {
  .video-container {
    height: 100vh;
    height: 100dvh;
    min-height: -webkit-fill-available;
  }

  #mse,
  .xgplayer,
  .xgplayer video {
    width: 100% !important;
    height: 100% !important;
    max-height: 100vh;
    max-height: 100dvh;
  }

  .episode-list-container {
    bottom: env(safe-area-inset-bottom, 0);
    padding: 20px max(20px, env(safe-area-inset-right, 20px))
      max(20px, env(safe-area-inset-bottom, 20px))
      max(20px, env(safe-area-inset-left, 20px));
  }
}

#mse,
.xgplayer,
.xgplayer video {
  width: 100% !important;
  height: 100% !important;
}

.xgplayer video {
  object-fit: contain;
}

.swipe-indicator {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1000;
  pointer-events: none;
  font-size: 14px;
}

.swipe-indicator.show {
  opacity: 1;
}

.swipe-arrow {
  display: flex;
  align-items: center;
  font-size: 14px;
}

.swipe-arrow svg {
  margin-left: 8px;
  width: 16px;
  height: 16px;
}

.episode-transition {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.episode-transition.show {
  opacity: 1;
  visibility: visible;
}

.transition-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.transition-text {
  color: white;
  font-size: 16px;
  text-align: center;
}

.custom-top-controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.8) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    transparent 100%
  );
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.custom-top-controls.show {
  opacity: 1;
  pointer-events: auto;
}

.top-controls-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.back-btn {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.movie-title {
  color: white;
  flex: 1;
}

.movie-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.episode-info {
  font-size: 14px;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.custom-right-controls {
  position: absolute;
  right: 20px;
  top: 80%;
  transform: translateY(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 15px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.custom-right-controls.show {
  opacity: 1;
  pointer-events: auto;
}

.control-btn {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.control-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.control-btn.disabled {
  opacity: 0.5;
}

.quality-menu {
  position: absolute;
  right: 50px;
  top: 0;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 120px;
  backdrop-filter: blur(10px);
}

.quality-item {
  padding: 8px 16px;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 14px;
}

.quality-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.quality-item.active {
  background: rgba(255, 255, 255, 0.2);
}

.episode-list-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  padding: 20px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1500;
  max-height: 60vh;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.episode-list-container.show {
  transform: translateY(0);
}

.episode-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.episode-list-title {
  color: white;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.episode-list-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.episode-list-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 5px;
  padding: 0;
}

.episode-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.episode-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.episode-item.current {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  border-color: #ff6b6b;
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
}

.episode-item.current:hover {
  background: linear-gradient(135deg, #ff5252, #d63031);
}

.episode-list-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1400;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.episode-list-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Remove old subtitle-menu styles and add new subtitle list styles */
.subtitle-list-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  padding: 16px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1500;
  max-height: 40vh;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.subtitle-list-container.show {
  transform: translateY(0);
}

.subtitle-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.subtitle-list-title {
  color: white;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.subtitle-list-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.subtitle-list-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.subtitle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0;
}

.subtitle-list-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1400;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.subtitle-list-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Update subtitle item styles to match episode items */
.subtitle-item {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 500;
}

.subtitle-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.subtitle-item.active {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  border-color: #ff6b6b;
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
  color: white;
}

.subtitle-item.active:hover {
  background: linear-gradient(135deg, #ff5252, #d63031);
}

.subtitle-check {
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: white;
  flex-shrink: 0;
}

.subtitle-item.active .subtitle-check {
  opacity: 1;
}

.control-btn.subtitle-active {
  background: rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
}

.xgplayer-progress-played {
  background: #ff6b6b !important;
}

/* Add mobile responsive styles */
@media screen and (max-width: 768px) {
  .subtitle-list-container {
    bottom: env(safe-area-inset-bottom, 0);
    padding: 20px max(20px, env(safe-area-inset-right, 20px))
      max(20px, env(safe-area-inset-bottom, 20px))
      max(20px, env(safe-area-inset-left, 20px));
  }
}
