:root {
  --accent: #ff6b35;
  --accent-dark: #e85a2b;
  --success: #4caf50;
  --info: #2196f3;
  --warning: #ff9800;
  --danger: #f44336;
  --gold: #ffd700;
  --bg-dark: #0d1b2a;
  --bg-mid: #1b2838;
  --bg-light: #1a237e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-mid) 50%, var(--bg-light) 100%);
  color: #fff;
  overflow: hidden;
}

.app {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* 通用按钮 */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 14px 32px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.35);
  transition: transform 0.15s, background 0.15s;
}

.btn-primary:hover { background: var(--accent-dark); transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

/* 开始页 */
.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
}

.start-screen h1 {
  font-size: 46px;
  margin: 0 0 8px;
  color: var(--gold);
  text-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.start-screen .subtitle {
  font-size: 16px;
  color: #b0bec5;
  margin-bottom: 24px;
}

.rules-card {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 18px;
  text-align: left;
  margin-bottom: 24px;
}

.rules-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
  text-align: center;
  color: #e0e0e0;
}

.rule-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #cfd8dc;
}

.rule-row .icon {
  font-size: 18px;
  width: 26px;
  flex-shrink: 0;
  text-align: center;
}

/* 游戏页 */
.game-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 10px 12px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}

.level-badge .level {
  font-size: 15px;
  font-weight: 700;
}

.level-badge .difficulty {
  font-size: 11px;
  margin-top: 1px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid;
}

.combo-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255,215,0,0.12);
  border: 1px solid rgba(255,215,0,0.35);
  font-size: 13px;
  min-height: 26px;
}

.combo-badge .streak { color: var(--gold); font-weight: 700; }
.combo-badge .multiplier { color: var(--accent); font-weight: 700; }
.combo-badge .label { color: var(--success); font-weight: 700; }

.score-display {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #b0bec5;
  margin-bottom: 4px;
}

.status-bar .correct { color: var(--success); }

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

.question-card {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  margin-bottom: 6px;
}

.question-card .chapter {
  font-size: 12px;
  color: #b0bec5;
  margin-bottom: 4px;
}

.question-card .line {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  min-height: 26px;
}

.question-card .prompt {
  font-size: 12px;
  color: var(--accent);
  margin: 2px 0;
}

.explanation {
  display: none;
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  text-align: left;
}

.explanation.correct { background: rgba(76,175,80,0.15); color: #81c784; }
.explanation.wrong { background: rgba(244,67,54,0.15); color: #ef9a9a; }

.feedback {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  min-height: 28px;
  margin-bottom: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.feedback.show { opacity: 1; }
.feedback.good { color: var(--gold); }
.feedback.bad { color: var(--danger); }

.canvas-wrap {
  flex: 1;
  position: relative;
  border-radius: 16px;
  border: 2px solid #4fc3f7;
  overflow: hidden;
  background: #0d47a1;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

.canvas-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  pointer-events: none;
  background: rgba(0,0,0,0.35);
  padding: 3px 10px;
  border-radius: 12px;
}

/* 关卡结果页 */
.round-result, .game-over {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
}

.round-result h2, .game-over h2 {
  font-size: 28px;
  margin: 0 0 8px;
}

.pass-status {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 16px;
}

.pass-status.pass { color: var(--success); }
.pass-status.fail { color: var(--danger); }

.stats-grid {
  display: flex;
  width: 100%;
  justify-content: space-around;
  margin: 16px 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-item .value {
  font-size: 32px;
  font-weight: 700;
}

.stat-item .label {
  font-size: 12px;
  color: #78909c;
  margin-top: 2px;
}

.result-card {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 20px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #b0bec5;
  margin-top: 8px;
}

.result-row .highlight { color: var(--accent); font-weight: 700; }

.next-info {
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 12px;
  min-height: 20px;
}

.rank {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 16px;
}

.back-link {
  display: inline-block;
  margin-top: 16px;
  color: #b0bec5;
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover { color: #fff; }

.countdown-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

#countdown {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

#countdown.danger { color: var(--danger); }
#countdown.warning { color: var(--warning); }
