/* Voice Debate Show — оформление (тёмная и светлая темы). Логику не трогает. */
:root {
  color-scheme: dark;
  --bg: #0b0d12; --panel: #151922; --panel2: #1b2030; --line: #ffffff14; --line2: #ffffff22;
  --text: #eceef5; --dim: #9aa1b4; --input: #0f1219;
  --a: #4f8cff; --b: #ff9f43;
  --shadow: 0 18px 50px -24px #000c;
  --ease: cubic-bezier(.22,.8,.24,1);
  --radius: 20px;
  --theme-dur: .7s;
  --idle-op: .7;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f8; --panel: #ffffff; --panel2: #f4f6fc; --line: #1b223314; --line2: #1b223326;
  --text: #1a2133; --dim: #667089; --input: #f3f5fb;
  --a: #2f6df6; --b: #f28a1a;
  --shadow: 0 18px 40px -22px #3a4a7a55;
  --idle-op: 1; /* в светлой теме аватары не гасим: полупрозрачность выглядела как размытие */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input { font: inherit; color: inherit; }
object { pointer-events: none; }
.ico { width: 20px; height: 20px; flex: none; display: block; }

/* ---------- Фон: два слоя, плавно перетекают друг в друга ---------- */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; transition: opacity var(--theme-dur) ease; }
.bg-dark {
  background:
    radial-gradient(60vw 50vh at 12% 8%, #4f8cff26, transparent 70%),
    radial-gradient(55vw 50vh at 92% 92%, #ff9f4322, transparent 70%),
    radial-gradient(40vw 40vh at 55% 40%, #7c5cff14, transparent 70%),
    #0b0d12;
}
.bg-light {
  background:
    radial-gradient(60vw 50vh at 10% 6%, #8fb4ff55, transparent 70%),
    radial-gradient(55vw 50vh at 92% 94%, #ffc78a55, transparent 70%),
    radial-gradient(40vw 40vh at 55% 40%, #c9b8ff40, transparent 70%),
    #eef1f8;
}
:root[data-theme="dark"] .bg-light, :root:not([data-theme="light"]) .bg-light { opacity: 0; }
:root[data-theme="light"] .bg-dark { opacity: 0; }
.bg::after {
  content: ""; position: absolute; inset: -20%;
  background: radial-gradient(30vw 30vw at 30% 30%, #ffffff0a, transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(14%, 10%) scale(1.15); } }

/* ---------- Каркас ---------- */
.app {
  position: relative; z-index: 1; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px;
  padding: 16px 20px 14px; max-width: 1680px; margin: 0 auto;
}

/* Плавная смена темы: на время перехода включаем переходы для всех цветов (кроме аватаров). */
.theme-anim *:not(.stage):not(.stage *):not(.bg):not(svg *) {
  transition: background-color var(--theme-dur) ease, color var(--theme-dur) ease,
              border-color var(--theme-dur) ease, box-shadow var(--theme-dur) ease !important;
}

/* ---------- Верхняя панель ---------- */
.topbar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { width: 40px; height: 40px; filter: drop-shadow(0 6px 12px #4f8cff55); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-2px) rotate(-3deg); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 12px; color: var(--dim); }

.topic {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 0 14px; height: 44px; border-radius: 14px;
  background: var(--input); border: 1px solid var(--line);
  transition: border-color .25s, box-shadow .25s, background-color .25s;
}
.topic:focus-within, .controls:focus-within { border-color: var(--a); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a) 22%, transparent); }
.topic input, .controls input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 15px; }
.topic { position: relative; }
.photo-btn { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; border: 0; background: none; color: var(--dim); cursor: pointer; transition: color .2s, background-color .2s; }
.photo-btn:hover { color: var(--text); background: color-mix(in srgb, var(--a) 18%, transparent); }
.photo-btn .ico { width: 20px; height: 20px; }
.topic.dragover { border-color: var(--a); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a) 28%, transparent); }
.photo-chip { position: absolute; left: 0; top: calc(100% + 8px); z-index: 30; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 10px 30px -10px #000a; font-size: 13px; white-space: nowrap; }
.photo-chip[hidden] { display: none; }
.photo-chip img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.photo-chip.busy #photoState::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border-radius: 50%; border: 2px solid var(--dim); border-top-color: transparent; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip-link { background: none; border: 0; color: var(--a); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.chip-x { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.chip-x:hover { color: var(--text); }
.photo-card textarea { width: 100%; min-height: 190px; max-height: 46vh; resize: vertical; margin: 0 0 12px; padding: 12px; border-radius: 12px; background: var(--input); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; text-align: left; outline: 0; }
.photo-card textarea:focus, .photo-card input:focus { border-color: var(--a); }
.photo-card input { width: 100%; margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--input); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 15px; outline: 0; }
.photo-card label { display: block; text-align: left; font-size: 12px; color: var(--dim); margin: 0 0 4px; }
.photo-card { width: min(560px, 100%); }
.topic input::placeholder, .controls input::placeholder { color: var(--dim); }

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

/* ---------- Кнопки ---------- */
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line2);
  background: var(--panel2); cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .25s, filter .25s, background-color .25s, opacity .25s;
}
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled) { transform: translateY(0) scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, #7c5cff, #4f8cff 60%, #22b8f0);
  box-shadow: 0 10px 24px -10px #4f8cffcc;
  background-size: 160% 160%; background-position: 0% 50%;
}
.btn.primary:hover:not(:disabled) { background-position: 100% 50%; box-shadow: 0 14px 30px -10px #4f8cffee; }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--panel2); }
.icon-btn { width: 44px; padding: 0; }

.theme-btn { position: relative; overflow: hidden; }
.theme-btn .ico { position: absolute; transition: transform .6s var(--ease), opacity .45s ease; }
:root[data-theme="dark"] .theme-btn .sun, :root:not([data-theme="light"]) .theme-btn .sun { transform: rotate(-120deg) scale(.3); opacity: 0; }
:root[data-theme="light"] .theme-btn .moon { transform: rotate(120deg) scale(.3); opacity: 0; }
.theme-btn:hover .ico { filter: drop-shadow(0 0 6px #fbbf2488); }

.icon-btn.mic.recording { animation: rec 1.1s ease-in-out infinite; border-color: #f43f5e; }
@keyframes rec { 50% { box-shadow: 0 0 0 8px #f43f5e33; } }

/* ---------- Доска: три колонки ---------- */
.board {
  display: grid; grid-template-columns: clamp(230px, 22vw, 310px) minmax(0, 1fr) clamp(230px, 22vw, 310px);
  gap: 16px; min-height: 0;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 0;
}
.stage-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px 14px 18px; position: relative; overflow: hidden; }
.stage-wrap::before {
  content: ""; position: absolute; inset: 0; opacity: .9; pointer-events: none;
  background: radial-gradient(90% 55% at 50% 0%, color-mix(in srgb, var(--c) 20%, transparent), transparent 70%);
}
.side-a { --c: var(--a); } .side-b { --c: var(--b); }

.stage {
  position: relative; width: 100%; aspect-ratio: 1; order: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: var(--idle-op); transition: opacity .35s ease;
}
.stage.speaking { opacity: 1; }
.stage.speaking::after {
  content: ""; position: absolute; inset: 4%; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--glow); opacity: 0; animation: ring 1.8s ease-out infinite;
}
@keyframes ring { 0% { transform: scale(.9); opacity: .6; } 100% { transform: scale(1.14); opacity: 0; } }
.stage object { width: 88%; height: 88%; }

.plate { order: 2; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.plate b { font-size: 20px; letter-spacing: .2px; }
.plate span { font-size: 13px; color: var(--dim); }
.plate.a b { color: var(--a); } .plate.b b { color: var(--b); }

.rating { order: 3; width: 100%; margin-top: auto; padding: 12px 14px; border-radius: 16px; background: var(--panel2); border: 1px solid var(--line); position: relative; }
.rating-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rating-title { display: inline-flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
.rating-title .ico { width: 18px; height: 18px; }
.score-num { font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.score-num.a { color: var(--a); } .score-num.b { color: var(--b); }
.bar { height: 8px; border-radius: 99px; background: var(--input); overflow: hidden; }
.bar-fill { height: 100%; width: 50%; border-radius: 99px; }
.rating.a .bar-fill { background: linear-gradient(90deg, #7c5cff, var(--a)); box-shadow: 0 0 14px color-mix(in srgb, var(--a) 70%, transparent); }
.rating.b .bar-fill { background: linear-gradient(90deg, #ff6b6b, var(--b)); box-shadow: 0 0 14px color-mix(in srgb, var(--b) 70%, transparent); }
.rating.b .bar-fill { width: 50%; }

/* ---------- Лента реплик ---------- */
.feed-card { display: flex; flex-direction: column; overflow: hidden; }
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line); }
.chip .ico { width: 16px; height: 16px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); min-height: 20px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 0 #34d39966; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px #34d39900; } 100% { box-shadow: 0 0 0 0 #34d39900; } }

.feed {
  flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line2) transparent;
}
.feed.empty::before {
  content: attr(data-hint); margin: auto; max-width: 420px; text-align: center; color: var(--dim);
  padding: 26px 22px; border: 1px dashed var(--line2); border-radius: 18px; animation: fadein .8s ease both;
}
.msg { max-width: 84%; animation: bubble .5s var(--ease) both; }
.msg.a { align-self: flex-start; --c: var(--a); }
.msg.b { align-self: flex-end; --c: var(--b); }
.msg.u { align-self: center; max-width: 70%; --c: #34d399; }
@keyframes bubble { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.msg-head { display: flex; align-items: center; gap: 8px; margin: 0 6px 6px; }
.msg.b .msg-head { flex-direction: row-reverse; }
.msg-head b { color: var(--c); font-size: 14px; }
.msg-head .chip { padding: 2px 9px; font-size: 11px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); border-color: color-mix(in srgb, var(--c) 30%, transparent); }
.bubble {
  padding: 12px 16px; border-radius: 18px; line-height: 1.55; font-size: 15px;
  background: color-mix(in srgb, var(--c) 11%, var(--panel2));
  border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);
  box-shadow: 0 10px 26px -18px var(--c);
  overflow-wrap: anywhere;
}
.msg.a .bubble { border-top-left-radius: 6px; } .msg.b .bubble { border-top-right-radius: 6px; }
.caret { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 12px; color: var(--c); font-style: italic; vertical-align: baseline; }
.caret::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; transform: scale(.7); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Нижняя панель ---------- */
.composer { display: flex; flex-direction: column; gap: 6px; }
.controls {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color .25s, box-shadow .25s;
}
.pencil { width: 22px; height: 22px; }
.status-row { font-size: 12px; color: var(--dim); padding: 0 8px; }
.ws { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #f43f5e; transition: background-color .3s, box-shadow .3s; }
.dot.connected { background: #34d399; box-shadow: 0 0 10px #34d399aa; }

/* ---------- Появление страницы ---------- */
.topbar, .board > *, .composer { animation: rise .7s var(--ease) both; }
.board > :nth-child(1) { animation-delay: .08s; } .board > :nth-child(2) { animation-delay: .16s; } .board > :nth-child(3) { animation-delay: .24s; }
.composer { animation-delay: .32s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .topbar { grid-template-columns: 1fr auto; }
  .topic { grid-column: 1 / -1; order: 3; }
  .board { grid-template-columns: 1fr 1fr; }
  .feed-card { grid-column: 1 / -1; order: 3; height: 55vh; }
  .brand-text span { display: none; }
}
@media (max-width: 560px) { .btn span { display: none; } .btn { padding: 0 14px; } .btn.primary span { display: inline; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}


/* ---------- Судья ---------- */
.feed-card { position: relative; }
.judge { display: flex; align-items: center; gap: 12px; margin: 12px 18px 0; padding: 9px 14px; border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, #f59e0b 12%, var(--panel2)), var(--panel2)); border: 1px solid color-mix(in srgb, #f59e0b 28%, transparent); }
.judge-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); }
.judge-ico .ico { width: 22px; height: 22px; transform-origin: 50% 20%; }
.judge[data-state="thinking"] .judge-ico .ico { animation: weigh 1.4s ease-in-out infinite; }
@keyframes weigh { 0%,100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
.judge[data-state="verdict"] .judge-ico { animation: pop .6s var(--ease); box-shadow: 0 0 0 4px #f59e0b33; }
@keyframes pop { 0% { transform: scale(.8); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.judge-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.judge-text b { font-size: 13px; } .judge-text small { font-weight: 500; color: var(--dim); margin-left: 4px; }
.judge-text span { font-size: 12.5px; color: var(--dim); }
.judge-delta { font-weight: 700; font-size: 13px; padding: 4px 11px; border-radius: 99px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); animation: pop .5s var(--ease); }
.judge-delta[hidden] { display: none; }

/* ---------- Победитель ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }
.victory { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; border-radius: inherit; overflow: hidden;
  background: radial-gradient(70% 60% at 50% 45%, color-mix(in srgb, var(--panel) 55%, transparent), color-mix(in srgb, var(--panel) 92%, transparent));
  backdrop-filter: blur(3px); animation: fadein .5s ease both; }
.victory[hidden] { display: none; }
.v-rays { position: absolute; width: 150%; aspect-ratio: 1; left: -25%; top: 50%; margin-top: -75%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--c, #f59e0b) 22%, transparent) 0 8deg, transparent 8deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 0, transparent 62%); mask: radial-gradient(circle, #000 0, transparent 62%);
  animation: spin 24s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.v-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 40px 24px; border-radius: 26px; text-align: center;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--c, #f59e0b) 50%, transparent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--c, #f59e0b) 14%, transparent), 0 30px 70px -20px color-mix(in srgb, var(--c, #f59e0b) 60%, #000);
  animation: vin .9s cubic-bezier(.2,1.3,.3,1) both; }
@keyframes vin { from { opacity: 0; transform: translateY(40px) scale(.6) rotate(-4deg); } to { opacity: 1; transform: none; } }
.v-crown { width: 84px; height: 63px; filter: drop-shadow(0 8px 14px #f59e0b88); animation: crown 2.4s ease-in-out .9s infinite; }
@keyframes crown { 50% { transform: translateY(-6px) rotate(-4deg) scale(1.06); } }
.v-label { font-size: 13px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); }
.v-name { font-size: 40px; font-weight: 800; line-height: 1.1; color: var(--c, var(--text)); text-shadow: 0 0 28px color-mix(in srgb, var(--c, #f59e0b) 55%, transparent); }
.v-score { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.v-score .sa { color: var(--a); } .v-score .sb { color: var(--b); }
.v-judge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); margin: 2px 0 10px; }
.v-judge .ico { width: 16px; height: 16px; }
.victory.draw .v-crown { display: none; }

.stage-wrap.is-winner { border-color: var(--c); animation: winglow 2s ease-in-out infinite; transform: translateY(-4px); transition: transform .6s var(--ease), border-color .5s; }
@keyframes winglow { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent), 0 0 60px 6px color-mix(in srgb, var(--c) 45%, transparent); } }
.stage-wrap.is-loser .plate, .stage-wrap.is-loser .rating { opacity: .55; transition: opacity .6s; }
.win-crown { position: absolute; top: 6px; left: 50%; width: 64px; height: 48px; margin-left: -32px; z-index: 5; pointer-events: none;
  filter: drop-shadow(0 6px 10px #f59e0b99); animation: crowndrop 1s cubic-bezier(.2,1.4,.3,1) both, crown 2.4s ease-in-out 1s infinite; }
@keyframes crowndrop { from { opacity: 0; transform: translateY(-60px) rotate(-25deg) scale(.5); } to { opacity: 1; transform: none; } }


/* ---------- Окно итогов (карточка = та же, что уходит в мессенджер) ---------- */
.v-actions { display: flex; gap: 10px; margin-top: 6px; }
.results { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 70%, #000 30%); backdrop-filter: blur(8px); animation: fadein .35s ease both; }
.results[hidden] { display: none; }
.res-panel { display: flex; gap: 20px; align-items: stretch; max-height: 100%; animation: vin .6s cubic-bezier(.2,1.2,.3,1) both; }
.res-stage { position: relative; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px -20px #000a; border: 1px solid var(--line2); background: var(--panel); flex: none; }
.res-stage iframe { position: absolute; left: 0; top: 0; width: 1080px; height: 1350px; border: 0; transform-origin: 0 0; }
.res-side { width: 230px; display: flex; flex-direction: column; gap: 12px; padding: 20px 16px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); align-self: flex-start; }
.res-side h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.res-note { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.4; }
.res-side .btn { width: 100%; text-decoration: none; }
.res-variants { display: flex; flex-wrap: wrap; gap: 6px; }
.res-variants button { flex: 1 1 40%; height: 34px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; font-size: 12.5px; transition: background-color .2s, border-color .2s, transform .2s; }
.res-variants button:hover { transform: translateY(-1px); }
.res-variants button.on { border-color: var(--a); background: color-mix(in srgb, var(--a) 16%, var(--panel2)); }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 90; transform: translateX(-50%); padding: 12px 20px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line2); box-shadow: var(--shadow); animation: rise .4s var(--ease) both; max-width: 90vw; }
#startBtn.attn { animation: attn 1.6s ease-in-out infinite; }
@keyframes attn { 50% { box-shadow: 0 0 0 10px #4f8cff33, 0 10px 24px -10px #4f8cffcc; } }
@media (max-width: 760px) { .res-panel { flex-direction: column; overflow: auto; } .res-side { width: 100%; align-self: stretch; } }

/* ---------- Фото-аватары (photo-avatar.js) ---------- */
.stage.has-photo object { display: none; }
/* фото-аватар во время речи не пульсирует кольцом: ничего вокруг модели не двигается (светится только рамка) */
.stage.has-photo.speaking::after { animation: none; display: none; }
.stage.thinking { opacity: 0.85; }

.pa-frame {
  position: relative;
  width: var(--pa-size, 86%);
  aspect-ratio: 1;
  background: #b4b4b2; /* серый фон картинок: если кадр чуть сдвинулся, шва не видно */
  overflow: hidden;
}
.pa-circle { border-radius: 50%; box-shadow: 0 0 0 3px #ffffff14, 0 12px 30px -10px #000a; }
.pa-rounded { border-radius: 28px; box-shadow: 0 0 0 3px #ffffff14, 0 12px 30px -10px #000a; }
.pa-none { background: none; overflow: visible; border-radius: 0; }

.pa-wrap { position: absolute; inset: 0; will-change: transform; }
.pa-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  transform-origin: var(--fx) var(--fy);
  /* --ax/--ay: выравнивание кадра относительно neutral (AVATAR_CONFIG.align) */
  transform: translate(calc(var(--tx) + var(--ax, 0%)), calc(var(--ty) + var(--ay, 0%))) scale(var(--zoom));
  visibility: hidden;
  user-select: none; pointer-events: none;
}
.pa-layer.on { visibility: visible; }
.pa-eyes {
  position: absolute; inset: 0; width: 100%; height: 100%;
  transform-origin: var(--fx) var(--fy);
  transform: translate(calc(var(--tx) + var(--ax, 0%)), calc(var(--ty) + var(--ay, 0%))) scale(var(--zoom));
  z-index: 9000; display: none; pointer-events: none;
}
.pa-eyes canvas { position: absolute; }
.pa-none .pa-layer { filter: drop-shadow(0 12px 18px #0009); }

/* ?debug=1 */
.pa-debug { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.pa-debug button { padding: 6px 10px; font-size: 12px; background: #ffffff14; color: var(--text); }
.pa-debug button.missing { opacity: 0.45; }

/* Свечение рамки говорящего (цвет — по слоту) */
#stageA { --glow: var(--a); }
#stageB { --glow: var(--b); }
.pa-frame { transition: box-shadow 0.3s ease; }
.stage.speaking .pa-circle,
.stage.speaking .pa-rounded {
  box-shadow: 0 0 0 3px var(--glow), 0 0 30px 8px color-mix(in srgb, var(--glow) 45%, transparent), 0 12px 30px -10px #000a;
}
.judge-text span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Окно ошибки провайдера: закончились токены/кредиты, неверный ключ, лимит */
.err-modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; background: #05060bcc; backdrop-filter: blur(6px); animation: rise .3s var(--ease) both; }
.err-card { width: min(440px, 100%); padding: 28px 26px 22px; border-radius: 22px; text-align: center; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 30px 80px -20px #000c; }
.err-card h3 { margin: 14px 0 8px; font-size: 20px; }
.err-card p { margin: 0 0 20px; color: var(--dim); line-height: 1.5; font-size: 15px; }
.err-ico { width: 62px; height: 62px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #fff; background: linear-gradient(135deg, #f43f5e, #f59e0b); box-shadow: 0 0 0 8px #f43f5e22; animation: errpulse 1.8s ease-in-out infinite; }
.err-modal[data-code="auth"] .err-ico, .err-modal[data-code="rate"] .err-ico { background: linear-gradient(135deg, #6366f1, #06b6d4); box-shadow: 0 0 0 8px #6366f122; }
.err-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.err-actions .btn { text-decoration: none; }
@keyframes errpulse { 50% { box-shadow: 0 0 0 14px #f43f5e10; } }

/* Окно «Мнение судьи» */
.judge-modal { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 20px; background: #05060bcc; backdrop-filter: blur(6px); overflow: auto; animation: rise .3s var(--ease) both; }
.jm-card { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px 26px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 30px 80px -20px #000c; display: flex; flex-direction: column; gap: 14px; }
.jm-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.jm-card h3 { margin: 0; font-size: 20px; }
.jm-badge { font-size: 12px; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.jm-head { margin: 0; font-size: 17px; } .jm-head b { color: var(--dim); font-weight: 600; margin-left: 6px; }
.jm-card h5 { margin: 0 0 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.jm-card section p { margin: 0; line-height: 1.55; }
.jm-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.jm-side { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); }
.jm-side[data-k="A"] { border-top: 3px solid var(--a); } .jm-side[data-k="B"] { border-top: 3px solid var(--b); }
.jm-side.win { box-shadow: 0 0 0 1px #fde04766, 0 10px 30px -14px #fde047aa; }
.jm-side h4 { margin: 0 0 8px; font-size: 15px; } .jm-side h4 small { color: var(--dim); font-weight: 500; margin-left: 4px; }
.jm-side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; }
.jm-side li::before { display: inline-block; width: 1.2em; font-weight: 700; }
.jm-side li.plus::before { content: "+"; color: #34d399; } .jm-side li.minus::before { content: "−"; color: #f87171; }
.jm-opinion { padding: 12px 14px; border-radius: 14px; background: #ffffff0a; border: 1px dashed var(--line2); }
@media (max-width: 560px) { .jm-sides { grid-template-columns: 1fr; } }

/* Согласие на отправку итогов в WhatsApp */
.ask-card { position: fixed; left: 50%; bottom: 26px; z-index: 80; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; max-width: min(560px, 94vw); background: var(--panel); border: 1px solid var(--line2); box-shadow: var(--shadow); animation: rise .45s var(--ease) both; flex-wrap: wrap; }
.ask-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; flex: none; }
.ask-txt { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; } .ask-txt span { font-size: 13px; color: var(--dim); }
.ask-btns { display: flex; gap: 8px; }

/* Окно публикации Reels */
.pub-modal { position: fixed; inset: 0; z-index: 88; display: grid; place-items: center; padding: 20px; background: #05060bcc; backdrop-filter: blur(6px); animation: rise .3s var(--ease) both; }
.pm-card { width: min(420px, 100%); padding: 26px; border-radius: 22px; text-align: center; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 30px 80px -20px #000c; }
.pm-card h3 { margin: 0 0 14px; font-size: 20px; }
.pm-hint { margin: 12px 0 0; color: var(--dim); font-size: 14px; line-height: 1.5; }
.pm-spin { width: 54px; height: 54px; margin: 0 auto 14px; } .pm-spin i { display: block; width: 100%; height: 100%; border-radius: 50%; border: 4px solid var(--line2); border-top-color: #e11d2a; animation: pmspin .9s linear infinite; }
.pm-steps { list-style: none; margin: 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 9px; }
.pm-steps li { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 15px; transition: color .3s; }
.pm-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line2); flex: none; }
.pm-steps li.done { color: var(--fg, inherit); } .pm-steps li.done .pm-dot { background: #34d399; border-color: #34d399; }
.pm-steps li.now { color: var(--fg, inherit); font-weight: 600; } .pm-steps li.now .pm-dot { border-color: #e11d2a; background: #e11d2a; animation: pmpulse 1s ease-in-out infinite; }
.pm-ok { width: 74px; height: 74px; margin: 0 auto; } .pm-ok svg { width: 100%; height: 100%; fill: none; stroke: #34d399; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.pm-ok circle { stroke-dasharray: 152; stroke-dashoffset: 152; animation: pmdraw .6s ease forwards; } .pm-ok path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: pmdraw .4s .5s ease forwards; }
.pm-bad { width: 62px; height: 62px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #f43f5e, #f59e0b); }
.pm-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; } .pm-actions .btn { text-decoration: none; }
@keyframes pmspin { to { transform: rotate(360deg); } } @keyframes pmdraw { to { stroke-dashoffset: 0; } } @keyframes pmpulse { 50% { box-shadow: 0 0 0 6px #e11d2a33; } }
.ask-hint { font-size: 12px !important; color: #fbbf24 !important; }

/* ---------- Аватар победителя в карточке «Победитель» ---------- */
.v-ava { display: flex; justify-content: center; margin: -22px 0 8px; }
.v-ava[hidden] { display: none; }
.v-ava .ava { width: 128px; height: 128px; border-radius: 50%; overflow: hidden; border: 3px solid var(--c, #f59e0b); background: var(--panel2);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--c, #f59e0b) 22%, transparent), 0 14px 34px -10px color-mix(in srgb, var(--c, #f59e0b) 70%, transparent);
  animation: avapop .7s cubic-bezier(.2,1.4,.3,1) .25s both; }
.v-ava .ava img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; display: block; transform: scale(2.2); transform-origin: 50% 20%; }
.v-ava .ava + .ava { margin-left: -18px; }
.victory.draw .v-ava .ava { width: 104px; height: 104px; }
.v-crown { position: relative; z-index: 2; }
@keyframes avapop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* ---------- Иконки мессенджеров в кнопках итогов ---------- */
.ico.brand { width: 22px; height: 22px; }
.ico.brand.wa { color: #25d366; }
.ico.brand.ig { color: #fff; }
.res-side .btn { white-space: nowrap; }
.topbar { position: relative; z-index: 40; }
