:root {
  --bg-deep: #0b0f1e;
  --bg-surface: #131a31;
  --bg-card: #1b2442;
  --bg-card-hover: #243056;
  --border-subtle: rgba(148, 163, 184, 0.18);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.38);
  --gold: #facc15;
  --emerald: #10b981;
  --rose: #f43f5e;
  --cyan: #06b6d4;
  --radius-lg: 22px;
  --radius-md: 14px;
}

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

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: radial-gradient(circle at 18% 12%, #1d2650 0%, var(--bg-deep) 58%, #070913 100%);
  color: var(--text-main);
  overflow-x: hidden;
  user-select: none;
}

button, input {
  font-family: inherit;
}

/* Верхняя панель управления ведущего */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(11, 15, 30, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: grid;
  place-items: center;
  font-size: 21px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-color: transparent;
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  border-color: transparent;
  color: #0f172a;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 16px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
  border-radius: 9px;
}

/* Основной контейнер сцены */
.stage {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 40px;
  min-height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.fade-in {
  animation: fadeSlide 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* Стартовый экран / Регистрация команд */
.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 28px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: rgba(24, 33, 62, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: #c7d2fe;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero-title {
  font-size: clamp(36px, 4.8vw, 58px);
  font-weight: 900;
  line-height: 1.06;
  margin-bottom: 14px;
  background: linear-gradient(120deg, #ffffff 10%, #a5b4fc 55%, #f472b6 95%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 18px;
  line-height: 1.55;
  color: #cbd5e1;
  margin-bottom: 22px;
}

.prep-timer-box {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(250, 204, 21, 0.32);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.prep-timer-clock {
  font-size: 32px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* Список команд */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 20px;
  max-height: 330px;
  overflow-y: auto;
  padding-right: 4px;
}

.team-row {
  display: grid;
  grid-template-columns: 46px 1fr 0.8fr 36px;
  gap: 8px;
  align-items: center;
  background: rgba(15, 23, 42, 0.65);
  padding: 8px 10px;
  border-radius: 13px;
  border: 1px solid var(--border-subtle);
}

.avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  font-size: 22px;
  cursor: pointer;
}

.team-input {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
}

.team-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

/* Карта раундов */
.rounds-header {
  text-align: center;
  margin-bottom: 26px;
}

.rounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}

.round-card {
  background: rgba(24, 33, 62, 0.88);
  border: 2px solid var(--border-subtle);
  border-radius: 20px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}

.round-card:hover {
  transform: translateY(-4px);
  border-color: var(--round-color, var(--accent));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
}

.round-card.done {
  border-color: rgba(16, 185, 129, 0.65);
}

.round-icon {
  font-size: 42px;
  margin-bottom: 8px;
}

.round-num {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 800;
  color: #cbd5e1;
}

.round-name {
  font-size: 24px;
  font-weight: 800;
  margin: 4px 0 6px;
}

.round-sub {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Заставка раунда */
.round-intro {
  max-width: 880px;
  margin: 0 auto;
  text-align: center;
}

.rules-list {
  text-align: left;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 22px 0;
}

.rules-list li {
  background: rgba(15, 23, 42, 0.65);
  border-left: 4px solid var(--accent);
  padding: 13px 18px;
  border-radius: 0 12px 12px 0;
  font-size: 18px;
  line-height: 1.45;
}

.example-box {
  background: rgba(250, 204, 21, 0.1);
  border: 1px dashed rgba(250, 204, 21, 0.45);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 17px;
}

/* Экран вопроса */
.q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.q-pill {
  padding: 7px 15px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  background: rgba(99, 102, 241, 0.22);
  border: 1px solid rgba(129, 140, 248, 0.45);
}

.q-type {
  font-size: 15px;
  font-weight: 700;
  color: #fde047;
}

.review-banner {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.25), rgba(6, 182, 212, 0.25));
  border: 1px solid rgba(16, 185, 129, 0.6);
  color: #a7f3d0;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
}

/* Таймер вопроса */
.timer-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--border-subtle);
  padding: 7px 14px;
  border-radius: 16px;
}

.timer-widget.urgent {
  border-color: var(--rose);
  box-shadow: 0 0 22px rgba(244, 63, 94, 0.45);
  animation: pulseUrgent 0.6s infinite alternate;
}

@keyframes pulseUrgent {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

.timer-digits {
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 66px;
  text-align: center;
}

.q-card {
  background: rgba(22, 30, 58, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 28px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.q-prompt {
  font-size: clamp(22px, 2.5vw, 31px);
  font-weight: 800;
  line-height: 1.32;
  text-align: center;
  margin-bottom: 24px;
}

/* Визуальные карточки Раунда 1 */
.logic-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.logic-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.logic-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 860px) {
  .logic-grid.cols-3, .logic-grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.logic-item {
  border-radius: 20px;
  padding: 16px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 215px;
  position: relative;
  transition: transform 0.2s ease, border-color 0.25s ease, opacity 0.25s ease;
}

.logic-letter {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 17px;
}

.logic-svg {
  width: 100%;
  max-width: 185px;
  height: 145px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logic-svg svg {
  width: 100%;
  height: 100%;
}

.logic-caption {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
}

.logic-item.is-odd-revealed {
  border-color: var(--gold);
  box-shadow: 0 0 32px rgba(250, 204, 21, 0.55);
  transform: scale(1.04);
}

.logic-item.is-dimmed {
  opacity: 0.45;
}

/* Аудиоплеер Раунда 2 */
.audio-box {
  max-width: 680px;
  margin: 8px auto 18px;
  background: rgba(11, 15, 30, 0.78);
  border: 1px solid rgba(236, 72, 153, 0.4);
  border-radius: 22px;
  padding: 24px 28px;
  text-align: center;
}

.equalizer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 7px;
  height: 62px;
  margin-bottom: 18px;
}

.eq-bar {
  width: 10px;
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f472b6, #6366f1);
  transition: height 0.15s ease;
}

.equalizer.playing .eq-bar {
  animation: eqBounce 0.65s ease-in-out infinite alternate;
}

.equalizer.playing .eq-bar:nth-child(2n) { animation-duration: 0.48s; }
.equalizer.playing .eq-bar:nth-child(3n) { animation-duration: 0.78s; }
.equalizer.playing .eq-bar:nth-child(5n) { animation-duration: 0.55s; }

@keyframes eqBounce {
  from { height: 12px; }
  to { height: 58px; }
}

.audio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.audio-progress-wrap {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.audio-progress {
  flex: 1;
  accent-color: #ec4899;
  cursor: pointer;
}

.transcript-box {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.72);
  border-radius: 12px;
  font-size: 17px;
  line-height: 1.45;
  color: #e2e8f0;
  font-style: italic;
}

/* Эмодзи-ребусы Раунда 3 */
.emoji-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 18px 0 24px;
}

.emoji-tile {
  width: 122px;
  height: 122px;
  border-radius: 26px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 2px solid rgba(250, 204, 21, 0.35);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  font-size: 66px;
  transition: transform 0.2s ease;
}

.emoji-tile:hover {
  transform: scale(1.08) rotate(-2deg);
}

/* Раунд 4: Верю — Не верю */
.tf-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 680px;
  margin: 12px auto 18px;
}

.tf-card {
  padding: 22px;
  border-radius: 20px;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.03em;
  border: 3px solid transparent;
  transition: transform 0.2s ease, opacity 0.25s ease;
}

.tf-true {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.tf-false {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.5);
  color: #fda4af;
}

.tf-card.winner {
  transform: scale(1.05);
  box-shadow: 0 0 32px currentColor;
}

.tf-card.loser {
  opacity: 0.28;
}

/* Раунд 5: Нейросеть */
.ai-frame {
  max-width: 660px;
  margin: 0 auto 16px;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid rgba(6, 182, 212, 0.45);
  background: #090d16;
  position: relative;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  cursor: zoom-in;
}

.ai-frame img {
  display: block;
  width: 100%;
  max-height: 410px;
  object-fit: contain;
  background: #090d16;
}

.zoom-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: #e2e8f0;
}

/* Подсказка и Блок правильного ответа */
.hint-banner {
  margin-top: 14px;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #fef08a;
  font-size: 17px;
  text-align: center;
}

.answer-reveal {
  margin-top: 20px;
  padding: 20px 24px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.18));
  border: 2px solid rgba(16, 185, 129, 0.65);
  animation: fadeSlide 0.28s ease;
}

.answer-title {
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 900;
  color: #6ee7b7;
  margin-bottom: 6px;
}

.answer-explain {
  font-size: 17px;
  color: #e2e8f0;
  line-height: 1.45;
}

.answer-accept {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 6px;
}

/* Быстрое начисление +1 балл командам прямо при проверке ответов */
.quick-award {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.award-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-main);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.award-chip.awarded {
  background: rgba(16, 185, 129, 0.28);
  border-color: #10b981;
  color: #a7f3d0;
}

/* Нижняя навигация вопроса */
.q-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.dots-nav {
  display: flex;
  gap: 8px;
}

.dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 800;
  cursor: pointer;
}

.dot.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

/* Модальное окно Табло и Лайтбокс */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.84);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 28px;
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
}

.score-table th, .score-table td {
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.score-table th:first-child, .score-table td:first-child {
  text-align: left;
}

.score-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px 6px;
  border-radius: 10px;
}

.step-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: var(--bg-card-hover);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.step-btn:hover {
  background: var(--accent);
}

.total-cell {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
}

/* Пьедестал победителей */
.podium-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  margin: 28px 0 30px;
  flex-wrap: wrap;
}

.podium-col {
  width: 230px;
  border-radius: 22px 22px 12px 12px;
  padding: 22px 16px;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.podium-1 {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.3), rgba(161, 98, 7, 0.35));
  border-color: var(--gold);
  min-height: 265px;
  box-shadow: 0 0 40px rgba(250, 204, 21, 0.28);
}

.podium-2 {
  background: linear-gradient(180deg, rgba(226, 232, 240, 0.22), rgba(71, 85, 105, 0.32));
  border-color: #cbd5e1;
  min-height: 220px;
}

.podium-3 {
  background: linear-gradient(180deg, rgba(251, 146, 60, 0.24), rgba(124, 45, 18, 0.32));
  border-color: #fb923c;
  min-height: 190px;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
}
