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

html, body {
  height: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, #1d1d28, #000);
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#video.mirror { transform: scaleX(-1); }

#no-camera {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  padding: 24px;
}
#no-camera[hidden] { display: none; }
.no-camera-icon { font-size: 48px; }

/* ---- top bar ---- */
#top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + 14px) 40px calc(env(safe-area-inset-left) + 14px);
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0));
  pointer-events: none;
}

.host {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  padding: 4px 14px 4px 4px;
  min-width: 0;
  max-width: 60vw;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.avatar {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff3d6e, #ff9f1c);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}
.host-text { min-width: 0; }
.host-name, .stream-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.host-name { font-weight: 700; font-size: 15px; }
.stream-title { font-size: 12px; opacity: 0.8; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.live-badge, .pill {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 6px;
  line-height: 1;
  white-space: nowrap;
}
.live-badge {
  background: #ff2d55;
  letter-spacing: 0.05em;
  animation: pulse 2s ease-in-out infinite;
}
.pill {
  background: rgba(0, 0, 0, 0.45);
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.pill[hidden] { display: none; }
@keyframes pulse { 50% { opacity: 0.75; } }

/* ---- comments ---- */
#comments {
  position: absolute;
  left: calc(env(safe-area-inset-left) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  width: min(420px, 72vw);
  max-height: 42vh;
  list-style: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to top, #000 70%, transparent);
  mask-image: linear-gradient(to top, #000 70%, transparent);
  pointer-events: none;
}
.comment {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 14px;
  padding: 6px 10px 6px 6px;
  align-self: flex-start;
  max-width: 100%;
  font-size: 15px;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  animation: comment-in 0.25s ease-out;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.comment .c-avatar {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #111;
  text-shadow: none;
}
.comment .c-body { min-width: 0; overflow-wrap: anywhere; }
.comment .c-user { font-weight: 700; font-size: 13px; margin-right: 6px; }
@keyframes comment-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* ---- reactions ---- */
#reactions {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 10px);
  bottom: calc(env(safe-area-inset-bottom) + 70px);
  width: 90px;
  height: 55vh;
  pointer-events: none;
}
.reaction {
  position: absolute;
  bottom: 0;
  font-size: 30px;
  animation: float-up var(--dur, 3s) ease-out forwards;
  will-change: transform, opacity;
}
@keyframes float-up {
  0%   { transform: translate(0, 0) scale(0.4); opacity: 0; }
  10%  { transform: translate(0, -20px) scale(1.1); opacity: 1; }
  50%  { transform: translate(var(--drift, 10px), -26vh) scale(1); }
  100% { transform: translate(calc(var(--drift, 10px) * -1), -52vh) scale(0.9); opacity: 0; }
}

/* ---- controls ---- */
#controls {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  gap: 8px;
  opacity: 0.35;
  transition: opacity 0.3s;
}
#controls:hover, #controls:focus-within { opacity: 1; }
#controls button {
  width: 42px; height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
#controls button[hidden] { display: none; }

/* ---- start screen ---- */
#start {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10;
  padding: 16px;
}
#start[hidden] { display: none; }
.start-card { text-align: center; max-width: 340px; }
.start-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ff2d55;
  margin: 0 auto 18px;
  box-shadow: 0 0 0 0 rgba(255, 45, 85, 0.7);
  animation: ring 1.6s infinite;
}
@keyframes ring { 70% { box-shadow: 0 0 0 16px rgba(255, 45, 85, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 45, 85, 0); } }
.start-card h1 { font-size: 24px; margin-bottom: 10px; }
.start-card p { font-size: 14px; opacity: 0.7; margin-bottom: 24px; line-height: 1.4; }
#btn-start {
  border: 0;
  border-radius: 999px;
  padding: 14px 40px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: #ff2d55;
  cursor: pointer;
}

/* ---- offline screen ---- */
#offline {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, #1d1d28, #000);
  z-index: 5;
  padding: 16px;
  text-align: center;
}
#offline[hidden] { display: none; }
.offline-card { max-width: 340px; }
.offline-icon { font-size: 48px; margin-bottom: 14px; }
.offline-card h1 { font-size: 24px; margin-bottom: 10px; }
.offline-card p { font-size: 14px; opacity: 0.7; line-height: 1.4; }

@media (min-width: 900px) {
  .comment { font-size: 17px; }
  .reaction { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-badge, .start-dot { animation: none; }
}
