:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-bg: #ffffff;
  --color-text: #1f2937;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-shadow: rgba(0, 0, 0, 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  background: var(--color-bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen[hidden] {
  display: none !important;
}

.screen--loading {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.screen--error,
.screen--completed,
.screen--welcome,
.screen--thanks,
.screen--offline {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-content,
.error-content,
.completed-content,
.welcome-content,
.thanks-content,
.offline-content {
  width: 100%;
  max-width: 320px;
  animation: fadeIn 0.4s ease;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-lg);
}

.spinner__circle {
  width: 100%;
  height: 100%;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 1rem;
  color: var(--color-text-secondary);
}

.error-icon,
.completed-icon,
.welcome-emoji,
.thanks-emoji,
.offline-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  animation: bounceIn 0.5s ease;
}

.error-title,
.completed-title,
.welcome-title,
.thanks-title,
.offline-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.error-message,
.completed-message,
.welcome-description,
.thanks-message,
.offline-message {
  font-size: 1rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.completed-submessage,
.offline-submessage {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
  line-height: 1.5;
  opacity: 0.85;
}

.welcome-subtitle {
  font-size: 1.25rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--color-primary);
  color: white;
  width: 100%;
  box-shadow: 0 2px 8px var(--color-shadow);
}

.btn--primary:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--color-shadow);
}

.btn--large {
  padding: var(--space-lg) var(--space-xl);
  font-size: 1.125rem;
  min-height: 56px;
  border-radius: var(--radius-lg);
}

.btn--text {
  background: transparent;
  color: var(--color-text-secondary);
  padding: var(--space-sm);
  font-weight: 500;
}

.btn--text:hover {
  color: var(--color-text);
}

.screen--question {
  padding: 0;
}

.question-header {
  padding: var(--space-lg);
  padding-top: var(--space-xl);
  background: linear-gradient(180deg, #f9fafb 0%, var(--color-bg) 100%);
}

.progress {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.progress__bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
  min-width: 4%;
}

.progress__text {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.question-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  padding-top: var(--space-xl);
}

.question-text {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xl);
  line-height: 1.4;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.option-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  padding: var(--space-lg);
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
}

.option-btn:hover {
  border-color: var(--color-primary);
  background: #f8fafc;
}

.option-btn:active {
  transform: scale(0.98);
  background: #eff6ff;
}

.option-btn__indicator {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.option-btn:hover .option-btn__indicator {
  border-color: var(--color-primary);
}

.option-btn__text {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--color-text);
  flex: 1;
}

.option-btn.selected {
  border-color: var(--color-primary);
  background: #eff6ff;
}

.option-btn.selected .option-btn__indicator {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: inset 0 0 0 4px white;
}

.question-footer {
  padding: var(--space-lg);
  padding-bottom: var(--space-xl);
}

.thanks-checkmark {
  margin-top: var(--space-xl);
}

.checkmark {
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.checkmark__circle {
  stroke: var(--color-success);
  stroke-width: 3;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark__check {
  stroke: var(--color-success);
  stroke-width: 3;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.6s forwards;
}

.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-text);
  color: white;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--color-error);
}

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

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

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 360px) {
  .screen {
    padding: var(--space-md);
  }
  
  .question-text {
    font-size: 1.25rem;
  }
  
  .btn--large {
    font-size: 1rem;
    padding: var(--space-md) var(--space-lg);
  }
  
  .option-btn {
    padding: var(--space-md);
  }
  
  .option-btn__text {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-text: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-border: #334155;
  }
  
  .question-header {
    background: linear-gradient(180deg, #1e293b 0%, var(--color-bg) 100%);
  }
  
  .option-btn {
    background: #1e293b;
    border-color: #334155;
  }
  
  .option-btn:hover {
    background: #334155;
  }
  
  .option-btn.selected {
    background: rgba(37, 99, 235, 0.2);
  }
}
