/* 夜场直播间：炭黑舞台 + 电光钴蓝 */
:root {
  --bg: #07080c;
  --ink: #f3f6fb;
  --muted: rgba(243, 246, 251, 0.7);
  --accent: #1E6FE8;
  --accent-ink: #f7fbff;
  --accent-dim: rgba(30, 111, 232, 0.42);
  --mint: #7AADFF;
  --rose: #ff5c7a;
  --panel: rgba(10, 14, 22, 0.58);
  --stroke: rgba(255, 255, 255, 0.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --composer-h: 64px;
}

* { box-sizing: border-box; }

button, a, input, textarea {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  min-height: 100%;
  min-height: 100dvh;
  max-width: 100%;
  position: fixed;
  inset: 0;
  background: #000;
  color: var(--ink);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.stage {
  --vx: 0px;
  --vy: 0px;
  --vw: 100%;
  --vh: 100%;
  --kbd: 0px;
  --top-h: 52px;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

.video-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
  z-index: 0;
}

body.is-sound-off .video-clip {
  filter: blur(42px) brightness(0.88) saturate(1.05);
  -webkit-filter: blur(42px) brightness(0.88) saturate(1.05);
  transform: scale(1.22);
  transform-origin: center center;
}

body:not(.is-sound-off) .video-clip {
  filter: none !important;
  -webkit-filter: none !important;
  transform: none !important;
}

#video,
.live-poster,
.live-canvas,
.media-hit {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#video,
.live-poster {
  top: 0;
  left: 50%;
  width: auto;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  transform: translateX(-50%);
  object-fit: cover !important;
  object-position: center top !important;
  background: #000;
}

#video {
  z-index: 0;
  opacity: 0;
}
#video.ready { opacity: 1; }

#video::-webkit-media-controls,
#video::-webkit-media-controls-enclosure,
#video::-webkit-media-controls-start-playback-button,
#video::-webkit-media-controls-overlay-play-button,
#video::-internal-media-controls-overlay-cast-button {
  display: none !important;
  -webkit-appearance: none;
}

.live-canvas {
  z-index: 1;
  pointer-events: none;
  background: transparent;
}

.live-canvas:not(.on) {
  display: none;
}

.live-poster {
  z-index: 2;
  pointer-events: none;
}

.media-veil {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #07080c;
  pointer-events: none;
}

.media-veil[hidden] { display: none !important; }

.media-hit {
  z-index: 3;
  background: transparent;
}
.media-hit[hidden] { display: none !important; }

.danmaku-layer {
  position: absolute;
  top: var(--vy);
  left: var(--vx);
  width: var(--vw);
  height: var(--vh);
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) 0 calc(8px + var(--safe-l));
  pointer-events: none;
}

.anchor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  width: max-content;
  max-width: calc(100% - 168px);
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  pointer-events: auto;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #10192a, #1E6FE8);
  color: #f7fbff;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  font-size: 13px;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.has-img span { display: none; }

.anchor-meta {
  min-width: 0;
  overflow: hidden;
}

.anchor-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

.anchor-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
  flex-shrink: 0;
  margin-left: 0;
  gap: 5px;
  pointer-events: auto;
}

.notice-bar {
  position: absolute;
  left: calc(12px + var(--safe-l));
  width: calc(100% - 24px - var(--safe-l) - var(--safe-r));
  top: calc(var(--top-h, 52px) + 6px);
  z-index: 6;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--accent-dim);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  white-space: pre-wrap;
}

.notice-bar[hidden],
.pinned-bar[hidden] {
  display: none !important;
}

.chat-stack {
  position: absolute;
  left: calc(12px + var(--safe-l));
  width: calc(100% - 100px - var(--safe-l) - var(--safe-r));
  bottom: calc(var(--composer-h) + 8px);
  z-index: 5;
  max-height: max(72px, min(240px, calc(var(--vh) - var(--top-h, 52px) - var(--composer-h) - 16px)));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
}

.pinned-bar {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(16, 24, 40, 0.72);
  border: 1px solid var(--accent-dim);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
}

.pinned-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
}

.chat-rail {
  position: relative;
  z-index: 5;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: none;
  contain: layout paint;
}

.live-badge {
  flex-shrink: 0;
  font-family: ui-sans-serif, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(80, 80, 80, 0.65);
  color: #ddd;
}

.live-badge.on {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.stat {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 3px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.stat b {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 1.6em;
  text-align: right;
}

.stat:nth-child(2) { color: var(--mint); }
.stat:nth-child(2) b { color: var(--mint); }
.stat:nth-child(3) { color: var(--rose); }
.stat:nth-child(3) b { color: var(--rose); }

.wx-gate-qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 0 auto 12px;
  padding: 8px;
  background: #fff;
  border-radius: 12px;
}

.wx-gate-qr[hidden] { display: none !important; }

.chat-item {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  align-self: flex-start;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.42);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
  content-visibility: auto;
}

.chat-face {
  width: 18px;
  height: 18px;
  margin: 1px 6px 0 0;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-item .nick {
  color: #8eb8ff;
  font-weight: 500;
  margin-right: 6px;
}

.chat-item.sys .nick { color: var(--accent); }

.chat-item.admin .nick {
  color: #c5d8f5;
  font-weight: 700;
}

.chat-item.admin .nick::after {
  content: "管";
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  color: #fff;
  background: #eb0400;
}

.composer {
  position: absolute;
  left: 0;
  width: 100%;
  bottom: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  touch-action: manipulation;
}

.comment-form {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 0;
}

#commentInput {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(20, 22, 28, 0.82);
  color: var(--ink);
  font-size: 16px;
  outline: none;
}

#commentInput:focus-visible {
  border-color: rgba(30, 111, 232, 0.85);
  box-shadow: 0 0 0 3px rgba(30, 111, 232, 0.22);
}

#commentInput::placeholder { color: rgba(243, 246, 251, 0.4); }

.btn-send,
.btn-like {
  flex-shrink: 0;
  height: 44px;
  border: none;
  cursor: pointer;
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
}

.btn-send {
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
}

.btn-send:hover { filter: brightness(1.06); }
.btn-send:active { filter: brightness(0.96); }
.btn-send:focus-visible,
.btn-like:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-like {
  width: 44px;
  border-radius: 50%;
  background: rgba(255, 92, 122, 0.2);
  border: 1px solid rgba(255, 92, 122, 0.45);
  color: var(--rose);
  display: grid;
  place-items: center;
  overflow: hidden;
  contain: layout paint;
  touch-action: manipulation;
}

.btn-like svg {
  transform: translateZ(0);
  pointer-events: none;
}

.btn-like:hover { background: rgba(255, 92, 122, 0.32); }
.btn-like:active { background: rgba(255, 92, 122, 0.4); }
.btn-like.pop svg { animation: like-pop 0.22s ease; }

@keyframes like-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.hearts {
  position: absolute;
  right: calc(10px + var(--safe-r));
  left: auto;
  bottom: calc(var(--composer-h) + 8px);
  width: 48px;
  height: min(220px, calc(var(--vh) * 0.36));
  z-index: 6;
  pointer-events: none;
  overflow: hidden;
}

.heart {
  position: absolute;
  bottom: 0;
  right: 8px;
  font-size: 22px;
  animation: float-heart 1.6s ease-out forwards;
  opacity: 0.95;
}

@keyframes float-heart {
  0% { transform: translate3d(0, 0, 0) scale(0.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate3d(var(--dx, -12px), -180px, 0) scale(1.1); opacity: 0; }
}

.unmute {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 8;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 22px 12px 16px;
  border: 1px solid rgba(126, 176, 255, 0.45);
  border-radius: 18px;
  background: rgba(8, 12, 20, 0.88);
  color: #f7fbff;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  animation: unmute-pulse 1.6s ease-in-out infinite;
}

.unmute[hidden] { display: none !important; }

.unmute-ico {
  flex-shrink: 0;
  display: block;
  color: #7EB6FF;
}

.unmute-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}

.unmute-text b {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.unmute-text i {
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: rgba(247, 251, 255, 0.72);
}

.unmute:hover { background: rgba(12, 18, 30, 0.94); }
.unmute:active { background: rgba(16, 22, 36, 0.96); }
.unmute:focus-visible {
  outline: 2px solid #7EB6FF;
  outline-offset: 3px;
}

@keyframes unmute-pulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55); }
  50% { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.68); }
}

.wx-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px calc(12px + var(--safe-b));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.22) 42%, transparent 72%);
  pointer-events: none;
}

.wx-gate[hidden] { display: none !important; }

.wx-gate-card {
  width: min(100%, 360px);
  padding: 16px 16px 10px;
  border-radius: 16px;
  background: #14161c;
  border: 1px solid var(--stroke);
  color: var(--ink);
  pointer-events: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.wx-gate-card p {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
}

.wx-gate-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  text-align: center;
  text-decoration: none;
  color: var(--accent-ink);
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  line-height: 44px;
  border-radius: 999px;
  cursor: pointer;
}

.wx-gate-btn.wx-gate-open {
  background: #07c160;
  color: #fff;
  font-size: 17px;
  line-height: 48px;
}

.wx-gate-btn[hidden] { display: none !important; }

.wx-gate-wait {
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--accent);
}

.wx-gate-wait[hidden] { display: none !important; }

.wx-gate-skip {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 40px;
  cursor: pointer;
}

.wx-gate-skip[hidden] { display: none !important; }

.wx-auth-chip {
  position: absolute;
  left: calc(12px + var(--safe-l));
  bottom: calc(var(--composer-h) + 10px);
  z-index: 7;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.wx-auth-chip[hidden] { display: none !important; }

body.has-wx-gate .unmute { display: none !important; }

@media (max-width: 360px) {
  .stat { padding: 3px 5px; font-size: 11px; }
  .live-badge { padding: 3px 5px; }
  .btn-send { padding: 0 12px; }
}

@media (max-height: 620px) {
  .chat-stack { max-height: max(64px, min(160px, calc(var(--vh) - var(--top-h, 52px) - var(--composer-h) - 12px))); }
  .hearts { height: min(140px, calc(var(--vh) * 0.28)); }
  .unmute { padding: 10px 16px 10px 12px; gap: 10px; }
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  html, body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #050507;
  }
  .stage {
    position: relative;
    inset: auto;
    width: min(420px, 100vw - 24px, calc((100svh - 24px) * 9 / 16));
    height: min(100svh - 24px, calc((100vw - 24px) * 16 / 9));
    max-height: calc(100svh - 24px);
    aspect-ratio: 9 / 16;
    margin: 0;
    border: 1px solid #1a1a1a;
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-like.pop, .heart, .unmute { animation: none; }
}
