/* 词力·初中英语学习系统 - 零外部依赖样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f0f4f8;
  color: #2d3748;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 3px solid #38a169;
  margin-bottom: 20px;
}

header h1 { font-size: 22px; color: #276749; }

.user-info { display: flex; align-items: center; gap: 12px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#login-btn, #logout-btn {
  padding: 8px 16px;
  background: #38a169;
  color: #fff;
}

/* ===== 区块切换 ===== */
.section { display: none; }
.section.active { display: block; }

/* ===== 登录界面 ===== */
.login-form {
  max-width: 360px;
  margin: 40px auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fff;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.login-form input {
  padding: 12px;
  font-size: 16px;
  border: 2px solid #cbd5e0;
  border-radius: 8px;
}

.login-form button {
  padding: 12px;
  background: #38a169;
  color: #fff;
  font-size: 17px;
}

.login-form button#register-btn {
  background: #edf2f7;
  color: #2d3748;
}

.login-message {
  min-height: 24px;
  font-size: 15px;
  text-align: center;
  color: #4a5568;
}

.login-message.err { color: #c53030; font-weight: bold; }

/* ===== 进度条 ===== */
.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  margin-bottom: 24px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background: #38a169;
  width: 0%;
  transition: width 0.4s;
}

/* ===== 答题区 ===== */
.exercise-container {
  background: #fff;
  border-radius: 12px;
  padding: 32px 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.question { text-align: center; margin-bottom: 28px; }

#chinese-sentence {
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 28px;
  color: #1a202c;
}

.blanks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  min-height: 60px;
}

.blank {
  min-width: 110px;
  padding: 6px 10px 10px;
  font-size: 26px;
  text-align: center;
  border-bottom: 3px solid #a0aec0;
  cursor: pointer;
  color: #2b6cb0;
  min-height: 48px;
}

.blank.focused {
  border-bottom-color: #38a169;
  background: #f0fff4;
}

.blank.correct { border-bottom-color: #38a169; color: #276749; }
.blank.error {
  border-bottom-color: #e53e3e;
  color: #e53e3e;
  animation: shake 0.4s;
}

.blank.hint-prefix { color: #2b6cb0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes flashRed {
  0%, 100% { background: #fff; }
  50% { background: #fed7d7; }
}

.exercise-container.flash-error { animation: flashRed 0.8s 2; }

/* ===== 虚拟键盘 ===== */
.virtual-keyboard {
  margin: 24px auto 0;
  max-width: 640px;
  background: #e2e8f0;
  border-radius: 12px;
  padding: 10px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.keyboard-row:last-child { margin-bottom: 0; }

.key {
  flex: 1;
  max-width: 56px;
  height: 52px;
  background: #fff;
  border-radius: 8px;
  font-size: 20px;
  box-shadow: 0 2px 0 #cbd5e0;
}

.key:active { transform: translateY(2px); box-shadow: none; background: #edf2f7; }

.key.space { max-width: 280px; flex: 4; font-size: 16px; }
.key.submit { max-width: 120px; flex: 2; background: #38a169; color: #fff; font-size: 16px; }

/* ===== 控制按钮 ===== */
.controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.controls button {
  padding: 12px 32px;
  font-size: 18px;
}

#submit-btn { background: #38a169; color: #fff; }
#reset-btn { background: #edf2f7; color: #4a5568; }
#next-btn { background: #3182ce; color: #fff; }
#hint-btn { background: #fefcbf; color: #975a16; border: 1px solid #f6e05e; }
#answer-btn { background: #e2e8f0; color: #2d3748; border: 1px solid #cbd5e0; }

/* 通过提示/看答案填出的空：橙色标识，区别于自己答对的绿色 */
.blank.hinted {
  border-bottom-color: #ed8936;
  color: #c05621;
  background: #fffaf0;
}

/* ===== 结果提示 ===== */
.result-message {
  text-align: center;
  font-size: 20px;
  margin-top: 20px;
  min-height: 32px;
  font-weight: bold;
}

.result-message.ok { color: #276749; }
.result-message.err { color: #c53030; }

/* ===== 统计与错题本 ===== */
.stats-bar {
  display: flex;
  justify-content: space-around;
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  font-size: 15px;
}

.wrong-book {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.wrong-book h3 { color: #c53030; margin-bottom: 12px; }
.wrong-book li { padding: 8px 4px; border-bottom: 1px dashed #e2e8f0; list-style: none; font-size: 15px; }
.wrong-book li:hover { background: #fff5f5; }

#category-select {
  padding: 6px 10px;
  font-size: 15px;
  border: 2px solid #cbd5e0;
  border-radius: 6px;
  background: #fff;
}

#wrongbook-btn {
  padding: 6px 14px;
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #feb2b2;
  font-size: 15px;
}

#practice-wrong-btn {
  padding: 6px 14px;
  background: #ebf8ff;
  color: #2b6cb0;
  border: 1px solid #90cdf4;
  font-size: 15px;
}

#practice-wrong-btn.active-mode {
  background: #2b6cb0;
  color: #fff;
}

footer {
  text-align: center;
  color: #a0aec0;
  font-size: 13px;
  margin-top: 32px;
}

/* ===== 答对奖励动画 ===== */
#success-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 99;
  background: rgba(255, 255, 255, 0.65);
}

#success-overlay.show { opacity: 1; }

.check-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: #38a169;
  color: #fff;
  font-size: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(56, 161, 105, 0.45);
  animation: checkPop 0.5s;
}

@keyframes checkPop {
  0% { transform: scale(0.2); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.reward-text {
  margin-top: 18px;
  font-size: 30px;
  font-weight: bold;
  color: #276749;
  animation: rewardUp 0.5s;
}

@keyframes rewardUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ===== 触屏适配（iPad/Android） ===== */
@media (max-width: 768px) {
  #chinese-sentence { font-size: 26px; }
  .blank { min-width: 90px; font-size: 22px; }
  .key { height: 48px; font-size: 18px; }
}
