* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #1e2a78 0%, #3a1c71 50%, #4b2e83 100%);
  color: #2d2d44;
  min-height: 100vh;
  padding-bottom: 40px;
}
.topbar {
  background: rgba(255,255,255,0.96);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-size: 22px; font-weight: 800; color: #4b2e83; }
.hud { display: flex; gap: 16px; font-size: 14px; }
.hud-item { background: #f0ecff; padding: 6px 12px; border-radius: 20px; }
.hud-item b { color: #6c3fc5; }
.progress-track { flex: 1; min-width: 140px; height: 10px; background: #e3dcff; border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg,#48dbfb,#1dd1a1); transition: width .4s; }

.tabs { display: flex; gap: 10px; padding: 16px 22px 0; }
.tab {
  background: rgba(255,255,255,0.18); color: #fff; border: none;
  padding: 9px 18px; border-radius: 10px 10px 0 0; font-size: 15px; cursor: pointer;
  transition: background .2s;
}
.tab.active { background: #fff; color: #4b2e83; font-weight: 700; }
.tab:hover { background: rgba(255,255,255,0.4); }

main { padding: 18px 22px; max-width: 1080px; margin: 0 auto; }

/* 关卡地图 */
.level-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.level-card {
  background: #fff; border-radius: 16px; padding: 18px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15); transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
}
.level-card:hover { transform: translateY(-4px); box-shadow: 0 10px 22px rgba(0,0,0,0.22); }
.level-card.locked { opacity: .55; cursor: not-allowed; filter: grayscale(.4); }
.level-card.done { border-color: #1dd1a1; }
.level-icon { font-size: 38px; }
.level-title { font-weight: 800; margin: 8px 0 4px; color: #3a1c71; font-size: 15px; }
.level-summary { font-size: 13px; color: #666; min-height: 34px; }
.level-badge { margin-top: 10px; font-size: 13px; font-weight: 700; color: #6c3fc5; }

/* 学习面板 */
.lesson-panel, .sandbox-panel {
  background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 4px 18px rgba(0,0,0,0.18);
}
.lesson-panel h2 { color: #3a1c71; margin-bottom: 14px; }
.lesson-panel h3 { color: #6c3fc5; margin: 18px 0 8px; font-size: 16px; }
.points { padding-left: 22px; line-height: 1.9; font-size: 14.5px; }
.code-block {
  background: #1e1e2e; color: #e6e6e6; padding: 14px; border-radius: 10px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: 13.5px;
  white-space: pre-wrap; line-height: 1.6; overflow-x: auto;
}
.primary-btn {
  background: linear-gradient(90deg,#6c3fc5,#9b59ff); color: #fff; border: none;
  padding: 11px 22px; border-radius: 10px; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 12px; transition: transform .12s, filter .12s;
}
.primary-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.back-btn { background: #eee; border: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; margin-bottom: 8px; }

/* 答题 */
.quiz-q { background: #f7f5ff; border-radius: 12px; padding: 14px; margin: 12px 0; }
.q-text { font-size: 15px; margin-bottom: 8px; }
.opt { display: block; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.opt:hover { background: #ece6ff; }
.q-feedback { margin-top: 8px; font-size: 13px; padding: 8px 10px; border-radius: 8px; display: none; }
.q-feedback.ok { display: block; background: #e3fcec; color: #1b7a45; }
.q-feedback.bad { display: block; background: #fde8e8; color: #b42318; }
.quiz-result { margin-top: 16px; background: #eaf4ff; border-radius: 12px; padding: 14px; font-size: 15px; line-height: 1.8; }

/* 沙盒 */
.hint { font-size: 13px; color: #777; margin-bottom: 8px; }
.sandbox-code {
  width: 100%; min-height: 160px; background: #1e1e2e; color: #e6e6e6;
  border: none; border-radius: 10px; padding: 14px; font-family: Consolas, monospace;
  font-size: 14px; line-height: 1.6; resize: vertical;
}
.sandbox-status { font-size: 12px; color: #888; margin: 8px 2px; }
.sandbox-output {
  background: #0f0f1a; color: #7CFC00; padding: 14px; border-radius: 10px;
  font-family: Consolas, monospace; font-size: 13.5px; min-height: 60px;
  white-space: pre-wrap; margin-top: 10px;
}

/* 吐司 & 彩带 */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(120px);
  background: #3a1c71; color: #fff; padding: 13px 22px; border-radius: 30px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.3); opacity: 0;
  transition: transform .35s, opacity .35s; z-index: 20; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 15; overflow: hidden; }
.confetti {
  position: absolute; top: -10px; width: 9px; height: 14px; border-radius: 2px;
  animation: fall 1.6s linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: .2; }
}
