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

:root {
  --bg-dark: #070b14;
  --bg-card: #0d1628;
  --bg-card2: #111d35;
  --accent-blue: #00c6ff;
  --accent-cyan: #0ef;
  --accent-gold: #ffd700;
  --accent-purple: #7c3aed;
  --accent-green: #00f5a0;
  --accent-red: #ff4757;
  --text-primary: #e8f4fd;
  --text-muted: #7a9bc4;
  --border: rgba(0,198,255,0.15);
  --glow-blue: rgba(0,198,255,0.4);
  --glow-gold: rgba(255,215,0,0.3);
  --font-display: 'Orbitron', monospace;
  --font-body: 'Inter', sans-serif;
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow: hidden; /* Game is full screen app-like */
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ===================== HUD ===================== */
#game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(7,11,20,0.9);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

#game-hud.hidden {
  display: none;
}

.hud-left { display: flex; align-items: center; gap: 1.5rem; }
.hud-back { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; transition: color 0.3s; }
.hud-back:hover { color: var(--accent-cyan); }
.hud-level-title { font-family: var(--font-display); font-weight: 700; color: var(--accent-gold); }

.hud-center { display: flex; align-items: center; gap: 1rem; width: 40%; max-width: 400px; }
.hud-progress-track { flex: 1; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
#hud-progress-fill { width: 0%; height: 100%; background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan)); transition: width 0.3s; }
#hud-progress-label { font-family: var(--font-display); font-size: 0.8rem; font-weight: bold; width: 40px; }

.hud-right { display: flex; gap: 1.5rem; font-family: var(--font-display); font-weight: bold; }
.hud-stat { color: var(--accent-cyan); display: flex; align-items: center; gap: 0.3rem; }

/* ===================== SCREENS ===================== */
.screen {
  flex: 1;
  overflow-y: auto;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  padding-top: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  background: var(--bg-dark);
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}
#screen-intro.active { padding-top: 0; justify-content: center; }

/* ===================== BUTTONS ===================== */
.btn-game {
  font-family: var(--font-body);
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  box-shadow: 0 0 15px var(--glow-blue);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px var(--glow-blue);
}
.btn-primary:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn-secondary {
  background: transparent; border: 1px solid var(--border); color: var(--accent-cyan);
}
.btn-secondary:hover { background: rgba(0,198,255,0.1); }

/* ===================== INTRO ===================== */
.intro-container {
  text-align: center; max-width: 800px; padding: 3rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 0 50px rgba(0,0,0,0.5);
  animation: slideUp 0.8s ease-out;
}
.intro-badge {
  display: inline-block; padding: 0.3rem 1rem;
  background: rgba(0,198,255,0.1); border: 1px solid var(--accent-blue);
  border-radius: 20px; color: var(--accent-cyan);
  font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 2px; margin-bottom: 1.5rem;
}
.intro-title {
  font-family: var(--font-display); font-size: 3rem; margin-bottom: 1rem;
  color: var(--text-primary); text-shadow: 0 0 15px var(--glow-blue);
}
.intro-desc { font-size: 1.1rem; line-height: 1.6; color: var(--text-muted); margin-bottom: 2rem; }
.intro-objectives {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
  text-align: left; margin-bottom: 2.5rem;
}
.objective-item {
  background: var(--bg-card2); padding: 1rem; border-radius: 8px;
  border-left: 4px solid var(--accent-blue); font-size: 0.95rem;
}

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

/* ===================== CHAPTER ===================== */
#screen-chapter { flex-direction: row; align-items: stretch; padding-top: 70px; }
#chapter-nav { width: 280px; background: var(--bg-card); border-right: 1px solid var(--border); padding: 2rem 1rem; overflow-y: auto; }
.nav-item {
  padding: 0.8rem 1rem; margin-bottom: 0.5rem; border-radius: 8px; cursor: pointer;
  color: var(--text-muted); font-weight: 500; transition: all 0.2s; display: flex; align-items: center; gap: 0.8rem;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active { background: rgba(0,198,255,0.1); color: var(--accent-cyan); border-left: 3px solid var(--accent-cyan); }
.nav-item.completed { color: var(--accent-green); }
.nav-icon { font-size: 1.2rem; }

#chapter-body { flex: 1; display: flex; flex-direction: column; background: var(--bg-dark); position: relative; overflow-y: auto; scroll-behavior: smooth; }
#chapter-content { flex: 1; padding: 3rem 4rem; max-width: 1000px; margin: 0 auto; width: 100%; }
.chapter-header { margin-bottom: 2rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 1rem; }
.chapter-title { font-family: var(--font-display); font-size: 2.2rem; color: var(--accent-gold); }

.content-section { display: none; animation: fadeIn 0.5s ease; }
.content-section.active { display: block; }
.content-section h3 { color: var(--text-primary); margin: 2rem 0 1rem; font-size: 1.5rem; border-left: 4px solid var(--accent-cyan); padding-left: 10px; }
.content-section p { line-height: 1.8; color: var(--text-muted); margin-bottom: 1.2rem; font-size: 1.1rem; }
.content-section ul { margin: 1rem 0 1.5rem 2.5rem; color: var(--text-muted); line-height: 1.8; font-size: 1.05rem; }
.content-section li { margin-bottom: 0.8rem; }

.analogy-box {
  background: rgba(0,198,255,0.05); border: 1px dashed var(--accent-blue);
  border-radius: 12px; padding: 1.5rem; margin: 2rem 0; display: flex; gap: 1.5rem; align-items: flex-start;
}
.analogy-icon { font-size: 2.5rem; background: rgba(0,0,0,0.3); padding: 1rem; border-radius: 50%; }
.analogy-text h4 { color: var(--accent-cyan); margin-bottom: 0.5rem; font-size: 1.2rem; }
.analogy-text p { color: var(--text-primary); line-height: 1.6; font-size: 1.05rem; margin-bottom: 0; }

.comparison-table { width: 100%; border-collapse: collapse; margin: 2rem 0; background: var(--bg-card); border-radius: 8px; overflow: hidden; }
.comparison-table th { background: rgba(0,198,255,0.1); color: var(--accent-cyan); padding: 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 1.1rem; }
.comparison-table td { padding: 1rem; border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--text-muted); font-size: 1.05rem; line-height: 1.5; }
.comparison-table tr:hover td { background: rgba(255,255,255,0.02); color: var(--text-primary); }

/* ===================== INFOGRAPHICS (NEW) ===================== */
.info-graphic {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin: 2.5rem 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.info-title {
  text-align: center; font-family: var(--font-display); color: var(--accent-gold);
  margin-bottom: 1.5rem; font-size: 1.3rem; letter-spacing: 1px; text-transform: uppercase;
}
/* Flex variants */
.info-flex-row { display: flex; gap: 1rem; justify-content: space-between; align-items: stretch; }
.info-flex-col { display: flex; flex-direction: column; gap: 1rem; }
/* Cards inside infographics */
.info-card {
  flex: 1; background: var(--bg-card2); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 1.5rem; text-align: center;
}
.info-card h4 { color: var(--text-primary); margin: 1rem 0 0.5rem; font-size: 1.2rem; }
.info-card p { font-size: 0.95rem; color: var(--text-muted); line-height: 1.5; margin:0; }
.info-emoji { font-size: 3.5rem; display: block; filter: drop-shadow(0 0 10px rgba(255,255,255,0.2)); }
/* Arrows */
.info-arrow { display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--accent-cyan); }
/* Layers */
.info-layer {
  padding: 1rem; border-radius: 8px; text-align: center; font-weight: bold; margin-bottom: 0.5rem; border: 1px solid transparent;
}

/* ===================== WORKFLOW SEQUENCE (NEW) ===================== */
.workflow-sequence {
  margin: 2.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.step {
  display: flex;
  gap: 1.5rem;
  background: var(--bg-card2);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 1.5rem;
  border-radius: 12px;
  position: relative;
  transition: all 0.3s ease;
}
.step:hover {
  border-color: var(--accent-cyan);
  transform: translateX(10px);
  box-shadow: 0 5px 20px rgba(0,245,160,0.1);
}
.step::after {
  content: '↓';
  position: absolute;
  bottom: -1.2rem;
  left: 2.3rem;
  color: var(--accent-cyan);
  font-size: 1.2rem;
  font-weight: bold;
}
.step:last-child::after { content: none; }
.step-num {
  background: var(--accent-cyan);
  color: var(--bg-dark);
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-family: var(--font-display);
  font-size: 1.2rem;
  box-shadow: 0 0 15px var(--accent-cyan);
}
.step-content h4 {
  color: var(--accent-cyan);
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
}
.step-content p {
  margin: 0;
  font-size: 0.95rem !important;
  color: var(--text-primary) !important;
}

.project-steps {
  border-left: 2px solid var(--accent-purple);
  padding-left: 2rem;
  margin: 2rem 0;
}

#chapter-footer {
  padding: 1.5rem 4rem; background: var(--bg-card); border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; position: sticky; bottom: 0; z-index: 10;
}
#section-dots { display: flex; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.2); transition: all 0.3s; }
.dot.active { background: var(--accent-cyan); transform: scale(1.3); }
.dot.completed { background: var(--accent-green); }

/* ===================== QUIZ ===================== */
#screen-quiz { padding: 100px 2rem 2rem; background: radial-gradient(circle at center, #111d35 0%, #070b14 100%); }
.quiz-container { max-width: 800px; width: 100%; margin: 0 auto; }
.quiz-header { text-align: center; margin-bottom: 2rem; }
.quiz-title { font-family: var(--font-display); font-size: 2rem; color: var(--accent-gold); margin-bottom: 0.5rem; }
.quiz-progress { color: var(--text-muted); font-size: 1.1rem; }

.question-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 2.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); margin-bottom: 2rem; animation: slideInRight 0.5s ease;
}
.question-text { font-size: 1.3rem; font-weight: 600; margin-bottom: 2rem; color: var(--text-primary); line-height: 1.5; }
.options-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.option-btn {
  background: var(--bg-card2); border: 1px solid rgba(255,255,255,0.1); padding: 1.2rem;
  border-radius: 8px; text-align: left; font-size: 1.05rem; color: var(--text-primary);
  cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 1rem;
}
.option-letter {
  background: rgba(0,0,0,0.3); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: bold; color: var(--text-muted);
}
.option-btn:hover:not(.disabled) { background: rgba(0,198,255,0.05); border-color: var(--accent-cyan); transform: translateX(5px); }
.option-btn:hover:not(.disabled) .option-letter { color: var(--accent-cyan); background: rgba(0,198,255,0.1); }
.option-btn.selected { background: rgba(0,198,255,0.1); border-color: var(--accent-blue); }
.option-btn.correct { background: rgba(0,245,160,0.1); border-color: var(--accent-green); }
.option-btn.correct .option-letter { color: var(--accent-green); }
.option-btn.incorrect { background: rgba(255,71,87,0.1); border-color: var(--accent-red); }
.option-btn.incorrect .option-letter { color: var(--accent-red); }
.option-btn.disabled { cursor: default; }

.feedback-box { margin-top: 1.5rem; padding: 1.5rem; border-radius: 8px; display: none; animation: fadeIn 0.4s ease; }
.feedback-box.correct { background: rgba(0,245,160,0.05); border-left: 4px solid var(--accent-green); display: block; }
.feedback-box.incorrect { background: rgba(255,71,87,0.05); border-left: 4px solid var(--accent-red); display: block; }
.feedback-title { font-weight: bold; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }
.correct .feedback-title { color: var(--accent-green); }
.incorrect .feedback-title { color: var(--accent-red); }
.feedback-text { color: var(--text-muted); line-height: 1.5; font-size: 1.05rem; }

.quiz-footer { text-align: right; margin-top: 2rem; display: none; }
.quiz-footer.visible { display: block; }

@keyframes slideInRight { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===================== VICTORY ===================== */
.victory-container {
  text-align: center; max-width: 600px; margin: auto; padding: 4rem;
  background: var(--bg-card); border: 1px solid var(--accent-gold); border-radius: 20px;
  box-shadow: 0 0 80px rgba(255,215,0,0.15); animation: bounceIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.victory-icon { font-size: 5rem; margin-bottom: 1rem; filter: drop-shadow(0 0 20px var(--accent-gold)); }
.victory-title { font-family: var(--font-display); font-size: 3rem; color: var(--accent-gold); margin-bottom: 1rem; }
.victory-stats { display: flex; justify-content: center; gap: 2rem; margin: 2rem 0; }
.v-stat { background: var(--bg-card2); padding: 1.5rem; border-radius: 12px; min-width: 120px; }
.v-stat-val { font-family: var(--font-display); font-size: 2.5rem; color: var(--accent-cyan); font-weight: bold; margin-bottom: 0.5rem; }
.v-stat-label { color: var(--text-muted); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; }
.victory-desc { font-size: 1.1rem; color: var(--text-primary); margin-bottom: 2rem; line-height: 1.6; }

@keyframes bounceIn { 0% { opacity: 0; transform: scale(0.3); } 50% { opacity: 1; transform: scale(1.05); } 70% { transform: scale(0.9); } 100% { transform: scale(1); } }

#chapter-content::-webkit-scrollbar, #chapter-nav::-webkit-scrollbar { width: 6px; }
#chapter-content::-webkit-scrollbar-track, #chapter-nav::-webkit-scrollbar-track { background: transparent; }
#chapter-content::-webkit-scrollbar-thumb, #chapter-nav::-webkit-scrollbar-thumb { background: var(--accent-blue); border-radius: 3px; }
