:root {
  --bg: #0f1226;
  --bg2: #1a1f3c;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-solid: #1c2142;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --gold: #ffcf5c;
  --gold2: #ff9d3c;
  --accent: #6c7bff;
  --accent2: #34d6c8;
  --good: #2fd07a;
  --bad: #ff5d6c;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

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

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% -10%, #2a2f63 0%, transparent 60%),
              radial-gradient(1000px 700px at 100% 0%, #3a2a63 0%, transparent 55%),
              linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.container { max-width: 720px; margin: 0 auto; padding: 18px 16px 48px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px 10px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: .5px; }
.topbar .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  display: grid; place-items: center; font-size: 20px; box-shadow: var(--shadow);
}
.topbar .back { color: var(--muted); font-size: 14px; cursor: pointer; padding: 6px 10px; border-radius: 10px; }
.topbar .back:hover { color: var(--text); background: var(--panel); }

.hero { text-align: center; padding: 26px 8px 10px; }
.hero h1 { font-size: 30px; margin: 8px 0 6px; background: linear-gradient(90deg, var(--gold), #fff, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); margin: 4px 0 0; font-size: 14px; line-height: 1.6; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.mode-card {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius); padding: 20px 16px; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease; min-height: 180px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.mode-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.mode-card .emoji { font-size: 40px; }
.mode-card h3 { margin: 12px 0 6px; font-size: 19px; }
.mode-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.mode-card .tag { position: absolute; top: 12px; right: 12px; font-size: 11px; color: var(--gold); border: 1px solid rgba(255,207,92,.4); padding: 2px 8px; border-radius: 999px; }

.panel {
  background: var(--panel); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius); padding: 16px; margin-top: 18px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 13px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; color: #1a1330; background: linear-gradient(135deg, var(--gold), var(--gold2));
  transition: transform .12s ease, filter .12s ease; width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid rgba(255,255,255,.16); }
.btn.accent { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.btn.small { padding: 9px 14px; font-size: 13px; width: auto; }

input, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; font-size: 15px;
  border: 1px solid rgba(255,255,255,.16); background: rgba(0,0,0,.25); color: var(--text);
  margin-bottom: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label { font-size: 13px; color: var(--muted); display: block; margin: 4px 0 6px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 10px 0 2px; }

/* 题目卡片 */
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }
.chip.cat { color: var(--accent2); }
.chip.diff-easy { color: var(--good); }
.chip.diff-medium { color: var(--gold); }
.chip.diff-hard { color: var(--bad); }

.q-text { font-size: 19px; line-height: 1.6; margin: 8px 0 18px; font-weight: 600; }
.q-progress { font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 14px 14px; cursor: pointer; font-size: 15px; color: var(--text);
  transition: background .12s, border-color .12s, transform .08s;
}
.option:hover:not(.locked) { border-color: var(--accent); background: rgba(108,123,255,.14); }
.option:active:not(.locked) { transform: scale(.99); }
.option .key { width: 26px; height: 26px; flex: none; border-radius: 8px; background: rgba(255,255,255,.1); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--gold); }
.option.correct { border-color: var(--good); background: rgba(47,208,122,.18); }
.option.wrong { border-color: var(--bad); background: rgba(255,93,108,.16); }
.option.locked { cursor: default; }
.option.dim { opacity: .55; }

/* 计时条 */
.timer-wrap { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; margin: 4px 0 16px; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), var(--gold)); transition: width .2s linear; }
.timer-bar.warn { background: linear-gradient(90deg, var(--gold2), var(--bad)); }

/* 故事章节地图 */
.chapters { display: flex; flex-direction: column; gap: 12px; }
.chapter {
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer; transition: .15s;
}
.chapter:hover { border-color: var(--gold); transform: translateX(2px); }
.chapter.locked { opacity: .5; cursor: not-allowed; }
.chapter .num { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 18px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.chapter.locked .num { background: rgba(255,255,255,.12); color: var(--muted); }
.chapter .body { flex: 1; }
.chapter h3 { margin: 0 0 3px; font-size: 16px; }
.chapter .sub { font-size: 12px; color: var(--muted); }
.chapter .stars { color: var(--gold); font-size: 13px; margin-top: 4px; }

/* 通用结果/遮罩 */
.overlay {
  position: fixed; inset: 0; background: rgba(8,10,24,.78); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.overlay.show { display: flex; }
.overlay .box { background: var(--panel-solid); border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 22px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.overlay h2 { margin: 4px 0 10px; }
.overlay p { color: var(--muted); line-height: 1.6; font-size: 14px; }

.score-big { font-size: 44px; font-weight: 800; color: var(--gold); margin: 6px 0; }

/* 排行榜 */
.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: rgba(255,255,255,.04); border-radius: 10px; }
.lb-row .rank { width: 24px; text-align: center; font-weight: 800; color: var(--gold); }
.lb-row .nm { flex: 1; font-size: 14px; }
.lb-row .sc { font-weight: 800; }
.lb-row:nth-child(1) .rank { color: #ffd34d; }
.lb-row:nth-child(2) .rank { color: #cfd6ff; }
.lb-row:nth-child(3) .rank { color: #ffb27a; }

/* 房间/多人 */
.lobby-players { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.pp {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 10px 14px; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.pp .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.pp.host { border-color: var(--gold); }
.code-badge { font-size: 26px; font-weight: 800; letter-spacing: 4px; color: var(--gold); text-align: center; margin: 8px 0; }

.result-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(255,255,255,.05); border-radius: 10px; font-size: 14px; }
.result-row .ok { color: var(--good); }
.result-row .no { color: var(--bad); }
.result-row .pts { margin-left: auto; font-weight: 800; color: var(--gold); }

.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  background: var(--bad); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 540px) {
  .modes { grid-template-columns: 1fr; }
  .hero h1 { font-size: 25px; }
  .q-text { font-size: 17px; }
}

/* 语言切换 */
.lang-slot { display: flex; align-items: center; }
.lang-switch {
  display: inline-flex; align-items: center;
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.04);
}
.lang-switch button {
  background: transparent; border: none; color: var(--muted);
  font-size: 12px; padding: 5px 10px; cursor: pointer; line-height: 1; white-space: nowrap;
  font-family: inherit;
}
.lang-switch button + button { border-left: 1px solid rgba(255,255,255,.14); }
.lang-switch button.active { background: var(--accent); color: #fff; }
.lang-switch button:active { transform: scale(.96); }

/* 双语文本 */
.en-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; line-height: 1.45; }
.zh-text { font-weight: 600; }
.q-text .en-sub { margin-top: 6px; }
.opt-txt { display: flex; flex-direction: column; flex: 1; }

/* 实时生成题目加载动画 */
.spinner {
  width: 42px; height: 42px; margin: 0 auto;
  border: 4px solid rgba(255,255,255,.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text); }

/* ===== 多人 hotseat ===== */
.count-pick { display: flex; gap: 10px; margin: 6px 0 12px; }
.count-btn { flex: 1; padding: 12px 0; border-radius: 12px; border: 1px solid rgba(255,255,255,.16); background: var(--panel); color: var(--text); font-size: 16px; font-weight: 700; cursor: pointer; }
.count-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.name-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.name-row .pid { width: 26px; height: 26px; flex: none; border-radius: 8px; background: rgba(255,255,255,.1); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--gold); }
.players-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pchip { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid transparent; font-size: 13px; }
.pchip.active { background: rgba(255,213,79,.16); border-color: var(--gold); }
.pchip .pname { font-weight: 700; }
.pchip .pscore { color: var(--gold); font-weight: 800; }
.round-result { margin-top: 12px; font-weight: 700; }
.round-result.ok { color: var(--good); }
.round-result.bad { color: var(--bad); }
.result-row .rk { width: 24px; height: 24px; flex: none; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.result-row .rn { flex: 1; font-weight: 700; }
.result-row .rs { color: var(--gold); font-weight: 800; }
.option .opt-txt .en-sub { margin-top: 2px; }
