/* ============================================================
   Roy4d LIVE — TikTok-live style video chat
   Design system + components
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --bg: #08080d;
  --bg-2: #0d0d15;
  --bg-3: #12121c;
  --card: #15151f;
  --card-2: #1b1b28;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f4f4f8;
  --muted: #9a9aa8;
  --faint: #5b5b6b;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-3: #f97316;
  --live: #ff2d55;
  --live-soft: rgba(255, 45, 85, 0.16);
  --green: #22c55e;
  --gold: #fbbf24;
  --cyan: #22d3ee;
  --grad: linear-gradient(120deg, #8b5cf6 0%, #ec4899 55%, #f97316 110%);
  --grad-live: linear-gradient(135deg, #ff2d55, #f97316);
  --glass: rgba(18, 18, 28, 0.55);
  --glass-2: rgba(12, 12, 20, 0.72);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.4);
  --glow: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 8px 40px rgba(139, 92, 246, 0.25);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1100px 500px at 85% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(900px 420px at -10% 10%, rgba(236, 72, 153, 0.12), transparent 55%);
  background-attachment: fixed;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea {
  font-family: inherit;
  color: inherit;
}

ul {
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--faint);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.hidden {
  display: none !important;
}

/* ---------- App shell ---------- */
#app {
  position: relative;
  min-height: 100dvh;
}

.view {
  display: none;
  animation: viewIn 0.38s var(--ease);
}

.view.active {
  display: block;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Shared: buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 30px rgba(236, 72, 153, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 12px 36px rgba(236, 72, 153, 0.5);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-2);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: var(--grad-live);
  color: #fff;
  box-shadow: 0 10px 28px rgba(255, 45, 85, 0.35);
}

.btn-lg {
  padding: 15px 30px;
  font-size: 16px;
  border-radius: 16px;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   SPLASH / ONBOARDING
   ============================================================ */
#view-splash .splash {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px calc(24px + var(--safe-b));
  text-align: center;
  position: relative;
  overflow: hidden;
}

.splash-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  animation: orbFloat 9s ease-in-out infinite;
}

.splash-orb.o1 {
  width: 340px;
  height: 340px;
  background: var(--accent);
  top: -80px;
  right: -60px;
}

.splash-orb.o2 {
  width: 280px;
  height: 280px;
  background: var(--accent-2);
  bottom: -70px;
  left: -70px;
  animation-delay: -4.5s;
}

@keyframes orbFloat {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-24px) scale(1.08);
  }
}

.splash-logo {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 24px 60px rgba(236, 72, 153, 0.4), 0 0 0 8px rgba(255, 255, 255, 0.04);
  margin-bottom: 22px;
  position: relative;
}

.splash-logo::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 32px;
  border: 2px solid transparent;
  background: linear-gradient(120deg, #ff2d55, #8b5cf6, #22d3ee) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spinRing 6s linear infinite;
}

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

.splash-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(120deg, #fff 20%, #c4b5fd 50%, #f9a8d4 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.splash-sub {
  color: var(--muted);
  font-size: 15px;
  max-width: 320px;
  margin-bottom: 30px;
}

.splash-points {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 28px;
}

.splash-point {
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.splash-point .sp-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.18);
}

.splash-point b {
  display: block;
  font-size: 14px;
}

.splash-point span {
  font-size: 12.5px;
  color: var(--muted);
}

.name-form {
  width: 100%;
  max-width: 340px;
  display: grid;
  gap: 12px;
}

.name-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 15px 18px;
  font-size: 16px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.name-input::placeholder {
  color: var(--faint);
}

/* ============================================================
   FEED
   ============================================================ */
.shell {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(92px + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  background: linear-gradient(180deg, rgba(8, 8, 13, 0.92) 40%, rgba(8, 8, 13, 0));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 24px rgba(236, 72, 153, 0.35);
}

.brand-name {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.4px;
  background: linear-gradient(120deg, #fff 30%, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}

.live-now h2 {
  font-size: 19px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 9px;
}

.live-now .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(255, 45, 85, 0.6);
  animation: pulseDot 1.6s infinite;
}

@keyframes pulseDot {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 45, 85, 0.55);
  }

  70% {
    box-shadow: 0 0 0 9px rgba(255, 45, 85, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 45, 85, 0);
  }
}

.live-count {
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
}

/* Featured carousel */
.featured-wrap {
  padding: 4px 0 6px;
}

.featured-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 6px 20px 14px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.featured-row::-webkit-scrollbar {
  display: none;
}

.feature-card {
  flex: 0 0 218px;
  scroll-snap-align: start;
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  aspect-ratio: 9 / 12;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.25s;
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.feature-card .thumb {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-card .avatar {
  width: 72px;
  height: 72px;
  font-size: 26px;
  box-shadow: var(--shadow-2);
}

.feature-card .fc-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 14px 13px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.82));
}

.feature-card .fc-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feature-card .fc-host {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 12.5px;
  color: #d7d7e2;
}

.feature-card .fc-host .avatar {
  width: 18px;
  height: 18px;
  font-size: 9px;
}

/* Feed grid */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 10px 20px;
}

.live-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.25s;
}

.live-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
}

.live-card .thumb {
  position: relative;
  aspect-ratio: 9 / 12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.live-card .thumb .avatar {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.live-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--grad-live);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 7px;
  box-shadow: 0 4px 14px rgba(255, 45, 85, 0.45);
}

.live-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: blink 1.1s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.viewers-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tag-chip {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.card-meta {
  padding: 10px 12px 12px;
}

.card-meta .host-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-meta .host-row .avatar {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

.card-meta .host-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #e7e7ef;
}

.card-title {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gradient thumbnails (deterministic per sid) */
.gthumb {
  position: absolute;
  inset: 0;
  opacity: 0.9;
}

.gthumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 20% 10%, rgba(255, 255, 255, 0.22), transparent 50%);
}

.gthumb .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.75;
  animation: orbFloat 8s ease-in-out infinite;
}

/* Empty state */
.feed-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}

.feed-empty .fe-ico {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 26px;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  box-shadow: var(--glow);
}

/* ---------- Floating Go-Live FAB ---------- */
.fab-live {
  position: fixed;
  right: 18px;
  bottom: calc(84px + var(--safe-b));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 999px;
  background: var(--grad-live);
  color: #fff;
  font-weight: 800;
  font-size: 14.5px;
  box-shadow: 0 14px 36px rgba(255, 45, 85, 0.45);
  transition: transform 0.18s var(--ease);
}

.fab-live:hover {
  transform: translateY(-2px) scale(1.02);
}

.fab-live:active {
  transform: scale(0.95);
}

.fab-live .plus {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

.fab-live .ring {
  position: absolute;
  inset: -3px;
  border-radius: 999px;
  border: 2px solid rgba(255, 45, 85, 0.5);
  animation: fabPulse 2s infinite;
}

@keyframes fabPulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 560px;
  z-index: 46;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 8px calc(10px + var(--safe-b));
  background: rgba(10, 10, 16, 0.82);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--line);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 14px;
  transition: color 0.2s;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: #fff;
}

.nav-center {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 10px 28px rgba(236, 72, 153, 0.45);
  transform: translateY(-6px);
  border: 4px solid var(--bg);
  transition: transform 0.2s var(--ease);
}

.nav-center:hover {
  transform: translateY(-9px) scale(1.04);
}

/* ============================================================
   PRE-LIVE SETUP
   ============================================================ */
#view-prelive .prelive {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.prelive-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 10px;
}

.prelive-top .pl-title {
  font-size: 18px;
  font-weight: 800;
}

.cam-stage {
  position: relative;
  margin: 8px 18px 14px;
  border-radius: 24px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 9 / 16;
  max-height: 58dvh;
  width: calc(100% - 36px);
  align-self: center;
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
}

.cam-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}

.cam-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.cam-placeholder .pc-ico {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  animation: pulseDot 2s infinite;
}

.cam-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cam-actions .icon-btn {
  width: 46px;
  height: 46px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

.cam-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  background: var(--grad-live);
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.prelive-form {
  padding: 6px 20px 30px;
  display: grid;
  gap: 16px;
}

.field label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 7px;
}

.field label .count {
  color: var(--faint);
  font-weight: 500;
}

.title-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.title-input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.18);
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  transition: all 0.18s;
}

.tag-pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tag-pill.on {
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.35), rgba(236, 72, 153, 0.35));
  border-color: var(--accent-2);
  color: #fff;
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.25);
}

.prelive-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(34, 211, 238, 0.07);
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

/* ============================================================
   ROOM — the live experience
   ============================================================ */
.room {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
}

.stage video.full {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage .stage-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 120px;
  opacity: 0.5;
}

.stage .stage-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

/* Guest rack (right edge, stacked) */
.guest-rack {
  position: absolute;
  top: 96px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 12;
  max-height: calc(100% - 220px);
  overflow-y: auto;
  scrollbar-width: none;
}

.guest-rack::-webkit-scrollbar {
  display: none;
}

.guest-tile {
  position: relative;
  width: 108px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: #111;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  animation: tileIn 0.3s var(--ease);
}

.guest-tile.speaking {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

@keyframes tileIn {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.9);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.guest-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.guest-tile .gt-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guest-tile .gt-avatar .avatar {
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.guest-tile .gt-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 7px 6px;
  font-size: 10.5px;
  font-weight: 700;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.8));
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guest-tile .gt-mic {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

.guest-tile .gt-mic.on {
  background: rgba(34, 197, 94, 0.85);
}

.guest-tile .gt-mic.off {
  background: rgba(255, 45, 85, 0.9);
}

.guest-tile .gt-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 5px;
}

.guest-tile:hover .gt-controls,
.guest-tile.touch .gt-controls {
  display: flex;
}

.guest-tile .gt-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.guest-tile .gt-btn.red {
  color: var(--live);
}

/* Top overlay */
.stage-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
  z-index: 20;
}

.stage-top .icon-btn {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
}

.host-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  min-width: 0;
}

.host-chip .avatar {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.host-chip .hc-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.host-chip .hc-name {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.host-chip .hc-name .badge-live {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  background: var(--grad-live);
  color: #fff;
  padding: 2px 6px;
  border-radius: 5px;
  animation: pulseDot 1.6s infinite;
}

.host-chip .hc-meta {
  font-size: 11px;
  color: #cfcfdd;
  display: flex;
  align-items: center;
  gap: 7px;
}

.host-chip .hc-meta .vi {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stage-top .spacer {
  flex: 1;
}

.timer-pill {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 7px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Comments floating over the stage */
.comments-overlay {
  position: absolute;
  left: 12px;
  right: 96px;
  bottom: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 32vh;
  overflow: hidden;
  z-index: 15;
  pointer-events: none;
}

.comment-bubble {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: commentIn 0.3s var(--ease);
  max-width: 100%;
}

@keyframes commentIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.comment-bubble .cb-name {
  font-weight: 800;
  font-size: 12.5px;
}

.comment-bubble .cb-text {
  font-size: 13px;
  color: #eeeef6;
  line-height: 1.3;
  word-break: break-word;
}

.comment-bubble .cb-pill {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 7px 11px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.comment-bubble.cb-gift .cb-pill {
  background: linear-gradient(120deg, rgba(251, 191, 36, 0.22), rgba(236, 72, 153, 0.22));
  border-color: rgba(251, 191, 36, 0.4);
}

.comment-bubble.cb-system .cb-pill {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.25);
  color: #a5f3fc;
}

.comment-bubble.leaving {
  animation: commentOut 0.4s var(--ease) forwards;
}

@keyframes commentOut {
  to {
    opacity: 0;
    transform: translateX(-16px);
  }
}

/* Stage bottom controls */
.stage-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 56px 14px calc(14px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.6));
  z-index: 18;
}

.ctl-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.ctl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: #e5e5ef;
}

.ctl-btn .cb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  transition: transform 0.15s, background 0.2s;
}

.ctl-btn:active .cb {
  transform: scale(0.9);
}

.ctl-btn.hot .cb {
  background: var(--grad-live);
  border-color: transparent;
  animation: heartPump 0.5s var(--ease);
}

.ctl-btn.cb-end .cb {
  background: var(--grad-live);
  border-color: transparent;
}

.ctl-btn .bubble {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--live);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #000;
}

.chat-input-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 8px 8px 16px;
  max-width: 360px;
}

.chat-input-pill input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  min-width: 0;
}

.chat-input-pill input::placeholder {
  color: var(--faint);
}

.chat-input-pill .send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.chat-input-pill .send-btn:disabled {
  opacity: 0.4;
}

/* Join request banner */
.join-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(120px + var(--safe-b));
  z-index: 25;
  width: calc(100% - 32px);
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass-2);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  animation: bannerIn 0.3s var(--ease);
}

@keyframes bannerIn {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Centered dialog entrance — no -50% X shift (used by flex-centered modals) */
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.join-banner .jb-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.join-banner .jb-actions {
  display: flex;
  gap: 8px;
}

.join-banner .btn {
  padding: 9px 16px;
  font-size: 13px;
}

.join-banner .btn-reject {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.join-banner .btn-accept {
  background: var(--grad);
  color: #fff;
}

/* ============================================================
   SIDE PANEL (chat / viewers / requests)
   ============================================================ */
.side-panel {
  display: none;
}

.panel-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.panel-tab {
  position: relative;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 10px 10px 0 0;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-tab.active {
  color: #fff;
}

.panel-tab.active::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px;
  background: var(--grad);
}

.panel-tab .tab-badge {
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--live);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 14px;
}

.chat-row {
  display: flex;
  gap: 9px;
  padding: 6px 0;
  animation: chatRowIn 0.25s var(--ease);
}

@keyframes chatRowIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.chat-row .avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
  margin-top: 2px;
}

.chat-row .cr-body {
  min-width: 0;
}

.chat-row .cr-name {
  font-size: 12px;
  font-weight: 800;
  color: #c4c4d6;
}

.chat-row .cr-text {
  font-size: 13.5px;
  word-break: break-word;
}

.chat-row.cr-system .cr-text {
  color: #7dd3fc;
  font-size: 12.5px;
}

.chat-row.cr-like .cr-text {
  color: var(--accent-2);
  font-size: 12.5px;
}

.chat-row.cr-gift .cr-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-row .cr-gift-emoji {
  font-size: 26px;
  display: inline-block;
  animation: giftBounce 0.6s var(--ease);
}

@keyframes giftBounce {
  0% {
    transform: scale(0) rotate(-20deg);
  }

  60% {
    transform: scale(1.3) rotate(8deg);
  }

  100% {
    transform: scale(1);
  }
}

.chat-row.cr-gift .cr-gift-label {
  font-size: 12.5px;
  background: linear-gradient(120deg, rgba(251, 191, 36, 0.25), rgba(236, 72, 153, 0.25));
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.chat-row.cr-me .cr-text {
  color: #d8d8ff;
}

.viewer-list {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}

.viewer-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 8px;
  border-radius: 12px;
  transition: background 0.15s;
}

.viewer-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.viewer-row .avatar {
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.viewer-row .vr-name {
  font-size: 13.5px;
  font-weight: 600;
}

.viewer-row .vr-role {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.viewer-row .vr-role.host {
  background: var(--grad-live);
  color: #fff;
}

.viewer-row .vr-role.guest {
  background: rgba(34, 211, 238, 0.18);
  color: var(--cyan);
}

.viewer-row .vr-watch {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.requests-empty,
.chat-empty {
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  padding: 40px 20px;
}

/* Host insights: gifts received + likers */
.insight-list {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.insight-head {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 8px 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.insight-head b {
  color: var(--text);
  font-size: 15px;
}

.gift-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
}

.gift-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.gift-row .g-emoji {
  font-size: 26px;
  width: 36px;
  text-align: center;
}

.gift-row .g-name {
  font-weight: 600;
  font-size: 14px;
}

.gift-row .g-count {
  margin-left: auto;
  font-size: 13px;
  font-weight: 800;
}

.gift-row .g-value {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  min-width: 64px;
  text-align: right;
}

.like-count {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--live);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.panel-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}

.panel-input input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
}

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

.panel-input .send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   BOTTOM SHEETS (mobile chat, gift tray, ended)
   ============================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 60;
  animation: fadeIn 0.25s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 560px;
  max-height: 74dvh;
  background: var(--bg-2);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line-2);
  z-index: 61;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  animation: sheetUp 0.32s var(--ease);
}

@keyframes sheetUp {
  from {
    transform: translate(-50%, 100%);
  }

  to {
    transform: translate(-50%, 0);
  }
}

.sheet-grab {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--line-2);
  margin: 10px auto 4px;
  flex-shrink: 0;
}

/* Gift tray */
.gift-tray {
  padding: 6px 14px 16px;
  overflow-y: auto;
}

.gift-tray .gt-header {
  font-size: 15px;
  font-weight: 800;
  padding: 8px 4px 12px;
}

.gift-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.gift-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 6px 10px;
  transition: transform 0.16s, border 0.16s, background 0.16s;
}

.gift-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent-2);
  background: var(--card-2);
}

.gift-item .g-emoji {
  font-size: 30px;
  animation: giftIdle 1.6s ease-in-out infinite;
}

@keyframes giftIdle {
  50% {
    transform: translateY(-3px) scale(1.06);
  }
}

.gift-item .g-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.gift-item .g-val {
  font-size: 10.5px;
  color: var(--gold);
  font-weight: 700;
}

.gift-item .g-coin {
  color: var(--gold);
}

/* Ended overlay */
.ended-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(4, 4, 8, 0.86);
  backdrop-filter: blur(10px);
  padding: 24px;
}

.ended-overlay .eo-emoji {
  font-size: 56px;
  margin-bottom: 10px;
  animation: giftIdle 1.8s infinite;
}

.ended-overlay h2 {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 6px;
}

.ended-overlay p {
  color: var(--muted);
  margin-bottom: 22px;
}

.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 26px;
}

.stat-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 20px;
  min-width: 96px;
}

.stat-box b {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.stat-box span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Heart burst layer (full room) */
.heart-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 22;
  overflow: hidden;
}

.heart-burst {
  position: absolute;
  font-size: 30px;
  will-change: transform, opacity;
  animation: heartFloat 1.4s ease-out forwards;
  filter: drop-shadow(0 4px 10px rgba(236, 72, 153, 0.5));
}

@keyframes heartFloat {
  0% {
    transform: translate(-50%, -50%) scale(0.3) rotate(-18deg);
    opacity: 0;
  }

  14% {
    transform: translate(-50%, -55%) scale(1.15) rotate(6deg);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -320%) scale(1) rotate(14deg);
    opacity: 0;
  }
}

/* Gift fly animation */
.gift-fly {
  position: absolute;
  left: 50%;
  bottom: 46%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  animation: flyUp 2.4s cubic-bezier(0.2, 0.6, 0.35, 1) forwards;
}

.gift-fly .gf-emoji {
  font-size: 52px;
  filter: drop-shadow(0 8px 22px rgba(251, 191, 36, 0.6));
}

.gift-fly .gf-name {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(120deg, rgba(251, 191, 36, 0.9), rgba(236, 72, 153, 0.9));
  padding: 5px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@keyframes flyUp {
  0% {
    transform: translateX(-50%) translateY(0) scale(0.4);
    opacity: 0;
  }

  12% {
    transform: translateX(-50%) translateY(-20px) scale(1.15);
    opacity: 1;
  }

  100% {
    transform: translateX(-50%) translateY(-230px) scale(1);
    opacity: 0;
  }
}

/* Like counter popup */
.like-pop {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  z-index: 23;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(120deg, #fda4af, #f9a8d4, #fcd34d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: likePop 1.2s ease-out forwards;
  pointer-events: none;
  text-shadow: 0 4px 20px rgba(236, 72, 153, 0.5);
}

@keyframes likePop {
  0% {
    transform: translateX(-50%) scale(0.5);
    opacity: 0;
  }

  15% {
    transform: translateX(-50%) scale(1.15);
    opacity: 1;
  }

  70% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }

  100% {
    transform: translateX(-50%) scale(1.05);
    opacity: 0;
  }
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: 100%;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--glass-2);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  animation: toastIn 0.3s var(--ease);
  max-width: calc(100% - 32px);
}

.toast .t-ico {
  font-size: 17px;
}

.toast.out {
  animation: toastOut 0.35s var(--ease) forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-14px) scale(0.95);
  }
}

/* ============================================================
   NAME MODAL
   ============================================================ */
#name-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.name-modal {
  width: 100%;
  max-width: 340px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: modalIn 0.3s var(--ease);
}

.nm-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 12px;
}

/* ============================================================
   CONFIRM MODAL (end live)
   ============================================================ */
#end-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-modal {
  width: 100%;
  max-width: 340px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 26px 22px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: modalIn 0.3s var(--ease);
}

.cm-ico {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}

.cm-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.cm-text {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 16px;
}

.cm-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 20px;
}

.cm-stat b {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.cm-stat span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cm-actions {
  display: flex;
  gap: 10px;
}

/* ============================================================
   RELOAD GUARD — block pull-to-refresh while inside a live room
   (html/body get `.live-guard` added/removed from JS)
   ============================================================ */
html.live-guard,
body.live-guard {
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
}

/* Guest tile name ellipsis */
.guest-tile .gt-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#panel-close {
  display: none;
}

/* ============================================================
   Skeleton loaders
   ============================================================ */
.skel {
  position: relative;
  overflow: hidden;
  background: #181824;
  border-radius: 12px;
}

.skel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* ============================================================
   Desktop layout (>= 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  .shell {
    max-width: 760px;
  }

  .feed-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-nav {
    max-width: 760px;
  }

  /* Room: stage left + side panel right */
  .room {
    flex-direction: row;
  }

  /* TikTok-style: center a portrait 9:16 stage so a portrait feed fills it
     with minimal cropping (full-bleed on mobile, which is already portrait) */
  .stage {
    flex: 0 1 auto;
    align-self: center;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 9 / 16;
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 18px;
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.5),
      0 26px 80px -24px rgba(0, 0, 0, 0.95),
      0 0 46px rgba(236, 72, 153, 0.10),
      0 0 90px rgba(139, 92, 246, 0.06);
  }

  .side-panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    flex-shrink: 0;
    background: var(--bg-2);
    border-left: 1px solid var(--line);
  }

  .guest-rack {
    top: 90px;
    right: 16px;
  }

  .guest-tile {
    width: 150px;
  }

  .panel-input {
    padding-bottom: 12px;
  }

  .chat-input-pill {
    display: none;
  }

  /* Hide stage chat pill on desktop — chat lives in the panel */
  .stage-controls {
    padding-right: 24px;
    padding-left: 24px;
  }

  /* Keep floating comments above the controls bar */
  .comments-overlay {
    bottom: 312px;
  }
}

/* Mobile: the side panel becomes a bottom sheet, shown on demand */
@media (max-width: 1023.98px) {
  .side-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    height: 76dvh;
    flex-direction: column;
    border-radius: 22px 22px 0 0;
    border-top: 1px solid var(--line-2);
    border-left: none;
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.55);
    z-index: 62;
    display: none;
  }

  .room.chat-open .side-panel {
    display: flex;
    animation: sheetUp 0.32s var(--ease);
  }

  .room.chat-open .sheet-backdrop {
    display: block;
    z-index: 61;
  }

  .panel-close-visible {
    display: inline-flex !important;
  }

  #panel-close {
    display: none;
  }

  .room.chat-open #panel-close {
    display: inline-flex;
  }

  .panel-tab {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* ---- compact stage controls: no width overflow, comments stay visible ---- */
  .stage-controls {
    flex-wrap: wrap;
    gap: 6px;
    padding: 28px 10px calc(10px + var(--safe-b));
  }

  /* First (Join/Mic/Flip) and last (Gift/Like/Chat) children share the top row;
     the chat pill is re-ordered to the bottom as the last child */
  .stage-controls>.ctl-row {
    flex-direction: row;
    gap: 16px;
  }

  #viewer-ctls {
    order: 1;
    flex: 0 0 auto;
    justify-content: flex-start;
  }

  .stage-controls>.ctl-row:not(#viewer-ctls) {
    order: 2;
    flex: 0 0 auto;
  }

  .ctl-btn .cb {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .chat-input-pill {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
    padding-left: 14px;
  }

  /* Floating comments sit above the controls bar */
  .comments-overlay {
    bottom: 176px;
    right: 10px;
    max-height: 28vh;
  }

  @media (max-width: 380px) {

    /* icon-only buttons keep everything on-screen on very narrow devices */
    .ctl-btn>span:last-child:not(.cb) {
      display: none;
    }

    .stage-controls>.ctl-row {
      gap: 10px;
    }

    .comments-overlay {
      bottom: 158px;
    }
  }
}