/* ============================================================
   YBH 小游戏 · 共用样式
   ------------------------------------------------------------
   设计约定：
   · 移动优先（学生基本都用手机玩），所有可点目标 ≥ 44px；
   · 零外部依赖：不引 CDN、不引外部字体，用系统字体栈；
   · 配色对齐站点身份：暖白纸感 + 青绿主色（与 App 一致）；
   · 深色模式走 prefers-color-scheme，不额外加开关。
   ============================================================ */

:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #23211f;
  --muted: #6f6a64;
  --line: #e6e2db;
  --brand: #2e7d78;
  --brand-soft: #e3f1ef;
  --warm: #c8792c;
  --ok: #2e9e6b;
  --bad: #d0553f;
  --shadow: 0 1px 2px rgba(35, 33, 31, .05), 0 8px 24px rgba(35, 33, 31, .06);
  --radius: 16px;
  --font: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1c1e;
    --card: #24262a;
    --ink: #e9e7e3;
    --muted: #9a958e;
    --line: #34373c;
    --brand: #4fb3ac;
    --brand-soft: #1f3231;
    --warm: #d99a52;
    --ok: #4cc08a;
    --bad: #e2705a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

a { color: var(--brand); text-decoration: none; }

/* ---------------------------------------------------------------- 顶栏 */
.gbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.gbar .back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: -6px;
  border-radius: 11px; color: var(--ink);
  font-size: 19px; line-height: 1;
}
.gbar .back:active { background: var(--brand-soft); }
.gbar .title { font-weight: 700; font-size: 16.5px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gbar .score { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- 容器 */
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 14px 40px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 650;
  background: var(--brand); color: #fff;
  transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); opacity: .9; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.plain { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------------------------------------------------------------- 选项按钮（答题类共用） */
.opts { display: grid; gap: 10px; margin-top: 14px; }
.opts.two { grid-template-columns: 1fr 1fr; }
.opt {
  min-height: 52px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--card); color: var(--ink);
  font-family: inherit; font-size: 17px; font-weight: 600;
  cursor: pointer; text-align: center;
  transition: border-color .15s ease, background .15s ease, transform .08s ease;
}
.opt:active { transform: scale(.985); }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--card)); }
.opt[disabled] { opacity: .7; }

/* ---------------------------------------------------------------- 计分条 */
.hud {
  display: flex; align-items: stretch; gap: 8px; margin-bottom: 14px;
}
.hud .cell {
  flex: 1; text-align: center;
  padding: 8px 6px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
}
.hud .k { font-size: 11.5px; color: var(--muted); }
.hud .v { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  padding: 9px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50;
  max-width: 82vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- 大厅 */
.hero { text-align: center; padding: 26px 8px 18px; }
.hero h1 { margin: 0 0 6px; font-size: 27px; letter-spacing: 1px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

.games { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 6px; }
@media (min-width: 560px) { .games { grid-template-columns: 1fr 1fr 1fr; } }

.game-card {
  display: block; position: relative;
  padding: 16px 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--ink);
  transition: transform .1s ease;
}
.game-card:active { transform: scale(.98); }
.game-card .emoji { font-size: 30px; line-height: 1; }
.game-card .name { margin-top: 10px; font-weight: 750; font-size: 16px; }
.game-card .desc { margin-top: 2px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.game-card .best {
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 999px; padding: 3px 8px;
}
.game-card .best:empty { display: none; }

.foot { margin-top: 26px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.9; }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* ---------------------------------------------------------------- 弹层（结束/开始） */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  padding: 20px; background: rgba(20, 19, 18, .5);
  backdrop-filter: blur(3px);
}
.overlay.show { display: flex; }
.sheet {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--card); border-radius: 20px; padding: 24px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.sheet h2 { margin: 0 0 6px; font-size: 21px; }
.sheet .big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 8px 0; }
.sheet .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row .btn { flex: 1; }

/* ---------------------------------------------------------------- 辅助 */
.center { text-align: center; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
