/* 수능 퀘스트 (CSAT Quest) - 밝고 화사한 라이트 테마 게이미피케이션 UI */
:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #475569;
  
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-hover: #1d4ed8;
  
  --accent-kor: #3b82f6;
  --accent-math: #10b981;
  --accent-eng: #8b5cf6;
  --accent-inq: #f59e0b;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Gamification Bar */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

.top-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  font-size: 1.8rem;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.logo-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  border: 1px solid #e2e8f0;
}

.stat-badge.hearts {
  color: #e11d48;
  background: #ffe4e6;
  border-color: #fecdd3;
}

.stat-badge.streak {
  color: #d97706;
  background: #fef3c7;
  border-color: #fde68a;
}

.stat-badge.rank {
  cursor: pointer;
  transition: all 0.2s;
}

.stat-badge.rank:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

/* XP Bar in Header */
.xp-container {
  background: #e2e8f0;
  height: 6px;
  width: 100%;
  position: relative;
}

.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  width: 0%;
  transition: width 0.4s ease;
}

/* Main Container */
main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  width: 100%;
}

/* Subject Navigation Tabs */
.subject-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.subject-btn {
  background: var(--bg-card);
  border: 2px solid #e2e8f0;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.subject-btn:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.subject-btn.active {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: var(--shadow-glow);
}

.subject-btn.active.korean { border-color: var(--accent-kor); }
.subject-btn.active.math { border-color: var(--accent-math); }
.subject-btn.active.english { border-color: var(--accent-eng); }
.subject-btn.active.inquiry { border-color: var(--accent-inq); }

.subject-btn .sub-icon {
  font-size: 1.6rem;
}

.subject-btn .sub-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
}

.subject-btn .sub-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Level Tabs */
.level-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.level-selector::-webkit-scrollbar {
  display: none;
}

.level-chip {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.level-chip:hover {
  background: #f1f5f9;
}

.level-chip.active {
  background: var(--text-main);
  color: #ffffff;
  border-color: var(--text-main);
}

.level-chip.killer {
  border-color: #fca5a5;
  color: #dc2626;
}

.level-chip.killer.active {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Roadmap Quest Cards Grid */
.quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.quest-card {
  background: var(--bg-card);
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.quest-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #94a3b8;
}

.quest-card.completed {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.quest-card.boss {
  border: 2px solid #f87171;
  background: linear-gradient(180deg, #ffffff 0%, #fef2f2 100%);
  grid-column: 1 / -1;
}

.quest-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.quest-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quest-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: #f1f5f9;
  color: var(--text-sub);
}

.quest-xp-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: #2563eb;
  background: #dbeafe;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.quest-card.boss .quest-xp-badge {
  background: #fee2e2;
  color: #dc2626;
}

.quest-status-icon {
  font-size: 1.3rem;
}

.quest-body h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
  line-height: 1.4;
}

.quest-body p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.quest-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

/* Quest Playing Modal & Arena */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: modalUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalUp {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.close-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.modal-scrollable {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Concept Cheat Card */
.concept-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
}

.concept-box.boss {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: #fca5a5;
}

.concept-box h4 {
  font-size: 0.9rem;
  font-weight: 800;
  color: #166534;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.concept-box.boss h4 {
  color: #991b1b;
}

.concept-box p {
  font-size: 0.88rem;
  color: #1f2937;
  white-space: pre-line;
  line-height: 1.6;
}

.concept-tip {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(22, 101, 52, 0.2);
  font-size: 0.82rem;
  font-weight: 700;
  color: #15803d;
}

.concept-box.boss .concept-tip {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.2);
}

/* Boss Arena Banner */
.boss-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 4px 15px rgba(49, 46, 129, 0.2);
}

.boss-avatar {
  font-size: 2.4rem;
  background: rgba(255, 255, 255, 0.1);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.boss-info {
  flex: 1;
}

.boss-info h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fca5a5;
}

.boss-hp-bar-wrap {
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
}

.boss-hp-bar {
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  height: 100%;
  width: 100%;
  transition: width 0.3s ease;
}

/* Question Area */
.question-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.question-text {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.7;
  white-space: pre-line;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.option-btn {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.option-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateX(3px);
}

.option-id {
  background: #f1f5f9;
  color: var(--text-sub);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 800;
  flex-shrink: 0;
}

.option-btn.correct {
  border-color: #10b981 !important;
  background: #ecfdf5 !important;
  color: #065f46 !important;
}

.option-btn.correct .option-id {
  background: #10b981;
  color: #ffffff;
}

.option-btn.wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
}

.option-btn.wrong .option-id {
  background: #ef4444;
  color: #ffffff;
}

/* Explanation Box */
.explanation-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 16px;
  display: none;
  animation: fadeIn 0.3s ease;
}

.explanation-box.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.explanation-box h4 {
  font-size: 0.92rem;
  font-weight: 800;
  color: #1e40af;
  margin-bottom: 6px;
}

.explanation-box p {
  font-size: 0.88rem;
  color: #1e3a8a;
  line-height: 1.6;
}

/* Action Buttons */
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-sub);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

/* Toast & Floating Message */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Canvas Particle */
#particle-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

/* Responsive */
@media (max-width: 768px) {
  .top-bar {
    padding: 10px 12px;
  }
  .subject-nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .user-status {
    gap: 8px;
  }
  .stat-badge {
    padding: 4px 8px;
    font-size: 0.78rem;
  }
  .quest-grid {
    grid-template-columns: 1fr;
  }
}
