/* ========================================================================
   林宇知识宇宙 · 全局样式
   4 大陆主题：启蒙(卡通暖橙) / 进阶(扁平青蓝) / 高阶(科幻深紫) / 大师(黑金)
   ======================================================================== */

/* ---------- 主题变量 ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-rounded: "PingFang SC", -apple-system, "Helvetica Rounded", sans-serif;

  /* 通用色 */
  --bg: #f5f7fb;
  --text: #1a1f36;
  --text-soft: #5a6378;
  --text-dim: #98a0b8;
  --card: #ffffff;
  --border: #e6e9f2;
  --shadow-sm: 0 2px 8px rgba(26,31,54,.06);
  --shadow-md: 0 8px 24px rgba(26,31,54,.10);
  --shadow-lg: 0 16px 48px rgba(26,31,54,.16);

  /* 启蒙大陆 - 圆润卡通暖橙黄 */
  --c-enlighten-bg: #fff8ed;
  --c-enlighten-primary: #ff9d3d;
  --c-enlighten-accent: #ffd166;
  --c-enlighten-text: #6b3410;
  --c-enlighten-card: #ffffff;

  /* 进阶大陆 - 扁平青蓝 */
  --c-advanced-bg: #eef5fb;
  --c-advanced-primary: #2bb6e6;
  --c-advanced-accent: #5ed4b8;
  --c-advanced-text: #0d3a5c;
  --c-advanced-card: #ffffff;

  /* 高阶大陆 - 科幻深紫 */
  --c-master-bg: #1a0f3d;
  --c-master-primary: #a47bff;
  --c-master-accent: #6ee7ff;
  --c-master-text: #ede9ff;
  --c-master-card: #261758;

  /* 大师大陆 - 黑金 */
  --c-grandmaster-bg: #0a0a0f;
  --c-grandmaster-primary: #f5c542;
  --c-grandmaster-accent: #ff8a3d;
  --c-grandmaster-text: #fff5d6;
  --c-grandmaster-card: #16161f;

  /* 反馈色 */
  --c-correct: #2ecc71;
  --c-wrong: #ff5c5c;
  --c-star: #ffc83d;

  /* 布局 */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --maxw: 960px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app { min-height: 100vh; }

/* ---------- 启动屏 ---------- */
.boot-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a0f3d 0%, #261758 50%, #0a0a0f 100%);
  z-index: 9999;
  transition: opacity .5s;
}
.boot-screen.hide { opacity: 0; pointer-events: none; }
.boot-orbit {
  width: 120px; height: 120px;
  position: relative;
  animation: spin 2s linear infinite;
}
.boot-planet {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd166, #ff9d3d);
  box-shadow: 0 0 40px #ff9d3d, 0 0 80px rgba(255,157,61,.4);
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
}
.boot-ring {
  position: absolute; inset: 0;
  border: 2px solid rgba(164,123,255,.4);
  border-radius: 50%;
  border-top-color: #a47bff;
}
.boot-text {
  margin-top: 32px;
  color: #ede9ff;
  font-size: 14px;
  letter-spacing: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.topbar-title .logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #ff9d3d, #a47bff);
  box-shadow: 0 0 12px rgba(164,123,255,.6);
}
.topbar-stats {
  display: flex; gap: 12px; align-items: center;
  font-size: 13px; color: var(--text-soft);
}
.stat-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
}
.stat-pill .star { color: var(--c-star); }

/* ---------- 主地图 ---------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 24px 16px 80px; }

.hero-banner {
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #1a0f3d 0%, #3d1f7a 60%, #6b2fbf 100%);
  color: #fff;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero-banner::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255,209,102,.3), transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(164,123,255,.4), transparent 50%);
}
.hero-banner > * { position: relative; }
.hero-banner h1 {
  font-size: 26px; font-weight: 800;
  font-family: var(--font-rounded);
  margin-bottom: 8px;
}
.hero-banner p { font-size: 14px; opacity: .9; line-height: 1.6; max-width: 560px; }
.hero-npc {
  position: absolute; right: 16px; bottom: 0;
  width: 96px; height: 96px;
  display: flex; align-items: flex-end; justify-content: center;
}
.hero-npc svg { width: 80px; height: 80px; }

/* 大陆区域 */
.world-section { margin-bottom: 32px; }
.world-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.world-badge {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.world-title {
  font-size: 18px; font-weight: 700;
  font-family: var(--font-rounded);
}
.world-subtitle {
  font-size: 12px; color: var(--text-dim);
  margin-top: 2px;
}

.planet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* 星球卡片 */
.planet-card {
  position: relative;
  border-radius: var(--radius-md);
  padding: 18px 14px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
  text-align: center;
}
.planet-card:active { transform: scale(.97); }
.planet-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.planet-card.locked { opacity: .5; cursor: not-allowed; }
.planet-card.locked:hover { transform: none; box-shadow: none; }

.planet-orb {
  width: 56px; height: 56px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  position: relative;
}
.planet-orb::after {
  content: ""; position: absolute;
  width: 72px; height: 18px;
  border: 1.5px solid rgba(255,255,255,.4);
  border-radius: 50%;
  transform: rotate(-20deg);
  top: 50%; left: 50%;
  margin-left: -36px; margin-top: -9px;
}
.planet-name {
  font-size: 14px; font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}
.planet-domain {
  font-size: 11px; color: var(--text-dim);
  margin-bottom: 8px;
}
.planet-progress {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11px; color: var(--text-soft);
}
.stars-mini { color: var(--c-star); letter-spacing: 1px; }
.lock-icon { font-size: 14px; opacity: .6; }

/* 大陆主题色应用 */
.world-enlighten .world-badge { background: var(--c-enlighten-bg); }
.world-enlighten .world-title { color: var(--c-enlighten-text); }
.world-enlighten .planet-orb {
  background: radial-gradient(circle at 30% 30%, var(--c-enlighten-accent), var(--c-enlighten-primary));
  box-shadow: 0 4px 16px rgba(255,157,61,.4);
}

.world-advanced .world-badge { background: var(--c-advanced-bg); }
.world-advanced .world-title { color: var(--c-advanced-text); }
.world-advanced .planet-orb {
  background: radial-gradient(circle at 30% 30%, var(--c-advanced-accent), var(--c-advanced-primary));
  box-shadow: 0 4px 16px rgba(43,182,230,.4);
}

.world-master .world-badge { background: rgba(164,123,255,.2); }
.world-master .world-title { color: var(--c-master-primary); }
.world-master .planet-orb {
  background: radial-gradient(circle at 30% 30%, var(--c-master-accent), var(--c-master-primary));
  box-shadow: 0 4px 20px rgba(164,123,255,.6);
}

.world-grandmaster .world-badge { background: rgba(245,197,66,.2); }
.world-grandmaster .world-title { color: var(--c-grandmaster-primary); }
.world-grandmaster .planet-orb {
  background: radial-gradient(circle at 30% 30%, var(--c-grandmaster-accent), var(--c-grandmaster-primary));
  box-shadow: 0 4px 20px rgba(245,197,66,.5);
}

/* ---------- 知识点关卡页 ---------- */
.topic-hero {
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  margin-bottom: 20px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.topic-hero h2 {
  font-size: 22px; font-weight: 800;
  font-family: var(--font-rounded);
  margin-bottom: 6px;
}
.topic-hero .topic-meta {
  font-size: 13px; opacity: .85;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.topic-hero .topic-meta span { display: inline-flex; align-items: center; gap: 4px; }

/* 阶梯路径 */
.ladder-path {
  position: relative;
  padding: 20px 0;
}
.ladder-step {
  display: flex; gap: 16px; align-items: flex-start;
  margin-bottom: 8px;
  position: relative;
}
.ladder-step::before {
  content: ""; position: absolute;
  left: 23px; top: 48px; bottom: -8px;
  width: 2px; background: var(--border);
}
.ladder-step:last-child::before { display: none; }
.ladder-step.done::before { background: var(--c-correct); }

.ladder-num {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
  flex-shrink: 0;
  background: var(--card);
  border: 2px solid var(--border);
  color: var(--text-dim);
  position: relative; z-index: 1;
}
.ladder-step.unlocked .ladder-num {
  border-color: var(--c-enlighten-primary);
  color: var(--c-enlighten-primary);
  background: var(--c-enlighten-bg);
}
.ladder-step.current .ladder-num {
  background: var(--c-enlighten-primary);
  color: #fff;
  border-color: var(--c-enlighten-primary);
  box-shadow: 0 0 0 6px rgba(255,157,61,.2);
  animation: pulse 2s infinite;
}
.ladder-step.done .ladder-num {
  background: var(--c-correct);
  color: #fff;
  border-color: var(--c-correct);
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(255,157,61,.2); }
  50% { box-shadow: 0 0 0 12px rgba(255,157,61,.1); }
}

.ladder-body {
  flex: 1; padding-bottom: 16px;
}
.ladder-title {
  font-size: 15px; font-weight: 700; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ladder-tag {
  font-size: 10px; padding: 2px 8px;
  border-radius: 999px;
  background: var(--c-enlighten-bg);
  color: var(--c-enlighten-text);
  font-weight: 600;
}
.ladder-desc {
  font-size: 13px; color: var(--text-soft);
  line-height: 1.6; margin-bottom: 10px;
}
.ladder-stars { color: var(--c-star); font-size: 13px; letter-spacing: 2px; }

.btn-enter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  background: var(--c-enlighten-primary);
  color: #fff;
  border: none; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: transform .15s;
}
.btn-enter:active { transform: scale(.95); }
.btn-enter:disabled { background: var(--text-dim); cursor: not-allowed; }

/* ---------- 学习/答题页 ---------- */
.learn-view {
  max-width: var(--maxw); margin: 0 auto;
  padding: 16px;
}
.learn-progress {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.progress-bar {
  flex: 1; height: 8px;
  background: var(--border);
  border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--c-enlighten-accent), var(--c-enlighten-primary));
  transition: width .4s;
}

.content-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.content-card h3 {
  font-size: 18px; margin-bottom: 12px;
  font-family: var(--font-rounded);
}
.content-card p { font-size: 15px; line-height: 1.8; color: var(--text); margin-bottom: 12px; }
.content-card .highlight {
  background: linear-gradient(180deg, transparent 60%, #ffe9a8 60%);
  padding: 0 2px; font-weight: 600;
}
.content-card .analogy {
  background: var(--c-enlighten-bg);
  border-left: 4px solid var(--c-enlighten-primary);
  padding: 14px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 12px 0;
  font-size: 14px;
}
.content-card .formula {
  text-align: center;
  font-size: 18px;
  padding: 16px;
  background: #f8f9fc;
  border-radius: var(--radius-sm);
  font-family: "STIX Two Math", "Times New Roman", serif;
  margin: 12px 0;
}

/* 互动演示容器 */
.demo-box {
  background: #1a1f36;
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
  color: #fff;
  position: relative;
  min-height: 200px;
}
.demo-canvas {
  width: 100%; height: 240px;
  background: #0f1326;
  border-radius: var(--radius-sm);
  display: block;
}
.demo-controls {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 14px;
}
.slider-row {
  display: flex; align-items: center; gap: 12px;
}
.slider-row label { font-size: 13px; min-width: 80px; opacity: .9; }
.slider-row input[type=range] { flex: 1; }
.slider-row .value {
  font-size: 14px; font-weight: 700; min-width: 56px; text-align: right;
  color: var(--c-enlighten-accent);
}

/* ---------- 题目组件 ---------- */
.quiz-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.quiz-type-tag {
  display: inline-block;
  font-size: 11px; padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-advanced-bg);
  color: var(--c-advanced-text);
  font-weight: 600;
  margin-bottom: 12px;
}
.quiz-question {
  font-size: 17px; font-weight: 700;
  line-height: 1.5;
  margin-bottom: 16px;
}
.quiz-scene {
  background: #f8f9fc;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px; color: var(--text-soft);
  line-height: 1.7;
  margin-bottom: 16px;
  border-left: 3px solid var(--c-advanced-primary);
}

/* 选项 */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: #f8f9fc;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  font-size: 15px;
  user-select: none;
}
.option:hover { border-color: var(--c-advanced-primary); background: var(--c-advanced-bg); }
.option .opt-mark {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: #fff;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.option.selected { border-color: var(--c-advanced-primary); background: var(--c-advanced-bg); }
.option.selected .opt-mark { background: var(--c-advanced-primary); color: #fff; border-color: var(--c-advanced-primary); }
.option.correct { border-color: var(--c-correct); background: rgba(46,204,113,.1); }
.option.correct .opt-mark { background: var(--c-correct); color: #fff; border-color: var(--c-correct); }
.option.wrong { border-color: var(--c-wrong); background: rgba(255,92,92,.1); }
.option.wrong .opt-mark { background: var(--c-wrong); color: #fff; border-color: var(--c-wrong); }

/* 拖拽连线 */
.dnd-area {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin: 16px 0;
}
.dnd-col { display: flex; flex-direction: column; gap: 10px; }
.dnd-item {
  padding: 12px 14px;
  background: #f8f9fc;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: grab;
  text-align: center;
  transition: all .15s;
  user-select: none;
}
.dnd-item:active { cursor: grabbing; }
.dnd-item.dragging { opacity: .5; border-style: dashed; }
.dnd-item.drop-target { border-color: var(--c-advanced-primary); background: var(--c-advanced-bg); }
.dnd-item.matched { border-color: var(--c-correct); background: rgba(46,204,113,.1); cursor: default; }
.dnd-slot {
  padding: 12px 14px;
  background: #fff;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
  min-height: 46px;
  display: flex; align-items: center; justify-content: center;
}
.dnd-slot.filled { border-style: solid; }

/* 反馈 */
.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  display: none;
}
.feedback.show { display: block; animation: slideUp .3s; }
.feedback.correct { background: rgba(46,204,113,.1); color: #1a7d43; border-left: 4px solid var(--c-correct); }
.feedback.wrong { background: rgba(255,92,92,.1); color: #a83838; border-left: 4px solid var(--c-wrong); }
.feedback .explain { margin-top: 8px; color: var(--text-soft); font-size: 13px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

.quiz-actions {
  display: flex; gap: 10px; margin-top: 18px;
}
.btn {
  padding: 12px 22px;
  border: none; border-radius: 999px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: transform .15s, opacity .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--c-enlighten-primary); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-success { background: var(--c-correct); color: #fff; }

/* ---------- 通关庆祝 ---------- */
.celebrate {
  position: fixed; inset: 0;
  background: rgba(10,10,15,.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.celebrate-card {
  background: linear-gradient(135deg, #fff8ed, #fff);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: pop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celebrate-stars {
  font-size: 40px;
  letter-spacing: 8px;
  margin-bottom: 12px;
}
.celebrate-title {
  font-size: 22px; font-weight: 800;
  font-family: var(--font-rounded);
  margin-bottom: 8px;
  color: var(--c-enlighten-text);
}
.celebrate-msg { font-size: 14px; color: var(--text-soft); line-height: 1.6; margin-bottom: 20px; }
.celebrate-actions { display: flex; gap: 10px; justify-content: center; }

/* NPC 对话气泡 */
.npc-bubble {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin: 12px 0;
  font-size: 14px; line-height: 1.7;
  position: relative;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--c-enlighten-primary);
}
.npc-bubble .npc-name {
  font-weight: 700; color: var(--c-enlighten-primary);
  font-size: 13px; margin-bottom: 4px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .page { padding: 16px 12px 60px; }
  .hero-banner { padding: 24px 18px; }
  .hero-banner h1 { font-size: 22px; }
  .hero-npc { width: 72px; height: 72px; }
  .hero-npc svg { width: 60px; height: 60px; }
  .planet-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .planet-card { padding: 14px 10px; }
  .planet-orb { width: 48px; height: 48px; font-size: 24px; }
  .planet-name { font-size: 13px; }
  .topbar-title { font-size: 14px; }
  .topbar-stats { font-size: 12px; gap: 8px; }
  .content-card, .quiz-card { padding: 18px 14px; }
  .quiz-question { font-size: 15px; }
  .option { padding: 12px 14px; font-size: 14px; }
  .dnd-area { grid-template-columns: 1fr; }
  .topic-hero { padding: 22px 16px; }
  .topic-hero h2 { font-size: 19px; }
}

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.text-dim { color: var(--text-dim); }
.text-soft { color: var(--text-soft); }
.small { font-size: 12px; }
