:root {
  --bg: #f0f7ff;
  --card: #ffffff;
  --ink: #2c3e50;
  --muted: #7a8ba0;
  --primary: #ff6b6b;
  --primary-dark: #ee5a5a;
  --blue: #4ecdc4;
  --yellow: #ffd166;
  --green: #06d6a0;
  --shadow: 0 10px 30px rgba(80, 120, 180, 0.15);
  --radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Nunito', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #e8f4ff 0%, #f6f0ff 50%, #eafaf5 100%);
  color: var(--ink);
  min-height: 100vh; overflow-x: hidden;
}
button, input { font-family: inherit; }
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.bubble { position: absolute; border-radius: 50%; opacity: 0.35; }
.b1 { width: 220px; height: 220px; background: #ffd6d6; top: -60px; left: -60px; }
.b2 { width: 160px; height: 160px; background: #c9f0e8; top: 40%; right: -50px; }
.b3 { width: 120px; height: 120px; background: #dcd4ff; bottom: 60px; left: 12%; }
.b4 { width: 180px; height: 180px; background: #fff0c4; bottom: -60px; right: 20%; }

.screen { display: none; animation: fadeIn 0.35s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== 登录页 ===== */
.login-screen { min-height: 100vh; display: none; align-items: center; justify-content: center; padding: 20px; position: relative; z-index: 2; }
.login-screen.active { display: flex; }
.login-card {
  background: var(--card); border-radius: 28px; padding: 42px 38px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 50px rgba(80,120,180,0.2); text-align: center;
}
.login-logo {
  font-size: 46px; width: 88px; height: 88px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff9a9e, #fecfef); border-radius: 24px;
  box-shadow: 0 8px 20px rgba(255,107,107,0.3);
}
.login-card h1 { font-size: 27px; font-weight: 900; color: var(--primary-dark); }
.login-sub { color: var(--muted); font-weight: 700; font-size: 14px; margin-top: 8px; margin-bottom: 28px; }
.field-label { display: block; text-align: left; font-weight: 900; font-size: 14px; margin-bottom: 8px; color: var(--ink); }
.nick-input {
  width: 100%; padding: 14px 16px; font-size: 17px; font-weight: 700;
  border: 3px solid #e3e9f2; border-radius: 14px; outline: none; margin-bottom: 22px;
}
.nick-input:focus { border-color: var(--blue); }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.avatar-opt {
  width: 46px; height: 46px; border-radius: 14px; border: 3px solid #e3e9f2;
  background: #f7f9fc; font-size: 24px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: transform 0.15s, border-color 0.15s;
}
.avatar-opt:hover { transform: translateY(-3px); }
.avatar-opt.selected { border-color: var(--primary); background: #fff0f0; transform: scale(1.05); }
.login-btn {
  width: 100%; padding: 16px; background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: #fff; font-size: 19px; font-weight: 900; border: none; border-radius: 16px;
  cursor: pointer; box-shadow: 0 8px 20px rgba(255,107,107,0.35); transition: transform 0.15s;
}
.login-btn:hover { transform: translateY(-2px); }
.login-tip { font-size: 12px; color: var(--muted); margin-top: 16px; font-weight: 600; line-height: 1.5; }

/* ===== 顶栏 ===== */
.topbar {
  position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: rgba(255,255,255,0.88); backdrop-filter: blur(12px);
  border-bottom: 3px solid #ffe3e3; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand-logo {
  font-size: 30px; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff9a9e, #fecfef); border-radius: 15px;
  box-shadow: 0 4px 12px rgba(255,107,107,0.3);
}
.brand h1 { font-size: 19px; font-weight: 900; color: var(--primary-dark); }
.brand p { font-size: 11px; color: var(--muted); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip { padding: 7px 13px; border-radius: 999px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.chip-star { background: #fff7df; border: 2px solid #ffe08a; color: #b8790b; }
.chip-fire { background: #fff0e8; border: 2px solid #ffd0b0; color: #d9660b; }
.user-chip {
  display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 5px 12px 5px 5px;
  border-radius: 999px; background: #eef4ff; border: 2px solid #dbe6f7;
}
.user-avatar { font-size: 20px; }
.user-nick { font-weight: 900; font-size: 14px; color: var(--ink); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 40px; height: 40px; border: none; border-radius: 13px; background: #eef4ff;
  font-size: 18px; cursor: pointer; transition: transform 0.15s, background 0.15s;
}
.icon-btn:hover { transform: translateY(-2px); background: #e0ebff; }

#app { position: relative; z-index: 2; max-width: 960px; margin: 0 auto; padding: 26px 20px 60px; }

/* ===== 首页 ===== */
.greeting {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(120deg, #ff9a9e 0%, #fecfef 100%);
  border-radius: var(--radius); padding: 22px 30px; margin-bottom: 24px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.greeting::after { content: ''; position: absolute; width: 180px; height: 180px; background: rgba(255,255,255,0.25); border-radius: 50%; right: -30px; top: -60px; }
.greeting h2 { font-size: 24px; font-weight: 900; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.greeting p { color: #fff; font-weight: 700; margin-top: 4px; font-size: 14px; opacity: 0.95; }
.greet-mascot { font-size: 68px; z-index: 1; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-12px) rotate(5deg); } }

.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 18px; font-weight: 900; margin: 22px 0 12px; color: var(--ink); }
.section-title span { font-size: 12px; color: var(--muted); font-weight: 700; margin-left: 6px; }
.date-tag { font-size: 13px; font-weight: 800; color: var(--muted); background: #fff; padding: 6px 12px; border-radius: 999px; }

.plan-card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border: 2px solid #ffe8cc; }
.plan-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.plan-day { font-size: 22px; font-weight: 900; color: var(--primary-dark); }
.plan-desc { font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 3px; }
.plan-progress-text { font-size: 15px; font-weight: 800; color: var(--muted); }
.plan-progress-text strong { font-size: 24px; color: var(--green); }
.plan-bar { height: 14px; background: #eef2f7; border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.plan-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffd166, #06d6a0); border-radius: 999px; transition: width 0.4s ease; }
.today-words { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.today-word {
  background: #f7f9fc; border: 2px solid #e8edf4; border-radius: 14px; padding: 12px 6px;
  text-align: center; transition: all 0.2s;
}
.today-word .tw-emoji { font-size: 30px; display: block; }
.today-word .tw-en { font-size: 13px; font-weight: 900; color: var(--ink); display: block; margin-top: 4px; word-break: break-word; }
.today-word .tw-zh { font-size: 11px; color: var(--muted); font-weight: 700; display: block; margin-top: 2px; }
.today-word.done { background: #e8faf3; border-color: var(--green); }
.today-word.done .tw-check { position: absolute; }
.today-word .badge-done { font-size: 10px; color: #05855f; font-weight: 900; display: block; margin-top: 4px; }
.plan-actions { margin-top: 18px; }
.plan-finish { text-align: center; color: #05855f; font-weight: 900; font-size: 15px; margin-top: 10px; }

.start-btn {
  display: block; width: 100%; padding: 15px; background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: #fff; font-size: 18px; font-weight: 900; border: none; border-radius: 15px;
  cursor: pointer; box-shadow: 0 8px 20px rgba(255,107,107,0.35); transition: transform 0.15s;
}
.start-btn:hover { transform: translateY(-3px); }
.start-btn:disabled { background: #c9d3e0; box-shadow: none; cursor: not-allowed; transform: none; }
.start-btn span { margin-left: 8px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.stat-mini { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 14px 18px; box-shadow: var(--shadow); }
.stat-mini > span { font-size: 30px; }
.stat-mini strong { font-size: 22px; font-weight: 900; display: block; line-height: 1; }
.stat-mini small { font-size: 11px; color: var(--muted); font-weight: 700; }

.grade-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.grade-card {
  background: var(--card); border-radius: 18px; padding: 16px 6px; text-align: center; cursor: pointer;
  border: 3px solid transparent; box-shadow: var(--shadow); transition: transform 0.18s, border-color 0.18s;
  position: relative;
}
.grade-card:hover { transform: translateY(-5px); }
.grade-card.selected { border-color: var(--grade-color); transform: translateY(-5px); }
.grade-card.selected::after { content: '✓'; position: absolute; top: 5px; right: 8px; color: var(--grade-color); font-weight: 900; font-size: 17px; }
.grade-emoji { font-size: 36px; display: block; margin-bottom: 4px; }
.grade-name { font-weight: 900; font-size: 15px; color: var(--grade-color); }
.grade-count { font-size: 10px; color: var(--muted); margin-top: 3px; font-weight: 700; }

.mode-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mode-card {
  background: var(--card); border: 3px solid transparent; border-radius: 18px; padding: 16px 8px;
  text-align: center; cursor: pointer; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform 0.18s, border-color 0.18s;
}
.mode-card:hover { transform: translateY(-4px); }
.mode-card.selected { border-color: var(--blue); background: #f0fdfb; }
.mode-card.selected::after { content: '✓ 已选'; color: var(--blue); font-size: 11px; font-weight: 900; }
.mode-emoji { font-size: 32px; }
.mode-card strong { font-size: 14px; font-weight: 900; }
.mode-card small { font-size: 10px; color: var(--muted); font-weight: 600; }
.home-actions { display: flex; gap: 12px; margin-top: 18px; }
.home-actions .btn-secondary { flex: 1; }

/* ===== 练习页 ===== */
.quiz-header { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.back-btn {
  background: #fff; border: 2px solid #e3e9f2; border-radius: 12px; padding: 10px 15px;
  font-weight: 800; font-size: 13px; cursor: pointer; color: var(--ink); white-space: nowrap;
}
.back-btn:hover { background: #f3f6fb; }
.progress-wrap { flex: 1; }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.progress-bar { height: 12px; background: #e3e9f2; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #4ecdc4, #06d6a0); border-radius: 999px; transition: width 0.3s ease; }
.score-chip { background: #fff7df; border: 2px solid #ffe08a; padding: 8px 13px; border-radius: 999px; font-weight: 900; color: #b8790b; white-space: nowrap; }
.quiz-area { background: var(--card); border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow); min-height: 440px; }
.question-count { text-align: center; font-size: 13px; color: var(--muted); font-weight: 800; margin-bottom: 6px; }
.question-prompt { text-align: center; font-size: 17px; font-weight: 800; color: var(--ink); margin-bottom: 20px; }
.word-display { text-align: center; font-size: 50px; font-weight: 900; color: var(--primary-dark); margin: 8px 0 22px; word-break: break-word; line-height: 1.2; }
.word-emoji { font-size: 70px; display: block; text-align: center; margin: 8px 0; }
.speaker-btn {
  display: block; margin: 0 auto 22px; width: 72px; height: 72px; border-radius: 50%;
  border: 4px solid #b8e6df; background: #eafaf7; font-size: 34px; cursor: pointer; transition: transform 0.15s;
}
.speaker-btn:hover { transform: scale(1.08); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.option-btn {
  background: #f7f9fc; border: 3px solid #e3e9f2; border-radius: 15px; padding: 16px;
  font-size: 17px; font-weight: 800; cursor: pointer; color: var(--ink); text-align: center; transition: all 0.15s;
}
.option-btn:hover:not(:disabled) { border-color: var(--blue); background: #f0fdfb; transform: translateY(-2px); }
.option-btn.correct { background: #d9f9ec; border-color: var(--green); color: #05855f; }
.option-btn.wrong { background: #ffe3e3; border-color: var(--primary); color: #c92a2a; }
.option-btn:disabled { cursor: default; }

.spell-input-wrap { text-align: center; }
.spell-input {
  width: 100%; max-width: 420px; padding: 15px 18px; font-size: 24px; font-weight: 800; text-align: center;
  border: 3px solid #e3e9f2; border-radius: 15px; outline: none; letter-spacing: 2px;
}
.spell-input:focus { border-color: var(--blue); }
.spell-submit { margin-top: 15px; background: linear-gradient(135deg, #4ecdc4, #06d6a0); color: #fff; border: none; border-radius: 13px; padding: 13px 36px; font-size: 17px; font-weight: 900; cursor: pointer; }
.spell-feedback { font-size: 17px; font-weight: 900; margin-top: 12px; min-height: 24px; }
.spell-feedback.ok { color: #05855f; }
.spell-feedback.no { color: #c92a2a; }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-item { padding: 11px 12px; border: 3px solid #e3e9f2; border-radius: 11px; background: #f7f9fc; font-weight: 800; font-size: 15px; cursor: pointer; transition: all 0.15s; text-align: center; }
.match-item:hover:not(.matched):not(.selected) { border-color: var(--yellow); transform: translateY(-2px); }
.match-item.selected { border-color: var(--blue); background: #eafaf7; }
.match-item.matched { border-color: var(--green); background: #d9f9ec; color: #05855f; cursor: default; opacity: 0.7; }
.match-item.wrong-flash { border-color: var(--primary); background: #ffe3e3; }
.feedback { text-align: center; margin-top: 18px; font-size: 17px; font-weight: 900; min-height: 26px; }
.feedback.ok { color: #05855f; }
.feedback.no { color: #c92a2a; }

/* ===== 结果页 ===== */
.result-card { background: var(--card); border-radius: var(--radius); padding: 42px 30px; text-align: center; box-shadow: var(--shadow); max-width: 560px; margin: 30px auto; }
.result-emoji { font-size: 84px; animation: pop 0.6s cubic-bezier(0.175,0.885,0.32,1.275); }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.result-card h2 { font-size: 28px; font-weight: 900; color: var(--primary-dark); margin: 8px 0; }
.result-msg { color: var(--muted); font-weight: 700; font-size: 15px; }
.result-stats { display: flex; justify-content: center; gap: 36px; margin: 26px 0; }
.result-stats div { display: flex; flex-direction: column; }
.result-stats strong { font-size: 32px; font-weight: 900; color: var(--blue); }
.result-stats span { font-size: 12px; color: var(--muted); font-weight: 700; }
.plan-update { background: #eefaf5; border: 2px solid #b8ebd8; border-radius: 14px; padding: 12px; margin-bottom: 20px; font-weight: 800; font-size: 14px; color: #05855f; }
.result-actions { display: flex; gap: 12px; justify-content: center; }
.btn-primary, .btn-secondary { padding: 13px 24px; border: none; border-radius: 13px; font-weight: 900; font-size: 15px; cursor: pointer; transition: transform 0.15s; }
.btn-primary { background: linear-gradient(135deg, #ff6b6b, #ff8e53); color: #fff; }
.btn-secondary { background: #eef4ff; color: var(--ink); border: 2px solid #dbe6f7; }
.btn-secondary.danger { background: #fff0f0; color: #c92a2a; border-color: #ffd6d6; }
.btn-primary:hover, .btn-secondary:hover { transform: translateY(-2px); }

/* ===== 统计页 ===== */
.stats-card { background: var(--card); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.stats-card h2 { font-size: 24px; font-weight: 900; margin: 16px 0; text-align: center; }
.stats-card h3 { font-size: 16px; font-weight: 900; margin: 22px 0 12px; }
.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-box { background: #f7f9fc; border-radius: 15px; padding: 18px; text-align: center; }
.stat-box strong { display: block; font-size: 30px; font-weight: 900; color: var(--primary); }
.stat-box span { font-size: 12px; color: var(--muted); font-weight: 700; }
.week-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-cell { background: #f7f9fc; border: 2px solid #e8edf4; border-radius: 12px; padding: 12px 4px; text-align: center; }
.day-cell .dc-week { font-size: 11px; color: var(--muted); font-weight: 700; }
.day-cell .dc-icon { font-size: 24px; display: block; margin: 4px 0; }
.day-cell .dc-date { font-size: 11px; font-weight: 800; }
.day-cell.checked { background: #e8faf3; border-color: var(--green); }
.day-cell.today { box-shadow: 0 0 0 3px #ffd166; }
.grade-progress-list { display: flex; flex-direction: column; gap: 10px; }
.gp-row { display: flex; align-items: center; gap: 12px; }
.gp-label { width: 74px; font-weight: 800; font-size: 13px; }
.gp-bar { flex: 1; height: 13px; background: #e3e9f2; border-radius: 999px; overflow: hidden; }
.gp-fill { height: 100%; background: linear-gradient(90deg, #a8e6cf, #06d6a0); border-radius: 999px; transition: width 0.4s; }
.gp-num { width: 62px; text-align: right; font-size: 12px; font-weight: 800; color: var(--muted); }
.settings-row { display: flex; gap: 12px; }

/* ===== 弹窗 / Toast ===== */
.modal { position: fixed; inset: 0; background: rgba(44,62,80,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: #fff; border-radius: 22px; padding: 26px; max-width: 340px; width: 100%; text-align: center; }
.modal-card h3 { font-weight: 900; margin-bottom: 16px; }
.modal-card .avatar-picker { justify-content: center; }
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: #2c3e50; color: #fff; padding: 13px 26px; border-radius: 999px; font-weight: 800; font-size: 14px; z-index: 300; opacity: 0; transition: all 0.3s; box-shadow: 0 8px 24px rgba(0,0,0,0.2); text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .brand h1 { font-size: 15px; }
  .brand p { font-size: 9px; }
  .brand-logo { width: 40px; height: 40px; font-size: 24px; }
  .chip { font-size: 12px; padding: 6px 10px; }
  .user-nick { max-width: 60px; font-size: 12px; }
  #app { padding: 18px 14px 50px; }
  .greeting { padding: 18px; }
  .greeting h2 { font-size: 19px; }
  .greet-mascot { font-size: 52px; }
  .today-words { grid-template-columns: repeat(3, 1fr); }
  .grade-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .stat-mini { padding: 10px; gap: 6px; flex-direction: column; text-align: center; }
  .stat-mini > span { font-size: 24px; }
  .stat-mini strong { font-size: 18px; }
  .quiz-area { padding: 22px 16px; }
  .word-display { font-size: 38px; }
  .options { grid-template-columns: 1fr; }
  .match-item { font-size: 13px; padding: 10px 6px; }
  .result-stats { gap: 18px; }
  .result-stats strong { font-size: 25px; }
  .stats-summary { grid-template-columns: 1fr; }
  .week-calendar { gap: 4px; }
  .day-cell { padding: 8px 2px; }
  .settings-row, .home-actions { flex-direction: column; }
  .login-card { padding: 30px 22px; }
}
