/* 单词大冒险 — 游戏化主题 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg1: #4A5CFF;
  --bg2: #7B5CFF;
  --card: #FFFFFF;
  --ink: #2B2D42;
  --sub: #7A7E9A;
  --accent: #FFC93C;
  --ok: #3DDC97;
  --bad: #FF6B6B;
  --fire1: #FF8A3C;
  --fire2: #FF5E62;
  --radius: 20px;
  --shadow: 0 8px 24px rgba(40, 40, 100, .16);
}

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; display: flex; flex-direction: column; }
#main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 88px;
}
#sidebar { display: none; }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around; align-items: center;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,.06);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
}
#tabbar.hidden { display: none; }
#tabbar a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--sub); font-size: 11px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#tabbar a .ic { font-size: 20px; line-height: 1; }
#tabbar a.active { color: var(--bg1); font-weight: 700; }

@media (min-width: 768px) {
  #app { flex-direction: row; }
  #sidebar {
    display: flex; flex-direction: column; gap: 6px;
    width: 220px; padding: 24px 16px; color: #fff;
  }
  #sidebar .logo { font-size: 20px; font-weight: 800; margin-bottom: 18px; letter-spacing: 1px; }
  #sidebar a {
    color: rgba(255,255,255,.85); text-decoration: none;
    padding: 12px 14px; border-radius: 14px; font-size: 15px;
    display: flex; align-items: center; gap: 10px;
  }
  #sidebar a.active, #sidebar a:hover { background: rgba(255,255,255,.18); color: #fff; }
  #main { padding: 32px 24px; }
  #tabbar { display: none; }
}

/* ---------- 通用卡片 / 按钮 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card h2 { font-size: 18px; margin-bottom: 12px; }
.muted { color: var(--sub); font-size: 13px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.grow { flex: 1; }

.btn {
  border: 0; border-radius: 16px; padding: 14px 22px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, var(--fire1), var(--fire2));
  color: #fff; box-shadow: 0 6px 16px rgba(255, 94, 98, .35);
  transition: transform .08s ease;
  min-height: 48px;
}
.btn:active { transform: scale(.96); }
.btn.secondary { background: #EEF0FF; color: var(--bg1); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--sub); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: 13px; min-height: 36px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, select.input, textarea.input {
  width: 100%; border: 2px solid #E6E8F5; border-radius: 14px;
  padding: 12px 14px; font-size: 16px; outline: none; background: #FAFBFF;
  min-height: 48px;
}
.input:focus { border-color: var(--bg1); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 6px; }

/* ---------- 首页 ---------- */
.hero { color: #fff; margin-bottom: 18px; }
.hero h1 { font-size: 24px; font-weight: 800; }
.hero .streak {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.18); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; margin-top: 8px;
}
.task-ring { display: flex; align-items: center; gap: 16px; }
.ring-wrap { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-wrap .ring-label {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 800; font-size: 18px;
}
.ring-wrap .ring-label small { font-size: 10px; font-weight: 600; color: var(--sub); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card {
  border-radius: 18px; padding: 18px 16px; color: #fff; cursor: pointer;
  min-height: 110px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow); transition: transform .1s;
}
.mode-card:active { transform: scale(.97); }
.mode-card .ic { font-size: 30px; }
.mode-card .t { font-size: 16px; font-weight: 800; }
.mode-card .d { font-size: 12px; opacity: .9; }
.m-fill { background: linear-gradient(135deg, #FF8A3C, #FF5E62); }
.m-listen { background: linear-gradient(135deg, #2FB7FF, #4A5CFF); }
.m-translate { background: linear-gradient(135deg, #3DDC97, #2BB3A3); }
.m-wrong { background: linear-gradient(135deg, #B06BFF, #7B5CFF); }

/* ---------- 答题页 ---------- */
.game-top { color: #fff; margin-bottom: 14px; }
.game-top .muted, .result-hero .muted { color: rgba(255, 255, 255, .85); }
.game-top .bar {
  height: 10px; background: rgba(255,255,255,.25); border-radius: 999px; overflow: hidden;
  margin-top: 10px;
}
.game-top .bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.combo {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, var(--fire1), var(--fire2));
  color: #fff; font-weight: 800; border-radius: 999px; padding: 6px 12px;
}
.combo.hot { animation: pulse .6s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

.q-prompt { text-align: center; padding: 18px 8px 8px; }
.q-word { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.q-fill { font-size: 36px; font-weight: 800; letter-spacing: 6px; font-family: ui-monospace, monospace; }
.q-sub { color: var(--sub); margin-top: 6px; min-height: 20px; }
.speaker {
  width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #2FB7FF, #4A5CFF); color: #fff; font-size: 42px;
  box-shadow: 0 10px 24px rgba(74, 92, 255, .4); margin: 8px auto;
}
.speaker:active { transform: scale(.94); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
@media (min-width: 768px) { .options { grid-template-columns: repeat(4, 1fr); } }
.opt {
  border: 2px solid #E6E8F5; background: var(--card); border-radius: 16px;
  padding: 16px 12px; font-size: 17px; font-weight: 700; cursor: pointer;
  min-height: 56px; transition: all .15s; word-break: break-word;
}
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--ok); background: #E7FBF2; color: #12865A; }
.opt.wrong { border-color: var(--bad); background: #FFECEC; color: #C33; animation: shake .3s; }
.opt.dim { opacity: .45; }
@keyframes shake {
  25% { transform: translateX(-5px); } 75% { transform: translateX(5px); }
}

.feedback-card {
  background: #FFF8E6; border-radius: 16px; padding: 14px; margin-top: 14px;
  border: 1px solid #FFE3A8;
}
.feedback-card .w { font-size: 20px; font-weight: 800; }
.feedback-card .m { color: #8A6D1F; margin-top: 4px; }

/* ---------- 结算 ---------- */
.result-hero { text-align: center; color: #fff; padding: 12px 0 20px; }
.result-hero .big { font-size: 52px; font-weight: 800; }
.result-hero .sub { opacity: .9; margin-top: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box {
  background: var(--card); border-radius: 16px; padding: 14px 8px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-box .n { font-size: 22px; font-weight: 800; }
.stat-box .l { font-size: 12px; color: var(--sub); margin-top: 2px; }

/* ---------- 列表 / 表格 ---------- */
.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid #F0F1F8;
}
.list-item:last-child { border-bottom: 0; }
.word-main { font-weight: 700; font-size: 16px; }
.badge {
  display: inline-block; border-radius: 999px; padding: 2px 10px;
  font-size: 11px; background: #EEF0FF; color: var(--bg1); margin-left: 6px;
}
.badge.warn { background: #FFECEC; color: var(--bad); }
.badge.ok { background: #E7FBF2; color: #12865A; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 8px; border-bottom: 1px solid #F0F1F8; text-align: left; }
table.data th { color: var(--sub); font-weight: 600; font-size: 12px; }

/* ---------- 成就墙 ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-card {
  border-radius: 16px; padding: 16px 12px; text-align: center;
  background: var(--card); box-shadow: var(--shadow);
}
.badge-card.locked { opacity: .45; filter: grayscale(1); }
.badge-card .ic { font-size: 34px; }
.badge-card .n { font-weight: 800; margin-top: 6px; }
.badge-card .d { font-size: 11px; color: var(--sub); margin-top: 4px; }

/* ---------- 柱状图 ---------- */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 8px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .col i {
  width: 70%; background: linear-gradient(180deg, var(--bg1), var(--bg2));
  border-radius: 6px 6px 0 0; min-height: 4px;
}
.chart .col span { font-size: 10px; color: var(--sub); }
.chart .col.done i { background: linear-gradient(180deg, var(--fire1), var(--fire2)); }

/* ---------- toast / 彩带 ---------- */
#toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast-item {
  background: rgba(30, 32, 60, .92); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: 14px; box-shadow: var(--shadow);
  animation: drop .25s ease;
}
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

.confetti-piece {
  position: fixed; width: 10px; height: 10px; top: -12px; z-index: 99;
  border-radius: 2px; pointer-events: none; animation: fall 1.4s linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .2; }
}

/* ---------- 表单页 ---------- */
.login-page {
  min-height: 80vh; display: flex; flex-direction: column; justify-content: center;
}
.login-page .card { max-width: 420px; width: 100%; margin: 0 auto; }
.login-logo { text-align: center; color: #fff; margin-bottom: 20px; }
.login-logo .t { font-size: 30px; font-weight: 800; letter-spacing: 2px; }
.login-logo .s { opacity: .85; margin-top: 6px; font-size: 14px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: 999px; background: #EEF0FF; color: var(--sub);
  cursor: pointer; font-size: 14px; border: 0;
}
.tab.active { background: var(--bg1); color: #fff; font-weight: 700; }

.empty { text-align: center; color: var(--sub); padding: 32px 12px; }
.empty .ic { font-size: 44px; }

.goal-banner {
  background: rgba(255,255,255,.16); color: #fff; border-radius: 16px;
  padding: 12px 16px; margin-bottom: 16px; font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
