/* ========== 全局变量 ========== */
:root {
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --accent: #FF9800;
  --danger: #F44336;
  --bg: #F5F5F5;
  --card: #FFFFFF;
  --text: #333333;
  --text-secondary: #757575;
  --border: #E0E0E0;
  --gold: #FFD700;
  --silver: #C0C0C0;
  --bronze: #CD7F32;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 12px;
}

/* 暗色模式 */
body.dark {
  --primary: #66BB6A;
  --primary-dark: #43A047;
  --bg: #1a1a2e;
  --card: #16213e;
  --text: #e0e0e0;
  --text-secondary: #999;
  --border: #2a2a4a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark .header { background: linear-gradient(135deg, #1b5e20, #0d3310); }
body.dark .nav { background: var(--card); }
body.dark .option-btn { background: var(--card); color: var(--text); }
body.dark .option-btn:hover { background: #1a3a1a; }
body.dark .flashcard .face { background: var(--card); }
body.dark .flashcard .back { background: #1a3a1a; }
body.dark .text-dialogue { background: #12122a; }
body.dark .vocab-table th { background: #1b5e20; }
body.dark .vocab-table tr:hover td { background: #1a1a3a; }
body.dark input, body.dark select { background: #12122a; color: #e0e0e0; border-color: var(--border); }
body.dark .tab-btns button { background: #12122a; }
body.dark details { color: var(--text); }
body.dark summary { color: var(--text); }

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

body {
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ========== 头部 ========== */
.header {
  background: linear-gradient(135deg, var(--primary), #2E7D32);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.header .logo {
  font-size: 18px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-bar .level-badge {
  background: rgba(255,255,255,0.2);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
}

.user-bar .points {
  font-weight: bold;
}

/* 每日剩余 */
.daily-info {
  background: rgba(255,255,255,0.2);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}

/* 暗色切换 */
.btn-dark-toggle {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 50%;
  transition: 0.2s;
}
.btn-dark-toggle:hover { background: rgba(255,255,255,0.2); }

/* 签到卡片 */
.checkin-card { background: linear-gradient(135deg, #FFF8E1, #FFECB3); }
body.dark .checkin-card { background: linear-gradient(135deg, #2a2a1a, #3a3a1a); }

/* 成就网格 */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.badge-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: 0.2s;
}
.badge-item.locked {
  opacity: 0.35;
  filter: grayscale(1);
}
.badge-item .badge-icon { font-size: 40px; margin-bottom: 8px; }
.badge-item .badge-name { font-weight: bold; font-size: 14px; }
.badge-item .badge-desc { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.badge-item .badge-date { font-size: 10px; color: var(--accent); margin-top: 4px; }

/* 复仇模式卡片 */
.game-mode-card[data-mode="revenge"] { border-color: #FF1744; }
.game-mode-card[data-mode="revenge"]:hover { border-color: #D50000; box-shadow: 0 0 12px rgba(255,23,68,0.3); }

/* ========== 导航 ========== */
.nav {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 99;
  overflow-x: auto;
}

.nav button {
  flex: 1;
  min-width: 64px;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav button .nav-icon { font-size: 20px; }

.nav button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: bold;
}

/* ========== 主内容区 ========== */
.page {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  display: none;
}

.page.active { display: block; }

/* ========== 卡片 ========== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--primary-dark);
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-large {
  padding: 14px 28px;
  font-size: 17px;
  border-radius: 12px;
}

.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ========== 登录页 ========== */
.login-page {
  max-width: 400px;
  margin: 60px auto;
  padding: 24px;
}

.login-page .logo-area {
  text-align: center;
  margin-bottom: 32px;
}

.login-page .logo-area .icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.school-badge {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 4px 16px rgba(21, 101, 192, 0.25);
  background: #f0f4ff;
}

.login-page .logo-area h1 {
  font-size: 24px;
  color: var(--primary-dark);
}

.login-page .logo-area p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.tab-btns {
  display: flex;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--primary);
}

.tab-btns button {
  flex: 1;
  padding: 10px;
  border: none;
  background: white;
  cursor: pointer;
  font-size: 15px;
  transition: 0.2s;
}

.tab-btns button.active {
  background: var(--primary);
  color: white;
}

/* ========== 游戏模式选择 ========== */
.game-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.game-mode-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.game-mode-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.game-mode-card .mode-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.game-mode-card .mode-name {
  font-weight: bold;
  font-size: 16px;
}

.game-mode-card .mode-desc {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 4px;
}

/* ========== 游戏界面 ========== */
.game-container {
  max-width: 600px;
  margin: 0 auto;
}

.game-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.game-progress .streak {
  color: var(--accent);
  font-weight: bold;
}

.game-progress .streak.fire { color: var(--danger); }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.question-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.question-card .word-en {
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 12px;
  color: var(--primary-dark);
}

.question-card .word-phonetic {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 4px;
}

.question-card .word-homophonic {
  background: #FFF3E0;
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 16px;
  color: #E65100;
  margin: 8px 0;
}

.question-card .fill-sentence {
  font-size: 20px;
  line-height: 1.8;
  text-align: left;
  color: var(--text);
}

.fill-sentence .blank {
  display: inline-block;
  border-bottom: 3px solid var(--accent);
  min-width: 80px;
  margin: 0 4px;
  text-align: center;
  animation: blink 1s infinite;
}

@keyframes blink {
  50% { border-bottom-color: transparent; }
}

.fill-answer-input {
  width: 100%;
  padding: 14px;
  font-size: 20px;
  border: 3px solid var(--accent);
  border-radius: 8px;
  text-align: center;
  margin: 12px 0;
}

.fill-answer-input:focus { outline: none; }

/* 选择题选项 */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.option-btn {
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.option-btn:hover {
  border-color: var(--primary);
  background: #E8F5E9;
}

.option-btn.correct {
  border-color: var(--primary);
  background: #C8E6C9;
  animation: pulse 0.5s;
}

.option-btn.wrong {
  border-color: var(--danger);
  background: #FFCDD2;
}

.option-btn:disabled { cursor: default; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 闪卡 */
.flashcard-container {
  perspective: 1000px;
  margin-bottom: 16px;
}

.flashcard {
  width: 100%;
  min-height: 200px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  position: relative;
}

.flashcard.flipped { transform: rotateY(180deg); }

.flashcard .face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  background: var(--card);
}

.flashcard .back {
  transform: rotateY(180deg);
  background: #E8F5E9;
}

.flashcard .face .word {
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 12px;
  color: var(--primary-dark);
}

.flashcard .face .meaning {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 8px;
}

.flashcard .face .hint {
  color: #E65100;
  font-size: 16px;
}

.flashcard-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.flashcard-btns button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

.flashcard-btns .btn-known { background: #C8E6C9; color: #2E7D32; }
.flashcard-btns .btn-partial { background: #FFF9C4; color: #F57F17; }
.flashcard-btns .btn-unknown { background: #FFCDD2; color: #C62828; }

/* 游戏结束 */
.game-result {
  text-align: center;
  padding: 24px;
}

.game-result .result-score {
  font-size: 48px;
  font-weight: bold;
  color: var(--primary-dark);
}

.game-result .result-detail {
  color: var(--text-secondary);
  margin: 12px 0;
  line-height: 1.8;
}

.game-result .new-level {
  background: linear-gradient(135deg, #FFD700, #FFA000);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  display: inline-block;
  margin: 8px 0;
  font-weight: bold;
  animation: bounce 0.6s;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ========== 单元列表 ========== */
.unit-list { display: flex; flex-direction: column; gap: 10px; }

.unit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 4px solid var(--border);
}

.unit-item:hover { transform: translateX(4px); border-left-color: var(--primary); }

.unit-item.locked { opacity: 0.5; cursor: not-allowed; }

.unit-item.locked:hover { transform: none; border-left-color: var(--border); }

.unit-item .unit-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.unit-item .unit-info { flex: 1; }

.unit-item .unit-info .unit-title { font-weight: bold; }

.unit-item .unit-info .unit-sub {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}

.unit-item .unit-badge {
  font-size: 12px;
  background: #E8F5E9;
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 12px;
}

/* 课文详情 */
.text-dialogue {
  background: #F9F9F9;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
}

.text-dialogue .line {
  margin-bottom: 8px;
  line-height: 1.6;
}

.text-dialogue .line .speaker {
  font-weight: bold;
  color: var(--primary-dark);
  margin-right: 6px;
}

.text-reading {
  line-height: 1.9;
  font-size: 15px;
}

.text-reading p { margin-bottom: 12px; }

.text-cn {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
  padding-left: 8px;
  border-left: 3px solid var(--border);
}

/* ========== 排名 ========== */
.ranking-list { display: flex; flex-direction: column; gap: 8px; }

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ranking-item .rank-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  flex-shrink: 0;
}

.ranking-item .rank-num.r1 { background: var(--gold); color: white; }
.ranking-item .rank-num.r2 { background: var(--silver); color: white; }
.ranking-item .rank-num.r3 { background: var(--bronze); color: white; }
.ranking-item .rank-num.rn { background: #EEEEEE; color: var(--text-secondary); }

.ranking-item .rank-info { flex: 1; }

.ranking-item .rank-name { font-weight: bold; }

.ranking-item .rank-level { font-size: 12px; color: var(--text-secondary); }

.ranking-item .rank-points {
  font-weight: bold;
  color: var(--accent);
  font-size: 16px;
}

.ranking-item .rank-bio {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-style: italic;
}

.rank-bio {
  font-size: 12px;
  color: #666;
  font-style: italic;
}

.my-rank-card {
  background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.season-tag {
  font-size: 12px;
  background: var(--accent);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
}

/* ========== 单词表视图 ========== */
.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.vocab-table th {
  background: var(--primary);
  color: white;
  padding: 10px 8px;
  text-align: left;
  font-weight: 500;
  position: sticky;
  top: 0;
}

.vocab-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.vocab-table tr:hover td { background: #F5F5F5; }

.vocab-table .homo {
  color: #E65100;
  font-weight: 500;
}

.vocab-table .phonetic {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ========== 弹窗/Toast ========== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeInOut 2.5s forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ========== 规则卡片 ========== */
.rules-card details summary {
  user-select: none;
}
.rules-card details[open] summary {
  margin-bottom: 8px;
}

/* ========== 侧边彩蛋（宽屏 ≥ 1100px 可见） ========== */
.side-easter {
  position: fixed;
  top: 120px;
  width: 180px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  font-size: 13px;
  z-index: 50;
  opacity: 0.85;
  transition: opacity 0.3s;
}
.side-easter:hover { opacity: 1; }
.left-easter  { left:  max(8px, calc((100vw - 1100px) / 2 - 200px)); }
.right-easter { right: max(8px, calc((100vw - 1100px) / 2 - 200px)); }
.side-easter .easter-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--primary-dark);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 6px;
}
.gaming-word-item {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  line-height: 1.6;
}
.gaming-word-item:last-child { border-bottom: none; }
.gaming-word-item .gw-en {
  font-weight: bold;
  color: var(--text);
}
.gaming-word-item .gw-cn {
  color: var(--text-secondary);
  font-size: 12px;
}
.gaming-word-item .gw-homo {
  color: #E65100;
  font-size: 11px;
}
.quote-text {
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 13px;
}
.quote-author {
  text-align: right;
  margin-top: 6px;
  font-size: 11px;
  color: #999;
}

/* ========== 发音按钮 ========== */
.btn-speak {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 26px;
  text-align: center;
  transition: transform 0.15s;
  vertical-align: middle;
  margin-left: 4px;
}
.btn-speak:hover { transform: scale(1.15); background: #E3F2FD; }
.btn-speak:active { transform: scale(0.9); }

/* ========== 名人墙 ========== */
.halloffame-season {
  border-left: 4px solid #FFD700;
  transition: transform 0.2s;
}
.halloffame-season:hover {
  transform: translateX(4px);
}
.hof-item {
  transition: background 0.2s;
}
.hof-item:hover {
  filter: brightness(0.95);
}
.hof-top5 {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 1100px) {
  .side-easter { display: none; }
}
@media (max-width: 600px) {
  .game-modes { grid-template-columns: 1fr; }
  .options-grid { grid-template-columns: 1fr; }
  .page { padding: 12px; }
  .question-card .word-en { font-size: 28px; }
  .nav button { font-size: 12px; padding: 8px 4px; }
}
