:root {
  --acc: #00E5CC;
  --live: #FF2D55;
  --txt: #fff;
  --pill: rgba(0, 0, 0, .32);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  color: var(--txt);
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }

/* Рамка обрезает увеличенное видео, чтобы страница не уезжала вбок */
.stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
#cam, #camBg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Пустые места вокруг кадра — размытая копия той же картинки */
#camBg { background: #000; filter: blur(28px) brightness(.65); transform: scale(1.2); }
#camBg.mirror { transform: scale(-1.2, 1.2); }
/* Кадр целиком, ползунок «Масштаб» увеличивает его через --s (1 = весь кадр) */
#cam { object-fit: contain; transform: scale(var(--s, 1)); }
#cam.mirror { transform: scale(calc(var(--s, 1) * -1), var(--s, 1)); }
.nocam {
  position: fixed; inset: 0;
  background: radial-gradient(120% 80% at 30% 20%, #1d3b3a 0%, #0b1416 55%, #000 100%);
}

.ui { position: fixed; inset: 0; pointer-events: none; }
.ui button, .ui .fake-input { pointer-events: auto; }

/* Верх */
.top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-top) + 12px) 12px 28px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  background: linear-gradient(rgba(0,0,0,.45), transparent);
}
.host {
  display: flex; align-items: center; gap: 8px;
  background: var(--pill); border-radius: 999px; padding: 4px 14px 4px 4px; min-width: 0; flex: 0 1 auto;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
/* Кольцо вокруг аватара, как у эфира в Instagram */
.ring {
  flex: none; width: 40px; height: 40px; border-radius: 50%; padding: 2px;
  background: linear-gradient(45deg, #feda75, #fa7e1e 30%, #d62976 60%, #962fbf 80%, #4f5bd5);
}
.ava {
  width: 100%; height: 100%; border-radius: 50%;
  background: linear-gradient(135deg, var(--acc), #0a6f8f) center/cover no-repeat;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #00211d;
  border: 2px solid #111;
}
.host-txt { min-width: 0; line-height: 1.15; }
.name { display: flex; align-items: center; gap: 3px; font-weight: 700; font-size: 13px; }
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tick { width: 14px; height: 14px; flex: none; }
.sub { font-size: 10.5px; font-weight: 600; opacity: .85; white-space: nowrap; }
.follow {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--acc); color: #00211d; font-weight: 800; font-size: 18px; line-height: 1;
  margin-left: 2px;
}
.right { display: flex; align-items: center; gap: 5px; flex: none; }
.live {
  background: var(--live); font-weight: 800; font-size: 11px; letter-spacing: .06em;
  padding: 5px 8px; border-radius: 6px;
}
.viewers {
  display: flex; align-items: center; gap: 4px;
  background: var(--pill); padding: 4px 9px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.viewers svg { width: 14px; height: 14px; }
.x { width: 24px; height: 28px; display: grid; place-items: center; }
.x svg { width: 20px; height: 20px; }

/* Чат */
.chat {
  position: absolute; left: 12px; right: 84px;
  bottom: calc(var(--safe-bot) + 72px);
  max-height: 38vh;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent 0, #000 22%);
          mask-image: linear-gradient(transparent 0, #000 22%);
}
.msg {
  display: flex; align-items: flex-start; gap: 8px;
  animation: msgIn .28s ease-out both;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.msg .a {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff;
  text-shadow: none;
}
.msg .b { min-width: 0; line-height: 1.25; }
.msg .n { font-size: 11.5px; font-weight: 600; opacity: .72; }
.msg .t { font-size: 13.5px; font-weight: 600; word-wrap: break-word; }
.msg.join .t { font-weight: 500; opacity: .8; font-size: 12.5px; }
.msg.gift .t { color: var(--acc); font-weight: 700; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Сердечки */
.hearts { position: absolute; right: 18px; bottom: calc(var(--safe-bot) + 70px); width: 60px; height: 45vh; }
.heart {
  position: absolute; bottom: 0; left: 18px; width: 26px; height: 26px;
  animation: float var(--d, 2.6s) ease-out forwards;
}
@keyframes float {
  0%   { opacity: 0; transform: translate(0, 0) scale(.4); }
  12%  { opacity: 1; transform: translate(0, -20px) scale(1); }
  100% { opacity: 0; transform: translate(var(--sx, 0px), -42vh) scale(.9) rotate(var(--r, 0deg)); }
}

/* Донат */
.donation {
  position: absolute; left: 50%; top: calc(var(--safe-top) + 92px);
  transform: translate(-50%, -12px) scale(.92); opacity: 0;
  min-width: 220px; max-width: 82vw;
  background: rgba(0, 20, 18, .62);
  border: 1.5px solid var(--acc);
  box-shadow: 0 0 24px rgba(0, 229, 204, .35);
  border-radius: 18px; padding: 10px 16px 12px;
  text-align: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity .25s, transform .35s cubic-bezier(.2, 1.4, .4, 1);
}
.donation.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.donation .dn { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 600; opacity: .9; }
.donation .dn .a { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 800; }
.donation .amt { font-size: 30px; font-weight: 800; color: var(--acc); margin: 2px 0; letter-spacing: -.01em; }
.donation .dm { font-size: 13px; font-weight: 600; }

/* Низ */
.bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 12px calc(var(--safe-bot) + 14px);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.4));
}
.fake-input {
  flex: 1; height: 40px; border-radius: 999px; background: var(--pill);
  display: flex; align-items: center; padding: 0 16px;
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,.75);
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ic {
  width: 40px; height: 40px; border-radius: 50%; background: var(--pill); display: grid; place-items: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ic svg { width: 21px; height: 21px; }
.like { color: var(--live); }
.like:active { transform: scale(.9); }

/* Индикатор записи — только на экране, в ролик не рисуется */
.rec-dot {
  position: fixed; z-index: 6; left: 12px; top: calc(var(--safe-top) + 64px);
  background: rgba(0,0,0,.45); color: #fff; border-radius: 999px; padding: 4px 10px;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rec-dot::first-letter { color: var(--live); }
.rec-dot[hidden] { display: none; }

/* Секретная зона */
.secret { position: fixed; left: 0; top: 0; width: 72px; height: calc(var(--safe-top) + 64px); z-index: 5; }

/* Старт */
.start {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: radial-gradient(120% 80% at 50% 30%, #0f3532 0%, #050b0c 70%);
}
.start[hidden] { display: none; }
.start-card { text-align: center; padding: 0 24px; }
.start-logo { font-size: 44px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 28px; }
.start-logo::after { content: ''; display: block; width: 48px; height: 4px; border-radius: 2px; background: var(--acc); margin: 10px auto 0; }
.hint { font-size: 12.5px; opacity: .6; margin-top: 18px; line-height: 1.4; }

.btn-main, .btn-acc, .btn-sec {
  display: block; width: 100%; border-radius: 14px; padding: 14px 18px;
  font-weight: 700; font-size: 15px;
}
.btn-main { background: var(--acc); color: #00211d; }
.start .btn-main { min-width: 240px; font-size: 17px; padding: 16px 22px; }
.btn-acc { background: rgba(0, 229, 204, .14); color: var(--acc); border: 1px solid rgba(0, 229, 204, .4); }
.btn-sec { background: rgba(255,255,255,.08); color: #fff; }
.btn-sec[hidden] { display: none; }
.btn-rec {
  display: block; width: 100%; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 15px;
  background: rgba(255,45,85,.15); color: #ff5c7a; border: 1px solid rgba(255,45,85,.45);
}
.btn-rec.on { background: var(--live); color: #fff; }

/* Настройки */
.settings {
  width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  border: 0; border-radius: 20px; padding: 0;
  background: #0d1416; color: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.settings::backdrop { background: rgba(0,0,0,.55); }
.settings form { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.settings h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; opacity: .95; }
.settings input, .settings select {
  font: inherit; font-size: 15px; font-weight: 500; color: #fff;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
.settings input[type=file] { font-size: 13px; padding: 8px; }
.settings select option { background: #0d1416; }
.settings input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--acc); height: 28px; }
.settings .range-hint { display: flex; justify-content: space-between; font-size: 11px; font-weight: 500; opacity: .55; margin-top: -4px; }
.settings .cam-info { margin: -4px 0 0; font-size: 11.5px; opacity: .55; white-space: pre-line; }
.settings label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 14px; }
.settings label.check input { width: 20px; height: 20px; padding: 0; accent-color: var(--acc); }
.settings .row { display: flex; gap: 10px; }
.settings .row > * { flex: 1; font-size: 14px; padding: 12px 10px; }
