/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #000;
  color: #333;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}
button, a, .online-badge, .live-badge, .stream-info, .overlay-right, .emoji-item, .system-msg, .chat-msg, .msg-bubble, .msg-username, .msg-content, .emoji-cat, #stream-name, #connection-status {
  -webkit-user-select: none;
  user-select: none;
}

/* ============ Mobile: full-screen video + floating overlay ============ */
.layout {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Video: full screen ---------- */
.video-area {
  position: absolute;
  inset: 0;
  background: #000;
}

.video-container {
  width: 100%;
  height: 100%;
}

#video-player {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* Mute overlay */
.mute-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  cursor: pointer;
  z-index: 1;
}
.mute-overlay span { font-size: 18px; font-weight: 600; }
.mute-overlay small { font-size: 12px; opacity: 0.6; }

/* Top overlay */
.video-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent);
  font-size: 13px;
  color: #fff;
  z-index: 2;
}

.stream-info { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
#stream-name { font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }

.overlay-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
.overlay-right > * { pointer-events: auto; }

#fs-btn, #mute-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#fs-btn svg, #mute-btn svg { pointer-events: none; }

#mute-btn .mute-x { display: block; }
#fs-btn:active { background: rgba(255,255,255,0.3); }

.vol-slider {
  display: none;
  width: 60px;
  height: 4px;
  accent-color: #07c160;
  cursor: pointer;
}
@media (min-width: 768px) {
  .vol-slider { display: block; }
}

.live-badge {
  background: #e74c3c;
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  animation: pulse 1.5s ease-in-out infinite;
}

.online-badge {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.online-badge:hover { background: rgba(255,255,255,0.15); }
.online-badge::after { content: ' online'; font-weight: 400; opacity: 0.7; }

/* User dropdown */
.stream-info { position: relative; }

.user-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  min-width: 120px;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(20,20,20,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 10;
}

.user-item {
  padding: 7px 14px;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
}
.user-item:hover { background: rgba(255,255,255,0.1); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#connection-status { font-size: 12px; color: #ffc107; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }

/* ---------- Chat overlay ---------- */
.chat-area {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 3;
  pointer-events: none;       /* let taps pass through empty areas */
}

/* Messages: transparent bg, scrollable */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
  max-height: 35vh;
  touch-action: pan-y;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 10%);
}

.chat-messages::-webkit-scrollbar { display: none; }

.new-msg-badge {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(7,193,96,0.9);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  white-space: nowrap;
  animation: fadeUp 0.3s ease;
}
@keyframes fadeUp { from { opacity:0; transform:translateX(-50%) translateY(8px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

.system-msg {
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 4px 10px;
  margin: 4px auto;
  display: inline-block;
  max-width: 90%;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.sys-name {
  color: rgba(255,255,255,0.4);
  font-weight: 500;
}

.chat-msg {
  margin: 3px 0;
  max-width: 85%;
}

.chat-msg .msg-bubble {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.chat-msg .msg-username {
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  font-weight: 600;
}

.chat-msg .msg-content {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Input area ---------- */
.chat-input-area {
  padding: 8px 10px;
  padding-bottom: max(30px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  pointer-events: auto;
}

.login-prompt {
  display: flex;
  gap: 6px;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-row {
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.login-prompt input, .chat-form input {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  outline: none;
}

.login-prompt input { padding: 8px 12px; border-radius: 24px; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.25); }
.login-prompt input::placeholder, .chat-form input::placeholder { color: rgba(255,255,255,0.4); }

.login-prompt button {
  padding: 8px 18px;
  border: none;
  border-radius: 24px;
  background: #07c160;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-form button#send-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 20px;
  background: #07c160;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.login-prompt button:active, .chat-form button:active { opacity: 0.8; }

/* ---------- Emoji ---------- */
.emoji-btn {
  width: 36px; height: 36px;
  padding: 0 !important;
  font-size: 20px !important;
  background: transparent !important;
  border: none !important;
  border-radius: 50% !important;
  color: #fff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.emoji-btn svg { pointer-events: none; }

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 10px;
  background: rgba(30,30,30,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 4px;
}

.emoji-cat {
  grid-column: 1 / -1;
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  padding: 6px 2px 2px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.emoji-cat:first-child { border-top: none; padding-top: 0; }

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
}
.emoji-item:hover { background: rgba(255,255,255,0.1); }
.emoji-item img { width: 26px; height: 26px; }

/* ---------- Inline emoji ---------- */
.wx-emoji {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin: 0 1px;
}

.hidden { display: none !important; }


