:root {
  --bg: #0b0e14;
  --surface: #151a24;
  --surface2: #1b2230;
  --surface3: #222b3d;
  --border: rgba(255, 255, 255, 0.08);
  --text: #edf1f7;
  --muted: #8b95a8;
  --gold: #f2b33d;
  --gold2: #f5d67b;
  --cyan: #3ec9f2;
  --green: #35d07f;
  --purple: #7c5cff;
  --blue: #4d8dff;
  --rose: #ff5c7a;
  --orange: #ff8a3d;
  --danger: #ff5c7a;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  min-height: 100vh;
  background-image:
    radial-gradient(900px 420px at 85% -10%, rgba(124, 92, 255, 0.14), transparent 60%),
    radial-gradient(800px 380px at -10% 20%, rgba(62, 201, 242, 0.08), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(242, 179, 61, 0.07), transparent 60%);
  background-attachment: fixed;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

#app { max-width: 960px; margin: 0 auto; padding: 0 16px 96px; }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0 10px;
  background: linear-gradient(to bottom, rgba(11, 14, 20, 0.96), rgba(11, 14, 20, 0.85));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, var(--gold2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.topnav { display: flex; gap: 4px; margin-left: auto; }

.nav-btn {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.nav-btn.active { color: #15100a; background: var(--gold); font-weight: 700; }

.hud { display: flex; gap: 8px; }
.hud-chip {
  font-size: 13px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* ---------- Views ---------- */
.view { animation: fadeUp 0.35s ease both; }

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

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 26px 24px;
  background: linear-gradient(135deg, #24202c, #171a26 55%, #141822);
  border: 1px solid rgba(242, 179, 61, 0.22);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 179, 61, 0.22), transparent 65%);
  pointer-events: none;
}

.hero-mascot { font-size: 54px; line-height: 1; filter: drop-shadow(0 6px 18px rgba(242,179,61,0.3)); }
.hero h1 {
  font-size: 28px;
  font-weight: 900;
  margin: 10px 0 6px;
  background: linear-gradient(120deg, var(--gold2), var(--gold), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}
.hero .slogan { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 96px;
}
.stat-pill b { display: block; font-size: 18px; }
.stat-pill span { font-size: 12px; color: var(--muted); }

.xp-track { margin-top: 16px; }
.xp-track .lbl {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.xp-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface3);
  overflow: hidden;
}
.xp-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold2), var(--gold), var(--orange));
  transition: width 0.6s ease;
}

.continue-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 15px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 800;
  color: #15100a;
  background: linear-gradient(120deg, var(--gold2), var(--gold));
  box-shadow: 0 8px 24px rgba(242, 179, 61, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}
.continue-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(242, 179, 61, 0.35); }
.continue-btn:active { transform: translateY(0); }

/* ---------- Roadmap ---------- */
.section-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin: 26px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--gold2), var(--gold));
}

.roadmap {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scrollbar-width: none;
}
.roadmap::-webkit-scrollbar { display: none; }

.rm-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  width: 86px;
  position: relative;
}
.rm-step::after {
  content: "";
  position: absolute;
  top: 24px;
  left: 62px;
  width: 34px;
  height: 2px;
  background: var(--surface3);
}
.rm-step:last-child::after { display: none; }
.rm-step.done::after { background: var(--gold); }

.rm-ico {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.rm-step.done .rm-ico { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,179,61,0.15); }
.rm-step span { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Chapter cards ---------- */
.chapter-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  transition: transform 0.15s, border-color 0.15s;
  overflow: hidden;
}
.chapter-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.18); }
.chapter-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--cc);
}

.chapter-card.locked { opacity: 0.55; }
.chapter-card.locked:hover { transform: none; }

.cc-top { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.cc-ico {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: color-mix(in srgb, var(--cc) 16%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--cc) 40%, transparent);
}
.cc-title { font-size: 18px; font-weight: 800; }
.cc-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.cc-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cc) 18%, transparent);
  color: var(--cc);
  white-space: nowrap;
}
.cc-progress { display: flex; align-items: center; gap: 10px; }
.cc-progress .bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface3);
  overflow: hidden;
}
.cc-progress .bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--cc);
  transition: width 0.5s ease;
}
.cc-progress .txt { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cc-lock-msg { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Lesson view ---------- */
.lesson-head { margin-bottom: 16px; }
.lesson-back {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 10px 6px 0;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lesson-back:hover { color: var(--text); }
.lesson-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.lesson-meta .ico {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: color-mix(in srgb, var(--cc) 16%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--cc) 40%, transparent);
}
.lesson-meta h2 { font-size: 19px; font-weight: 800; line-height: 1.3; }
.lesson-meta .meta-row { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface3);
  color: var(--muted);
}
.pill.hot { color: var(--cc); background: color-mix(in srgb, var(--cc) 15%, transparent); }

.step-dots { display: flex; gap: 7px; margin-top: 10px; }
.step-dots i {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface3);
  transition: background 0.3s;
}
.step-dots i.on { background: var(--cc); }
.step-dots i.done { background: color-mix(in srgb, var(--cc) 55%, var(--surface3)); }

.step-card {
  border-radius: var(--radius);
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: fadeUp 0.3s ease both;
  margin-bottom: 14px;
}

.step-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--cc);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.step-card h3 { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.step-card p { color: #d3d9e4; margin-bottom: 12px; }
.step-card p:last-child { margin-bottom: 0; }

.story-scene {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--cc);
  background: color-mix(in srgb, var(--cc) 12%, transparent);
  border: 1px dashed color-mix(in srgb, var(--cc) 45%, transparent);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.story-body {
  font-size: 15.5px;
  line-height: 1.9;
  background: var(--surface2);
  border-left: 3px solid var(--cc);
  border-radius: 0 14px 14px 0;
  padding: 16px 18px;
}

.concept-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .concept-grid { grid-template-columns: 1fr 1fr; } }
.concept {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.concept b { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 6px; }
.concept span { font-size: 13.5px; color: var(--muted); }

.dad-tip {
  background: linear-gradient(135deg, rgba(242, 179, 61, 0.1), rgba(255, 138, 61, 0.05));
  border: 1px solid rgba(242, 179, 61, 0.28);
  border-radius: 14px;
  padding: 16px 18px;
}
.dad-tip .dt-title { font-size: 14px; font-weight: 800; color: var(--gold); margin-bottom: 6px; }
.dad-tip p { color: #e8ddc4; font-size: 14.5px; }

.quote-box {
  text-align: center;
  padding: 24px 18px;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.quote-box .q-mark { font-size: 34px; color: var(--cc); line-height: 1; }
.quote-box p { font-size: 16.5px; font-weight: 700; line-height: 1.8; margin: 8px 0 6px; }
.quote-box span { font-size: 12px; color: var(--muted); }

.news-box {
  background: var(--surface2);
  border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent);
  border-radius: 14px;
  padding: 16px 18px;
}
.news-box .n-title { font-size: 13px; font-weight: 800; color: var(--cyan); margin-bottom: 6px; }

.step-actions { margin-top: 16px; }
.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  color: #15100a;
  background: linear-gradient(120deg, var(--gold2), var(--gold));
  transition: transform 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); }

/* ---------- Quiz ---------- */
.quiz-card { text-align: center; padding: 24px 20px; }
.quiz-count { font-size: 12px; color: var(--muted); letter-spacing: 2px; margin-bottom: 14px; }
.quiz-q { font-size: 18px; font-weight: 800; line-height: 1.6; margin-bottom: 18px; }
.quiz-options { display: grid; gap: 10px; text-align: left; }
.quiz-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 13px 15px;
  border-radius: 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 14.5px;
  color: var(--text);
  transition: all 0.15s;
}
.quiz-opt .key {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface3);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.quiz-opt:hover:not(:disabled) { border-color: var(--cc); background: color-mix(in srgb, var(--cc) 8%, var(--surface2)); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.correct {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, var(--surface2));
}
.quiz-opt.correct .key { background: var(--green); color: #07130c; }
.quiz-opt.wrong {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, var(--surface2));
}
.quiz-opt.wrong .key { background: var(--danger); color: #fff; }

.quiz-feedback {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  text-align: left;
  display: none;
}
.quiz-feedback.show { display: block; animation: fadeUp 0.25s ease both; }
.quiz-feedback.ok { background: color-mix(in srgb, var(--green) 12%, var(--surface2)); color: #bfe9d3; }
.quiz-feedback.no { background: color-mix(in srgb, var(--danger) 12%, var(--surface2)); color: #f2c4ce; }

.result-box { padding: 26px 20px; text-align: center; }
.result-emoji { font-size: 60px; line-height: 1; margin-bottom: 10px; }
.result-box h3 { font-size: 22px; font-weight: 900; margin-bottom: 8px; }
.result-box .result-sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.xp-gain {
  display: inline-block;
  font-size: 15px;
  font-weight: 800;
  color: #15100a;
  background: linear-gradient(120deg, var(--gold2), var(--gold));
  padding: 8px 18px;
  border-radius: 999px;
  margin-bottom: 18px;
  animation: pop 0.5s ease both;
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.dad-note {
  margin-top: 16px;
  text-align: left;
  border-radius: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(242,179,61,0.12), rgba(124,92,255,0.08));
  border: 1px solid rgba(242,179,61,0.3);
}
.dad-note .dn-title { font-size: 14px; font-weight: 800; color: var(--gold); margin-bottom: 6px; }
.dad-note p { font-size: 14px; color: #e9dfc6; line-height: 1.8; }

/* ---------- Achievements ---------- */
.ach-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (min-width: 640px) { .ach-stats { grid-template-columns: repeat(4, 1fr); } }
.ach-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.ach-stat b { font-size: 24px; display: block; }
.ach-stat span { font-size: 12px; color: var(--muted); }

.checkin-card {
  border-radius: var(--radius);
  padding: 20px;
  background: linear-gradient(135deg, rgba(255,92,122,0.08), rgba(255,138,61,0.06));
  border: 1px solid rgba(255,138,61,0.25);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.checkin-card b { font-size: 16px; }
.checkin-card p { font-size: 13px; color: var(--muted); }
.checkin-btn {
  padding: 12px 22px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 14px;
  color: #2b0d05;
  background: linear-gradient(120deg, #ffab5e, var(--orange));
}
.checkin-btn:disabled { opacity: 0.6; cursor: default; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 640px) { .badge-grid { grid-template-columns: repeat(3, 1fr); } }
.badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 14px;
  text-align: center;
  transition: transform 0.15s;
}
.badge:not(.locked):hover { transform: translateY(-2px); }
.badge .b-ico { font-size: 34px; margin-bottom: 6px; filter: grayscale(1) opacity(0.35); }
.badge:not(.locked) .b-ico { filter: none; }
.badge b { font-size: 13px; display: block; margin-bottom: 2px; }
.badge p { font-size: 11px; color: var(--muted); line-height: 1.5; }
.badge.locked { opacity: 0.75; }

/* ---------- About ---------- */
.about-card {
  border-radius: var(--radius);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.about-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 10px; }
.about-card p { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.about-card p:last-child { margin-bottom: 0; }
.danger-zone { text-align: center; }
.reset-btn {
  padding: 12px 26px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: none;
  justify-content: space-around;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 14, 20, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bn-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  padding: 6px 18px;
  border-radius: 12px;
}
.bn-btn span { font-size: 20px; }
.bn-btn.active { color: var(--gold); }

@media (max-width: 720px) {
  .topnav { display: none; }
  .bottomnav { display: flex; }
  #app { padding-bottom: 110px; }
  .hud-chip { font-size: 12px; padding: 4px 8px; }
}

/* ---------- Confetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  animation: confettiFall linear both;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 64px;
  transform: translateX(-50%);
  z-index: 120;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  animation: toastIn 3s ease both;
  white-space: nowrap;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translate(-50%, -12px); }
  12%, 82% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ---------- Level badge ---------- */
.level-orb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 14px;
}
.level-orb .dot { font-size: 20px; }
