* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

:root {
  --vh: 1vh;
  --primary-color: #0284F3;
  --gradient-start: #005BE7;
  --gradient-end: #06A8FD;
  --primary-dark: #005BE7;
  --primary-light: #06A8FD;
  --secondary-color: #FFFFFF;
  --background-color: #FFFFFF;
  --surface-color: #F5F5F5;
  --text-primary: #000000;
  --text-secondary: #666666;
  --text-on-blue: #FFFFFF;
  --border-color: #E0E0E0;
  --success-color: #21b66f;
  --shadow-color: rgba(2, 132, 243, 0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8F9FA 100%);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .btn {
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Контейнер ─── */
.quiz-container {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: 100%;
  max-width: 420px;
  padding: calc(20px + env(safe-area-inset-top, 0)) calc(20px + env(safe-area-inset-right, 0)) calc(20px + env(safe-area-inset-bottom, 0)) calc(20px + env(safe-area-inset-left, 0));
  position: relative;
}

/* ─── Экраны ─── */
.screen {
  display: none;
  width: 100%;
  max-width: 420px;
}

.screen.active:not(.welcome-screen) {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Welcome экран ─── */
.screen.welcome-screen {
  display: none;
}

.screen.welcome-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 0;
}

.welcome-content {
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
  padding: 0 20px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-header {
  margin-bottom: 50px;
}

.welcome-title {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 320px;
  margin: 0 auto;
}

.welcome-features {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 50px 0;
  padding: 30px 0;
  flex-wrap: nowrap;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  animation: fadeIn 0.8s ease-out backwards;
  pointer-events: none;
  cursor: default;
}

.feature-item:nth-child(1) { animation-delay: 0.2s; }
.feature-item:nth-child(2) { animation-delay: 0.4s; }
.feature-item:nth-child(3) { animation-delay: 0.6s; }

.feature-icon {
  font-size: 40px;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0, 91, 231, 0.1) 0%, rgba(6, 168, 253, 0.1) 100%);
  border-radius: 16px;
  border: 2px solid rgba(2, 132, 243, 0.2);
}

.feature-text {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  font-family: 'Rubik', sans-serif;
  text-align: center;
  line-height: 1.3;
}

/* ─── Кнопки ─── */
.btn {
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  font-family: 'Rubik', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.btn-large {
  width: 100%;
  padding: 18px 40px;
  font-size: 18px;
  font-weight: 700;
}

.btn-primary {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  color: #fff;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Кнопка перезапуска — мягкая, не конкурирует с основным CTA */
.btn-restart {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: #eaf3ff;
  color: #28558a;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: 'Rubik', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.btn-restart:active {
  background: #d8ebff;
}

/* ─── Прогресс-бар ─── */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface-color);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  transition: width 0.3s ease;
  width: 0%;
  border-radius: 2px;
}

/* ─── Экран вопроса ─── */
.question-content {
  padding: 20px 0;
}

.question-number {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 500;
}

.question-text {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 28px;
  text-align: left;
  line-height: 1.4;
  color: var(--text-primary);
}

.answers-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-btn {
  padding: 16px 20px;
  background: var(--secondary-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  animation: slideIn 0.3s ease backwards;
  -webkit-tap-highlight-color: transparent;
}

.answer-btn:nth-child(1) { animation-delay: 0.05s; }
.answer-btn:nth-child(2) { animation-delay: 0.12s; }
.answer-btn:nth-child(3) { animation-delay: 0.19s; }
.answer-btn:nth-child(4) { animation-delay: 0.26s; }
.answer-btn:nth-child(5) { animation-delay: 0.33s; }

.answer-btn:active {
  background: #f5f9ff;
}

.answer-btn.selected {
  border-color: var(--primary-color);
  background: rgba(2, 132, 243, 0.08);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Экран результата ─── */
.result-screen {
  overflow: hidden;
}

.content {
  text-align: center;
  padding: 12px 0 20px;
}

.result-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  line-height: 1.3;
}

/* ─── Flip-карточка ─── */
.flip-card-container {
  position: relative;
  margin: 16px 0;
  perspective: 1000px;
}

.flip-card {
  background: transparent;
  width: 100%;
  height: 400px;
  min-height: 400px;
  perspective: 1000px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.flip-card.twitch {
  animation: cardTwitch 0.3s ease;
}

@keyframes cardTwitch {
  0%,  100% { transform: perspective(1000px) rotateY(0deg); }
  25%        { transform: perspective(1000px) rotateY(-3deg); }
  75%        { transform: perspective(1000px) rotateY(3deg); }
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.flip-card-front {
  background: #fff;
  border: 2px solid #e8f0fe;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.flip-card-back {
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  color: #fff;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

/* ─── Лицевая сторона — инфо о фильме ─── */
.flip-card-front h3 {
  font-size: 22px;
  color: var(--primary-color);
  margin-bottom: 10px;
  font-weight: 700;
  font-family: 'Rubik', sans-serif;
  line-height: 1.3;
  padding: 0 4px;
  text-align: center;
}

.flip-card-front p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 12px;
  flex-shrink: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: left;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.movie-poster {
  width: 110px;
  height: 110px;
  margin: 6px auto 12px;
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border: 2px solid rgba(2, 132, 243, 0.25);
  flex-shrink: 0;
}

/* ─── Тизер бонуса (лицевая) ─── */
.bonus-teaser {
  margin-top: auto;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(2, 132, 243, 0.18);
  background: rgba(2, 132, 243, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

.bonus-teaser__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 18px;
  flex-shrink: 0;
}

.bonus-teaser__title {
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.86);
  line-height: 1.2;
  flex: 1;
  text-align: center;
}

.bonus-teaser__cta {
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(2, 132, 243, 0.14);
  color: var(--primary-color);
  border: 1px solid rgba(2, 132, 243, 0.2);
  flex-shrink: 0;
}

.tap-hint {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.45);
  font-weight: 500;
  flex-shrink: 0;
  transition: opacity 0.4s ease;
}

.tap-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ─── Обратная сторона — прomo sheet ─── */
.promo-sheet {
  height: 100%;
  border-radius: 14px;
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.promo-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.promo-title {
  margin: 0;
  font-family: 'Rubik', sans-serif;
  font-weight: 900;
  font-size: 16px;
  color: rgba(0, 0, 0, 0.9);
  line-height: 1.25;
}

.promo-points {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.promo-point {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.72);
  line-height: 1.3;
}

.promo-point::before {
  content: "•";
  font-weight: 900;
  color: var(--primary-color);
  margin-right: 6px;
}

/* ─── Карточка промокода ─── */
.promo-code-card {
  position: relative;
  flex-shrink: 0;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(2, 132, 243, 0.04);
  padding: 12px;
  padding-top: 34px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.promo-code-label {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.55);
  margin: 0;
  font-weight: 700;
}

.promo-code-row {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px dashed rgba(2, 132, 243, 0.55);
  border-radius: 12px;
  overflow: hidden;
}

.promo-code {
  flex: 1;
  font-size: 18px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-weight: 900;
  letter-spacing: 2px;
  color: rgba(0, 0, 0, 0.88);
  padding: 10px 12px;
  cursor: pointer;
  user-select: all;
  background: transparent;
  border: none;
}

.promo-copy-btn {
  flex-shrink: 0;
  width: 48px;
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid rgba(2, 132, 243, 0.25);
  color: var(--primary-color);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.15s;
}

.promo-copy-btn:active {
  transform: scale(0.92);
}

.promo-validity {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  margin: 0;
  line-height: 1.4;
}

/* «Перейти на сайт» — всегда синяя, не зависит от темы TMA */
.promo-btn {
  display: block;
  text-align: center;
  text-decoration: none !important;
  font-weight: 900;
  padding: 12px 14px;
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(2, 132, 243, 0.2);
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: linear-gradient(135deg, #005BE7 0%, #06A8FD 100%) !important;
  color: #ffffff !important;
  margin-top: 4px;
}

/* ─── Плашка «Реклама» ─── */
.advertisement-label {
  position: relative;
  z-index: 20;
}

.ad-on-card {
  position: absolute;
  top: 8px;
  right: 8px;
}

.ad-label-text {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Rubik', sans-serif;
  display: inline-block;
  user-select: none;
}

.ad-label-text:active {
  background: rgba(0, 0, 0, 0.1);
}

.ad-legal-info {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.92);
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  min-width: 230px;
  max-width: 280px;
  font-size: 11px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 30;
}

.ad-legal-info.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.ad-legal-content p {
  margin: 0 0 5px 0;
  color: #fff;
}

.ad-legal-content p:last-child {
  margin-bottom: 0;
}

.ad-legal-note {
  font-size: 10px;
  opacity: 0.75;
  font-style: italic;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%) translateY(8px);
  border-radius: 10px;
  background: var(--success-color);
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Rubik', sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
  z-index: 100;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Адаптив ─── */
@media (max-width: 400px) {
  .welcome-title {
    font-size: 34px;
  }

  .welcome-subtitle {
    font-size: 15px;
  }

  .welcome-header {
    margin-bottom: 36px;
  }

  .welcome-features {
    margin: 36px 0;
    padding: 16px 0;
    gap: 10px;
  }

  .feature-icon {
    width: 58px;
    height: 58px;
    font-size: 30px;
  }

  .feature-text {
    font-size: 11px;
  }

  .btn-large {
    font-size: 17px;
    padding: 16px 28px;
  }

  .question-text {
    font-size: 21px;
  }

  .flip-card {
    height: 360px;
    min-height: 360px;
  }

  .flip-card-front {
    padding: 16px;
  }

  .flip-card-front h3 {
    font-size: 20px;
  }

  .flip-card-front p {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .movie-poster {
    width: 90px;
    height: 90px;
    font-size: 32px;
  }

  .promo-code {
    font-size: 16px;
    letter-spacing: 1px;
    padding: 9px 10px;
  }
}
