﻿/* =========================================================
   QuizQuest - Retro Academic & Cyber Gaming Theme Stylesheet
   ========================================================= */

:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 26, 44, 0.85);
  --bg-card-hover: rgba(26, 38, 64, 0.95);
  --bg-accent: #1e293b;
  
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.4);
  --secondary: #a855f7;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.3);
  
  --font-base: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-base);
  background: radial-gradient(circle at 50% 0%, #172554 0%, var(--bg-dark) 55%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Background Stars Grid */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    radial-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px);
  background-size: 32px 32px, 64px 64px;
  background-position: 0 0, 16px 16px;
  pointer-events: none;
  z-index: 0;
}

/* App Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

/* ================= Header ================= */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  margin: 0 -16px 20px -16px;
  padding: 10px 20px 0;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 10px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.logo-icon {
  font-size: 28px;
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
  animation: pulse 3s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 4px #38bdf8); }
  100% { transform: scale(1.05); filter: drop-shadow(0 0 12px #a855f7); }
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #38bdf8, #c084fc, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.stat-badge:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.stat-badge.hearts {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.25);
}

.stat-badge.streak {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

.stat-badge.rank {
  cursor: pointer;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(168, 85, 247, 0.15));
  border-color: rgba(168, 85, 247, 0.4);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

/* XP Bar */
.xp-wrapper {
  margin-top: 4px;
}

.xp-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 3px;
}

.xp-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #a855f7);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================= Navigation & Modes ================= */
.mode-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.mode-nav::-webkit-scrollbar {
  display: none;
}

.mode-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-main);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(168, 85, 247, 0.2));
  color: var(--text-main);
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.25);
}

/* Filters bar (Category + Level) */
.filters-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.category-chips, .level-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.category-chips::-webkit-scrollbar, .level-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.chip.active {
  background: var(--primary);
  color: #04101e;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 12px var(--primary-glow);
}

.chip.level-basic.active { background: #38bdf8; color: #04101e; }
.chip.level-intermediate.active { background: #f59e0b; color: #1e1302; }
.chip.level-advanced.active { background: #ec4899; color: #1f0412; }

/* ================= Banner / Quest Status ================= */
.quest-banner {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.9));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.banner-content h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-content p {
  font-size: 13px;
  color: var(--text-muted);
}

.banner-metrics {
  display: flex;
  gap: 12px;
  text-align: right;
  flex-shrink: 0;
}

.metric-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 70px;
}

.metric-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  font-family: var(--font-mono);
}

.metric-lbl {
  font-size: 11px;
  color: var(--text-dim);
}

/* ================= Quiz Area ================= */
.quiz-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #a855f7, #ec4899);
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-tags {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tag-cat {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.tag-lvl {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.tag-xp {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-family: var(--font-mono);
}

.quiz-question {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 24px;
}

/* Options Grid */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.option-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
}

.option-btn:hover:not(.disabled) {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--primary);
  transform: translateX(4px);
}

.opt-index {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-mono);
  transition: all 0.2s;
}

.option-btn:hover:not(.disabled) .opt-index {
  background: var(--primary);
  color: #04101e;
}

/* Option States */
.option-btn.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: var(--success) !important;
  color: #a7f3d0;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.option-btn.correct .opt-index {
  background: var(--success);
  color: #022c22;
}

.option-btn.wrong {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: var(--danger) !important;
  color: #fecaca;
  animation: shake 0.4s ease;
}

.option-btn.wrong .opt-index {
  background: var(--danger);
  color: #450a0a;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.option-btn.disabled {
  cursor: default;
  opacity: 0.6;
}

/* ================= Explanation Card ================= */
.explanation-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
  animation: slideUp 0.35s ease;
}

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

.exp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.exp-status {
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.exp-status.correct { color: var(--success); }
.exp-status.wrong { color: var(--danger); }

.exp-section {
  margin-bottom: 14px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  border-left: 3px solid var(--primary);
}

.exp-section.principle {
  border-left-color: #38bdf8;
  background: rgba(56, 189, 248, 0.05);
}

.exp-section.trap {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.05);
}

.exp-section-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.exp-section.trap .exp-section-title {
  color: #f59e0b;
}

.exp-body {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
}

.exp-keywords {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.keyword-tag {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text-dim);
}

.quiz-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
}

/* ================= Concept Codex View ================= */
.codex-view {
  display: none;
}

.codex-search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.codex-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
}

.codex-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-glow);
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.codex-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
}

.codex-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.codex-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #38bdf8;
}

.codex-principle {
  font-size: 13px;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.08);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-weight: 600;
}

.codex-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
  flex: 1;
}

/* ================= Speed Rush (Time Attack) View ================= */
.time-attack-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 14px;
  padding: 10px 18px;
  margin-bottom: 16px;
  font-family: var(--font-mono);
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
  color: #f87171;
}

/* ================= Modal Styles ================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: #0f172a;
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Achievement Item */
.ach-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ach-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.ach-item.unlocked {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.06);
}

.ach-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: grayscale(1);
  opacity: 0.4;
}

.ach-item.unlocked .ach-icon {
  filter: none;
  opacity: 1;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(168, 85, 247, 0.2));
}

.ach-details h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.ach-details p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ================= SEO & Crawler Static Section ================= */
.seo-knowledge-hub {
  margin-top: 60px;
  border-top: 1px solid var(--border);
  padding-top: 36px;
}

.seo-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.seo-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
}

.seo-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 8px;
}

.seo-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Footer */
footer {
  margin-top: 40px;
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--primary);
}

/* ================= Responsive ================= */
@media (max-width: 640px) {
  header {
    margin: 0 -12px 16px -12px;
    padding: 8px 12px 0;
  }
  
  .app-container {
    padding: 0 12px 40px;
  }
  
  .quiz-box {
    padding: 18px 14px;
    border-radius: 16px;
  }
  
  .quiz-question {
    font-size: 16px;
  }
  
  .option-btn {
    padding: 12px 14px;
    font-size: 14px;
  }
  
  .banner-metrics {
    display: none;
  }
}
