/* ============================================================
   Квиз «Молодёжь. Власть. Выборы»
   Общие стили: экран ведущего (проектор) и экран участника (телефон)
   ============================================================ */

:root {
  --bg: #0a1430;
  --bg-2: #0f1d40;
  --surface: #152650;
  --surface-2: #1c3060;
  --line: #2a4176;

  --text: #f3f6ff;
  --muted: #97a8cf;
  --dim: #6d80ad;

  --accent: #3b7bff;
  --accent-soft: #6ea0ff;
  --gold: #ffc24b;
  --ok: #3dd68c;
  --bad: #ff5f70;

  --radius: 16px;
  --radius-sm: 10px;
  --pad: 20px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, 'Noto Sans', sans-serif;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 15% -10%, #1b3a7a 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, #162a5e 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Шапка с логотипами ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 20, 48, 0.82);
  backdrop-filter: blur(8px);
}

.logos {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Логотип МГЕР почти целиком состоит из тёмно-синего и красного, поэтому
   на тёмном фоне сайта он бы утонул. Ставим его на белую подложку — так
   фирменные цвета остаются нетронутыми и логотип читается. */
.logo-plate {
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.logo-slot {
  height: 40px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  display: block;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-right: auto;
}

.topbar-title span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

/* На узких экранах шапка не должна разрастаться на пол-экрана. */
@media (max-width: 560px) {
  .topbar {
    gap: 10px;
    padding: 10px 14px;
  }
  .topbar-title {
    font-size: 13px;
    /* Не даём заголовку расползтись на три строки и съесть пол-экрана. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .topbar-title span {
    display: none;
  }
  .logo-plate {
    padding: 5px 8px;
    border-radius: 8px;
  }
  .logo-slot {
    height: 28px;
    max-width: 130px;
  }
  /* Индикатор связи сжимается до цветной точки — подпись на телефоне лишняя. */
  #connBadge {
    font-size: 0;
    padding: 0;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
  }
  #connBadge::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
  }
}

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge.live {
  color: var(--ok);
  border-color: rgba(61, 214, 140, 0.4);
  background: rgba(61, 214, 140, 0.1);
}

.badge.off {
  color: var(--bad);
  border-color: rgba(255, 95, 112, 0.4);
  background: rgba(255, 95, 112, 0.1);
}

/* На проекторе логотип должен читаться с задних рядов. */
@media (min-width: 1400px) {
  .logo-plate {
    padding: 8px 14px;
    border-radius: 12px;
  }
  .logo-slot {
    height: 56px;
    max-width: 260px;
  }
}

/* ---------- Общие блоки ---------- */

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: var(--pad);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0 0 10px;
}

h2 {
  font-size: 19px;
  margin: 0 0 8px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.dim {
  color: var(--dim);
}

.small {
  font-size: 13px;
}

.center {
  text-align: center;
}

.kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin-bottom: 8px;
}

/* ---------- Кнопки ---------- */

button {
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
  border: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border: 1px solid transparent;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.wide {
  width: 100%;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-2);
  filter: none;
}

.btn.gold {
  background: var(--gold);
  color: #2a1c00;
}

.btn.danger {
  background: transparent;
  border-color: rgba(255, 95, 112, 0.5);
  color: var(--bad);
}

.btn.sm {
  padding: 8px 13px;
  font-size: 14px;
  border-radius: 8px;
}

/* ---------- Поля ввода ---------- */

input[type='text'],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  outline: none;
}

input[type='text']:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}

label.check {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  margin: 16px 0;
  line-height: 1.45;
}

label.check input {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

a {
  color: var(--accent-soft);
}

/* ---------- Варианты ответа ---------- */

.options {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 2px solid var(--line);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}

.opt .letter {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.09);
  font-weight: 800;
  font-size: 14px;
}

.opt .label {
  flex: 1;
  position: relative;
  z-index: 1;
}

.opt:hover:not(:disabled) {
  border-color: var(--accent-soft);
}

.opt.picked {
  border-color: var(--accent);
  background: rgba(59, 123, 255, 0.22);
}

.opt.picked .letter {
  background: var(--accent);
}

.opt.correct {
  border-color: var(--ok);
  background: rgba(61, 214, 140, 0.16);
}

.opt.correct .letter {
  background: var(--ok);
  color: #06301c;
}

.opt.wrong {
  border-color: var(--bad);
  background: rgba(255, 95, 112, 0.14);
}

.opt.wrong .letter {
  background: var(--bad);
}

.opt:disabled {
  cursor: default;
}

/* Полоса-заливка с долей ответов (на экране ведущего) */
.opt .bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(110, 160, 255, 0.2);
  width: 0;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 0;
}

.opt.correct .bar {
  background: rgba(61, 214, 140, 0.26);
}

.opt .pct {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Таймер ---------- */

.timer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
}

.timer .track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.timer .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  border-radius: 999px;
  transition: width 0.25s linear;
}

.timer.urgent .fill {
  background: linear-gradient(90deg, #ff7a45, var(--bad));
}

.timer .num {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 18px;
  min-width: 38px;
  text-align: right;
}

/* ---------- Плашка результата ---------- */

.verdict {
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 16px;
}

.verdict.ok {
  background: rgba(61, 214, 140, 0.16);
  border: 1px solid rgba(61, 214, 140, 0.45);
  color: var(--ok);
}

.verdict.bad {
  background: rgba(255, 95, 112, 0.14);
  border: 1px solid rgba(255, 95, 112, 0.45);
  color: var(--bad);
}

.verdict.neutral {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
}

.verdict .sub {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
}

.note {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* ---------- Таблица лидеров ---------- */

.board {
  display: grid;
  gap: 7px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.row .place {
  width: 30px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.row .who {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .pts {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  flex-shrink: 0;
}

.row.me {
  border-color: var(--accent);
  background: rgba(59, 123, 255, 0.2);
}

.row.top1 .place {
  color: var(--gold);
}

/* ---------- Утилиты ---------- */

.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: 12px;
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(140%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  z-index: 90;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.err {
  border-color: rgba(255, 95, 112, 0.6);
  color: #ffd7db;
}

/* Уважаем системную настройку «уменьшить движение»: кому-то анимация
   мешает, а на проекторе она и не нужна. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Подвал с логотипом агентства ---------- */

.credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 26px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--muted);
  /* Без скругления: вместе с border-top оно рисует линию с загнутыми
     концами — выглядит как обрезанная рамка, а не как разделитель. */
  transition: color 0.15s ease, background 0.15s ease;
}

.credit:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.credit img {
  height: 42px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.credit-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}

.credit-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--dim);
}

.credit-name {
  font-size: 16px;
  font-weight: 700;
  color: inherit;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.pop {
  animation: pop 0.28s ease both;
}

/* На невысоких экранах — iPhone SE/7/8 и бюджетные Android 360x640 — четыре
   варианта ответа вместе с вопросом и таймером не помещались: «Г» уходил под
   нижний край, и участник, отвечая на время, его просто не видел. Адресная
   строка браузера съедает ещё 60–90 px, поэтому считаем по высоте окна.
   Порог по ширине в 950 px отделяет телефон от ноутбука: повёрнутый
   горизонтально телефон (667x375) сюда попадает — там за край уходила даже
   кнопка «Присоединиться», — а ноутбук 1366x768, с которого идёт проектор,
   уже нет: его экран ужимать нельзя, текст читают с задних рядов. */
@media (max-height: 700px) and (max-width: 950px) {
  :root {
    --pad: 14px;
  }
  .topbar {
    padding: 6px 14px;
  }
  h1 {
    font-size: 21px;
    margin-bottom: 6px;
  }
  .kicker {
    margin-bottom: 5px;
  }
  .timer {
    margin: 8px 0 2px;
  }
  .options {
    gap: 7px;
    margin: 8px 0;
  }
  .opt {
    padding: 10px 13px;
    gap: 10px;
  }
  .opt .letter {
    width: 26px;
    height: 26px;
  }
}

/* Экраны ниже 520 px — это iPhone 5/SE первого поколения, где после адресной
   строки остаётся около 460 px. Четвёртому варианту там не хватало четырёх
   пикселей, поэтому дополнительно ужимаем логотип и заголовок вопроса. */
@media (max-height: 520px) and (max-width: 950px) {
  .logo-slot {
    height: 22px;
  }
  h1 {
    font-size: 19px;
  }
  .kicker {
    margin-bottom: 3px;
  }
  .options {
    gap: 6px;
    margin: 6px 0;
  }
}
