/* ---------- страница зрителя (navy + teal) ---------- */

/* ===== экран входа ===== */

.join {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
}

.join-head { text-align: center; }

.join-logo {
  width: min(84vw, 380px);
  height: auto;
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 40px rgba(0, 194, 203, 0.18));
}

.join-tagline {
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
}

.join-card {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.emoji-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-cell:hover { background: rgba(255, 255, 255, 0.09); }
.emoji-cell:active { transform: scale(0.88); }
.emoji-cell.sel {
  background: var(--teal-soft);
  border-color: var(--teal);
}

/* цвета — ровная плитка 7×2, каждый оттенок различим */
.color-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 9px;
}

.color-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.color-dot:active { transform: scale(0.88); }
.color-dot.sel {
  border-color: var(--bg);
  box-shadow: 0 0 0 2.5px var(--teal), 0 4px 16px rgba(0, 0, 0, 0.4);
  transform: scale(1.1);
}

.join-btn {
  width: 100%;
  margin-top: 22px;
  padding: 16px;
  font-size: 17px;
}

/* ===== основной экран ===== */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px 12px calc(10px + env(safe-area-inset-bottom));
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* шапка: полноценная полоса во всю ширину, закругление снизу; чуть выше нижней */
.topbar {
  flex-shrink: 0;
  margin: -12px -12px 0;
  padding: 13px 14px;
  padding-top: calc(13px + env(safe-area-inset-top));
  background: rgba(16, 34, 45, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 22px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

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

.topbar-logo {
  display: block;
  height: 36px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0, 194, 203, 0.25));
}

.head-sep {
  width: 1px;
  align-self: stretch;
  margin: 3px 1px;
  background: var(--line);
  flex-shrink: 0;
}

.online-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  flex-shrink: 0;
}

/* зелёный человечек — «в сети» */
.online-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(163, 230, 53, 0.14);
  color: var(--lime);
  flex-shrink: 0;
}

.online-chip {
  font-size: 15px;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  line-height: 1;
}
.online-chip b { color: var(--text); }

.my-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid var(--my-color, var(--teal));
  box-shadow: 0 0 16px color-mix(in srgb, var(--my-color, #00c2cb) 40%, transparent);
  flex-shrink: 0;
}

.my-name {
  font-family: 'Unbounded', var(--font-body);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 22vw;
}

/* ===== чат ===== */

.chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 4px 10px 12px 8px;
  min-height: 0;
}

/* фон чуть тише — текст читается увереннее */
.bg-blobs i { opacity: 0.3; }

/* ===== сообщения — канон мессенджера ===== */

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.msg.own { justify-content: flex-end; }

.msg-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  font-size: 17px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--msg-color, #00c2cb) 18%, #12242f);
  border: 1.5px solid color-mix(in srgb, var(--msg-color, #00c2cb) 70%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--msg-color, #00c2cb) 25%, transparent);
  flex-shrink: 0;
}

.msg-col {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  min-width: 0;
}

.msg-bubble {
  position: relative;
  padding: 10px 14px 8px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: rgba(21, 42, 55, 0.88);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 18px rgba(0, 0, 0, 0.25);
  word-break: break-word;
}

.msg-author {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--msg-color, var(--teal));
  margin-bottom: 1px;
}

.msg-text {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.35;
  color: var(--text);
}

.msg-time {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.38);
  flex-shrink: 0;
}

/* своё сообщение — неоновый градиент в цвет зрителя, тёмный текст */
.msg.own .msg-bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--msg-color, #00c2cb), color-mix(in srgb, var(--msg-color, #00c2cb) 55%, #22d3ee));
  border: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 8px 22px color-mix(in srgb, var(--msg-color, #00c2cb) 32%, transparent);
}

.msg.own .msg-text { color: #05222c; font-weight: 700; }
.msg.own .msg-time { color: rgba(5, 34, 44, 0.55); }

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--faint);
  font-size: 15px;
  padding: 30px;
  font-weight: 700;
}
.chat-empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* реакции — ряд эмодзи внутри пузыря, рядом со временем (как в мессенджерах) */

.msg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
}

.msg-react {
  display: inline-flex;
  gap: 3px;
}

.msg.own .msg-react { margin-left: auto; }

.react-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* частые тапы не зумят страницу */
}
.react-btn i {
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  color: var(--dim);
}
.react-btn:hover { background: rgba(255, 255, 255, 0.12); }
.react-btn:active { transform: scale(0.85); }
.react-btn.mine {
  background: var(--teal-soft);
  border-color: rgba(0, 194, 203, 0.55);
}
.react-btn.mine i { color: var(--teal); }

/* реакции на своём градиентном пузыре — тёмные чипы */
.msg.own .react-btn { background: rgba(4, 30, 40, 0.14); }
.msg.own .react-btn i { color: rgba(5, 34, 44, 0.65); }
.msg.own .react-btn.mine { background: rgba(4, 30, 40, 0.32); border-color: rgba(5, 34, 44, 0.45); }
.msg.own .react-btn.mine i { color: #05222c; }

/* ===== поле ввода — полоса во всю ширину, закругление сверху ===== */

.composer {
  flex-shrink: 0;
  margin: 0 -12px calc(-10px - env(safe-area-inset-bottom));
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(16, 34, 45, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
}

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

.bar-sep {
  width: 1px;
  align-self: stretch;
  margin: 4px 0;
  background: var(--line);
  flex-shrink: 0;
}

.heart-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 77, 141, 0.35);
  background: rgba(255, 77, 141, 0.12);
  color: var(--pink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* частые тапы не зумят страницу */
}

.input.bare {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 10px 4px;
}
.input.bare:focus { box-shadow: none; }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--grad);
  color: #06222b;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, filter 0.2s;
  box-shadow: 0 6px 20px rgba(0, 194, 203, 0.3);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* частые тапы не зумят страницу */
}
.send-btn svg { display: block; }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { filter: grayscale(0.8); opacity: 0.5; cursor: not-allowed; }

.composer-foot {
  display: flex;
  justify-content: space-between;
  padding: 4px 14px 0;
}

/* тост всплывает над полем ввода, а не поверх него */
body:has(#composer:not(.hidden)) #toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ===== голосование ===== */

.vote-area {
  flex-shrink: 0;
  padding: 16px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.vote-title {
  font-size: 17px;
  text-align: center;
  letter-spacing: 0.02em;
}

.vote-options { display: flex; flex-direction: column; gap: 8px; }

.vote-opt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.12s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.vote-opt:active { transform: scale(0.98); }
.vote-opt.sel {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.vote-opt .fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 194, 203, 0.2), rgba(34, 211, 238, 0.2));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.vote-opt .vote-label { position: relative; z-index: 1; text-align: left; }
.vote-opt .vote-pct {
  position: relative;
  z-index: 1;
  font-weight: 900;
  font-size: 15px;
  min-width: 46px;
  text-align: right;
  color: var(--dim);
}

.vote-opt.winner { border-color: var(--lime); }
.vote-opt.winner .vote-pct { color: var(--lime); }

.vote-status {
  text-align: center;
  font-size: 13px;
  color: var(--dim);
  font-weight: 700;
}

.vote-submit { width: 100%; margin-top: 2px; }

/* ===== сердечко ведущему ===== */

.heart-btn:active { transform: scale(0.86); }

.heart-btn.pop { animation: heart-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

/* автовход: у зрителя с сохранённым профилем регистрация скрыта до первой отрисовки */
html.auto-join #join { display: none !important; }

/* пока тихо идёт автовход — мягкая подпись вместо мигающей регистрации */
html.auto-join body::after {
  content: 'подключаемся…';
  position: fixed;
  left: 0;
  right: 0;
  bottom: 10vh;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--dim);
  pointer-events: none;
}

/* ---------- финал шоу: донаты и VK ---------- */

.finale-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(7, 16, 23, 0.62);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.finale-card {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 20px 20px;
  border-radius: 26px;
  text-align: center;
  /* внутри оверлея с backdrop-filter вложенный blur ломает отрисовку
     карточки в Chromium — содержимое перестаёт рисоваться */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.finale-logo { height: 46px; width: auto; }

.finale-heading {
  font-size: 21px;
  line-height: 1.3;
  margin-bottom: 4px;
}

.finale-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  text-decoration: none;
  color: #ffffff;
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.finale-link:active { transform: scale(0.98); }

.finale-link.donate {
  background: linear-gradient(100deg, #00c2cb, #22d3ee);
  color: #06222b;
  box-shadow: 0 10px 30px rgba(0, 194, 203, 0.3);
}
.finale-link.vk {
  background: linear-gradient(100deg, #0077ff, #3a8fff);
  box-shadow: 0 10px 30px rgba(0, 119, 255, 0.32);
}

.finale-ico {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
}
.finale-ico-vk {
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.finale-link-txt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  min-width: 0;
}
.finale-link-txt b { font-size: 16px; font-weight: 900; }
.finale-link-txt i {
  font-style: normal;
  font-size: 12px;
  opacity: 0.72;
  word-break: break-all;
  text-align: left;
}

.finale-arr { font-weight: 900; font-size: 18px; opacity: 0.8; }
