/* 直播画面监看墙：网格铺满所有在播直播间，点击后单路独占并开启声音。 */

.live-screens { padding: 30px; }

.screens-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.screens-header h2 { margin: 0; font-size: clamp(22px, 2.4vw, 30px); letter-spacing: -.02em; }
.screens-header h2 em { font-style: normal; color: var(--cyan); margin-left: 12px; font-size: 14px; letter-spacing: 0; font-weight: 500; }
.screens-hint { margin: 12px 0 0; max-width: 760px; color: var(--muted); font-size: 12.5px; line-height: 1.9; }
.screens-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.screens-status-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 20px 0 16px; font-size: 12px; color: var(--muted); }
.screens-status-row #screensStatus { display: inline-flex; align-items: center; gap: 8px; }
.screens-status-row #screensStatus i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.screens-status-row #screensStatus[data-state=active] { color: var(--cyan); }
.screens-status-row #screensStatus[data-state=active] i { background: var(--cyan); box-shadow: 0 0 0 3px rgba(53, 231, 206, .18); }
.screens-status-row #screensStatus[data-state=loading] i { background: var(--amber); animation: screens-pulse 1.1s ease-in-out infinite; }
.screens-status-row #screensStatus[data-state=error] { color: #c65a6e; }
.screens-status-row #screensStatus[data-state=error] i { background: #c65a6e; }

@keyframes screens-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* 抖音直播源为竖屏，监看墙卡片固定 9:16 */
.screens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(198px, 1fr)); gap: 14px; }

.screen-card {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #05080d;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease;
}
.screen-card:hover { border-color: var(--cyan); transform: translateY(-1px); }
.screen-card video { display: block; width: 100%; height: 100%; object-fit: contain; background: #05080d; }

.screen-card-bar {
  position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; gap: 10px;
  padding: 26px 12px 10px; font-size: 12px;
  background: linear-gradient(transparent, rgba(4, 8, 14, .88));
}
.screen-card-bar strong { color: #f4f8fc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-card-bar span { color: #b9c6d6; white-space: nowrap; }

.screen-card-badge {
  position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; background: rgba(220, 60, 84, .92); color: #fff;
  font: 10px/1.5 ui-monospace, monospace; letter-spacing: .12em;
}
.screen-card-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #fff; }

.screen-card-expand {
  position: absolute; top: 8px; right: 8px; padding: 6px 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(6, 11, 18, .72); color: #eaf3fb; font-size: 12px;
  opacity: 0; transition: opacity .16s ease;
}
.screen-card:hover .screen-card-expand { opacity: 1; }
.screen-card-expand:hover { background: rgba(9, 18, 28, .92); }

/* 画面状态提示：黑屏不再只是黑屏，直接说明是在重连还是已中断，并给重试入口。 */
.screen-hint {
  position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 18px;
  background: radial-gradient(circle at 50% 42%, rgba(23, 37, 51, .9), rgba(4, 7, 12, .96));
  color: #cbd8e6; font-size: 12px; line-height: 1.8; text-align: center;
  pointer-events: none;
}
.screen-hint[hidden] { display: none; }
.screen-hint-text { display: block; max-width: 100%; }
.screen-hint-retry {
  pointer-events: auto; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(120, 200, 230, .42); background: rgba(16, 34, 48, .88);
  color: #d9ecf7; font-size: 12px;
}
.screen-hint-retry:hover { background: rgba(22, 46, 64, .95); color: #fff; }
/* 自动重连中不需要用户点按钮，给一个呼吸的指示点即可 */
.screen-hint[data-tone="connecting"] .screen-hint-retry { display: none; }
.screen-hint[data-tone="connecting"] .screen-hint-text::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px;
  border-radius: 50%; background: var(--cyan); vertical-align: middle;
  animation: screens-pulse 1.1s ease-in-out infinite;
}
.screen-card[data-screen-state="error"] .screen-card-badge,
.screen-card[data-screen-state="connecting"] .screen-card-badge { opacity: .5; }

/* 弹幕叠加层：飘在画面上方，不响应鼠标；文字带描边保证亮暗画面都可读。 */
.screen-danmaku {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 3;
}
.screen-danmaku span {
  position: absolute; left: 100%; white-space: nowrap; will-change: transform;
  color: #fff; font-weight: 600; line-height: 1.55; text-shadow:
    -1px -1px 0 rgba(0, 0, 0, .85), 1px -1px 0 rgba(0, 0, 0, .85),
    -1px 1px 0 rgba(0, 0, 0, .85), 1px 1px 0 rgba(0, 0, 0, .85), 0 0 6px rgba(0, 0, 0, .6);
  animation: screen-danmaku-roll 8s linear forwards;
}
@keyframes screen-danmaku-roll {
  from { transform: translateX(0); }
  to { transform: translateX(var(--dist, -120%)); }
}

.screens-empty {
  padding: 46px 20px; border: 1px dashed var(--line); border-radius: 14px; text-align: center;
  color: var(--muted); font-size: 13px; line-height: 2;
}

/* 单路独占：竖屏视频居中占满可用高度，两侧留黑。 */
.screens-focus { position: fixed; inset: 0; z-index: 220; display: flex; flex-direction: column; background: #04070c; }
.screens-focus-bar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  border-bottom: 1px solid rgba(173, 198, 224, .16); background: #0a1017;
}
.screens-focus-bar button {
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 13px;
  border: 1px solid rgba(173, 198, 224, .26); background: #131b25; color: #dfe9f3;
}
.screens-focus-bar button:hover { background: #1b2531; color: #fff; }
.screens-focus-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.screens-focus-title strong { color: #f4f8fc; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screens-focus-title span { color: #93a3b5; font-size: 12px; white-space: nowrap; }
#screensFocusRetry { margin-left: auto; }

.screens-focus-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 12px; }
.screens-focus-stage video { max-width: 100%; max-height: 100%; width: auto; height: 100%; object-fit: contain; aspect-ratio: 9 / 16; background: #04070c; }
/* 独占画面时弹幕层与视频等宽对齐（视频 9:16 居中，弹幕只盖在视频上） */
.screens-focus-stage .screen-danmaku {
  inset: auto; width: min(100%, calc((100vh - 120px) * 9 / 16)); aspect-ratio: 9 / 16;
}

body.screens-focus-open { overflow: hidden; }

@media (max-width: 900px) {
  .live-screens { padding: 18px; }
  .screens-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .screens-header { align-items: flex-start; }
  .screens-focus-title span { display: none; }
}

@media print {
  .live-screens { display: none !important; }
}
