/* ===== CSS Variables (Dark mode first) ===== */
:root {
  --primary: #f43f5e;
  --primary-light: #fb7185;
  --primary-dark: #e11d48;
  --primary-glow: #f43f5e33;
  --primary-glow-strong: #f43f5e55;
  --bg: #0a0a0f;
  --bg2: #0f0f18;
  --surface: #1a1a2e;
  --surface2: #252540;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --border2: rgba(255, 255, 255, 0.15);
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
}

/* ===== Light mode ===== */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg2: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: rgba(0, 0, 0, 0.1);
  --border2: rgba(0, 0, 0, 0.15);
  --primary-glow: #f43f5e22;
  --primary-glow-strong: #f43f5e44;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.3s, color 0.3s;
}

/* ===== Skip link ===== */
.skip-link {
  position: absolute; top: -50px; left: 0;
  background: var(--primary); color: #fff;
  padding: 8px 16px; text-decoration: none;
  z-index: 10001; border-radius: 0 0 4px 0;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ===== App loader ===== */
#app-loader {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000; transition: opacity 0.4s;
}
.loader-icon {
  font-size: 64px;
  animation: loaderPulse 1s ease-in-out infinite;
}
@keyframes loaderPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.2) rotate(10deg); }
}

/* ===== Theme toggle ===== */
.theme-toggle {
  position: fixed; top: 12px; left: 12px; z-index: 1000;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; backdrop-filter: blur(12px);
  transition: border-color 0.2s, background 0.2s;
}
.theme-toggle:hover { border-color: var(--primary); }

/* ===== Language selector ===== */
.lang-selector { position: fixed; top: 12px; right: 12px; z-index: 1000; }
.lang-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 7px 13px; border-radius: 20px;
  cursor: pointer; font-size: 13px; backdrop-filter: blur(12px);
  transition: border-color 0.2s;
}
.lang-btn:hover { border-color: var(--primary); }
.lang-dropdown {
  display: none; position: absolute; right: 0; top: 42px;
  background: rgba(18, 18, 30, 0.97); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px; min-width: 150px;
  backdrop-filter: blur(20px); z-index: 1001;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
[data-theme="light"] .lang-dropdown {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
.lang-dropdown.open { display: block; }
.lang-option {
  display: block; width: 100%; padding: 8px 12px;
  background: none; border: none; color: var(--text);
  cursor: pointer; text-align: left; border-radius: 8px;
  font-size: 13px; transition: background 0.15s;
}
.lang-option:hover { background: var(--surface2); }

/* ===== Layout ===== */
main {
  width: 100%; display: flex; flex-direction: column;
  align-items: center; flex: 1;
}
.container { width: 100%; max-width: 640px; padding: 20px; }

header {
  text-align: center; padding: 40px 20px 16px;
  width: 100%; max-width: 640px;
}
.app-title {
  font-size: clamp(24px, 6vw, 38px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.app-subtitle {
  color: var(--text-muted); font-size: 15px;
}

/* ===== Start screen ===== */
.start-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 32px 24px;
  text-align: center; backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.warning-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: 30px; padding: 10px 20px;
  font-size: 14px; font-weight: 600; color: var(--primary);
  margin-bottom: 24px;
  animation: warningPulse 2s ease-in-out infinite;
}
@keyframes warningPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(244, 63, 94, 0); }
}
.warning-icon { font-size: 18px; }
.archetype-preview {
  display: flex; justify-content: center; gap: 12px;
  font-size: 32px; margin: 20px 0;
  flex-wrap: wrap;
}
.start-desc {
  color: var(--text-muted); font-size: 14px; margin-bottom: 24px;
}
.start-btn {
  width: 100%; padding: 18px; border-radius: 16px; border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 18px; font-weight: 800;
  cursor: pointer; box-shadow: 0 4px 28px var(--primary-glow);
  transition: all 0.2s; min-height: 52px;
  letter-spacing: 0.3px;
}
.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 36px var(--primary-glow-strong);
}
.start-btn:active { transform: translateY(0); }

/* ===== Progress bar (green to red gradient) ===== */
.progress-container { margin: 0 0 16px; }
.progress-bar-bg {
  height: 6px; background: var(--border); border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px var(--primary-glow);
}
.progress-text {
  text-align: center; font-size: 13px;
  color: var(--text-muted); margin-top: 8px;
}

/* ===== Question card ===== */
.question-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 28px 24px;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.question-number {
  font-size: 12px; color: var(--primary); font-weight: 700;
  margin-bottom: 12px; letter-spacing: 2px;
  text-transform: uppercase;
}
.question-text {
  font-size: 17px; font-weight: 600; line-height: 1.6;
  margin-bottom: 24px; color: var(--text);
}

/* ===== Choice buttons ===== */
.choice-container {
  display: flex; flex-direction: column; gap: 10px;
}
.choice-btn {
  width: 100%; padding: 16px 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--border);
  border-radius: 14px; color: var(--text);
  cursor: pointer; font-size: 14px;
  text-align: left; transition: all 0.2s ease;
  display: flex; align-items: center; gap: 12px;
  line-height: 1.5; min-height: 44px;
}
[data-theme="light"] .choice-btn {
  background: rgba(0, 0, 0, 0.02);
}
.choice-btn:hover {
  border-color: var(--primary);
  background: rgba(244, 63, 94, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--primary-glow);
}
.choice-btn:active { transform: translateY(0); }
.choice-btn.selected {
  border-color: var(--primary);
  background: rgba(244, 63, 94, 0.15);
  box-shadow: 0 0 24px var(--primary-glow);
}
.choice-label {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
}

/* ===== Result screen ===== */
.result-hero {
  background: linear-gradient(135deg, var(--primary), #be123c);
  border-radius: 24px; padding: 40px 24px;
  text-align: center; margin-bottom: 20px;
  box-shadow: 0 8px 36px var(--primary-glow-strong);
  position: relative; overflow: hidden;
}
.result-hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.12), transparent 60%);
}
.result-emoji {
  font-size: 80px; margin-bottom: 16px;
  position: relative; z-index: 1;
  animation: emojiPop 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
@keyframes emojiPop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}
.result-title {
  font-size: 26px; font-weight: 900; color: #fff;
  margin-bottom: 12px; position: relative; z-index: 1;
}
.result-desc {
  font-size: 15px; color: rgba(255, 255, 255, 0.85);
  line-height: 1.6; position: relative; z-index: 1;
  max-width: 400px; margin: 0 auto;
}

/* ===== Toxicity meter ===== */
.toxicity-meter {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 24px;
  margin-bottom: 16px; text-align: center;
}
.meter-label {
  font-size: 14px; font-weight: 700; color: var(--text-muted);
  margin-bottom: 16px; text-transform: uppercase;
  letter-spacing: 1px;
}
.meter-bar-bg {
  height: 16px; background: var(--border);
  border-radius: 8px; overflow: hidden;
  position: relative;
}
.meter-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow), #f97316, var(--red));
  border-radius: 8px;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 16px var(--primary-glow);
}
.meter-value {
  font-size: 36px; font-weight: 900;
  color: var(--primary); margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

/* ===== Secondary trait ===== */
.secondary-trait {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 20px;
  margin-bottom: 16px; font-size: 14px;
  color: var(--text-muted); text-align: center;
}

/* ===== "I feel attacked" badge ===== */
.badge-container {
  display: flex; justify-content: center; margin-bottom: 20px;
}
.attacked-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(244, 63, 94, 0.1);
  border: 2px solid var(--primary);
  border-radius: 30px; padding: 12px 24px;
  font-size: 15px; font-weight: 700;
  color: var(--primary); cursor: pointer;
  transition: all 0.2s;
  animation: badgeShake 3s ease-in-out infinite;
}
.attacked-badge:hover {
  background: rgba(244, 63, 94, 0.2);
  transform: scale(1.05);
}
.badge-icon { font-size: 20px; }
@keyframes badgeShake {
  0%, 100% { transform: rotate(0deg); }
  2% { transform: rotate(-3deg); }
  4% { transform: rotate(3deg); }
  6% { transform: rotate(-3deg); }
  8% { transform: rotate(0deg); }
}

/* ===== Share section ===== */
.share-section {
  text-align: center; margin-bottom: 16px;
}
.share-btns {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap;
}
.share-btn {
  padding: 12px 22px; border-radius: 12px; border: none;
  cursor: pointer; font-size: 14px; font-weight: 700;
  transition: all 0.2s; min-height: 44px;
}
.share-btn:hover { transform: translateY(-2px); opacity: 0.9; }
.share-copy {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text);
}
.share-twitter {
  background: #1a1a1a; color: #fff;
  border: 1px solid #333;
}
[data-theme="light"] .share-twitter {
  background: #0f1419; color: #fff;
}
.share-copied {
  display: none; color: var(--green);
  font-size: 13px; font-weight: 600;
  margin-top: 8px;
}
.share-copied.show { display: block; }

/* ===== Retake button ===== */
.retake-btn {
  display: block; width: 100%; padding: 18px;
  background: var(--surface); border: 2px solid var(--border);
  color: var(--text); border-radius: 16px;
  cursor: pointer; font-size: 16px; font-weight: 700;
  margin-bottom: 20px; min-height: 52px;
  transition: all 0.2s;
}
.retake-btn:hover {
  border-color: var(--primary);
  background: rgba(244, 63, 94, 0.08);
  transform: translateY(-2px);
}

/* ===== Cross promo ===== */
.cross-promo-section { width: 100%; margin: 20px 0; }

/* ===== Footer ===== */
footer {
  text-align: center; padding: 24px 20px;
  color: var(--text-muted); font-size: 13px;
  width: 100%; max-width: 640px;
}
footer a {
  color: var(--text-muted); text-decoration: none;
  transition: color 0.2s;
}
footer a:hover { color: var(--primary); }

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.4s ease; }

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

/* ===== Responsive ===== */
@media (max-width: 480px) {
  header { padding: 28px 16px 12px; }
  .question-card { padding: 22px 16px; }
  .start-card { padding: 24px 16px; }
  .archetype-preview { font-size: 26px; gap: 8px; }
  .result-hero { padding: 32px 16px; }
  .result-emoji { font-size: 64px; }
  .result-title { font-size: 22px; }
}
