/* ===== CSS Variables ===== */
:root {
  --primary: #00C9A7;
  --primary-light: #33D4B8;
  --primary-dark: #009E84;
  --primary-glow: rgba(0, 201, 167, 0.4);
  --bg: #0a0a0a;
  --bg-card: rgba(20, 20, 20, 0.85);
  --bg-card-border: rgba(0, 201, 167, 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: #f0f7f5;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-border: rgba(0, 201, 167, 0.15);
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #999;
  --surface: #ffffff;
  --surface-hover: #e8f5f2;
  --shadow: rgba(0, 201, 167, 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;
}

/* Game-themed grid background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0, 201, 167, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 201, 167, 0.08) 0%, transparent 50%),
    linear-gradient(rgba(0, 201, 167, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 201, 167, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0, 201, 167, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 201, 167, 0.04) 0%, transparent 50%),
    linear-gradient(rgba(0, 201, 167, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 201, 167, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
}

/* ===== 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;
}

.npc-icon {
  margin: 0 auto 24px;
  width: 120px;
  height: 120px;
  animation: npcFloat 3s ease-in-out infinite;
  image-rendering: pixelated;
}

@keyframes npcFloat {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 4px 12px var(--primary-glow)); }
  50% { transform: translateY(-8px); filter: drop-shadow(0 12px 20px var(--primary-glow)); }
}

.npc-question-mark {
  animation: questionPulse 1.5s ease-in-out infinite;
}

@keyframes questionPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.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;
  font-family: 'Courier New', monospace;
}

/* ===== 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;
  padding-left: 40px;
}

/* Game-style option indicator */
.option-btn::before {
  content: '>';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  font-family: 'Courier New', monospace;
  font-weight: bold;
  font-size: 1.1rem;
  opacity: 0;
  transition: all var(--transition);
}

.option-btn:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  padding-left: 44px;
}

.option-btn:hover::before {
  opacity: 1;
}

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

.option-btn.selected::before {
  opacity: 1;
  content: '>';
}

/* ===== 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); }
}

/* ===== NPC Meter ===== */
.npc-meter {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 28px;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
  font-family: 'Courier New', monospace;
}

.meter-label-left {
  color: var(--text-muted);
}

.meter-label-right {
  color: var(--primary-light);
}

.meter-track {
  width: 100%;
  height: 12px;
  background: var(--surface);
  border-radius: 6px;
  position: relative;
  overflow: visible;
  border: 1px solid rgba(0, 201, 167, 0.1);
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg,
    #666 0%,
    #888 20%,
    var(--primary-dark) 40%,
    var(--primary) 60%,
    var(--primary-light) 80%,
    #FFD700 100%
  );
  transition: width 1.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px var(--primary-glow);
  position: relative;
}

.meter-indicator {
  position: absolute;
  top: -6px;
  left: 0%;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border: 3px solid #fff;
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 1.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px var(--primary-glow);
  z-index: 2;
}

.meter-score {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 12px;
  font-family: 'Courier New', monospace;
}

/* ===== Tier Icon ===== */
.tier-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
  background: linear-gradient(135deg, rgba(0, 201, 167, 0.2), rgba(0, 201, 167, 0.05));
}

.tier-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); }
}

/* Tier-specific colors */
.tier-icon.tier-npc { background: linear-gradient(135deg, #1a1a2e, #2d2d4e); }
.tier-icon.tier-npc::after { border-color: #666; }
.tier-icon.tier-extra { background: linear-gradient(135deg, #1a2a1a, #2d3e2d); }
.tier-icon.tier-extra::after { border-color: #888; }
.tier-icon.tier-side { background: linear-gradient(135deg, #0a2a2e, #1b4e4a); }
.tier-icon.tier-side::after { border-color: var(--primary); }
.tier-icon.tier-main { background: linear-gradient(135deg, #2e2a0a, #4e4a1b); }
.tier-icon.tier-main::after { border-color: #FFD700; }
.tier-icon.tier-boss { background: linear-gradient(135deg, #2e0a0a, #4e1b1b); }
.tier-icon.tier-boss::after { border-color: #FF4500; }

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

.result-tagline {
  font-size: 1rem;
  color: var(--primary-light);
  font-style: italic;
  margin-bottom: 16px;
  font-family: 'Courier New', monospace;
}

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

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

.trait-tag {
  padding: 6px 14px;
  background: rgba(0, 201, 167, 0.1);
  border: 1px solid rgba(0, 201, 167, 0.25);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--primary-light);
  font-weight: 500;
  font-family: 'Courier New', monospace;
}

/* ===== 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;
  position: relative;
}

.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-tier-name {
    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);
}
