/* ============================================================
   行测双人对战 · 主题样式
   ============================================================
   第八阶段 UI 要求逐条落实：

   1. 低饱和度、护眼配色
      浅色模式：米白 #F5F5F0 系（不用纯白 #FFF）
      深色模式：深灰蓝 #1E1E2E 系（不用纯黑 #000）
   2. 强调色用柔和蓝绿 / 暖橙，避免刺眼的高饱和红黄
   3. 系统默认无衬线字体，字号足够大，行距宽松
   4. 动效平滑，不闪烁、不突然跳变
   5. 答题反馈用柔和绿 / 红，不用荧光色
   6. 移动端适配：响应式、视口、触摸优化
   ============================================================ */

/* ---------------- 浅色模式（默认） ---------------- */
:root {
  /* 背景层：米白，不用纯白 */
  --bg:            #F5F5F0;
  --bg-elevated:   #FBFBF7;
  --bg-sunken:     #EDEDE6;
  --surface:       #FFFFFF;
  --surface-hover: #F7F7F2;

  /* 文字：不用纯黑，降低对比疲劳 */
  --text:          #2E2E38;
  --text-secondary:#5A5A68;
  --text-muted:    #8A8A96;
  --text-inverse:  #FBFBF7;

  /* 边框：柔和 */
  --border:        #E2E2D8;
  --border-strong: #CFCFC4;

  /* 强调色：柔和蓝绿（主）+ 暖橙（辅） */
  --accent:        #4A9D8E;
  --accent-soft:   #E3F0ED;
  --accent-hover:  #3F8B7E;
  --accent-warm:   #D99058;
  --accent-warm-soft: #F7EBE0;

  /* 答题反馈：柔和绿 / 红，绝不荧光 */
  --correct:       #5B9E6B;
  --correct-soft:  #E6F1E8;
  --wrong:         #C4736B;
  --wrong-soft:    #F6E8E6;
  --pending:       #B8A15E;
  --pending-soft:  #F5F0E0;

  /* 状态色（用于徽标） */
  --badge-frequent-bg: #F7EBE0;
  --badge-frequent-fg: #A96A3C;
  --badge-key-bg:      #F6E8E6;
  --badge-key-fg:      #A8524A;

  /* 阴影：轻柔 */
  --shadow-sm: 0 1px 2px rgba(46,46,56,.05);
  --shadow:    0 2px 8px rgba(46,46,56,.07);
  --shadow-lg: 0 8px 24px rgba(46,46,56,.10);

  /* 圆角与间距 */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* 字体：系统默认无衬线 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          "Noto Sans CJK SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* 字号：偏大，行距宽松 */
  --fs-xs: 13px;
  --fs-sm: 15px;
  --fs-base: 17px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 30px;
  --lh-tight: 1.4;
  --lh: 1.75;
  --lh-loose: 1.9;

  /* 动效：平滑，无闪烁 */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 380ms;

  /* 布局 */
  --maxw: 960px;
  --header-h: 60px;
}

/* ---------------- 深色模式 ---------------- */
/* 深灰蓝底，不用纯黑；对比度略降，夜间不刺眼 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #1E1E2E;
    --bg-elevated:   #252536;
    --bg-sunken:     #191926;
    --surface:       #282840;
    --surface-hover: #2F2F4A;

    --text:          #E4E4EC;
    --text-secondary:#B4B4C4;
    --text-muted:    #8A8A9E;
    --text-inverse:  #1E1E2E;

    --border:        #35354E;
    --border-strong: #45455F;

    --accent:        #6FBFAE;
    --accent-soft:   #23423C;
    --accent-hover:  #82CDBD;
    --accent-warm:   #E0A470;
    --accent-warm-soft: #3D2F22;

    --correct:       #7BB98A;
    --correct-soft:  #23392A;
    --wrong:         #D68E85;
    --wrong-soft:    #3B2624;
    --pending:       #CBB677;
    --pending-soft:  #38321F;

    --badge-frequent-bg: #3D2F22;
    --badge-frequent-fg: #E0A470;
    --badge-key-bg:      #3B2624;
    --badge-key-fg:      #D68E85;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
    --shadow:    0 2px 10px rgba(0,0,0,.30);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.40);
  }
}

/* 手动切换深色（覆盖系统设置） */
:root[data-theme="dark"] {
  --bg:            #1E1E2E;
  --bg-elevated:   #252536;
  --bg-sunken:     #191926;
  --surface:       #282840;
  --surface-hover: #2F2F4A;
  --text:          #E4E4EC;
  --text-secondary:#B4B4C4;
  --text-muted:    #8A8A9E;
  --text-inverse:  #1E1E2E;
  --border:        #35354E;
  --border-strong: #45455F;
  --accent:        #6FBFAE;
  --accent-soft:   #23423C;
  --accent-hover:  #82CDBD;
  --accent-warm:   #E0A470;
  --accent-warm-soft: #3D2F22;
  --correct:       #7BB98A;
  --correct-soft:  #23392A;
  --wrong:         #D68E85;
  --wrong-soft:    #3B2624;
  --pending:       #CBB677;
  --pending-soft:  #38321F;
  --badge-frequent-bg: #3D2F22;
  --badge-frequent-fg: #E0A470;
  --badge-key-bg:      #3B2624;
  --badge-key-fg:      #D68E85;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
  --shadow:    0 2px 10px rgba(0,0,0,.30);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.40);
}

/* ---------------- 基础重置 ---------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  /* 触摸优化：禁止双击缩放导致的延迟 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  /* 主题切换平滑过渡，不闪烁 */
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 尊重用户的"减少动效"偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

h1, h2, h3, h4 {
  margin: 0 0 .6em;
  line-height: var(--lh-tight);
  font-weight: 650;
  color: var(--text);
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--accent-hover); }

img {
  max-width: 100%;
  height: auto;
  /* 图片按需加载时，先占位再淡入，避免跳变 */
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
}
img.loaded { opacity: 1; }

/* 题目图片：白底卡片，方便看图表 */
.q-image {
  display: block;
  margin: 12px auto;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}
.q-image.inline {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 3px;
  vertical-align: middle;
  max-height: 2.6em;
}

/* ---------------- 布局 ---------------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header .brand {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
  white-space: nowrap;
}
.header .brand .dot { color: var(--accent); }
.header .spacer { flex: 1; }

.main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.footer {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  border-top: 1px solid var(--border);
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card.tight { padding: 14px; }
.card.center { text-align: center; }
.card-title {
  font-size: var(--fs-lg);
  font-weight: 650;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  min-height: 46px;          /* 触摸友好 */
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-inverse);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  /* 触摸优化 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur) var(--ease),
              opacity var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn.warm { background: var(--accent-warm); }
.btn.warm:hover:not(:disabled) { background: var(--accent-warm); filter: brightness(1.05); }

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  font-weight: 500;
}
.btn.ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn.small { padding: 8px 14px; min-height: 38px; font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 28px; min-height: 54px; font-size: var(--fs-lg); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 13px 15px;
  min-height: 48px;
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  /* 触摸优化 */
  touch-action: manipulation;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-muted); }

/* 房间码输入框：等宽、大字、字距宽 */
.input.code {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  letter-spacing: .3em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
}

.hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; line-height: 1.6; }

/* ---------------- 房间码展示 ---------------- */
.room-code {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: .22em;
  color: var(--accent);
  padding: 18px 10px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  text-align: center;
  user-select: all;            /* 方便分享时复制 */
  word-break: break-all;
  transition: background-color var(--dur) var(--ease);
}

/* ---------------- 徽标 / 标签 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.correct { background: var(--correct-soft); color: var(--correct); }
.badge.wrong { background: var(--wrong-soft); color: var(--wrong); }
.badge.pending { background: var(--pending-soft); color: var(--pending); }
.badge.frequent { background: var(--badge-frequent-bg); color: var(--badge-frequent-fg); }
.badge.key { background: var(--badge-key-bg); color: var(--badge-key-fg); }

.tag {
  display: inline-block;
  padding: 2px 9px;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ---------------- 题号导航（模块内自选题） ---------------- */
.qnav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.qnav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;             /* 触摸友好 */
  font-size: var(--fs-base);
  font-weight: 650;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.qnav-item:hover { background: var(--surface-hover); transform: translateY(-1px); }
.qnav-item:active { transform: translateY(0); }
.qnav-item.current {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.qnav-item.correct {
  border-color: var(--correct);
  background: var(--correct-soft);
  color: var(--correct);
}
.qnav-item.wrong {
  border-color: var(--wrong);
  background: var(--wrong-soft);
  color: var(--wrong);
}
/* 已答/未答/对错状态标记：小圆点 */
.qnav-item .mark {
  position: absolute;
  margin-top: -26px;
  margin-left: 26px;
  font-size: 11px;
}

/* ---------------- 题目 ---------------- */
.stem {
  font-size: var(--fs-lg);
  line-height: var(--lh-loose);   /* 行距宽松，长题干好读 */
  margin-bottom: 18px;
  color: var(--text);
}
.material {
  padding: 14px 16px;
  margin-bottom: 18px;
  background: var(--bg-sunken);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
  color: var(--text-secondary);
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  min-height: 52px;              /* 触摸友好 */
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.option:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.option:active { transform: scale(.995); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--correct); background: var(--correct-soft); }
.option.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.option.disabled { cursor: default; opacity: .92; }
.option .label {
  flex: 0 0 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: var(--bg-sunken);
  border-radius: 50%;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.option.selected .label { background: var(--accent); color: var(--text-inverse); }
.option.correct .label { background: var(--correct); color: #fff; }
.option.wrong .label { background: var(--wrong); color: #fff; }
.option .text { flex: 1; }

/* ---------------- 反馈 ---------------- */
.feedback {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: fadeSlide var(--dur-slow) var(--ease);
}
.feedback.correct { background: var(--correct-soft); color: var(--correct); }
.feedback.wrong { background: var(--wrong-soft); color: var(--wrong); }
.feedback.info { background: var(--accent-soft); color: var(--accent); }

/* 平滑出现，不闪烁 */
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------------- 计时器 ---------------- */
.timer {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  transition: color var(--dur) var(--ease);
}
.timer.urgent { color: var(--accent-warm); }

/* ---------------- 对手进度条 ---------------- */
.progress-bar {
  height: 8px;
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  /* 进度变化平滑，不跳变 */
  transition: width var(--dur-slow) var(--ease);
}
.progress-bar.warm > i { background: var(--accent-warm); }
.progress-bar.correct > i { background: var(--correct); }
.progress-bar.wrong > i { background: var(--wrong); }

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.player-row + .player-row { border-top: 1px solid var(--border); }
.player-row .who { flex: 0 0 auto; font-weight: 650; }
.player-row .stats { margin-left: auto; font-size: var(--fs-sm); color: var(--text-secondary); }
.player-row .bar-wrap { flex: 1; min-width: 90px; }

/* ---------------- 错题诊断：占比条形图 ---------------- */
.ratio-list { display: flex; flex-direction: column; gap: 12px; }
.ratio-item { }
.ratio-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.ratio-label { font-weight: 600; font-size: var(--fs-sm); }
.ratio-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.ratio-track {
  height: 12px;
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.ratio-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}
.ratio-fill.frequent { background: var(--accent-warm); }
.ratio-fill.key { background: var(--wrong); }

/* ---------------- 结果页 ---------------- */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.score-cell {
  padding: 14px 10px;
  text-align: center;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  transition: background-color var(--dur) var(--ease);
}
.score-cell .num {
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.score-cell .lbl { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 3px; }
.score-cell.correct .num { color: var(--correct); }
.score-cell.wrong .num { color: var(--wrong); }
.score-cell.accent .num { color: var(--accent); }

.winner-banner {
  padding: 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  animation: fadeSlide var(--dur-slow) var(--ease);
}
.winner-banner .title { font-size: var(--fs-xl); font-weight: 750; color: var(--accent); }
.winner-banner .sub { color: var(--text-secondary); margin-top: 6px; font-size: var(--fs-sm); }

/* ---------------- 解析卡片 ---------------- */
.analysis {
  padding: 16px;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  line-height: var(--lh-loose);
  font-size: var(--fs-base);
  animation: fadeIn var(--dur-slow) var(--ease);
}
.analysis h4 { font-size: var(--fs-base); color: var(--accent); margin: 14px 0 6px; }
.analysis h4:first-child { margin-top: 0; }
.analysis p { margin: 0 0 .8em; }
.analysis code {
  font-family: var(--font-mono);
  font-size: .92em;
  padding: 1px 5px;
  background: var(--bg-elevated);
  border-radius: 4px;
}
.analysis strong { color: var(--text); font-weight: 700; }

.feedback-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.btn.learned { background: var(--correct); }
.btn.not-understood { background: var(--accent-warm); }

/* ---------------- 加载 / 提示 ---------------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}
.toast {
  padding: 12px 18px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: fadeSlide var(--dur) var(--ease);
  max-width: 100%;
  text-align: center;
}
.toast.error { background: var(--wrong); color: #fff; }
.toast.success { background: var(--correct); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }

/* ---------------- 弹窗 ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 20, 30, .45);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: fadeSlide var(--dur-slow) var(--ease);
}

/* ---------------- 对局状态条 ---------------- */
.game-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
  position: sticky;
  top: var(--header-h);
  z-index: 40;
}
.game-bar .meta { display: flex; flex-direction: column; gap: 2px; }
.game-bar .meta .k { font-size: var(--fs-xs); color: var(--text-muted); }
.game-bar .meta .v { font-weight: 700; font-size: var(--fs-sm); }

/* ---------------- 工具类 ---------------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--text-muted); }
.secondary-text { color: var(--text-secondary); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 640px) {
  :root {
    --fs-base: 16px;
    --fs-lg: 19px;
    --fs-xl: 22px;
    --fs-2xl: 26px;
    --maxw: 100%;
    --header-h: 56px;
  }
  .main { padding: 14px 12px 64px; }
  .card { padding: 16px; border-radius: var(--radius); }
  .room-code { font-size: 32px; letter-spacing: .16em; padding: 14px 6px; }
  .input.code { font-size: var(--fs-xl); letter-spacing: .22em; }
  .stem { font-size: var(--fs-base); }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }
  .btn-row.end { flex-direction: row; justify-content: flex-end; }
  .btn-row.end .btn { width: auto; }
  .qnav { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
  .qnav-item { min-height: 42px; font-size: var(--fs-sm); }
  .header .brand { font-size: var(--fs-base); }
  .material { max-height: 240px; font-size: var(--fs-xs); }
  .score-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 横屏手机：压缩纵向空间 */
@media (max-height: 480px) and (orientation: landscape) {
  .material { max-height: 140px; }
  .room-code { font-size: 26px; padding: 10px; }
}

/* 打印：错题集可以直接打印出来复习 */
@media print {
  .header, .footer, .btn, .game-bar, .toast-wrap, .modal-backdrop { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
}
