/* ===== CSS Variables ===== */
:root {
  --primary: #8B0000;
  --primary-light: #B22222;
  --primary-dark: #5C0000;
  --primary-glow: rgba(139, 0, 0, 0.4);
  --bg: #0a0a0a;
  --bg-card: rgba(20, 20, 20, 0.85);
  --bg-card-border: rgba(139, 0, 0, 0.2);
  --text: #f0f0f0;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --surface: #1a1a1a;
  --surface-hover: #2a2a2a;
  --shadow: rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #f5f0f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-border: rgba(139, 0, 0, 0.15);
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #999;
  --surface: #ffffff;
  --surface-hover: #f0e8e8;
  --shadow: rgba(139, 0, 0, 0.1);
}

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

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

/* ===== Base ===== */
html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Dark dramatic background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(139, 0, 0, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 0, 0, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(92, 0, 0, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(139, 0, 0, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 0, 0, 0.05) 0%, transparent 50%);
}

/* ===== Skip Link ===== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  z-index: 10001;
  text-decoration: none;
  font-weight: 600;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 16px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--bg-card-border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: all var(--transition);
}

.theme-toggle:hover {
  background: var(--surface-hover);
  transform: scale(1.05);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ===== Language Selector ===== */
.lang-selector {
  position: fixed;
  top: 16px;
  right: 70px;
  z-index: 100;
}

.lang-selector select {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-card-border);
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
}

.lang-selector select:hover {
  border-color: var(--primary);
}

/* ===== Screens ===== */
.screen {
  display: none;
  min-height: 100vh;
  padding: 80px 16px 40px;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}

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

/* ===== Glassmorphism Card ===== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 8px 32px var(--shadow);
  transition: all var(--transition);
}

/* ===== Intro Screen ===== */
.intro-card {
  text-align: center;
}

.villain-icon {
  margin: 0 auto 24px;
  width: 100px;
  height: 100px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px var(--primary-glow)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 20px var(--primary-glow)); }
}

.villain-icon svg path,
.villain-icon svg circle,
.villain-icon svg line {
  stroke: var(--primary);
}

.villain-icon svg path[fill] {
  fill: var(--primary);
}

.intro-card h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 1rem;
}

.question-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 16px;
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  min-width: 200px;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px var(--primary-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

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

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  min-width: 200px;
  padding: 14px 32px;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary-light);
}

/* ===== Progress Bar ===== */
.progress-container {
  margin-bottom: 28px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary), var(--primary-light));
  border-radius: 3px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px var(--primary-glow);
}

.progress-text {
  display: block;
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Question Area ===== */
.question-text {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.5;
  min-height: 60px;
}

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

.option-btn {
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.option-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform var(--transition);
}

.option-btn:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  transform: translateX(4px);
}

.option-btn:hover::before {
  transform: scaleY(1);
}

.option-btn.selected {
  border-color: var(--primary);
  background: rgba(139, 0, 0, 0.15);
}

/* ===== Result Screen ===== */
.result-card {
  text-align: center;
  max-width: 600px;
}

.result-reveal {
  animation: revealResult 0.8s ease;
}

@keyframes revealResult {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Power Meter */
.power-meter {
  width: 100%;
  max-width: 300px;
  margin: 0 auto 24px;
  position: relative;
}

.power-meter .meter-fill {
  height: 8px;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary), #ff4444);
  border-radius: 4px;
  width: 0%;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px var(--primary-glow);
}

.power-meter .meter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Archetype Icon */
.archetype-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
}

.archetype-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  animation: rotateGlow 3s linear infinite;
}

@keyframes rotateGlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.archetype-icon.mastermind { background: linear-gradient(135deg, #1a0a2e, #2d1b4e); }
.archetype-icon.charmer { background: linear-gradient(135deg, #2e0a1a, #4e1b2d); }
.archetype-icon.rebel { background: linear-gradient(135deg, #0a2e1a, #1b4e2d); }
.archetype-icon.tyrant { background: linear-gradient(135deg, #2e1a0a, #4e2d1b); }
.archetype-icon.trickster { background: linear-gradient(135deg, #0a1a2e, #1b2d4e); }
.archetype-icon.fallen { background: linear-gradient(135deg, #1a1a2e, #2d2d4e); }

.result-type {
  font-size: 0.9rem;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.result-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--primary-light), #ff6666);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* Traits */
.result-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.trait-tag {
  padding: 6px 14px;
  background: rgba(139, 0, 0, 0.15);
  border: 1px solid rgba(139, 0, 0, 0.3);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--primary-light);
  font-weight: 500;
}

/* Villain Quote */
.villain-quote {
  font-style: italic;
  color: var(--text-secondary);
  padding: 16px 20px;
  border-left: 3px solid var(--primary);
  background: rgba(139, 0, 0, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Score Breakdown */
.score-breakdown {
  margin-bottom: 24px;
}

.score-breakdown h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.score-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 90px;
  text-align: right;
  flex-shrink: 0;
}

.score-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-value {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}

.score-bar-value.mastermind { background: #6a0dad; }
.score-bar-value.charmer { background: #c2185b; }
.score-bar-value.rebel { background: #2e7d32; }
.score-bar-value.tyrant { background: #e65100; }
.score-bar-value.trickster { background: #1565c0; }
.score-bar-value.fallen { background: #455a64; }

/* Result Actions */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-share {
  gap: 8px;
}

/* ===== Share Modal ===== */
.share-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.share-modal.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.share-modal-content {
  max-width: 400px;
  text-align: center;
}

.share-modal-content h3 {
  margin-bottom: 20px;
  font-size: 1.2rem;
}

.share-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  min-width: 80px;
  min-height: 80px;
  background: var(--surface);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.8rem;
}

.share-btn:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.share-twitter:hover { color: #1da1f2; }
.share-facebook:hover { color: #1877f2; }
.share-copy:hover { color: var(--primary-light); }

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .glass-card {
    padding: 40px 36px;
  }

  .intro-card h1 {
    font-size: 2.2rem;
  }

  .question-text {
    font-size: 1.25rem;
  }

  .result-title {
    font-size: 1.9rem;
  }

  .result-actions {
    flex-direction: row;
    justify-content: center;
  }
}

@media (max-width: 360px) {
  .glass-card {
    padding: 24px 16px;
  }

  .lang-selector {
    right: 64px;
  }

  .lang-selector select {
    padding: 8px 8px;
    font-size: 12px;
  }
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--bg-card-border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 2000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 16px var(--shadow);
}

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

/* ===== Percentile Stat ===== */
.percentile-stat {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 20px;
  padding: 10px 16px;
  background: rgba(139, 0, 0, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(139, 0, 0, 0.15);
}

/* ===== Related Tests ===== */
.related-tests {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--bg-card-border);
  width: 100%;
}

.related-tests h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-align: center;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.related-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.related-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--card-color, var(--primary));
}

.related-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-color, var(--primary));
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.related-emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.related-name {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

@media (min-width: 640px) {
  .related-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
