/* ===== 比例实验室 · 全局样式 v0.2 ===== */

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

:root {
  --primary: #ff6b35;
  --primary-dark: #e85a26;
  --secondary: #2c5f8d;
  --secondary-light: #4a8bc2;
  --bg: #fafbfc;
  --bg-card: #ffffff;
  --text: #1a2332;
  --text-muted: #6b7785;
  --border: #e1e6ed;
  --success: #2ecc71;
  --warning: #f39c12;
  --error: #e74c3c;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #fef5e7 0%, #e8f4f8 100%);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; font-size: 16px; }

/* ===== 顶部导航 ===== */
.topbar {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-logo { font-size: 18px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.topbar-user { font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 12px; }
.user-badge { background: var(--secondary); color: white; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.timer-badge { background: var(--warning); color: white; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.timer-badge.timeout { background: var(--error); animation: pulse 0.6s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.btn-logout { background: transparent; color: var(--text-muted); padding: 4px 10px; font-size: 12px; border-radius: 6px; border: 1px solid var(--border); transition: all 0.2s; }
.btn-logout:hover { border-color: var(--error); color: var(--error); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }

/* ===== 登录页 ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--bg-card); border-radius: 20px; padding: 40px 32px; width: 100%; max-width: 440px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1); }
.login-icon { font-size: 56px; text-align: center; margin-bottom: 12px; }
.login-title { font-size: 26px; font-weight: 700; text-align: center; color: var(--text); margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 32px; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-input { width: 100%; padding: 12px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); transition: all 0.2s; outline: none; }
.form-input:focus { border-color: var(--primary); background: white; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.btn-primary { width: 100%; padding: 14px; background: var(--primary); color: white; border-radius: var(--radius); font-size: 16px; font-weight: 600; transition: all 0.2s; margin-top: 12px; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3); }
.btn-primary:active { transform: translateY(0); }

/* ===== 主菜单 ===== */
.welcome-section { text-align: center; padding: 32px 20px 16px; }
.welcome-title { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.welcome-subtitle { font-size: 15px; color: var(--text-muted); }

.progress-bar { background: var(--bg-card); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0 24px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; }
.progress-info { flex: 1; }
.progress-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.progress-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%); transition: width 0.4s; border-radius: 4px; }
.progress-percent { font-size: 18px; font-weight: 700; color: var(--primary); min-width: 50px; text-align: right; }

/* ===== 关卡地图（主菜单核心） ===== */
.level-tower { position: relative; display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.tower-path { position: absolute; top: 50px; left: 50%; width: 4px; height: calc(100% - 100px); background: linear-gradient(180deg, transparent 0%, var(--border) 10%, var(--border) 90%, transparent 100%); z-index: 0; }
.exp-tower {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  z-index: 1;
  border: 3px solid transparent;
}
.exp-tower:hover:not(.locked) { transform: translateX(4px); box-shadow: var(--shadow-hover); }
.exp-tower.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.6); }
.exp-tower.completed { border-color: var(--success); }
.exp-tower-num { font-size: 12px; color: var(--text-muted); font-weight: 700; letter-spacing: 1px; min-width: 50px; }
.exp-tower-icon { width: 70px; height: 70px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 36px; flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.15); transition: all 0.3s; }
.exp-tower.completed .exp-tower-icon { background: var(--success); }
.exp-tower.locked .exp-tower-icon { background: #ccc; }
.exp-tower-name { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.exp-tower-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.exp-tower-dots { display: flex; gap: 4px; margin-bottom: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.dot.done { background: var(--success); }
.exp-tower-progress { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.exp-tower-badge { position: absolute; top: 12px; right: 12px; background: var(--success); color: white; font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.exp-tower-lock-tip { position: absolute; top: 12px; right: 12px; background: var(--text-muted); color: white; font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 500; }

/* 解锁闪光动画 */
.unlock-flash { animation: unlockFlash 1.2s ease-out; }
@keyframes unlockFlash {
  0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.8); border-color: gold; }
  50% { box-shadow: 0 0 0 20px rgba(255, 215, 0, 0); border-color: gold; }
  100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

/* ===== 成就墙 ===== */
.achievements-bar { background: var(--bg-card); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); margin-top: 16px; }
.ach-bar-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.ach-bar-items { display: flex; gap: 10px; flex-wrap: wrap; }
.ach-item { width: 40px; height: 40px; background: var(--bg); border: 2px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; opacity: 0.4; transition: all 0.2s; }
.ach-item.got { opacity: 1; background: linear-gradient(135deg, #fff3c4 0%, #ffd54f 100%); border-color: var(--warning); transform: scale(1.1); }

/* ===== 实验台内页通用 ===== */
.experiment-page { min-height: calc(100vh - 60px); padding: 24px 20px; }
.exp-header { text-align: center; margin-bottom: 24px; }
.exp-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.exp-tagline { font-size: 14px; color: var(--text-muted); }
.btn-back { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-card); padding: 8px 16px; border-radius: 999px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; box-shadow: var(--shadow); transition: all 0.2s; }
.btn-back:hover { color: var(--primary); }
.experiment-stage { background: var(--bg-card); border-radius: var(--radius); padding: 32px 24px; box-shadow: var(--shadow); max-width: 800px; margin: 0 auto; }

/* ===== 实验台介绍卡 ===== */
.exp-intro { border-radius: var(--radius); padding: 24px; color: white; display: flex; align-items: center; gap: 20px; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.exp-intro-icon { font-size: 56px; }
.exp-intro-text h2 { font-size: 22px; margin-bottom: 4px; }
.exp-intro-text p { font-size: 14px; opacity: 0.9; }

/* ===== 子关卡列表 ===== */
.sublevel-list { display: flex; flex-direction: column; gap: 12px; }
.sublevel-card { background: var(--bg-card); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; align-items: center; gap: 16px; cursor: pointer; transition: all 0.2s; }
.sublevel-card:hover:not(.locked) { border-color: var(--primary); transform: translateX(4px); }
.sublevel-card.done { background: linear-gradient(135deg, #e8f8f0 0%, #d4f1e0 100%); border-color: var(--success); }
.sublevel-card.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.5); }
.sublevel-num { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.sublevel-card.done .sublevel-num { background: var(--success); }
.sublevel-card.locked .sublevel-num { background: #ccc; }
.sublevel-body { flex: 1; min-width: 0; }
.sublevel-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.sublevel-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.sublevel-meta { font-size: 11px; color: var(--text-muted); }
.sublevel-icon { font-size: 28px; flex-shrink: 0; }

/* ===== 滑块 ===== */
.slider-group { margin-bottom: 20px; }
.slider-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slider-name { font-size: 14px; font-weight: 500; }
.slider-value { font-size: 18px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.slider { width: 100%; height: 6px; background: var(--border); border-radius: 3px; -webkit-appearance: none; appearance: none; outline: none; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; background: var(--primary); border-radius: 50%; cursor: pointer; box-shadow: 0 2px 6px rgba(255, 107, 53, 0.3); transition: transform 0.1s; }
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb { width: 24px; height: 24px; background: var(--primary); border-radius: 50%; cursor: pointer; border: none; }

/* ===== 数据显示 ===== */
.data-display { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 24px 0; }
.data-card { background: var(--bg); border-radius: var(--radius-sm); padding: 16px; text-align: center; border: 2px solid var(--border); }
.data-card.highlight { background: linear-gradient(135deg, #fff5f0 0%, #ffe8dc 100%); border-color: var(--primary); }
.data-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.data-value { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.data-card.highlight .data-value { color: var(--primary); }

/* ===== 挑战题 ===== */
.challenge-box { background: linear-gradient(135deg, #fff8e1 0%, #fff3c4 100%); border: 2px solid var(--warning); border-radius: var(--radius); padding: 20px; margin-top: 24px; }
.challenge-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.challenge-question { font-size: 14px; color: var(--text); margin-bottom: 16px; }
.challenge-options { display: grid; gap: 8px; }
.challenge-option { background: white; border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; text-align: left; font-size: 14px; transition: all 0.2s; }
.challenge-option:hover:not(:disabled) { border-color: var(--primary); }
.challenge-option:disabled { cursor: not-allowed; }
.challenge-option.correct { background: var(--success); color: white; border-color: var(--success); animation: correctPulse 0.6s; }
.challenge-option.wrong { background: var(--error); color: white; border-color: var(--error); animation: shake 0.4s; }
@keyframes correctPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.challenge-feedback { margin-top: 12px; padding: 12px; background: white; border-radius: var(--radius-sm); font-size: 13px; display: none; }
.challenge-feedback.show { display: block; }
.challenge-feedback.correct { border-left: 4px solid var(--success); color: #1e7e34; }
.challenge-feedback.wrong { border-left: 4px solid var(--error); color: #c0392b; }

/* ===== 玻璃杯（果汁台） ===== */
.glass-container { display: flex; justify-content: center; align-items: flex-end; gap: 24px; margin: 24px 0; flex-wrap: wrap; }
.juice-glass { width: 100px; height: 200px; background: rgba(0,0,0,0.05); border: 3px solid var(--text); border-radius: 0 0 12px 12px; position: relative; overflow: hidden; }
.juice-fill { position: absolute; bottom: 0; left: 0; right: 0; height: var(--fill-height, 50%); background: linear-gradient(180deg, #ff6b35 0%, #e85a26 100%); transition: height 0.4s, background 0.3s; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 14px; }
.juice-label { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 8px; font-weight: 500; }
/* 液面波纹 */
.juice-fill::before { content: ''; position: absolute; top: -6px; left: -50%; width: 200%; height: 12px; background: radial-gradient(ellipse at center, rgba(255,255,255,0.6) 0%, transparent 70%); border-radius: 50%; animation: wave 2s linear infinite; }
@keyframes wave { 0% { transform: translateX(0) translateY(0); } 50% { transform: translateX(-25%) translateY(-2px); } 100% { transform: translateX(0) translateY(0); } }

/* ===== 比例鉴定仪 ===== */
.checker-display { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 32px 16px; background: linear-gradient(135deg, #e8f4f8 0%, #d6e9f2 100%); border-radius: var(--radius); margin-bottom: 20px; }
.checker-ratio { font-size: 36px; font-weight: 700; color: var(--secondary); font-variant-numeric: tabular-nums; padding: 12px 20px; background: white; border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.checker-arrow { font-size: 18px; color: var(--text-muted); }
.checker-vs { font-size: 48px; font-weight: 900; color: var(--primary); animation: vsBounce 1.2s infinite; }
@keyframes vsBounce { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ===== 解方程天秤 ===== */
.balance-stage { padding: 32px 16px; background: linear-gradient(180deg, #f0f9f4 0%, #e0f2e9 100%); border-radius: var(--radius); margin-bottom: 20px; }
.balance-arm { display: flex; align-items: center; justify-content: space-between; position: relative; min-height: 140px; }
.balance-side { flex: 1; display: flex; justify-content: center; }
.balance-pan { background: linear-gradient(180deg, #8B4513 0%, #654321 100%); color: white; border-radius: 12px 12px 50% 50%; padding: 16px 24px; min-width: 100px; text-align: center; box-shadow: 0 8px 16px rgba(0,0,0,0.2); }
.balance-obj { display: inline-block; background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 6px; margin: 2px 4px; font-size: 18px; font-weight: 700; }
.balance-pivot { position: absolute; left: 50%; top: 0; transform: translateX(-50%); font-size: 32px; animation: tilt 4s ease-in-out infinite; }
@keyframes tilt { 0%,100% { transform: translateX(-50%) rotate(-2deg); } 50% { transform: translateX(-50%) rotate(2deg); } }

/* ===== 双胞胎赛跑 ===== */
.race-track { background: linear-gradient(180deg, #fff8e1 0%, #f0f4c3 100%); border-radius: var(--radius); padding: 24px 16px; margin-bottom: 20px; position: relative; min-height: 140px; overflow: hidden; }
.race-track::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: repeating-linear-gradient(90deg, transparent 0%, transparent 30px, rgba(0,0,0,0.05) 30px, rgba(0,0,0,0.05) 32px); }
.runner { position: relative; z-index: 1; font-size: 20px; padding: 4px 8px; background: white; border-radius: 999px; display: inline-block; margin: 8px 0; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
#runner-fast { background: linear-gradient(90deg, #fff 0%, #ffe0b2 100%); }
#runner-slow { background: linear-gradient(90deg, #fff 0%, #c8e6c9 100%); }
.finish { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 32px; z-index: 0; }
.race-hint { background: #e8f4f8; border-radius: var(--radius-sm); padding: 12px; text-align: center; font-size: 13px; color: var(--secondary); font-weight: 500; margin-bottom: 16px; }
@keyframes runFast { 0% { transform: translateX(0); } 50% { transform: translateX(8px); } 100% { transform: translateX(0); } }
@keyframes runSlow { 0% { transform: translateX(0); } 50% { transform: translateX(3px); } 100% { transform: translateX(0); } }

/* ===== 成就弹窗 ===== */
.achievement-popup { position: fixed; top: 80px; right: 20px; background: linear-gradient(135deg, #fff3c4 0%, #ffd54f 100%); border: 3px solid var(--warning); border-radius: var(--radius); padding: 16px 20px; box-shadow: 0 8px 24px rgba(243, 156, 18, 0.3); z-index: 1000; display: none; animation: slideInRight 0.4s, fadeOut 0.4s 3.6s forwards; max-width: 320px; }
.achievement-popup.show { display: block; }
.achievement-icon { font-size: 32px; margin-bottom: 4px; }
.achievement-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.achievement-desc { font-size: 12px; color: var(--text-muted); }
@keyframes slideInRight { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(400px); } }

/* ===== 撒星星粒子 ===== */
.star-particle { position: fixed; font-size: 24px; pointer-events: none; z-index: 999; animation: starBurst 1s forwards; }
@keyframes starBurst { 0% { transform: translate(0, 0) scale(0.5); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.5) rotate(360deg); opacity: 0; } }

/* ===== 反馈框按钮 ===== */
.fb-content { margin-bottom: 12px; }
.fb-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.fb-next-btn, .fb-retry-btn, .fb-skip-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}
.fb-next-btn { background: var(--success); color: white; }
.fb-next-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3); }
.fb-retry-btn { background: var(--primary); color: white; }
.fb-retry-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3); }
.fb-skip-btn { background: white; color: var(--text-muted); border: 1px solid var(--border); }
.fb-skip-btn:hover { color: var(--text); }

/* ===== 彩带 ===== */
.confetti { position: fixed; top: -20px; width: 10px; height: 18px; z-index: 998; pointer-events: none; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 100% { transform: translateY(110vh) rotate(720deg); opacity: 0.7; } }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 12px 24px; border-radius: 999px; font-size: 14px; z-index: 1000; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .container { padding: 16px 12px; }
  .topbar { padding: 10px 14px; }
  .topbar-logo { font-size: 16px; }
  .login-card { padding: 32px 24px; }
  .login-title { font-size: 22px; }
  .welcome-title { font-size: 22px; }
  .experiment-stage { padding: 20px 16px; }
  .exp-title { font-size: 20px; }
  .glass-container { gap: 12px; }
  .juice-glass { width: 80px; height: 160px; }
  .data-display { grid-template-columns: 1fr 1fr; }
  .achievement-popup { right: 12px; left: 12px; max-width: none; }
  .exp-tower { padding: 16px; }
  .exp-tower-icon { width: 56px; height: 56px; font-size: 28px; }
  .exp-tower-num { font-size: 10px; min-width: 40px; }
  .checker-display { flex-wrap: wrap; gap: 8px; }
  .checker-ratio { font-size: 24px; padding: 8px 12px; }
  .balance-pan { padding: 12px 16px; min-width: 80px; }
  .balance-obj { font-size: 14px; }
  .tower-path { display: none; }
}

@media (max-width: 480px) {
  .data-display { grid-template-columns: 1fr; }
  .juice-glass { width: 70px; height: 140px; }
  .exp-tower { flex-direction: column; text-align: center; }
}
