/* ========================================
   ТАЙНАЯ СОВМЕСТИМОСТЬ — CLEAN & AIRY
   Fotostrana.ru | Minimal Emotional Design
   ======================================== */

:root {
  --color-primary: #7C3AED;
  --color-primary-light: #A78BFA;
  --color-secondary: #EC4899;
  --color-accent: #14B8A6;
  --color-bg: #FEFCFF;
  --color-card: #FFFFFF;
  --color-text: #1E293B;
  --color-text-muted: #64748B;
  --shadow-soft: 0 4px 20px rgba(124, 58, 237, 0.12);
  --shadow-hover: 0 8px 32px rgba(124, 58, 237, 0.2);
  --radius: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --text-base: 17px;
  --text-lg: 19px;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: 100%;
  max-width: 520px;
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.screen {
  display: none;
  padding: 24px 20px;
  animation: fadeIn 300ms var(--ease);
}

.screen.active { display: block; }

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

/* ===== ГЕНДЕРНЫЙ ВЫБОР ===== */
.gender-header {
  text-align: center;
  padding: 20px 0 32px;
}

.gender-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.gender-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.gender-options {
  display: flex;
  gap: 16px;
  margin-top: 20px;
}

.gender-option {
  flex: 1;
  padding: 32px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 300ms var(--ease);
}

.gender-option:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-soft);
}

.gender-option.selected {
  border-color: var(--color-primary);
  background: linear-gradient(to bottom right, #F5F3FF, #FEF3FF);
}

.gender-icon {
  font-size: 48px;
}

.gender-text {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text);
}

/* ===== ПРИВЕТСТВИЕ — ЧИСТЫЙ ДИЗАЙН ===== */
.welcome-header {
  text-align: center;
  padding: 28px 20px 20px;
}

/* Иконка приветствия — аккуратная, без фона */
.welcome-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  margin-bottom: 16px;
  position: relative;
}

.welcome-icon-box::before {
  content: '';
  position: absolute;
  inset: -8px;
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(236,72,153,0.2));
  border-radius: 50%;
  animation: softPulse 3s ease-in-out infinite;
  z-index: -1;
}

@keyframes softPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 0.9; }
}

.welcome-icon {
  font-size: 48px;
  animation: gentleBounce 2.5s ease-in-out infinite;
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  font-size: 16px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.welcome-content {
  padding: 12px 4px 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0;
}

.stat-card {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  border: 1px solid rgba(124, 58, 237, 0.1);
}

.stat-number {
  display: block;
  font-size: 19px;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

.features-list {
  margin: 24px 0;
  padding: 16px;
  background: var(--color-bg);
  border-radius: var(--radius);
  border-left: 3px solid var(--color-primary-light);
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: var(--text-base);
}

.feature-item::before {
  content: '✨';
  font-size: 16px;
}

/* ===== КНОПКИ ===== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 18px 28px;
  font-size: var(--text-lg);
  font-weight: 600;
  cursor: pointer;
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease);
  box-shadow: var(--shadow-soft);
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-large {
  padding: 20px 32px;
  font-size: 18px;
  margin: 12px 0 4px;
}

.privacy-note {
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 16px;
}

.privacy-note a {
  color: var(--color-primary);
  text-decoration: none;
}

/* ===== QUIZ SCREEN — ЧИСТЫЙ ДИЗАЙН ===== */
.quiz-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.progress-bar {
  height: 5px;
  background: #E2E8F0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-pill);
  transition: width 300ms var(--ease);
}

.question-counter {
  display: block;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
}

/* ===== КАРТОЧКА ВОПРОСА — БЕЗ ТЯЖЁЛЫХ ФОНОВ ===== */
.question-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px;
}

/* Контейнер иконки — чистый, без фона */
.question-icon-box {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
  position: relative;
}

.question-icon-box::before {
  content: '';
  position: absolute;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(236,72,153,0.15));
  border-radius: 50%;
  animation: softGlow 4s ease-in-out infinite;
  z-index: -1;
}

@keyframes softGlow {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

.question-icon {
  font-size: 44px;
  animation: iconFloat 3.5s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.question-text {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 22px;
  line-height: 1.4;
}

/* ===== КНОПКИ ОТВЕТОВ ===== */
.answers-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 18px;
  background: var(--color-bg);
  border: 2px solid #E2E8F0;
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: all 250ms var(--ease);
}

.answer-btn:hover {
  border-color: var(--color-primary-light);
  background: #F8FAFC;
  transform: translateX(4px);
}

.answer-btn:active { transform: scale(0.995); }

.answer-btn.selected {
  border-color: var(--color-primary);
  background: linear-gradient(135deg, rgba(124,58,237,0.1), rgba(236,72,153,0.08));
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.15);
}

.answer-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.answer-btn.selected .answer-letter {
  background: var(--color-secondary);
}

/* ===== LOADING SCREEN ===== */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  text-align: center;
  padding: 20px;
}

.loader {
  width: 60px;
  height: 60px;
  margin-bottom: 20px;
  position: relative;
  margin-left: -50px;
}

.loader::before,
.loader::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 3px solid transparent;
  animation: spin 1.5s linear infinite;
}

.loader::before {
  width: 100%;
  height: 100%;
  border-top-color: var(--color-primary);
  border-left-color: var(--color-secondary);
}

.loader::after {
  width: 70%;
  height: 70%;
  top: 15%;
  left: 15%;
  border-top-color: var(--color-accent);
  animation-duration: 2s;
  animation-direction: reverse;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-content h3 {
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 8px;
}

.loading-text {
  font-size: var(--text-base);
  color: var(--color-text-muted);
}

/* ===== RESULT SCREEN ===== */
.result-header {
  text-align: center;
  margin-bottom: 20px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-card {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 24px;
  border: 1px solid rgba(124, 58, 237, 0.15);
}

.result-icon {
  font-size: 56px;
  margin-bottom: 14px;
  animation: iconBounce 2.5s ease-in-out infinite;
}

@keyframes iconBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.result-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 18px;
  line-height: 1.3;
}

.values-title {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.values-container {
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.values-container li {
  padding: 12px 18px 12px 40px;
  position: relative;
  font-size: var(--text-base);
  background: var(--color-card);
  border-radius: 14px;
  border-left: 3px solid var(--color-primary-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.values-container li::before {
  content: '✨';
  position: absolute;
  left: 14px;
  font-size: 15px;
  top: 50%;
  transform: translateY(-50%);
}

.match-section {
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.06);
  margin-top: 20px;
}

.match-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.match-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-card);
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(0,0,0,0.05);
}

.match-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
}

.percent-number {
  font-size: 26px;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1;
}

.percent-symbol {
  font-size: 15px;
  color: var(--color-text-muted);
}

/* ===== RESULT ACTIONS ===== */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.share-section {
  text-align: center;
}

.share-label {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.share-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 19px;
  cursor: pointer;
  transition: transform 250ms var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-card);
  box-shadow: var(--shadow-soft);
}

.share-btn:hover { transform: translateY(-4px); }

.share-btn.whatsapp { background: #25D366; color: white; }
.share-btn.telegram { background: #0088cc; color: white; }
.share-btn.vk { background: #0077FF; color: white; }

/* ===== REDIRECT SCREEN ===== */
.redirect-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  text-align: center;
}

.loader-mini {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(124, 92, 237, 0.25);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 18px;
}

.redirect-content p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
}

/* ===== TELEGRAM DARK MODE ===== */
body.telegram-dark { background: #0f1419; }
body.telegram-dark .app-container { background: #1a2332; color: #f0f4f8; }
body.telegram-dark .welcome-title { -webkit-text-fill-color: #f0f4f8; }
body.telegram-dark .question-card,
body.telegram-dark .match-card,
body.telegram-dark .values-container li {
  background: #232e3c;
  border-color: rgba(255,255,255,0.1);
}
body.telegram-dark .answer-btn {
  background: #232e3c;
  color: #f0f4f8;
  border-color: #334155;
}
body.telegram-dark .stat-card { background: rgba(124, 58, 237, 0.15); }
body.telegram-dark .result-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(236,72,153,0.15));
}
body.telegram-dark .subtitle,
body.telegram-dark .stat-label,
body.telegram-dark .values-title,
body.telegram-dark .match-label { color: #94a3b8; }

/* ===== DESKTOP ===== */
@media (min-width: 601px) {
  body { padding: 24px; }
  .app-container { border-radius: 28px; }
  .screen { padding: 32px 28px; }
  .btn-large { padding: 22px 36px; }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}