/* ===== CS Adventure — Bright & Pop Design ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f0ff;
  --surface: #ffffff;
  --surface2: #f7f5ff;
  --text: #2d2040;
  --text2: #6b5f80;
  --border: #e2ddf0;
  --shadow: 0 4px 24px rgba(100,80,200,0.10);
  --shadow-hover: 0 8px 32px rgba(100,80,200,0.18);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Nunito', 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(180,160,255,0.18) 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(255,170,200,0.18) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 920px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== PROGRESS BAR ===== */
#progress-bar {
  width: 100%; height: 6px;
  background: var(--border);
  position: fixed; top: 0; left: 0; z-index: 100;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #f472b6, #fb923c);
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
  width: 0%;
  border-radius: 0 3px 3px 0;
}

/* ===== SCENE ===== */
.scene {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 24px 20px 32px;
  animation: popIn 0.4s cubic-bezier(.34,1.56,.64,1);
}
.scene.active { display: flex; }

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

/* ===== BACK LINK ===== */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700;
  color: var(--text2);
  text-decoration: none;
  padding: 8px 14px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  align-self: flex-start;
  transition: all 0.2s;
  border: 1.5px solid var(--border);
}
.back-link:hover { color: var(--text); box-shadow: var(--shadow-hover); transform: translateY(-1px); }

/* ===== CHAPTER LABEL ===== */
.chapter-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent, #7c3aed);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.chapter-label::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent, #7c3aed);
}

/* ===== SCENE TITLE ===== */
.scene-title {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 14px;
  line-height: 1.3;
  color: var(--text);
}

.scene-desc {
  font-size: 15px;
  color: var(--text2);
  line-height: 1.9;
  margin-bottom: 24px;
}
.scene-desc strong { color: var(--text); }

/* ===== STAGE ===== */
.stage {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  min-height: 160px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stage::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent, #7c3aed), var(--accent2, #ec4899));
}

/* ===== NEXT BUTTON ===== */
.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent, #7c3aed), var(--accent2, #ec4899));
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  align-self: flex-end;
  margin-top: auto;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
  letter-spacing: 0.3px;
}
.btn-next:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 24px rgba(124,58,237,0.4);
}
.btn-next:active { transform: translateY(0) scale(0.98); }
.btn-next:disabled {
  background: linear-gradient(135deg, #c4b5d4, #d4a5b4);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ===== ACTION BUTTON ===== */
.btn-action {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--accent, #7c3aed), var(--accent2, #ec4899));
  color: white;
  border: none;
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 3px 12px rgba(124,58,237,0.25);
  font-family: inherit;
}
.btn-action:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 6px 18px rgba(124,58,237,0.35); }
.btn-action:active { transform: scale(0.97); }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ===== STEP DOTS ===== */
.step-dots { display:flex; gap:8px; justify-content:center; margin-bottom:20px; }
.step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s cubic-bezier(.34,1.56,.64,1);
}
.step-dot.active { background: var(--accent, #7c3aed); transform: scale(1.4); }
.step-dot.done   { background: #34d399; }

/* ===== INFO BOX ===== */
.info-box {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.8;
}
.info-box strong { color: var(--text); }

/* ===== CODE ===== */
.code-block {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  background: #1e1b2e;
  border-radius: var(--radius-sm);
  padding: 16px;
  line-height: 1.8;
  color: #e2e0f0;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}
.kw  { color: #c084fc; }
.fn  { color: #60a5fa; }
.str { color: #86efac; }
.num { color: #fb923c; }
.cm  { color: #6b7280; font-style: italic; }

/* ===== QUIZ ===== */
.quiz-options { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:16px 0; }
.quiz-opt {
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  text-align: center;
  color: var(--text);
  box-shadow: var(--shadow);
}
.quiz-opt:hover { border-color: var(--accent, #7c3aed); transform: translateY(-2px) scale(1.02); box-shadow: var(--shadow-hover); }
.quiz-opt.correct { border-color: #10b981; background: #f0fdf4; color: #065f46; transform: scale(1.02); }
.quiz-opt.wrong   { border-color: #ef4444; background: #fef2f2; color: #991b1b; }

.feedback {
  font-size: 14px; font-weight: 700;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  display: none;
}
.feedback.show { display: block; }
.feedback.correct { background: #ecfdf5; color: #065f46; border: 1.5px solid #10b981; }
.feedback.wrong   { background: #fef2f2; color: #991b1b; border: 1.5px solid #ef4444; }

/* ===== DONE SCREEN ===== */
.done-screen { text-align: center; padding: 40px 0; }
.done-screen .trophy { font-size: 80px; margin-bottom: 16px; animation: bounceIn 0.6s cubic-bezier(.34,1.56,.64,1); }
@keyframes bounceIn { from{transform:scale(0.3);opacity:0} to{transform:scale(1);opacity:1} }
.done-screen h2 { font-size: 30px; font-weight: 900; margin-bottom: 12px; background: linear-gradient(135deg, var(--accent,#7c3aed), var(--accent2,#ec4899)); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
.done-screen p { color: var(--text2); font-size: 15px; line-height: 1.8; margin-bottom: 28px; }
.summary-box {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
  text-align: left;
  box-shadow: var(--shadow);
}
.summary-box h4 { font-size:14px; font-weight:800; color:var(--accent,#7c3aed); margin-bottom:12px; }
.summary-box li { font-size: 14px; color: var(--text2); line-height: 2.2; padding-left: 4px; }
.summary-box li::marker { color: var(--accent, #7c3aed); }
