/* 魔方教学页面样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg1: #0d1117;
  --bg2: #171d28;
  --panel-bg: rgba(19, 24, 34, 0.92);
  --card-bg: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e6edf3;
  --text-dim: #9aa7b5;
  --accent: #4da3ff;
  --accent-strong: #2f81f7;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #ffd500;
  --radius: 12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 55%, #1b2433 100%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

/* ---------- 3D 舞台 ---------- */
#stage { position: fixed; inset: 0; }
#canvas-host { position: absolute; inset: 0; }
#canvas-host canvas { display: block; }

#badge {
  position: absolute;
  top: 16px; left: 16px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  background: rgba(63, 185, 80, 0.16);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.4);
  transition: all 0.25s;
  user-select: none;
}
#badge.unsolved {
  background: rgba(255, 213, 0, 0.12);
  color: var(--yellow);
  border-color: rgba(255, 213, 0, 0.35);
}

#move-toast {
  position: absolute;
  left: 50%; bottom: 36px;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--card-border);
  font-size: 15px;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
#move-toast.show { opacity: 1; }

/* ---------- 侧面板 ---------- */
#panel-toggle {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 30;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

#panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 348px;
  padding: 18px 16px 24px;
  overflow-y: auto;
  background: var(--panel-bg);
  border-left: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  z-index: 20;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
#panel::-webkit-scrollbar { width: 6px; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 3px; }

#panel header h1 { font-size: 20px; font-weight: 700; }
#panel header h1 small { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 6px; }
#panel header .sub { margin-top: 4px; font-size: 12px; color: var(--text-dim); }

.card {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.card h2 { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.card h2 .hint { font-size: 11px; color: var(--text-dim); font-weight: 400; margin-left: 6px; }
.card h2 .progress { float: right; font-size: 12px; color: var(--accent); font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.2s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #4390f5; }
.btn.danger { background: rgba(248, 81, 73, 0.14); border-color: rgba(248, 81, 73, 0.4); color: #ff8a84; }
.btn.danger:hover:not(:disabled) { background: rgba(248, 81, 73, 0.24); }

/* ---------- 求解播放 ---------- */
.solve-stage { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--yellow); }
.solve-alg { margin-top: 4px; font-size: 12px; color: var(--text-dim); font-family: ui-monospace, Consolas, monospace; }

.move-chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 108px;
  overflow-y: auto;
}
.chip {
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  transition: all 0.15s;
}
.chip.done { opacity: 0.45; }
.chip.current {
  background: var(--accent-strong);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  transform: scale(1.08);
}

/* ---------- 闯关训练 ---------- */
.train-list li { cursor: pointer; }
.train-list li.locked { opacity: 0.42; cursor: not-allowed; }
.train-list li.passed { opacity: 0.85; }
.train-list li.passed::after { content: "⭐"; margin-left: 6px; }
.train-list li.playing {
  background: rgba(255, 213, 0, 0.10);
  border-color: rgba(255, 213, 0, 0.45);
}
.train-list li.playing::after { content: "▸ 挑战中"; font-size: 11px; color: var(--yellow); }
.train-goal {
  margin: 10px 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 213, 0, 0.08);
  border: 1px dashed rgba(255, 213, 0, 0.4);
  font-size: 12px;
  color: var(--yellow);
  line-height: 1.6;
}

/* ---------- 教学七步 ---------- */
.stage-list { list-style: none; counter-reset: stage; }
.stage-list li {
  counter-increment: stage;
  position: relative;
  padding: 8px 10px 8px 40px;
  border-radius: 9px;
  font-size: 13px;
  transition: background 0.25s;
  border: 1px solid transparent;
}
.stage-list li::before {
  content: counter(stage);
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-list li .alg {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, Consolas, monospace;
}
.stage-list li.done { opacity: 0.5; }
.stage-list li.done .alg::after { content: " ✓"; color: var(--green); }
.stage-list li.active {
  background: rgba(77, 163, 255, 0.12);
  border-color: rgba(77, 163, 255, 0.4);
}
.stage-list li.active::before { background: var(--accent-strong); color: #fff; }

/* ---------- 口诀速查 ---------- */
.alg-list { display: flex; flex-direction: column; gap: 7px; }
.alg-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-align: left;
}
.alg-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.11); }
.alg-btn:active:not(:disabled) { transform: scale(0.98); }
.alg-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.alg-btn .name { font-weight: 600; }
.alg-btn .seq {
  font-size: 11px;
  color: var(--accent);
  font-family: ui-monospace, Consolas, monospace;
  flex-shrink: 0;
}

/* ---------- 公式输入 / 设置 ---------- */
.formula-row { display: flex; gap: 8px; }
.formula-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 14px;
  font-family: ui-monospace, Consolas, monospace;
  outline: none;
}
.formula-row input:focus { border-color: var(--accent); }
.hint { margin-top: 8px; font-size: 11px; color: var(--text-dim); }

.speed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.speed-row input { flex: 1; accent-color: var(--accent-strong); }
.speed-row span { font-size: 12px; min-width: 74px; text-align: right; color: var(--text); }

footer.tips { margin-top: 16px; padding: 4px 6px; }
footer.tips p { margin: 5px 0; font-size: 12px; color: var(--text-dim); line-height: 1.5; }

/* ---------- 移动端 ---------- */
@media (max-width: 900px) {
  #panel-toggle { display: flex; }
  #panel {
    width: min(86vw, 348px);
    transform: translateX(105%);
    transition: transform 0.28s ease;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }
  #panel.open { transform: translateX(0); }
  #badge { font-size: 12px; padding: 4px 10px; }
}
