/* =================== */
/*  ФОН СТРАНИЦЫ        */
/* =================== */
body {
    background: #eef0f2;
}

/* =================== */
/*  ОБЁРТКА (как start) */
/* =================== */
.quiz-wrapper {
  max-width: 650px;
  margin: 0 auto;
  width: 100%;
  padding-top: 15px;
}

/* =================== */
/*  ЗАГОЛОВКИ           */
/* =================== */
.quiz-heading,
.review-heading {
  position: sticky;
  top: 120px;
  z-index: 100;
  background: #eef0f2;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 2px solid #e5e7eb;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  color: #1a1a1a;
  margin: 0 0 20px 0;
  padding: 0 12px;
  width: 100%;
  max-width: 100%;
}

.quiz-heading .text-dark {
  color: #1a1a1a;
  font-size: inherit;
  font-weight: inherit;
  /* Тот же фикс, что и у .text-accent ниже — без min-width:0 этот span
     тоже может отказаться сжиматься внутри flex-контейнера. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.quiz-heading .text-accent {
  color: #800020;
  font-size: inherit;
  font-weight: inherit;
  /* Без min-width: 0 text-overflow: ellipsis не работает у детей
     flex-контейнера — элемент отказывается сжиматься уже своего
     содержимого и вылезает за пределы .quiz-heading, а на мобильном
     это тянет за собой горизонтальный скролл всей страницы. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-heading span:first-child {
  color: #1a1a1a;
}

.review-heading span:last-child {
  color: #800020;
}

@media (max-width: 700px) {
  .quiz-heading,
  .review-heading {
    top: 115px;
    font-size: 17px;
    height: 34px;
    min-height: 34px;
    max-height: 34px;
  }
}

/* =================== */
/*  ОТСТУП ПРИ СКРОЛЛЕ  */
/* =================== */
.question-card,
.ad-container:not(#ad-place-3),
#ad-place-3 {
  scroll-margin-top: 160px;
}

@media (max-width: 700px) {
  .question-card,
  .ad-container,
  #ad-place-3 {
    scroll-margin-top: 145px;
  }
}

/* =================== */
/*  КАРТОЧКА ВОПРОСА   */
/* =================== */
.question-card {
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 650px;
  box-sizing: border-box;
}

.question-card.collapsing {
  animation: slideUp 1s ease forwards;
  pointer-events: none;
  overflow: hidden;
  transform-origin: bottom center;
}

@keyframes slideUp {
  0% {
    max-height: 800px;
    opacity: 1;
    margin-bottom: 24px;
    padding-top: 30px;
    padding-bottom: 30px;
    transform: scaleY(1) translateY(0);
    border-width: 1px;
  }
  30% { opacity: 1; transform: scaleY(1) translateY(0); }
  100% {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    transform: scaleY(0.8) translateY(-20px);
    border-width: 0;
  }
}

.q-tag {
  display: inline-block;
  background: var(--burgundy-soft);
  color: var(--burgundy);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* =================== */
/*  ТЕКСТ ВОПРОСА       */
/* =================== */
.question-card p.font-bold,
.question-card p.italic {
  font-size: 17px;
  margin-bottom: 14px;
  color: var(--text-dark);
  font-weight: 800;
}

.option-item {
  font-weight: normal;
}

/* =================== */
/*  БЛОК ПОДСКАЗОК      */
/* =================== */
.inline-hint {
  font-size: 15px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: block;
}

.hint-wrong {
  background: #ffe6e6;
  color: #b71c1c;
  border: 1px solid #f5c6cb;
}

.hint-neutral {
  background: #e8f0fe;
  color: #174ea6;
  border: 1px solid #c6d9f1;
}

.has-hint {
  border-color: #f87171 !important;
}

/* =================== */
/*  ОПЦИИ ОТВЕТОВ      */
/* =================== */
.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 10px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: 0.25s ease;
  font-size: 16px;
  background: #fff;
  position: relative;
}

.option-item:hover {
  border-color: var(--burgundy);
  background: rgba(128, 0, 32, 0.02);
}

.option-item input[type="radio"] {
  accent-color: var(--burgundy);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.option-item.correct {
  border-color: var(--green-success) !important;
  background: rgba(34, 197, 94, 0.06) !important;
}

.option-item.wrong {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.05) !important;
}

/* =================== */
/*  ТЕКСТОВЫЙ ВВОД (7) */
/* =================== */
.input-text {
  border: 2px solid #c0c7cf;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  width: 100%;
  max-width: 300px;
  transition: 0.2s ease;
  background: #fff;
  box-sizing: border-box;
}

.input-text:focus {
  border-color: var(--burgundy);
  outline: none;
  box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1);
}

.input-text.correct {
  border-color: var(--green-success) !important;
  background: rgba(34, 197, 94, 0.05);
}

.input-text.wrong {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.05);
}

.submit-text-btn {
  background: var(--burgundy);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.submit-text-btn:hover {
  background: var(--burgundy-dark);
}

/* Контейнер для строки ввода */
.text-answer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.text-answer-row .font-bold {
  flex-shrink: 0;
}

.text-answer-row .input-text {
  flex: 1;
  min-width: 150px;
  max-width: 100%;
}

.text-answer-row .submit-text-btn {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .text-answer-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .text-answer-row .input-text {
    width: 100%;
    max-width: 100%;
  }
  
  .text-answer-row .submit-text-btn {
    width: 100%;
    text-align: center;
  }
}

/* =================== */
/*  БЛОК ЧТЕНИЯ        */
/* =================== */
.reading-box {
  background: #f9fafb;
  border-left: 4px solid var(--burgundy);
  padding: 18px 22px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 15px;
  color: var(--text-dark);
  line-height: 1.6;
}

/* =================== */
/*  АУДИОПЛЕЕР         */
/* =================== */
.audio-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f3f4f6;
  padding: 12px 18px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.audio-icon {
  width: 44px;
  height: 44px;
  background: var(--burgundy);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
  position: relative;
}

.audio-icon:hover { background: var(--burgundy-dark); }

.audio-icon svg { 
  width: 22px; 
  height: 22px; 
  position: absolute;
}

/* Пауза скрыта всегда — показываем только play */
.audio-icon .pause-btn {
  display: none !important;
}

.audio-progress { flex: 1; accent-color: var(--burgundy); height: 6px; }
.time-display { font-size: 13px; font-weight: 600; color: var(--text-muted); min-width: 40px; text-align: right; }

/* =================== */
/*  СЕТКА ФЛАГОВ (16)  */
/* =================== */
.flag-grid { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.flag-option {
  border: 3px solid var(--border-color);
  border-radius: 14px;
  padding: 8px;
  cursor: pointer;
  transition: 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flag-option:hover { border-color: var(--burgundy); }
.flag-option.correct { border-color: var(--green-success) !important; }
.flag-option.wrong { border-color: #ef4444 !important; }
.flag-option img { width: 100px; height: auto; display: block; }
.flag-option input[type="radio"] { display: none; }

@media (max-width: 700px) {
  .flag-grid { flex-wrap: nowrap; gap: 10px; }
  .flag-option img { width: 60px; }
}

/* =================== */
/*  РЕКЛАМНЫЕ БЛОКИ     */
/* =================== */
.ad-container {
  margin: 30px 0;
  padding: 10px 0;
  min-height: 200px;
  background: #f8f9fa;
  border-radius: 12px;
  transition: max-height 0.5s ease, margin 0.5s ease, padding 0.5s ease, opacity 0.4s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.quiz-wrapper .ad-container { width: 100%; max-width: 650px; }

#ad-place-3 {
  width: 100%;
  max-width: 1060px;
  margin: 30px auto;
  padding: 10px 20px;
}

.ad-container.hidden-ad {
  opacity: 0;
  max-height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

/* =================== */
/*  РЕЗУЛЬТАТЫ         */
/* =================== */
.result-container {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 50px 30px;
  margin: 0 auto 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 650px;
  box-sizing: border-box;
  text-align: center;
}

.result-status-icon { font-size: 60px; display: block; margin-bottom: 16px; }
.result-title { font-size: 30px; font-weight: 900; color: var(--text-dark); margin-bottom: 12px; }
.result-stats-text { font-size: 17px; color: var(--text-muted); margin-bottom: 30px; }

.result-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 20px 0; }

.btn-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 32px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.3s ease;
  min-width: 260px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.btn-result-primary { background: var(--burgundy); color: #fff; }
.btn-result-primary:hover { background: var(--burgundy-dark); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(128, 0, 32, 0.3); }
.btn-result-secondary { background: #fff; color: var(--burgundy); border: 2px solid var(--burgundy); }
.btn-result-secondary:hover { background: var(--burgundy-soft); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(128, 0, 32, 0.15); }

.variant-buttons-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.btn-secondary {
  display: inline-block;
  padding: 12px 22px;
  background: #fff;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-dark);
  transition: 0.2s ease;
  font-size: 14px;
}
.btn-secondary:hover { border-color: var(--burgundy); color: var(--burgundy); }

/* =================== */
/*  ЛОАДЕР              */
/* =================== */
.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--burgundy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* =================== */
/*  MAIN               */
/* =================== */
main.container { min-height: 60vh; }

/* =================== */
/*  АДАПТИВ            */
/* =================== */
@media (max-width: 900px) {
  .question-card { padding: 20px; }
  .audio-wrapper { flex-wrap: wrap; }
  #ad-place-3 { max-width: calc(100% - 40px); margin: 30px 20px; }
}

@media (max-width: 700px) {
  .quiz-wrapper { padding: 0 10px; }
}

@media (max-width: 600px) {
  .result-actions { flex-direction: column; align-items: center; }
  .btn-result { width: 100%; max-width: 320px; }
}

/* =================== */
/*  МОДАЛЬНОЕ ОКНО      */
/* =================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-content {
  background: #fff;
  border-radius: 20px;
  padding: 30px 25px 25px;
  max-width: 550px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.modal-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-dark);
  margin-bottom: 20px;
  text-transform: uppercase;
}

.modal-title .accent {
  color: var(--burgundy);
}

.modal-text {
  text-align: left;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-text strong {
  color: var(--text-dark);
}

.modal-btn {
  display: inline-block;
  background: var(--burgundy);
  color: #fff;
  border: none;
  padding: 14px 40px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.modal-btn:hover {
  background: var(--burgundy-dark);
  transform: translateY(-2px);
}

@media (max-width: 500px) {
  .modal-overlay {
    padding: 10px;
  }
  
  .modal-content {
    padding: 20px 15px 20px;
    max-height: 85vh;
    border-radius: 16px;
  }
  
  .modal-icon {
    font-size: 36px;
    margin-bottom: 10px;
  }
  
  .modal-title {
    font-size: 17px;
    margin-bottom: 15px;
  }
  
  .modal-text {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
  }
  
  .modal-btn {
    padding: 12px 25px;
    font-size: 14px;
    margin-top: 15px;
    width: 100%;
    box-sizing: border-box;
  }
}

/* =================== */
/*  ИНСТРУКЦИЯ К АУДИО  */
/* =================== */
.audio-instruction {
  background: #f0f4ff;
  border-left: 4px solid #5b7fff;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 15px;
  color: #2c3e50;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.instruction-icon {
  font-size: 18px;
}

/* =================== */
/*  ДИАЛОГ (вопрос 10)  */
/* =================== */
.dialogue-box {
  background: #f9fafb;
  border: 2px dashed #d0d5dd;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 10px;
}

.dialogue-line {
  font-size: 17px;
  margin-bottom: 8px;
  line-height: 1.6;
}

.dialogue-line:last-child {
  margin-bottom: 0;
}

.dialogue-q {
  font-weight: 700;
  color: var(--text-dark);
}

.dialogue-underline {
  border-bottom: 2px solid var(--burgundy);
  color: var(--burgundy);
  font-weight: 600;
  padding: 0 4px;
}
@media (max-width: 480px) {
    .floating-btn-link {
        padding: 8px 14px;      /* чуть меньше отступы */
        font-size: 12px;         /* чуть меньше шрифт */
        gap: 8px;
    }
    .floating-btn-link .btn-text {
        display: inline;         /* текст ВИДЕН! */
    }
}