:root {
  --bg: #000;
  --text: #e8edf5;
  --muted: #8b95a8;
  --accent: #3d8bfd;
  --danger: #ff5c5c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 背景层：仅加载中/未播放时显示；播放后隐藏，黑边不再透出背景 */
.pp-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #000 url("../../imgs/bg.jpg") center center / 100% 100% no-repeat;
}

body.is-playing .pp-bg {
  display: none;
}

/* 整页就是播放器（透明，露出底层背景） */
.page,
.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: transparent;
}

#player {
  width: 100%;
  height: 100%;
  background: transparent;
}

/* 普通进度条已播放颜色（后台可自定义） */
#player .art-progress-played {
  background-color: var(--pp-progress-color, var(--art-theme)) !important;
}

/* 迷你进度条颜色（控制栏隐藏时独立配色） */
#player .art-video-player.art-mini-progress-bar .art-progress-played {
  background-color: var(--pp-mini-progress-color, var(--pp-progress-color, var(--art-theme))) !important;
}

/* 遮罩保持透明，避免挡住视频；播放时已隐藏海报背景，空位自然是页面黑底 */
#player .art-video-player,
#player .art-mask,
#player .art-poster {
  background-color: transparent !important;
  background-image: none !important;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
}

.overlay.show {
  display: flex;
}

.ad-box {
  position: relative;
  width: min(920px, 94vw);
  max-height: min(86vh, 92dvh);
  text-align: center;
  /* 按可视区域等比容纳广告，横屏也能点到按钮 */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 自定义尺寸：以配置宽高为基准，视口内等比缩放（手机/横屏都适用） */
.ad-box.has-size {
  width: min(var(--ad-w, 920px), 94vw);
  max-width: 94vw;
  max-height: min(var(--ad-h, 86vh), 86vh, 92dvh);
  aspect-ratio: var(--ad-ratio, auto);
  height: auto;
}

.ad-media {
  line-height: 0;
  width: 100%;
  max-width: 100%;
  max-height: inherit;
}

.ad-link {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: inherit;
  line-height: 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.ad-box img,
.ad-box video {
  display: block;
  width: auto;
  height: auto;
  max-width: min(920px, 94vw);
  max-height: min(86vh, 92dvh);
  object-fit: contain;
  border-radius: 8px;
  cursor: pointer;
  background: #000;
}

.ad-box.has-size img,
.ad-box.has-size video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 暂停广告在移动端更贴合画面，避免横屏溢出点不到 */
#pauseAd .ad-box {
  width: min(960px, 96vw);
  max-height: min(92vh, 96dvh);
}

#pauseAd .ad-box.has-size {
  width: min(var(--ad-w, 960px), 96vw);
  max-width: 96vw;
  max-height: min(var(--ad-h, 92vh), 92vh, 96dvh);
}

#pauseAd .ad-box img,
#pauseAd .ad-box video {
  max-width: min(960px, 96vw);
  max-height: min(88vh, 92dvh);
}

#pauseAd .ad-box.has-size img,
#pauseAd .ad-box.has-size video {
  max-width: 100%;
  max-height: 100%;
}

.ad-timer {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.2;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.ad-timer[hidden] {
  display: none !important;
}

.ad-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  z-index: 2;
  margin: 0;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.ad-skip {
  pointer-events: auto;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  background: var(--accent);
}

.ad-skip[hidden] {
  display: none !important;
}

.ad-skip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (orientation: landscape) and (max-height: 500px) {
  .ad-box,
  #pauseAd .ad-box {
    width: min(960px, 98vw);
    max-height: 96vh;
  }

  .ad-box.has-size,
  #pauseAd .ad-box.has-size {
    width: min(var(--ad-w, 960px), 98vw);
    max-width: 98vw;
    max-height: min(var(--ad-h, 96vh), 96vh);
  }

  .ad-box img,
  .ad-box video,
  #pauseAd .ad-box img,
  #pauseAd .ad-box video {
    max-width: 98vw;
    max-height: 96vh;
  }

  .ad-box.has-size img,
  .ad-box.has-size video,
  #pauseAd .ad-box.has-size img,
  #pauseAd .ad-box.has-size video {
    max-width: 100%;
    max-height: 100%;
  }

  .ad-timer {
    top: 6px;
    right: 6px;
    padding: 4px 8px;
    font-size: 12px;
  }

  .ad-meta {
    bottom: 8px;
  }

  .ad-skip {
    padding: 6px 12px;
    font-size: 12px;
  }
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pp-tip-color, #ffffff);
  font-size: var(--pp-tip-size, 18px);
  padding: 24px;
  text-align: center;
  z-index: 5;
  background: transparent;
}

.empty.hide {
  display: none;
}

.empty.is-error {
  color: var(--pp-tip-color, #ffffff);
  font-size: var(--pp-tip-size, 18px);
}

.empty.is-loading {
  color: transparent;
}

.pp-loading {
  width: 138px;
  height: 138px;
  object-fit: contain;
  display: block;
}

/*
  暂停态图标位置（改这里即可）
  --pp-state-right  : 距离右边，越大越靠左
  --pp-state-bottom : 距离底部，越大越往上
  --pp-state-size   : 图标大小
*/
:root {
  --pp-state-right: 68px;
  --pp-state-bottom: 98px;
  --pp-state-size: 72px;
}

/* 只改位置，不要强制 display，否则暂停层可能一直盖住视频 */
#player .art-state {
  position: absolute !important;
  inset: auto var(--pp-state-right) var(--pp-state-bottom) auto !important;
  align-items: center;
  justify-content: center;
  transform: none !important;
  margin: 0 !important;
  pointer-events: auto;
  cursor: pointer;
}

#player .art-state .pp-state-icon,
#player .art-icon-state img,
#player .art-state img {
  width: var(--pp-state-size);
  height: var(--pp-state-size);
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* 隐藏官方默认右键项（双保险） */
#player .art-contextmenu-info,
#player .art-contextmenu-version,
#player .art-contextmenu-close {
  display: none !important;
}

/* 移动端：右侧中间「横屏全屏」按钮（左侧锁定为 ArtPlayer 内置） */
#player .art-layer-pp-rotate {
  position: absolute;
  top: 50%;
  right: var(--art-padding, 10px);
  left: auto;
  width: var(--art-lock-size, 36px);
  height: var(--art-lock-size, 36px);
  transform: translateY(-50%);
  display: none;
  z-index: 50;
  pointer-events: auto;
}

#player .art-video-player.art-control-show .art-layer-pp-rotate {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 锁定后隐藏横屏按钮，只保留左侧解锁 */
#player .art-video-player.art-lock .art-layer-pp-rotate {
  display: none !important;
}

#player .pp-rotate-btn {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--art-tip-background, rgba(0, 0, 0, 0.55));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#player .pp-rotate-btn svg {
  display: block;
  pointer-events: none;
}

/* —— 移动端控制栏防溢出 —— */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  /* 音量手势可调，隐藏占位按钮 */
  #player .art-control-volume {
    display: none !important;
  }

  #player .art-controls {
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 2px;
  }

  #player .art-controls .art-control {
    flex-shrink: 0;
  }

  /* 时间过长时压缩字号 */
  #player .art-control-time {
    font-size: 11px !important;
    letter-spacing: -0.02em;
    max-width: 7.5em;
    overflow: hidden;
    white-space: nowrap;
  }

  #player .art-controls-center {
    min-width: 0;
    overflow: hidden;
  }

  /*
    弹幕发射器：用 bottom 锚定在控制按钮上方（禁止 top:0，否则会跑到画面顶）。
    显隐跟随控制栏；设置面板向上展开需 overflow:visible + 足够 z-index。
  */
  #player .art-bottom.has-pp-danmu {
    overflow: visible !important;
  }

  #player .art-video-player.art-control-show .art-bottom.has-pp-danmu {
    /* 给发射器腾出一行，避免和进度条/按钮重叠点不到 */
    padding-top: 42px;
  }

  #player .pp-danmu-mount {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    /* 略上移；宽度缩短并居中 */
    top: auto !important;
    bottom: calc(var(--art-control-height, 44px) + var(--art-bottom-gap, 10px) + 14px) !important;
    z-index: 60;
    width: min(86vw, 360px);
    max-width: calc(100% - 48px);
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    min-height: 34px;
    overflow: visible !important;
    pointer-events: auto;
  }

  #player .art-video-player.art-control-show .pp-danmu-mount,
  #player .pp-danmu-mount.is-show {
    display: flex;
  }

  #player .art-video-player.art-lock .pp-danmu-mount,
  #player .art-video-player.art-mini-progress-bar:not(.art-control-show) .pp-danmu-mount {
    display: none !important;
  }

  #player .pp-danmu-mount .artplayer-plugin-danmuku {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 1;
    min-width: 0;
    display: flex !important;
    align-items: center;
    gap: 6px;
    z-index: 1;
    pointer-events: auto !important;
    overflow: visible !important;
  }

  #player .pp-danmu-mount .apd-toggle,
  #player .pp-danmu-mount .apd-config,
  #player .pp-danmu-mount .apd-style,
  #player .pp-danmu-mount .apd-send {
    flex-shrink: 0;
    position: relative;
    z-index: 3;
    pointer-events: auto !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  #player .pp-danmu-mount .apd-emitter {
    position: relative !important;
    width: auto !important;
    max-width: none !important;
    flex: 1 1 auto;
    min-width: 0;
    pointer-events: auto !important;
    overflow: visible !important;
  }

  #player .pp-danmu-mount .apd-input {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    font-size: 12px !important;
    pointer-events: auto !important;
  }

  #player .pp-danmu-mount .apd-send {
    padding: 0 10px !important;
    font-size: 12px !important;
  }

  /* 弹幕设置 / 文字设置面板（点得开、不被挡） */
  #player .pp-danmu-mount .apd-config,
  #player .pp-danmu-mount .apd-style {
    overflow: visible !important;
  }

  #player .pp-danmu-mount .apd-config-panel,
  #player .pp-danmu-mount .apd-style-panel {
    z-index: 90 !important;
    overflow: visible !important;
  }

  /*
    插件默认用 :hover 显隐面板，移动端再次点击关不掉。
    用 .pp-panel-open 做点击切换。
  */
  #player .pp-danmu-mount .apd-config.pp-panel-open .apd-config-panel,
  #player .pp-danmu-mount .apd-style.pp-panel-open .apd-style-panel {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  #player .pp-danmu-mount .apd-config:not(.pp-panel-open) .apd-config-panel,
  #player .pp-danmu-mount .apd-style:not(.pp-panel-open) .apd-style-panel {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* 右键菜单样式 */
#player .art-contextmenus {
  min-width: 320px;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(28, 28, 28, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#player .art-contextmenu {
  padding: 0 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#player .art-contextmenu:last-child {
  border-bottom: 0;
}

.pp-cm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #eee;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
}

.pp-cm-action {
  cursor: pointer;
}

.pp-cm-label {
  color: #ddd;
  flex-shrink: 0;
}

.pp-cm-opts {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.pp-cm-opts i {
  font-style: normal;
  cursor: pointer;
  color: #eee;
  user-select: none;
}

.pp-cm-opts i:hover {
  color: #fff;
}

.pp-cm-opts i.is-on {
  color: #ff4d4f;
  font-weight: 600;
}

/* 自定义秒数弹窗 */
.pp-modal[hidden] {
  display: none !important;
}

.pp-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pp-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.pp-modal-card {
  position: relative;
  z-index: 1;
  width: min(360px, calc(100vw - 32px));
  padding: 20px 18px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c222c, #141920);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  color: #e8edf5;
}

.pp-modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.pp-modal-body {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.pp-modal-body input {
  flex: 1;
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0d1218;
  color: #fff;
  padding: 0 12px;
  font-size: 16px;
  outline: none;
}

.pp-modal-body input:focus {
  border-color: rgba(61, 139, 253, 0.8);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.2);
}

.pp-modal-unit {
  color: #9aa6b8;
  font-size: 14px;
}

.pp-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.pp-btn {
  border: 0;
  border-radius: 8px;
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
  cursor: pointer;
}

.pp-btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #e8edf5;
}

.pp-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.pp-btn.primary {
  background: #3d8bfd;
  color: #fff;
}

.pp-btn.primary:hover {
  background: #2f6fd1;
}
