/* MindQuest: Gamified Psychology Learning Platform (Bright & Clean Theme) */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfdfe;
  --border-color: #e2e8f0;
  --border-glow: #cbd5e1;
  
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --accent-cyan: #0284c7;
  --accent-pink: #db2777;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --danger: #dc2626;

  --tier-bronze: #b45309;
  --tier-silver: #64748b;
  --tier-gold: #d97706;
  --tier-diamond: #0284c7;

  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 24px -4px rgba(79, 70, 229, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --glass-blur: blur(16px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(79, 70, 229, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(2, 132, 199, 0.06) 0%, transparent 50%);
  background-attachment: fixed;
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Header & Status Bar */
.app-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.header-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  font-size: 2.1rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(79, 70, 229, 0.2));
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-dim);
  font-weight: 600;
}

.player-status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-badge {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.status-badge.hearts { color: #e11d48; border-color: #fecdd3; background: #fff1f2; }
.status-badge.combo { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.status-badge.exp { color: #0369a1; border-color: #bae6fd; background: #f0f9ff; }
.status-badge.rank { color: #7c3aed; border-color: #ddd6fe; background: #f5f3ff; }

.sound-toggle-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.sound-toggle-btn:hover {
  background: #f1f5f9;
  border-color: var(--primary);
  color: var(--primary);
}

/* Nav Tabs */
.app-nav {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-container::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 0.9rem 1.4rem;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-tab:hover {
  color: var(--primary);
  background: #f8fafc;
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #f5f7ff;
  font-weight: 700;
}

/* Main Content Area */
.main-wrapper {
  max-width: 1300px;
  margin: 1.75rem auto 4rem auto;
  padding: 0 1rem;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Level Filters */
.level-filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.filter-btn:hover {
  color: var(--text-main);
  border-color: var(--primary);
}

.filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.25);
}

.filter-btn.bronze.active { background: #b45309; border-color: #b45309; }
.filter-btn.silver.active { background: #475569; border-color: #475569; }
.filter-btn.gold.active { background: #d97706; border-color: #d97706; }
.filter-btn.diamond.active { background: #0284c7; border-color: #0284c7; }

/* Stage Grid */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stage-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.stage-card:hover {
  background: var(--bg-card-hover);
  border-color: #cbd5e1;
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stage-card.cleared {
  border-color: #86efac;
  background: linear-gradient(to bottom, #ffffff, #f0fdf4);
}

.stage-card.cleared::after {
  content: '✓ 완료';
  position: absolute;
  top: 12px;
  right: 12px;
  background: #dcfce7;
  color: var(--accent-emerald);
  border: 1px solid #86efac;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stage-tier-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.tier-bronze-text { color: #b45309; }
.tier-silver-text { color: #475569; }
.tier-gold-text { color: #d97706; }
.tier-diamond-text { color: #0284c7; }

.stage-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.stage-icon {
  font-size: 1.9rem;
  line-height: 1;
}

.stage-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  color: #0f172a;
}

.stage-subtitle {
  font-size: 0.83rem;
  color: var(--text-dim);
  margin-bottom: 0.85rem;
  flex-grow: 1;
}

.stage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  border-top: 1px solid #f1f5f9;
  padding-top: 0.75rem;
}

/* Study Modal */
.study-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.study-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.study-modal-content {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.25rem;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  color: var(--text-main);
}

.modal-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: #f1f5f9;
  border: none;
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.study-story-box {
  background: linear-gradient(135deg, #eef2ff 0%, #f0fdfa 100%);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-style: italic;
  color: #1e1b4b;
  border: 1px solid #e0e7ff;
}

.study-body-text {
  font-size: 0.98rem;
  line-height: 1.8;
  color: #334155;
  white-space: pre-line;
  margin-bottom: 1.5rem;
}

.study-key-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.concept-chip {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
}

/* Quiz Section */
.quiz-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 1.6rem;
}

.quiz-title-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
}

.quiz-question-text {
  font-size: 1.12rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  line-height: 1.5;
  color: #0f172a;
}

.quiz-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.quiz-option-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  padding: 0.95rem 1.25rem;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.quiz-option-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: var(--primary);
  transform: translateX(4px);
}

.quiz-option-btn.correct {
  background: #ecfdf5 !important;
  border-color: #34d399 !important;
  color: #065f46 !important;
  font-weight: 800;
}

.quiz-option-btn.wrong {
  background: #fef2f2 !important;
  border-color: #f87171 !important;
  color: #991b1b !important;
}

.quiz-feedback-box {
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  animation: fadeIn 0.3s ease;
}

.quiz-feedback-box.correct {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 5px solid var(--accent-emerald);
}

.quiz-feedback-box.wrong {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 5px solid var(--danger);
}

/* Brain Lab Layout */
.brain-lab-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .brain-lab-grid {
    grid-template-columns: 1fr;
  }
}

.brain-selector-panel {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.brain-part-btn {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: var(--text-main);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
}

.brain-part-btn:hover {
  background: #f8fafc;
  border-color: var(--primary-light);
}

.brain-part-btn.active {
  background: #eef2ff;
  border-color: var(--primary);
  color: var(--primary);
}

.brain-detail-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.brain-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-left: 1rem;
  margin-bottom: 1.5rem;
}

.brain-card-icon {
  font-size: 2.5rem;
}

.brain-card-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
}

.brain-card-subtitle {
  font-size: 0.92rem;
  color: var(--text-dim);
  font-weight: 600;
}

.brain-info-section {
  margin-bottom: 1.25rem;
}

.brain-info-section h4 {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.brain-feature-list {
  list-style: none;
}

.brain-feature-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.94rem;
  color: #334155;
}

.brain-feature-list .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.brain-badge {
  display: inline-block;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  color: #0369a1;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.88rem;
}

.brain-quote {
  background: #f8fafc;
  border-left: 3px solid #cbd5e1;
  border: 1px solid #e2e8f0;
  border-left-width: 4px;
  padding: 0.85rem 1.1rem;
  border-radius: 4px;
  font-style: italic;
  font-size: 0.92rem;
  color: #334155;
}

.brain-theory-text {
  color: #334155;
  font-size: 0.93rem;
  line-height: 1.6;
}

/* Experiments & Detective Styles */
.lab-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.lab-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #0f172a;
}

.lab-desc {
  font-size: 0.94rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.dilemma-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.btn {
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-choice {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}
.btn-choice:hover {
  border-color: var(--primary);
  background: #f8fafc;
  color: var(--primary);
}

.btn-choice.selected {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
  font-weight: 800;
}

.analysis-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 1.35rem;
  border-left: 5px solid var(--primary);
  margin-top: 1rem;
  color: #1e293b;
}

.scan-bar {
  margin: 0.6rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.bar-fill {
  display: inline-block;
  height: 10px;
  border-radius: 5px;
}
.bar-fill.high { width: 140px; background: linear-gradient(90deg, #4f46e5, #db2777); }
.bar-fill.mid { width: 70px; background: #94a3b8; }

.round-badge {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: #1e293b;
}

.history-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f5f9;
}

/* Detective Mode Styles */
.detective-case-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.detective-story {
  font-size: 1.05rem;
  line-height: 1.8;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 1.35rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  color: #1e293b;
}

.detective-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (max-width: 600px) {
  .detective-options { grid-template-columns: 1fr; }
}

.detective-feedback {
  margin-top: 1.25rem;
  padding: 1.35rem;
  border-radius: var(--radius-sm);
}
.detective-feedback.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 5px solid var(--accent-emerald);
  color: #065f46;
}
.detective-feedback.danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 5px solid var(--danger);
  color: #991b1b;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
}
