:root {
  --bg: #f6f7fb;
  --card: rgba(255, 255, 255, 0.92);
  --text: #151826;
  --muted: #667085;
  --line: #e8eaf2;
  --primary: #6c63ff;
  --primary-strong: #5a50ff;
  --primary-soft: rgba(108, 99, 255, 0.12);
  --success: #12b76a;
  --danger: #e5484d;
  --shadow: 0 12px 40px rgba(31, 41, 55, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --tap: 56px;
  --maxw: 100%;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(108, 99, 255, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(18, 183, 106, 0.08), transparent 22%),
    linear-gradient(180deg, #fbfcff 0%, #f4f6fb 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(16px, env(safe-area-inset-bottom))
    16px;
}

.app {
  flex: 1;
  width: 100%;
  min-height: 80vh;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
}

#questionnaire,
#screen-intro,
#screen-success,
#screen-server-error {
  width: 100%;
}

.card {
  width: 100%;
  max-width: 680px;
  min-height: 80vh;
  margin: 0 auto;
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 24px 18px;
  display: none;
  transform: translateY(10px) scale(0.985);
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.card.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 12px;
}

h1, h2 {
  margin: 0 0 10px 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.8rem, 6vw, 2.3rem);
}

h2 {
  font-size: clamp(1.35rem, 5vw, 1.7rem);
}

.lead,
.hint,
.error-text,
.footer,
.success-card p,
.error-card p {
  line-height: 1.5;
}

.lead {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 24px 0;
}

.hint {
  color: var(--muted);
  margin: 0 0 18px 0;
}

.error-text {
  min-height: 22px;
  color: var(--danger);
  font-size: 0.92rem;
  margin: 8px 0 0;
}

.step-top {
  margin-bottom: 18px;
}

.step-counter {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 700;
}

.progress {
  width: 100%;
  height: 10px;
  background: #edf0f7;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6c63ff 0%, #8a84ff 100%);
  transition: width 0.28s ease;
}

.choice-grid {
  display: grid;
  gap: 12px;
}

.choice-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-btn,
.score-btn,
.primary-btn,
.ghost-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.14s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}

.choice-btn {
  min-height: var(--tap);
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.04);
}

.choice-btn:active,
.primary-btn:active,
.ghost-btn:active,
.score-btn:active {
  transform: scale(0.97);
}

.choice-btn.selected,
.score-btn.selected {
  background: linear-gradient(180deg, #726aff 0%, #5f55ff 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(108, 99, 255, 0.28);
  animation: popSelect 0.22s ease;
}

@keyframes popSelect {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.input-wrap,
.textarea-wrap {
  display: block;
}

input[type="number"],
textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--text);
  padding: 16px;
  box-shadow: inset 0 1px 1px rgba(16, 24, 40, 0.02);
  outline: none;
}

input[type="number"] {
  min-height: 60px;
  font-size: 1.1rem;
  text-align: center;
  font-weight: 700;
}

textarea {
  resize: vertical;
  min-height: 132px;
  font-size: 1rem;
}

input[type="number"]:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.12);
}

.score-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.score-btn {
  min-height: 52px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.04);
}

.score-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.nav-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.primary-btn,
.ghost-btn {
  min-height: 56px;
  border-radius: 18px;
  padding: 0 18px;
  font-weight: 800;
  font-size: 1rem;
  flex: 1;
}

.primary-btn {
  background: linear-gradient(180deg, #726aff 0%, #5f55ff 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(108, 99, 255, 0.25);
}

.ghost-btn {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--line);
}

.primary-btn[disabled],
.ghost-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.success-card,
.error-card,
.intro-card {
  text-align: center;
}

.success-icon,
.error-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  font-size: 2rem;
  font-weight: 900;
}

.success-icon {
  background: rgba(18, 183, 106, 0.12);
  color: var(--success);
}

.error-icon {
  background: rgba(229, 72, 77, 0.12);
  color: var(--danger);
}

.footer {
  width: 100%;
  max-width: 680px;
  margin: 18px auto 0;
  text-align: center;
  color: #667085;
  font-size: 0.9rem;
  line-height: 1.4;
  padding: 6px 8px;
}

@media (max-width: 420px) {
  .card {
    padding: 20px 14px;
    border-radius: 20px;
  }

  .score-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .score-btn {
    min-height: 48px;
    font-size: 0.96rem;
  }

  .score-legend {
    font-size: 0.82rem;
  }
}

@media (max-width: 950px) and (orientation: landscape) {
  .app {
    min-height: auto;
  }

  .card {
    min-height: calc(100vh - 120px);
    max-width: 720px;
    justify-content: center;
  }

  .footer {
    max-width: 720px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}