*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.hidden { display: none !important; }

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "PingFang SC", "SF Pro Display", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#video {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}

.cover-layer {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: #000;
  overflow: hidden;
  transition: opacity 0.35s ease;
}

.cover-layer.hidden {
  opacity: 0;
  pointer-events: none;
}

.cover-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ad-layer {
  position: fixed;
  inset: 0;
  z-index: 19;
  pointer-events: none;
}

.corner-ad {
  position: absolute;
  display: grid;
  gap: 2px;
  max-width: min(38vw, 220px);
  padding: 8px 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-line;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.92);
}

.corner-top-left {
  top: calc(16px + env(safe-area-inset-top));
  left: calc(16px + env(safe-area-inset-left));
  text-align: left;
}

.corner-top-right {
  top: calc(16px + env(safe-area-inset-top));
  right: calc(68px + env(safe-area-inset-right));
  text-align: right;
}

.corner-bottom-left {
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: calc(16px + env(safe-area-inset-left));
}

.corner-bottom-right {
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: calc(16px + env(safe-area-inset-right));
  text-align: right;
}

/* ─── Loading Box ─── */
.loading-box {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  transition: opacity 0.35s;
}
.loading-box.hidden { opacity: 0; pointer-events: none; }

body.cover-active .loading-box {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  gap: 12px;
}

.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { color: rgba(255, 255, 255, 0.55); font-size: 13px; letter-spacing: 0.12em; }

body.cover-active .spinner {
  width: 34px;
  height: 34px;
  border-color: rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

body.cover-active .loading-text {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.72);
}

/* ─── UI Layer ─── */
.ui-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.4s;
}
.ui-layer.hidden { opacity: 0; }
.ui-layer.hidden .menu-btn { pointer-events: none; }
.ui-layer .menu-btn { pointer-events: auto; }

/* Info bar */
.info-bar {
  display: none !important;
}

.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #e53935; color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  padding: 3px 7px 3px 6px; border-radius: 4px;
  flex-shrink: 0;
}
.live-dot {
  width: 5px; height: 5px;
  background: #fff; border-radius: 50%;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.stream-name {
  color: #fff; font-size: 15px; font-weight: 600;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Menu button */
.menu-btn {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px;
  width: 38px; height: 38px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff; cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: background 0.2s, transform 0.2s;
}
.menu-btn svg { width: 18px; height: 18px; }
.menu-btn:active { background: rgba(255, 255, 255, 0.2); transform: scale(0.95); }

/* ─── Panel Overlay ─── */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 30;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.panel-overlay.visible { opacity: 1; pointer-events: auto; }

/* ─── Channel Panel ─── */
.channel-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(300px, 82vw);
  background: rgba(12, 12, 14, 0.96);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  z-index: 40;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.channel-panel.open { transform: translateX(0); }

.panel-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px;
  padding-top: calc(16px + env(safe-area-inset-top));
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.panel-title { color: #fff; font-size: 15px; font-weight: 600; }
.panel-close {
  width: 30px; height: 30px;
  background: rgba(255, 255, 255, 0.08); border: none;
  color: rgba(255, 255, 255, 0.7); cursor: pointer;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.panel-close:active { background: rgba(255, 255, 255, 0.18); }
.panel-close svg { width: 14px; height: 14px; }

.ch-list {
  flex: 1; overflow-y: auto; list-style: none;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}
.ch-list::-webkit-scrollbar { width: 3px; }
.ch-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

.ch-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; cursor: pointer;
  transition: background 0.15s, padding-left 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.ch-item:last-child { border-bottom: none; }
.ch-item:active, .ch-item:hover { background: rgba(255, 255, 255, 0.07); }
.ch-item.active { background: rgba(255, 255, 255, 0.08); border-left: 3px solid #3b82f6; padding-left: 13px; }

.ch-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.ch-info { flex: 1; min-width: 0; }
.ch-name { color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-desc { color: rgba(255,255,255,0.4); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-live-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: #4ade80; background: rgba(74, 222, 128, 0.12);
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid rgba(74, 222, 128, 0.28);
  flex-shrink: 0;
}

.ch-loading { padding: 24px 16px; color: rgba(255,255,255,0.35); font-size: 13px; text-align: center; }
.ch-empty { padding: 40px 16px; color: rgba(255,255,255,0.3); font-size: 13px; text-align: center; }

.support-widget {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 46;
  display: grid;
  justify-items: end;
  gap: 10px;
  pointer-events: none;
}

.support-toggle,
.support-panel {
  pointer-events: auto;
}

.support-toggle {
  position: relative;
  width: auto;
  min-width: 58px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(18, 18, 20, 0.42);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.support-badge {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}

.support-panel {
  width: min(320px, calc(100vw - 28px));
  height: min(430px, 62vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(12, 12, 14, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.support-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.support-head strong {
  display: block;
  color: #fff;
  font-size: 14px;
}

.support-head span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
}

.support-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  font-size: 20px;
}

.support-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.support-empty {
  margin: auto;
  color: rgba(255, 255, 255, 0.36);
  font-size: 13px;
}

.support-message {
  display: flex;
}

.support-message span {
  max-width: 84%;
  padding: 8px 10px;
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.support-message.from-visitor {
  justify-content: flex-end;
}

.support-message.from-visitor span {
  border-bottom-right-radius: 4px;
  background: #2563eb;
}

.support-message.from-admin {
  justify-content: flex-start;
}

.support-message.from-admin span {
  border-bottom-left-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.support-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.support-form input,
.support-form button {
  min-width: 0;
  height: 38px;
  border-radius: 12px;
  font: inherit;
}

.support-form input {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0 10px;
  outline: none;
}

.support-form button {
  border: 0;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 420px) {
  .corner-ad {
    max-width: min(42vw, 180px);
    padding: 7px 9px;
    font-size: 12px;
  }

  .corner-top-right {
    right: calc(64px + env(safe-area-inset-right));
  }

  .corner-bottom-left,
  .corner-bottom-right {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .support-panel {
    height: min(390px, 64vh);
  }
}
