/* WaveBlue© Streams - Global Styles */
:root {
  --bg: #0d0d0f;
  --bg2: #16161a;
  --bg3: #1e1e24;
  --border: #2a2a35;
  --accent: #1a6dff;
  --accent-hover: #0d5ce0;
  --accent2: #00c6ff;
  --text: #e8e8f0;
  --text2: #9090a8;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --host-color: #a78bfa;
  --guest-color: #34d399;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

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

button, a, input, label { touch-action: manipulation; }

html {
  overflow: hidden;
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Stream-Seiten: body komplett locked */
body.stream-page {
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* --- Login Page --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(26,109,255,0.15) 0%, var(--bg) 70%);
}

.login-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  justify-content: center;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
}

.btn-primary, .btn-secondary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover { border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.hint {
  color: var(--text2);
  font-size: 0.82rem;
  margin-top: 12px;
  text-align: center;
  line-height: 1.5;
}

/* --- Stream Layout --- */
.stream-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;
}

.stream-header .logo-small {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
}


.live-badge {
  background: var(--danger);
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1px;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.viewer-count {
  color: var(--text2);
  font-size: 0.85rem;
}

/* --- Video Grid --- */
.video-area {
  background: #080808;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
}

/* Wrapper mit definierter Höhe */
.video-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.cameras-grid {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 4px;
  padding: 4px;
  overflow: hidden;
  isolation: isolate;
}

.cameras-grid.count-1 { grid-template-columns: 1fr; }
.cameras-grid.count-2 { grid-template-columns: 1fr 1fr; }
.cameras-grid.count-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.cameras-grid.count-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.camera-box {
  position: relative;
  background: var(--bg3);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

.cameras-grid.count-3 .camera-box:first-child {
  grid-column: 1 / -1;
}

.camera-box video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.camera-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text2);
  height: 100%;
}

.camera-placeholder svg { opacity: 0.3; }

/* --- Host Controls --- */
.host-controls {
  padding: 12px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.btn-cam {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-cam:hover { border-color: var(--accent); }
.btn-cam.active { background: var(--accent); border-color: var(--accent); color: white; }
.btn-cam.danger { border-color: var(--danger); }
.btn-cam.danger:hover { background: var(--danger); color: white; }
.btn-cam.btn-icon { padding: 8px 10px; gap: 0; }

/* --- Sidebar – nur Zuschauer --- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow: hidden;
  min-width: 200px;
}

.sidebar-header {
  padding: 12px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* --- Gast PiP (verschiebbar) --- */
.guest-pips {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 15;
}

.guest-pip {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: visible;
  pointer-events: all;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.guest-pip:active { cursor: grabbing; }

.guest-pip-inner {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--guest-color);
  background: var(--bg3);
  box-shadow: 0 2px 20px rgba(0,0,0,0.7);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.guest-pip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  border-radius: 50%;
}

.guest-pip-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: white;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
  background: rgba(0,0,0,0.5);
  padding: 1px 6px;
  border-radius: 8px;
}

.pip-flip-btn, .pip-close-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
  pointer-events: all;
}
.pip-flip-btn  { top: -6px; right: -6px; }
.pip-close-btn { top: -6px; left: -6px; background: rgba(220,40,40,0.85); }
.guest-pip:hover .pip-flip-btn,
.guest-pip:hover .pip-close-btn { opacity: 1; }

/* --- Voice Pip --- */
.voice-pip {
  position: absolute;
  width: 72px;
  cursor: grab;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 10;
}
.voice-pip:active { cursor: grabbing; }

.voice-pip-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.voice-pip-avatar span {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  line-height: 1;
  z-index: 1;
}

.voice-pip-wave {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 2px;
  z-index: 2;
}

.voice-pip-wave span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.85);
  animation: voice-wave 0.8s ease-in-out infinite;
}
.voice-pip-wave span:nth-child(1) { height: 6px; animation-delay: 0s; }
.voice-pip-wave span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.voice-pip-wave span:nth-child(3) { height: 6px; animation-delay: 0.3s; }

@keyframes voice-wave {
  0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
  50%       { transform: scaleY(1);   opacity: 1; }
}

.voice-pip-label {
  font-size: 0.62rem;
  color: white;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.55);
  padding: 1px 6px;
  border-radius: 8px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Chat Overlay --- */
.chat-overlay {
  position: absolute;
  bottom: 56px;
  right: 12px;
  width: 320px;
  max-height: 50vh;
  background: rgba(13, 13, 15, 0.82);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  z-index: 20;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.chat-overlay-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.chat-tabs {
  display: flex;
  gap: 3px;
  flex: 1;
}

.chat-tab {
  flex: 1;
  padding: 5px 8px;
  border: none;
  background: rgba(255,255,255,0.05);
  color: var(--text2);
  cursor: pointer;
  font-size: 0.78rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.chat-tab.active {
  background: var(--accent);
  color: white;
}

.chat-tab-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-tab-content.hidden { display: none; }

.opacity-control {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  color: var(--text2);
}

.opacity-control input[type=range] {
  width: 70px;
  height: 4px;
  accent-color: var(--accent);
}

.overlay-close {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1;
}
.overlay-close:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* --- Admin Overlay --- */
.admin-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 310px;
  max-height: calc(100% - 90px);
  background: rgba(18, 18, 24, 0.96);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  z-index: 20;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
}

.admin-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- Chat --- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-msg-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.chat-msg-name.host { color: var(--host-color); }
.chat-msg-name.admin, .chat-msg-name.superadmin { color: #f59e0b; }
.chat-msg-name.beta { color: #10b981; }
.chat-msg-name.premium_moderator { color: #a855f7; }
.chat-msg-name.moderator { color: #0ea5e9; }
.chat-msg-name.guest { color: var(--guest-color); }

.chat-msg-time {
  font-size: 0.72rem;
  color: var(--text2);
}

.chat-msg-text {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.chat-msg.system {
  align-items: center;
  padding: 2px 0;
}

.chat-msg.system .chat-msg-text {
  font-size: 0.75rem;
  color: var(--text2);
  font-style: italic;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border-radius: 20px;
  padding: 2px 10px;
}

.chat-msg.system-warn .chat-msg-text {
  color: var(--warning);
  background: rgba(245,158,11,0.1);
}

/* Peer-Liste im Chat */
.chat-peer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-peer-item:hover {
  background: var(--bg3);
}

.chat-peer-item:hover .peer-mention-hint {
  opacity: 1;
}

.peer-mention-hint {
  opacity: 0;
  font-size: 0.7rem;
  color: var(--accent);
  margin-left: auto;
  transition: opacity 0.15s;
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

.chat-input-area input:focus { border-color: var(--accent); }

.btn-send {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  color: white;
  cursor: pointer;
  font-size: 0.88rem;
  transition: opacity 0.2s;
}

.btn-send:hover { opacity: 0.85; }

/* --- Peer List --- */
.peer-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.peer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: 8px;
}

.peer-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.peer-avatar.host { background: rgba(167,139,250,0.2); color: var(--host-color); }
.peer-avatar.guest { background: rgba(52,211,153,0.2); color: var(--guest-color); }

.peer-info { flex: 1; min-width: 0; }

.peer-name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.peer-role {
  font-size: 0.72rem;
  color: var(--text2);
}

.peer-actions {
  display: flex;
  gap: 4px;
}

.peer-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.peer-action-btn:hover { border-color: var(--danger); color: var(--danger); }

/* --- Werbeflächen --- */
.ad-bar {
  display: flex;
  gap: 6px;
  background: rgba(0,0,0,0.6);
  z-index: 18;
}

.ad-bar-top {
  flex-direction: row;
  align-items: center;
  padding: 4px 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.ad-bar-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  width: calc(var(--ad-size, 56px) + 16px);
}

.ad-item {
  display: block;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.15s;
}

.ad-item img {
  display: block;
  height: var(--ad-size, 56px);
  width: auto;
  max-width: 200px;
  object-fit: contain;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}

.ad-bar-left .ad-item img {
  height: auto;
  width: var(--ad-size, 56px);
  max-width: none;
}

a.ad-item:hover { opacity: 0.85; transform: scale(1.03); cursor: pointer; }

/* --- Stream Overlay (BRB / Handover / Werbung) --- */
.stream-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.overlay-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.overlay-brb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text2);
}

.overlay-brb p { font-size: 0.95rem; }

.overlay-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Notifications --- */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.88rem;
  animation: slide-in 0.3s ease;
  pointer-events: all;
  max-width: 280px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--accent); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Gift Alert --- */
.gift-alert {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #1a1040 0%, #2d1b69 100%);
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: 16px;
  padding: 16px 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 40px rgba(124,58,237,0.3);
  animation: gift-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.gift-alert-out {
  animation: gift-out 0.5s ease-in both;
}
.gift-alert-icon {
  font-size: 2.8rem;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(167,139,250,0.8));
  animation: gift-bounce 0.6s ease 0.3s both;
}
.gift-alert-text {
  color: #e2e8f0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.gift-alert-text strong {
  color: #c4b5fd;
}
.gift-alert-msg {
  margin-top: 4px;
  font-size: 0.85rem;
  color: #94a3b8;
  font-style: italic;
}
@keyframes gift-in {
  from { transform: translateX(-50%) translateY(40px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}
@keyframes gift-out {
  from { transform: translateX(-50%) translateY(0);   opacity: 1; }
  to   { transform: translateX(-50%) translateY(-20px); opacity: 0; }
}
@keyframes gift-bounce {
  0%   { transform: scale(0) rotate(-20deg); }
  60%  { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* --- Gift Picker --- */
.btn-gift-picker {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-gift-picker:hover { background: var(--bg3, rgba(255,255,255,0.08)); }

.gift-picker {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 10px;
}
.gift-picker-title {
  font-size: 0.75rem;
  color: var(--text2);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.gift-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.gift-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: var(--bg3, rgba(255,255,255,0.05));
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.gift-item:hover {
  background: rgba(124,58,237,0.15);
  border-color: rgba(167,139,250,0.5);
  transform: translateY(-2px);
}
.gift-item:active { transform: translateY(0); }
.gift-item-icon { font-size: 1.6rem; line-height: 1; }
.gift-item-name { font-size: 0.68rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gift-item-price { font-size: 0.7rem; color: #a78bfa; font-weight: 600; }

/* --- Guest Camera Button --- */
.guest-cam-bar {
  padding: 10px 12px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Like Button --- */
.btn-like {
  display: flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.15s;
}
.btn-like.liked {
  transform: scale(1.25);
  color: #ef4444;
}

/* --- Admin Panel --- */
.admin-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-section:last-child { border-bottom: none; }

.admin-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.admin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.admin-stat {
  background: var(--bg3);
  border-radius: 6px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-stat span { font-size: 0.7rem; color: var(--text2); }
.admin-stat strong { font-size: 1rem; }

.admin-peer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.admin-peer-item:last-child { border-bottom: none; }

.admin-ban-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}
.admin-ban-item:last-child { border-bottom: none; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* --- iOS Safe Areas --- */
@supports (padding-top: env(safe-area-inset-top)) {
  .stream-layout {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* --- Tablet (768px) --- */
@media (max-width: 768px) {
  /* Linke Werbeleiste auf Mobile/Tablet ausblenden */
  .ad-bar-left { display: none !important; }

  .stream-header {
    padding: 8px 12px;
  }
  .stream-header .logo-small { font-size: 0.95rem; }
  .stream-header .logo-small svg { width: 22px; height: 22px; }

  .cameras-grid.count-3,
  .cameras-grid.count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .cameras-grid.count-3 .camera-box:first-child {
    grid-column: 1 / -1;
  }

  .chat-overlay {
    width: 100%;
    right: 0;
    left: 0;
    bottom: 48px;
    max-height: 50vh;
    background: transparent;
    border: none;
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .chat-overlay .chat-messages {
    background: transparent;
    padding: 8px 12px;
  }
  .chat-overlay .chat-msg-text {
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  }
  .chat-overlay .chat-msg-name {
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  }
  .chat-overlay .chat-overlay-header {
    background: transparent;
    border-bottom: none;
  }
  .chat-overlay .chat-input-area {
    background: rgba(0,0,0,0.5);
    border-top: none;
    border-radius: 8px;
    margin: 0 8px 4px;
  }
  .chat-input-area input {
    font-size: 16px; /* verhindert iOS-Zoom */
  }
  .admin-overlay {
    width: calc(100vw - 16px);
    right: 8px;
    left: 8px;
  }

  /* Bildschirm-Teilen Button – prominent am linken Rand */
  #btn-guest-screen {
    position: fixed;
    left: 12px;
    bottom: 70px;
    z-index: 50;
    width: 48px;
    height: 48px;
    border-radius: 50% !important;
    background: var(--bg3) !important;
    border: 2px solid var(--border) !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
  }
  #btn-guest-screen.active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
  }

  .guest-pip { width: 90px; height: 90px; }
  .guest-pip-inner { width: 90px; height: 90px; }

  .lobby-body { padding: 20px 16px; }
  .lobby-body h2 { font-size: 1.2rem; }
}

/* --- Phone (max 520px) --- */
@media (max-width: 520px) {
  /* Header kompakt */
  .stream-header {
    padding: 6px 10px;
    gap: 6px;
  }
  .stream-header .logo-small { font-size: 0.85rem; gap: 5px; }
  .stream-header .logo-small svg { width: 20px; height: 20px; }
  .header-actions { gap: 6px; }
  .header-actions .btn-cam { padding: 6px 10px; font-size: 0.78rem; }
  .viewer-count { font-size: 0.75rem; }
  #username-display { font-size: 0.75rem !important; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Video: 2 Kameras → 2 Spalten beibehalten, bounded */
  .cameras-grid.count-2 { grid-template-columns: 1fr 1fr; }
  .cameras-grid.count-3,
  .cameras-grid.count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .cameras-grid.count-3 .camera-box:first-child {
    grid-column: 1 / -1;
  }

  /* Cam-Bar kompakt */
  .guest-cam-bar {
    padding: 6px 8px;
    gap: 5px;
  }
  .guest-cam-bar .btn-cam { padding: 6px 8px; font-size: 0.75rem; }
  .guest-cam-bar .btn-cam.btn-icon { padding: 6px 8px; }
  .guest-cam-bar .btn-cam.btn-icon svg { width: 16px; height: 16px; }
  .guest-cam-bar .btn-cam.btn-like { padding: 6px 8px; font-size: 0.75rem; }
  #cam-status { font-size: 0.7rem !important; display: none; }
  #btn-admin { font-size: 0.72rem; }

  /* Host-Controls kompakt */
  .host-controls {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 5px;
  }
  .host-controls .btn-cam { padding: 6px 10px; font-size: 0.78rem; min-height: 38px; }
  .host-controls .btn-cam.btn-icon { padding: 6px 8px; min-width: 38px; min-height: 38px; }
  .host-controls .btn-cam svg { width: 16px; height: 16px; }
  .host-controls #cam-count { display: none; }
  .host-controls #btn-end-stream { padding: 6px 10px; font-size: 0.75rem; margin-left: 4px; }

  /* Chat Overlay → transparent, links */
  .chat-overlay {
    width: 100%;
    right: 0;
    left: 0;
    bottom: 44px;
    max-height: 50vh;
    border-radius: 0;
    background: transparent;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .chat-overlay-header { padding: 8px 10px; }
  .chat-messages { font-size: 0.82rem; padding: 8px 10px; background: transparent; }
  .chat-input-area { padding: 6px 8px; gap: 4px; background: rgba(0,0,0,0.5); }
  .chat-input-area input { font-size: 16px; padding: 8px; }

  /* Admin Overlay → breiter */
  .admin-overlay {
    width: 100%;
    right: 0;
    left: 0;
    border-radius: 0;
  }

  /* PiP kleiner */
  .guest-pip { width: 72px; height: 72px; }
  .guest-pip-inner { width: 72px; height: 72px; border-width: 2px; }
  .guest-pip-label { font-size: 0.58rem; bottom: -14px; }

  .voice-pip { width: 56px; }
  .voice-pip-avatar { width: 48px; height: 48px; }
  .voice-pip-name { font-size: 0.55rem; }

  /* Invite Bar */
  .invite-bar { padding: 6px 10px; gap: 5px; }
  .invite-bar-label { font-size: 0.7rem; }
  .invite-bar-code { font-size: 0.7rem; }

  /* Live Badge */
  .live-badge { padding: 2px 7px; font-size: 0.7rem; }

  /* Lobby */
  .lobby-card { padding: 10px 12px; gap: 10px; }
  .lobby-card-avatar { width: 38px; height: 38px; font-size: 1.1rem; }
  .lobby-card-host { font-size: 0.88rem; }
  .lobby-card .btn-cam { padding: 6px 10px; font-size: 0.78rem; }

  /* Login Page */
  .login-container { padding: 24px 18px; margin: 0 8px; }

  /* Code Screen */
  .code-screen-box { padding: 28px 20px; }

  /* Register Modal */
  .reg-modal-box { padding: 18px; }
  .reg-modal-field input { font-size: 16px; } /* iOS zoom fix */

  /* Profil Popup */
  .profile-popup { min-width: 160px; padding: 12px 14px; }
}

/* --- Sehr kleine Phones (max 380px, z.B. iPhone SE) --- */
@media (max-width: 380px) {
  .stream-header .logo-small span,
  .stream-header .logo-small { font-size: 0; }
  .stream-header .logo-small svg { width: 22px; height: 22px; }

  .header-actions .btn-cam { padding: 5px 8px; font-size: 0.72rem; }
  #username-display { display: none !important; }
  .viewer-count { font-size: 0.7rem; }

  .guest-cam-bar { gap: 3px; padding: 5px 6px; padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px)); }
  .guest-cam-bar .btn-cam { padding: 5px 6px; }
  .guest-cam-bar .btn-cam.btn-like .like-count { display: none; }

  .host-controls { gap: 3px; padding: 6px 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  .host-controls .btn-cam { padding: 5px 7px; font-size: 0.72rem; }
  .host-controls #btn-end-stream span { display: none; } /* Nur Icon auf sehr kleinen Screens */

  .guest-pip { width: 60px; height: 60px; }
  .guest-pip-inner { width: 60px; height: 60px; }
}

/* --- Landscape auf Phones (kurze Höhe) --- */
@media (max-height: 500px) and (orientation: landscape) {
  .stream-header { padding: 4px 10px; }
  .stream-header .logo-small svg { width: 18px; height: 18px; }

  .guest-cam-bar { padding: 4px 8px; }
  .guest-cam-bar .btn-cam { padding: 4px 8px; font-size: 0.72rem; }

  .host-controls { padding: 4px 8px; }
  .host-controls .btn-cam { padding: 4px 8px; }

  .chat-overlay { max-height: 50vh; bottom: 32px; }

  .cameras-grid.count-2 { grid-template-columns: 1fr 1fr; }
}

/* --- Stream Lobby --- */
.stream-lobby {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.lobby-body {
  padding: 32px 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
.lobby-body h2 {
  font-size: 1.4rem;
  margin: 0 0 20px;
}
.lobby-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lobby-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  transition: border-color 0.2s;
}
.lobby-card:hover { border-color: var(--accent); }
.lobby-card-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: white;
  flex-shrink: 0;
}
.lobby-card-info { flex: 1; min-width: 0; }
.lobby-card-host { font-weight: 600; font-size: 1rem; }
.lobby-card-stats { font-size: 0.8rem; color: var(--text2); margin-top: 3px; }
.lobby-loading, .lobby-empty { color: var(--text2); padding: 20px 0; text-align: center; }

/* --- Invite Bar (Host) --- */
.invite-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(26, 109, 255, 0.08);
  border-top: 1px solid rgba(26, 109, 255, 0.2);
  flex-shrink: 0;
  flex-wrap: wrap;
  overflow: hidden;
  max-width: 100%;
}
.invite-bar-label {
  font-size: 0.78rem;
  color: var(--text2);
  white-space: nowrap;
}
.invite-bar-code {
  flex: 1;
  font-size: 0.78rem;
  color: #93c5fd;
  background: rgba(26,109,255,0.1);
  border-radius: 6px;
  padding: 3px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-family: monospace;
}
.invite-copy-btn { color: var(--accent) !important; }

/* --- Code-Eingabe Screen (Viewer) --- */
.code-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}
.code-screen-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}
.code-screen-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}
.code-screen-box h2 {
  font-size: 1.2rem;
  margin: 0 0 8px;
  color: var(--text);
}
.code-screen-box p {
  color: var(--text2);
  font-size: 0.9rem;
  margin: 0 0 16px;
}
.code-screen-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid var(--danger);
  color: #fca5a5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.code-screen-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.code-screen-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
}
.code-screen-input:focus { outline: none; border-color: var(--accent); }
.code-screen-hint {
  font-size: 0.78rem;
  color: var(--text2);
  margin: 0;
}

/* --- Registrierungs-Modal im Stream --- */
.reg-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.reg-modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: popup-in 0.2s ease;
}

.reg-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.reg-modal-field {
  margin-bottom: 12px;
}

.reg-modal-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text2);
  margin-bottom: 4px;
}

.reg-modal-field input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.reg-modal-field input:focus {
  border-color: var(--accent);
}

/* --- Social Buttons (v20) --- */
.peer-social-btns {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.btn-follow, .btn-like-social {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 3px 7px;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-follow:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(26, 109, 255, 0.1);
}

.btn-follow.active {
  background: rgba(26, 109, 255, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-like-social:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.btn-like-social.active {
  background: rgba(239, 68, 68, 0.18);
  border-color: #ef4444;
  color: #ef4444;
}

/* --- Profil-Popup --- */
.profile-popup {
  z-index: 9000;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  min-width: 200px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: popup-in 0.15s ease;
}

@keyframes popup-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.profile-popup-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
}

.profile-popup-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--text);
}

.profile-popup-stats {
  font-size: 0.78rem;
  color: var(--text2);
  margin-bottom: 10px;
  line-height: 1.6;
}

.profile-popup-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.peer-name-clickable {
  cursor: pointer;
}

.peer-name-clickable:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* --- Wallet Modal (v33) --- */
.wallet-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.wallet-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: popup-in 0.2s ease;
}

.wallet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.wallet-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.wallet-balance-display {
  text-align: center;
  padding: 16px;
  background: var(--bg3);
  border-radius: 12px;
  margin-bottom: 18px;
}

.wallet-balance-amount {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.wallet-balance-label {
  font-size: 0.78rem;
  color: var(--text2);
  margin-top: 2px;
}

.wallet-packages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.wallet-package {
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.wallet-package:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.wallet-package.selected {
  border-color: var(--accent);
  background: rgba(26, 109, 255, 0.08);
}

.wallet-package-credits {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.wallet-package-price {
  font-size: 0.85rem;
  color: var(--accent2);
  font-weight: 600;
  margin-top: 4px;
}

.wallet-package-bonus {
  font-size: 0.7rem;
  color: var(--success);
  margin-top: 2px;
}

.wallet-buy-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #0070ba, #003087);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.wallet-buy-btn:hover { opacity: 0.9; }
.wallet-buy-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wallet-buy-btn svg { flex-shrink: 0; }

.wallet-tx-list {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.wallet-tx-list h4 {
  font-size: 0.8rem;
  color: var(--text2);
  margin: 0 0 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wallet-tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.wallet-tx-desc { color: var(--text2); }
.wallet-tx-amount { font-weight: 600; }
.wallet-tx-amount.positive { color: var(--success); }
.wallet-tx-amount.negative { color: var(--danger); }

.wallet-header-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--accent2);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s;
}

.wallet-header-btn:hover { border-color: var(--accent); }

@media (max-width: 480px) {
  .wallet-modal { padding: 18px; max-width: 100%; }
  .wallet-packages { grid-template-columns: 1fr 1fr; gap: 8px; }
  .wallet-package { padding: 10px 8px; }
  .wallet-package-credits { font-size: 1.1rem; }
}
