/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F8F9FE;
  --surface: #FFFFFF;
  --text: #1A1A2E;
  --text-muted: #6B7280;
  --text-hint: #9CA3AF;
  --border: #E8EAF0;
  --primary: #FF5E3A;
  --primary-dark: #E04A28;
  --secondary: #4338CA;
  --accent: #00D9A3;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(26,26,46,0.06);
  --shadow-lg: 0 8px 32px rgba(26,26,46,0.12);
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Oswald', 'Noto Sans SC', sans-serif;
  --font-body: 'Noto Sans SC', -apple-system, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

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

/* ===== Screen System ===== */
.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.screen.active {
  display: flex;
  animation: screenIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ===== Welcome Screen ===== */
.welcome-container {
  width: 100%;
  max-width: 440px;
  position: relative;
}

.dna-decoration {
  position: absolute;
  top: -40px;
  right: -30px;
  width: 200px;
  height: 300px;
  opacity: 0.5;
  z-index: 0;
  animation: dnaFloat 6s ease-in-out infinite;
}

@keyframes dnaFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.welcome-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--primary);
  background: #FFF0EC;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 28px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 20px;
}

.title-line {
  display: inline-block;
}

.title-line.accent {
  color: var(--primary);
  position: relative;
}

.title-line.accent::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  height: 6px;
  background: #FFE0D8;
  border-radius: 3px;
  z-index: -1;
}

.welcome-desc {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.7;
}

.gene-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
}

.gene-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c) 12%, white);
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 25%, transparent);
}

.nickname-input-wrap {
  margin-bottom: 20px;
}

.nickname-input {
  width: 100%;
  max-width: 280px;
  padding: 14px 20px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  text-align: center;
  transition: border-color var(--transition);
}

.nickname-input:focus {
  border-color: var(--primary);
}

.nickname-input::placeholder {
  color: var(--text-hint);
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 700;
  color: white;
  background: var(--primary);
  border: none;
  padding: 16px 48px;
  border-radius: 30px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 6px 20px rgba(255,94,58,0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(255,94,58,0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.welcome-footer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-hint);
}

/* ===== Quiz Screen ===== */
.quiz-container {
  width: 100%;
  max-width: 520px;
}

.quiz-header {
  margin-bottom: 32px;
}

.progress-bar-wrap {
  position: relative;
  height: 6px;
  background: #E8EAF0;
  border-radius: 3px;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #FF8A65);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-dots {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  margin-top: 8px;
}

.progress-dot {
  flex: 1;
  height: 3px;
  background: #E8EAF0;
  border-radius: 2px;
  transition: background var(--transition);
}

.progress-dot.done {
  background: var(--primary);
}

.progress-dot.current {
  background: var(--primary);
  opacity: 0.5;
}

.progress-text {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-hint);
  letter-spacing: 1px;
}

#current-q {
  color: var(--primary);
  font-size: 18px;
}

/* ===== Question Card ===== */
.question-area {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.question-card {
  animation: questionIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes questionIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.question-number {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.question-text {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  line-height: 1.4;
}

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

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: #F8F9FE;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.option:hover {
  background: #FFF0EC;
  border-color: #FFD0C2;
  transform: translateX(4px);
}

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

.option-key {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  background: white;
  border: 2px solid #E8EAF0;
  border-radius: 8px;
  transition: all var(--transition);
}

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

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

/* ===== Loading Screen ===== */
.loading-container {
  text-align: center;
}

.dna-spinner {
  position: relative;
  width: 80px;
  height: 120px;
  margin: 0 auto 32px;
}

.dna-strand {
  position: absolute;
  width: 3px;
  height: 100%;
  border-radius: 2px;
  top: 0;
}

.dna-strand-1 {
  left: 20px;
  background: var(--primary);
  animation: dnaSpin1 1.5s ease-in-out infinite;
}

.dna-strand-2 {
  right: 20px;
  background: var(--accent);
  animation: dnaSpin2 1.5s ease-in-out infinite;
}

@keyframes dnaSpin1 {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(180deg); }
}

@keyframes dnaSpin2 {
  0%, 100% { transform: rotateY(180deg); }
  50% { transform: rotateY(360deg); }
}

.dna-rung {
  position: absolute;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--secondary);
  border-radius: 2px;
  opacity: 0.5;
}

.rung-1 { top: 20px; animation: rungPulse 1.5s ease-in-out 0s infinite; }
.rung-2 { top: 45px; animation: rungPulse 1.5s ease-in-out 0.2s infinite; }
.rung-3 { top: 70px; animation: rungPulse 1.5s ease-in-out 0.4s infinite; }
.rung-4 { top: 95px; animation: rungPulse 1.5s ease-in-out 0.6s infinite; }

@keyframes rungPulse {
  0%, 100% { opacity: 0.2; transform: scaleX(0.6); }
  50% { opacity: 0.7; transform: scaleX(1); }
}

.loading-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.loading-subtext {
  font-size: 13px;
  color: var(--text-hint);
  font-family: var(--font-display);
  letter-spacing: 2px;
}

/* ===== Result Screen ===== */
.result-container {
  width: 100%;
  max-width: 440px;
}

.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: resultIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes resultIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-header {
  padding: 36px 24px 28px;
  text-align: center;
  background: var(--result-bg, #FFF0EC);
  position: relative;
  overflow: hidden;
}

.result-header::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--result-color, #FF5E3A);
  opacity: 0.08;
}

.result-header::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--result-color, #FF5E3A);
  opacity: 0.06;
}

.result-icon {
  font-size: 56px;
  margin-bottom: 12px;
  display: inline-block;
  animation: iconBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.2s both;
}

@keyframes iconBounce {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-gene-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--result-color, #FF5E3A);
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.result-core-trait {
  font-size: 14px;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.result-body {
  padding: 24px;
}

.result-section {
  margin-bottom: 20px;
}

.result-section:last-child {
  margin-bottom: 0;
}

.result-section-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-hint);
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* DNA Bar */
.dna-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dna-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dna-bar-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.dna-bar-label {
  font-size: 13px;
  color: var(--text-muted);
  width: 70px;
  flex-shrink: 0;
}

.dna-bar-track {
  flex: 1;
  height: 8px;
  background: #F0F1F5;
  border-radius: 4px;
  overflow: hidden;
}

.dna-bar-fill {
  height: 100%;
  border-radius: 4px;
  animation: barFill 1s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes barFill {
  from { width: 0 !important; }
}

.dna-bar-percent {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* Scene boxes */
.scene-box {
  padding: 14px 16px;
  background: #F8F9FE;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--result-color, #FF5E3A);
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

.scene-box.avoid {
  border-left-color: #F59E0B;
  background: #FFF8E8;
}

/* Advice */
.advice-text {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.6;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--result-color, #FF5E3A) 8%, white);
  border-radius: var(--radius-sm);
}

/* Partner */
.partner-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #F8F9FE;
  border-radius: var(--radius-sm);
}

.partner-icon {
  font-size: 28px;
}

.partner-info {
  flex: 1;
}

.partner-label {
  font-size: 13px;
  color: var(--text-hint);
  margin-bottom: 2px;
}

.partner-desc {
  font-size: 13px;
  color: var(--text);
}

/* Result footer */
.result-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.result-footer-text {
  font-size: 12px;
  color: var(--text-hint);
  margin-bottom: 16px;
  line-height: 1.6;
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-share, .btn-retry {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 28px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-share {
  background: var(--result-color, #FF5E3A);
  color: white;
}

.btn-share:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-retry {
  background: #F0F1F5;
  color: var(--text-muted);
}

.btn-retry:hover {
  background: #E8EAF0;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  pointer-events: none;
}

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

/* ===== Responsive ===== */
@media (max-width: 380px) {
  .welcome-title { font-size: 44px; }
  .question-text { font-size: 18px; }
  .option { padding: 14px 14px; }
  .option-text { font-size: 14px; }
}

@media (min-width: 768px) {
  .welcome-title { font-size: 64px; }
  .question-text { font-size: 24px; }
}
