.detail-trailer { margin-bottom: 20px; padding: 12px; border: 1px solid #344155; border-radius: 14px; background: #111827; }
.detail-trailer-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.detail-trailer button { min-height: 44px; padding: 8px 12px; background: #253149; color: white; border-radius: 8px; border: 0; }
#detailTrailerStatus { color: #b7c3d5; font-size: 14px; margin: 10px 0; }
#detailTrailerMedia iframe, #detailTrailerMedia video { display: block; width: 100%; aspect-ratio: 16/9; border: 0; background: black; }
#detailTrailerMedia a { display: block; padding: 12px 0; color: #9dd8ff; }
/* One player layout for browser and Capacitor. The iPhone orientation is changed
   by the native plugin; CSS never rotates the video surface. */
.player-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90000;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: #000;
  overscroll-behavior: none;
  user-select: none;
}

.cinema-player-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: #000;
  --subtitle-safe-area: clamp(52px, 8vh, 74px);
}

.player-modal-overlay.cinema-fullscreen,
.cinema-player-wrapper.cinema-fullscreen {
  background: #000;
}

.video-element {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  background: #000;
  object-fit: contain;
  object-position: center center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cinema-player-wrapper.aspect-cover .video-element {
  height: 100%;
  margin: 0;
  object-fit: cover;
}

.cinema-player-wrapper.aspect-contain .video-element {
  object-fit: contain;
}

.movie-copyright-watermark {
  position: absolute;
  z-index: 28;
  top: max(14px, calc(env(safe-area-inset-top) + 8px));
  right: max(18px, calc(env(safe-area-inset-right) + 12px));
  max-width: min(24vw, 120px);
  overflow: hidden;
  color: rgba(255, 255, 255, .42);
  font-family: "Chalkboard SE", "Marker Felt", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  font-size: clamp(9px, 1.05vw, 14px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: .015em;
  text-align: right;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .72);
  white-space: nowrap;
  opacity: .66;
  transform: rotate(-1.5deg);
  transform-origin: right top;
  pointer-events: none;
  user-select: none;
}

@media (orientation: portrait) {
  .cinema-player-wrapper:not(.cinema-fullscreen) .movie-copyright-watermark {
    top: max(70px, calc(env(safe-area-inset-top) + 62px));
    font-size: clamp(9px, 2.35vw, 12px);
  }
}

.platform-android .video-element {
  touch-action: manipulation;
  transform: translateZ(0);
}
.platform-android .cinema-player-wrapper,
.platform-android .player-controls,
.platform-android .player-top-bar {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Portrait playback is a real video stage, not a full-height box that leaves
   the picture stranded in the middle of a black screen. */
@media (orientation: portrait) {
  .cinema-player-wrapper:not(.cinema-fullscreen) .video-element {
    position: absolute;
    top: max(62px, calc(env(safe-area-inset-top) + 54px));
    right: 0;
    left: 0;
    width: 100%;
    height: min(56.25vw, calc(100dvh - 224px));
    margin: 0;
    object-position: center top;
  }

  .player-modal-overlay .cinema-player-wrapper.aspect-contain:not(.cinema-fullscreen):not(.inactive) .video-element {
    height: min(56.25vw, calc(100dvh - 224px));
    margin-bottom: 0;
  }
}

/* While controls are visible, create a small real safe strip below the video.
   This protects native captions without wasting the former 12vh black band. */
.cinema-player-wrapper.aspect-contain:not(.inactive) .video-element {
  height: calc(100% - var(--subtitle-safe-area));
  margin-bottom: var(--subtitle-safe-area);
}

/* Only controls respect safe-area insets; the picture reaches every edge. */
.player-modal-overlay.cinema-fullscreen {
  inset: auto;
  top: var(--player-viewport-top, 0);
  left: var(--player-viewport-left, 0);
  width: var(--player-viewport-width, 100%);
  height: var(--player-viewport-height, 100%);
  padding: 0;
  border-radius: 0;
}
.cinema-player-wrapper.cinema-fullscreen {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  min-height: 0;
}
.player-center-toggle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 36;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.player-center-toggle svg { width: 32px; height: 32px; pointer-events: none; }
.cinema-player-wrapper.inactive .player-center-toggle { opacity: 0; }
.cinema-player-wrapper .player-center-toggle:focus-visible { opacity: 1; outline: 2px solid #facc15; }
@media (orientation: portrait) {
  .cinema-player-wrapper:not(.cinema-fullscreen) .player-center-toggle {
    top: calc(max(62px, calc(env(safe-area-inset-top) + 54px)) + min(28.125vw, calc((100dvh - 224px) / 2)));
  }
}

video::cue {
  color: #fff !important;
  background: rgba(0, 0, 0, .78) !important;
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: clamp(15px, 2.2vw, 27px) !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  text-shadow: 0 2px 4px #000 !important;
}

.player-buffering {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  background: rgba(0, 0, 0, .54);
  pointer-events: none;
}

.player-alert {
  position: absolute;
  z-index: 60;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  max-width: min(88vw, 620px);
  transform: translateX(-50%);
  padding: 9px 15px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  color: #fff;
  background: rgba(17, 24, 39, .94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.player-top-bar {
  position: absolute;
  z-index: 30;
  top: 0;
  right: 0;
  left: 0;
  min-height: 62px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(0, 1.5fr) minmax(110px, 1fr);
  align-items: center;
  gap: 10px;
  padding: max(9px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 9px max(14px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(0, 0, 0, .88), transparent);
  transition: opacity .22s ease;
}

.btn-back,
.btn-close-player,
.ctrl-btn,
.ctrl-btn-text,
.btn-player-server {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
}
.btn-back svg { width: 20px; height: 20px; }
.btn-back:hover, .btn-back:focus-visible { background: rgba(255, 255, 255, .15); }

.player-title-info {
  min-width: 0;
  color: #fff;
  text-align: center;
}
.player-title-info h3 {
  overflow: hidden;
  margin: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-title-info span { color: #f5c451; font-size: 12px; font-weight: 700; }

.player-top-actions {
  justify-self: end;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.badge-real-res,
.player-noads-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  box-sizing: border-box;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .25px;
  white-space: nowrap;
}
.badge-real-res.res-4k { color: #fbbf24; border-color: rgba(251, 191, 36, .72); background: rgba(217, 119, 6, .26); }
.badge-real-res.res-2k { color: #67e8f9; border-color: rgba(103, 232, 249, .68); background: rgba(8, 145, 178, .25); }
.badge-real-res.res-fhd { color: #6ee7b7; border-color: rgba(110, 231, 183, .68); background: rgba(5, 150, 105, .25); }
.badge-real-res.res-hd { color: #bfdbfe; border-color: rgba(147, 197, 253, .62); background: rgba(37, 99, 235, .24); }
.badge-real-res.res-auto { color: #c4b5fd; border-color: rgba(196, 181, 253, .62); background: rgba(109, 40, 217, .28); }
.player-noads-pill { color: #86efac; border-color: rgba(74, 222, 128, .45); background: rgba(22, 163, 74, .18); }

.btn-close-player {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  font-size: 20px;
  line-height: 1;
}
.btn-close-player:hover, .btn-close-player:focus-visible { background: rgba(255, 255, 255, .23); }

.player-controls {
  position: absolute;
  z-index: 35;
  right: 0;
  bottom: 0;
  left: 0;
  box-sizing: border-box;
  padding: 0 max(16px, env(safe-area-inset-right)) max(11px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(0deg, rgba(0, 0, 0, .92) 0%, rgba(0, 0, 0, .54) 64%, transparent 100%);
  transition: opacity .22s ease;
}
.cinema-player-wrapper.inactive .player-top-bar,
.cinema-player-wrapper.inactive .player-controls { opacity: 0; pointer-events: none; }

.progress-bar-container {
  position: relative;
  height: 8px;
  margin: 0 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .28);
  cursor: pointer;
}
.progress-buffer,
.progress-current {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}
.progress-buffer { width: 0; background: rgba(255, 255, 255, .4); }
.progress-current { width: 0; background: #e50914; }
.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .65);
  transform: translate(-50%, -50%) scale(0);
  transition: transform .15s ease;
  pointer-events: none;
}
.progress-bar-container:hover .progress-thumb { transform: translate(-50%, -50%) scale(1); }
.progress-hover-time {
  position: absolute;
  bottom: 16px;
  left: 0;
  display: none;
  padding: 3px 6px;
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, .86);
  font-size: 11px;
  font-weight: 700;
  transform: translateX(-50%);
  pointer-events: none;
}
.progress-bar-container:hover .progress-hover-time { display: block; }

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.controls-left, .controls-right { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ctrl-btn {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
}
.ctrl-btn svg { width: 22px; height: 22px; }
.ctrl-btn:hover, .ctrl-btn:focus-visible, .ctrl-btn.active { background: rgba(255, 255, 255, .18); }
.ctrl-btn-text,
.btn-player-server {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.ctrl-btn-text:hover, .btn-player-server:hover { background: rgba(255, 255, 255, .23); }
.ctrl-btn-text.active { color: #111827; background: #facc15; }
.ctrl-btn-text.quality-auto:disabled {
  color: #ddd6fe;
  border-color: rgba(196, 181, 253, .5);
  background: rgba(109, 40, 217, .26);
  cursor: default;
  opacity: 1;
}
.aspect-mode-control { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; background: rgba(0,0,0,.3); }
.aspect-mode-control .ctrl-btn-text { border: 0; background: transparent; }
.aspect-mode-control .ctrl-btn-text.active { color: #111827; background: #facc15; }
.volume-container { display: flex; align-items: center; gap: 2px; }
.volume-slider { width: 72px; accent-color: #e50914; }
.time-display { display: block; margin: 0 0 6px; color: #e5e7eb; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.dropdown-control { position: relative; }
.ctrl-dropdown {
  position: absolute;
  z-index: 100;
  right: 0;
  bottom: calc(100% + 9px);
  display: flex;
  min-width: 146px;
  max-height: min(260px, 54vh);
  padding: 6px;
  overflow-y: auto;
  flex-direction: column;
  gap: 3px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  background: rgba(17, 24, 39, .97);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
}
.player-server-menu { top: calc(100% + 9px); bottom: auto; }
.ctrl-dropdown button {
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  color: #e5e7eb;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}
.ctrl-dropdown button:hover, .ctrl-dropdown button.active { color: #fff; background: #d71920; }
.ctrl-dropdown button:disabled,
.ctrl-dropdown .quality-note { color: #9ca3af; cursor: default; }
.ctrl-dropdown button:disabled:hover,
.ctrl-dropdown .quality-note:hover { color: #9ca3af; background: transparent; }

@media (max-width: 760px) {
  .player-top-bar { grid-template-columns: 44px 1fr auto; min-height: 54px; padding-top: max(8px, env(safe-area-inset-top)); }
  .btn-back { width: 40px; min-width: 40px; padding: 8px; font-size: 0; }
  .btn-back svg { width: 22px; height: 22px; }
  .player-title-info h3 { font-size: 14px; }
  .player-title-info span, .player-noads-pill { display: none; }
  .badge-real-res { max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
  .btn-player-server { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
  .controls-row { gap: 4px; }
  .controls-left, .controls-right { gap: 2px; }
  .ctrl-btn { width: 38px; height: 38px; }
  .volume-slider { display: none; }
  .ctrl-btn-text, .btn-player-server { min-height: 32px; font-size: 11px; }
  .aspect-mode-control .ctrl-btn-text { padding-inline: 7px; }
}

@media (max-width: 560px) and (orientation: portrait) {
  .controls-row { flex-wrap: wrap; row-gap: 8px; }
  .controls-left, .controls-right { width: 100%; justify-content: space-between; }
  .controls-right .ctrl-btn-text { padding-inline: 8px; }
  .cinema-player-wrapper { --subtitle-safe-area: 108px; }
}

@media (orientation: landscape) and (max-height: 540px) {
  .cinema-player-wrapper { --subtitle-safe-area: 52px; }
  .player-top-bar { min-height: 46px; padding-top: max(5px, env(safe-area-inset-top)); padding-bottom: 5px; }
  .player-title-info, .player-noads-pill { display: none; }
  .player-top-bar { grid-template-columns: 48px 1fr auto; }
  .btn-back { font-size: 0; min-height: 34px; }
  .player-controls { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .progress-bar-container { margin-bottom: 5px; }
  .ctrl-btn { width: 34px; height: 34px; }
  .ctrl-btn svg { width: 20px; height: 20px; }
  .ctrl-btn-text { min-height: 30px; padding: 4px 8px; }
  .aspect-mode-control .ctrl-btn-text { padding-inline: 6px; }
  .volume-slider { display: none; }
}
