/* =========================================================================
 * 语文大冒险 · 三年级上册 随堂闯关 —— 独立样式
 * 明亮、卡通、适合小学生的闯关风格
 * ========================================================================= */

:root {
  --ink: #1f2a44;
  --muted: #6b7689;
  --line: #e7ecf5;
  --surface: #ffffff;
  --bg: #f3f7ff;
  --accent: #3d6bff;
  --accent-2: #7a5cff;
  --pink: #ff5c8a;
  --green: #22c07a;
  --amber: #ffb020;
  --red: #ff5b5b;
  --radius: 20px;
  --shadow-sm: 0 2px 8px rgba(31, 42, 68, .06);
  --shadow-md: 0 12px 34px rgba(61, 107, 255, .14);
  --shadow-lg: 0 22px 60px rgba(61, 107, 255, .22);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(720px 340px at 12% -6%, rgba(61, 107, 255, .16), transparent 60%),
    radial-gradient(640px 320px at 92% 0%, rgba(122, 92, 255, .14), transparent 55%),
    radial-gradient(560px 300px at 50% 110%, rgba(34, 192, 122, .10), transparent 60%),
    var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.game-shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 18px 56px;
}

/* ============ 顶部条 ============ */
.game-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}
.topbar-brand { font-weight: 800; font-size: 17px; }
.topbar-meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 16px; cursor: pointer;
  transition: transform .12s ease;
}
.icon-btn:hover { transform: scale(1.06); }

/* ============ 画面切换 ============ */
.screen { display: none; animation: fadeUp .35s ease both; }
.screen.is-active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 通用组件 ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 15px; font-weight: 700;
  padding: 12px 24px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-lg { padding: 15px 32px; font-size: 17px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 26px rgba(61, 107, 255, .32);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(61, 107, 255, .42); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-full { width: 100%; }

/* ============ 开始画面 ============ */
.start-hero { text-align: center; padding: 18px 4px 26px; }
.mascot {
  font-size: 76px;
  display: inline-block;
  animation: bob 2.6s ease-in-out infinite;
  filter: drop-shadow(0 14px 18px rgba(61, 107, 255, .22));
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}
.eyebrow {
  display: inline-block;
  font-size: 13px; font-weight: 700; letter-spacing: 1px;
  color: var(--accent);
  background: #eaf0ff;
  padding: 5px 14px; border-radius: 999px;
  margin: 12px 0 8px;
}
.start-title { font-size: clamp(34px, 7vw, 52px); margin: 6px 0 12px; letter-spacing: -1px; line-height: 1.1; }
.grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 55%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.start-sub { color: var(--muted); font-size: 15px; max-width: 560px; margin: 0 auto 22px; }
.start-stats { display: flex; gap: 26px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.stat { display: flex; flex-direction: column; }
.stat b {
  font-size: 26px; font-weight: 800;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat span { color: var(--muted); font-size: 12px; }

.start-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .start-grid { grid-template-columns: 1fr; } }
.start-grid h2 { margin: 0 0 12px; font-size: 17px; }

.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rules li { font-size: 14px; color: var(--muted); padding-left: 2px; }
.rules li b { color: var(--ink); }

.level-map { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; counter-reset: lv; }
.level-map li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 14px;
}
.level-map li .lm-emoji { font-size: 20px; }
.level-map li .lm-name { font-weight: 700; }
.level-map li .lm-desc { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }

/* ============ 关卡介绍 ============ */
.level-intro { text-align: center; padding: 40px 26px; margin-top: 10px; }
.level-badge {
  display: inline-block;
  font-size: 13px; font-weight: 700; color: var(--accent);
  background: #eaf0ff; padding: 6px 16px; border-radius: 999px;
}
.level-emoji { font-size: 72px; margin: 16px 0 6px; animation: bob 2.4s ease-in-out infinite; }
.level-intro h2 { font-size: 30px; margin: 4px 0 6px; }
.level-desc { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.level-note {
  text-align: left;
  background: #fff8e8;
  border: 1px solid #ffe3a6;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0 auto 16px;
  max-width: 460px;
}
.note-tag { font-weight: 800; font-size: 13px; color: #b7791f; }
.level-note p { margin: 4px 0 0; color: #8a6a33; font-size: 14px; }
.level-hearts-note { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ============ 答题画面 ============ */
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}
.hud-step { min-width: 180px; }
.hud-level { font-weight: 700; font-size: 14px; }
.progress { height: 8px; background: #e9eef8; border-radius: 999px; overflow: hidden; margin: 7px 0; }
.progress i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width .4s ease;
}
.hud-count { color: var(--muted); font-size: 12px; }
.hud-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 700;
  border-radius: 999px; padding: 6px 12px;
  border: 1px solid var(--line); background: #fff;
}
.chip b { font-size: 14px; }
.chip-score { color: #b7791f; background: #fff8e8; border-color: #ffe3a6; }
.chip-hearts { color: #e0486a; }
.chip-streak { color: #e0793c; }
.chip-streak.is-hot { background: #fff1e2; border-color: #ffc98a; animation: pulse .5s ease infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }

.passage {
  background: #f6f9ff;
  border: 1px dashed #b9cbf5;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.passage h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
.passage p { margin: 0; font-size: 15px; line-height: 1.9; color: var(--ink); }

.question-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
}
.q-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-badge {
  display: inline-block;
  font-size: 12px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 4px 12px; border-radius: 999px;
}
.q-type {
  display: inline-block;
  font-size: 12px; font-weight: 700; color: #fff;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent);
}
.type-pinyin { background: #2f7bff; }
.type-xingjin { background: #8a5cff; }
.type-ciyu { background: #1fb06e; }
.type-kewen { background: #ff5c8a; }
.type-gushi { background: #e0972f; }
.type-riji { background: #0fa6a0; }
.type-panduan { background: #6b7689; }
.type-yuedu { background: #5c63d8; }
.q-text { font-size: 19px; font-weight: 700; margin: 14px 0 20px; line-height: 1.6; }

.options { display: grid; gap: 12px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  text-align: left;
  width: 100%;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.opt:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.opt .opt-letter {
  flex: none;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: #eef2fb; color: var(--accent);
  font-weight: 800; font-size: 14px;
}
.opt.is-right { border-color: var(--green); background: #ecfbf3; }
.opt.is-right .opt-letter { background: var(--green); color: #fff; }
.opt.is-wrong { border-color: var(--red); background: #fff0f0; animation: shake .4s ease; }
.opt.is-wrong .opt-letter { background: var(--red); color: #fff; }
.opt.is-dim { opacity: .55; }
.opt:disabled { cursor: default; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.feedback {
  margin-top: 18px;
  border-radius: 16px;
  padding: 16px 18px;
  animation: fadeUp .3s ease both;
}
.feedback.is-good { background: #ecfbf3; border: 1px solid #b9ecd4; }
.feedback.is-bad { background: #fff5ec; border: 1px solid #ffd9b8; }
.feedback .fb-head { font-weight: 800; font-size: 16px; margin: 0 0 8px; }
.feedback.is-good .fb-head { color: #12855a; }
.feedback.is-bad .fb-head { color: #d96a34; }
.feedback .fb-explain { font-size: 14px; color: var(--ink); margin: 0 0 14px; line-height: 1.7; }
.feedback .fb-explain .fb-answer { font-weight: 800; color: #12855a; }

/* ============ 结算画面 ============ */
.result-card { text-align: center; padding: 42px 26px; margin-top: 10px; }
.result-emoji { font-size: 80px; animation: bob 2.4s ease-in-out infinite; }
.result-title {
  font-size: clamp(30px, 6vw, 44px); margin: 10px 0 6px;
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 55%, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-motto { color: var(--muted); margin: 0 0 26px; font-size: 15px; }
.result-stats { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.rstat {
  display: flex; flex-direction: column;
  min-width: 104px;
  background: #f6f9ff; border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 16px;
}
.rstat b {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rstat span { color: var(--muted); font-size: 12px; }
.result-best {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 14px; font-weight: 800; color: #b7791f;
  background: #fff8e8; border: 1px solid #ffe3a6;
  padding: 7px 16px; border-radius: 999px;
}

/* ============ 单元地图 ============ */
.map-head { text-align: center; margin: 16px 0 22px; }
.map-head h2 { font-size: clamp(26px, 5vw, 34px); margin: 4px 0 6px; }
.map-head p { color: var(--muted); font-size: 14px; margin: 0; }
.map-total {
  display: inline-block; margin-top: 12px;
  font-size: 14px; font-weight: 800; color: #b7791f;
  background: #fff8e8; border: 1px solid #ffe3a6;
  padding: 7px 16px; border-radius: 999px;
}
.map-total b { color: #c77a10; }

.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.unit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex; flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.unit-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.unit-card .uc-top { display: flex; align-items: center; justify-content: space-between; }
.unit-num { font-size: 12px; font-weight: 800; color: var(--accent); background: #eaf0ff; padding: 4px 10px; border-radius: 999px; }
.unit-emoji { font-size: 34px; }
.unit-card h3 { font-size: 19px; margin: 4px 0 2px; }
.unit-theme { color: var(--muted); font-size: 13px; margin: 0 0 4px; line-height: 1.5; }
.unit-meta { color: var(--muted); font-size: 12px; }
.unit-stars { font-size: 22px; letter-spacing: 3px; margin-top: 8px; }
.unit-stars .off { opacity: .25; filter: grayscale(1); }
.unit-stars .unit-stars-label { font-weight: 700; font-size: 12px; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.unit-card .btn { margin-top: auto; width: 100%; }

/* ============ 弹窗 ============ */
.modal { position: fixed; inset: 0; z-index: 999; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 30, 55, .5); backdrop-filter: blur(3px); }
.modal-dialog {
  position: relative;
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  animation: popIn .3s cubic-bezier(.34, 1.56, .64, 1) both;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(20px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-body { padding: 30px 24px; text-align: center; }
.modal-emoji { font-size: 64px; margin-bottom: 8px; }
.modal-title { font-size: 24px; font-weight: 800; margin: 0 0 8px; }
.modal-text { color: var(--muted); font-size: 14px; margin: 0 0 20px; line-height: 1.7; }
.modal-stars { font-size: 34px; letter-spacing: 4px; margin-bottom: 14px; }
.modal-stars .off { opacity: .25; filter: grayscale(1); }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ============ 飘字 / 撒花 ============ */
.toast {
  position: fixed; left: 50%; top: 22%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 16px; font-weight: 800;
  padding: 12px 22px;
  animation: toastPop .9s ease both;
  pointer-events: none;
}
.toast[hidden] { display: none; }
@keyframes toastPop {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(.8); }
  16% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(.92); }
}

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.confetti span {
  position: absolute; top: -20px;
  width: 12px; height: 12px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .4; }
}

/* ============ 我的成绩 & 错题本 ============ */
.history-head { text-align: center; margin: 16px 0 20px; }
.history-head h2 { font-size: clamp(24px, 5vw, 32px); margin: 4px 0 8px; }
.history-note { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.history-stats { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.history-tabs { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-family: var(--font);
  font-size: 14px; font-weight: 700;
  padding: 10px 20px; border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.tab-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
  box-shadow: 0 8px 20px rgba(61, 107, 255, .28);
}

.history-section { display: none; animation: fadeUp .3s ease both; }
.history-section.is-active { display: block; }

.wrong-list, .score-list { display: grid; gap: 12px; margin-bottom: 18px; }
.wrong-item, .score-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.wrong-item .wi-top, .score-item .si-top {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.wrong-item .wi-unit, .score-item .si-unit {
  font-size: 12px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 3px 10px; border-radius: 999px;
}
.wrong-item .wi-type {
  font-size: 12px; font-weight: 700; color: #fff;
  padding: 3px 10px; border-radius: 999px; background: var(--red);
}
.wrong-item .wi-date, .score-item .si-date { margin-left: auto; color: var(--muted); font-size: 12px; }
.wrong-item .wi-q { font-size: 15px; font-weight: 700; margin: 0 0 10px; line-height: 1.6; }
.wrong-item .wi-answer { font-size: 14px; margin: 4px 0; line-height: 1.6; }
.wrong-item .wi-answer.mine { color: #d96a34; }
.wrong-item .wi-answer.mine b { color: #c14b1f; }
.wrong-item .wi-answer.right { color: #12855a; }
.wrong-item .wi-answer.right b { color: #0b6b46; }
.wrong-item .wi-explain {
  font-size: 13px; color: var(--muted);
  background: #f6f9ff; border-radius: 10px; padding: 10px 12px; margin: 8px 0 0;
}

.score-item .si-stars { font-size: 18px; letter-spacing: 2px; }
.score-item .si-stars .off { opacity: .25; filter: grayscale(1); }
.score-item .si-body { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.score-item .si-body span { font-size: 13px; color: var(--muted); }
.score-item .si-body b { color: var(--ink); font-size: 15px; }

.history-empty {
  text-align: center; color: var(--muted); font-size: 15px;
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: 16px; padding: 34px 20px; margin-bottom: 18px;
}
.history-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ============ 对战模式 ============ */
.btn-battle {
  background: linear-gradient(135deg, #ff7a3c, #ff4d6d);
  color: #fff;
  box-shadow: 0 10px 26px rgba(255, 77, 109, .30);
}
.btn-battle:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(255, 77, 109, .40); }
.btn-sm { padding: 8px 16px; font-size: 14px; }

.battle-head { text-align: center; margin: 16px 0 20px; }
.battle-head h2 { font-size: clamp(24px, 5vw, 32px); margin: 4px 0 10px; }
.battle-sub { color: var(--muted); font-size: 14px; margin: 0 auto; max-width: 520px; line-height: 1.9; }

.battle-setup h3, .battle-actions h3 { margin: 0 0 14px; font-size: 16px; }
.battle-avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 16px; }
.avatar-btn {
  aspect-ratio: 1; font-size: 26px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: transform .12s ease, border-color .12s ease;
}
.avatar-btn:hover { transform: translateY(-2px); }
.avatar-btn.is-active { border-color: var(--accent); background: #eef3ff; box-shadow: 0 6px 16px rgba(61,107,255,.18); }

.field { display: block; margin: 4px 0 14px; }
.field span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .battle-join-row input {
  width: 100%; font-family: var(--font); font-size: 15px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink);
}
.field input:focus, .battle-join-row input:focus { outline: 2px solid rgba(61,107,255,.35); border-color: var(--accent); }

.battle-actions .btn { margin-bottom: 4px; }
.battle-join-row { display: flex; gap: 10px; margin: 12px 0 16px; }
.battle-join-row input { flex: 1; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.battle-join-row .btn { flex-shrink: 0; }
.battle-rooms { border-top: 1px solid var(--line); padding-top: 14px; }
.room-list { display: grid; gap: 8px; }
.room-tile {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; background: #f8faff; border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; font-family: var(--font); transition: border-color .12s ease;
}
.room-tile:hover { border-color: var(--accent); }
.rt-code { font-weight: 800; color: var(--accent); letter-spacing: 1px; }
.rt-meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.rt-join { font-size: 13px; font-weight: 700; color: var(--accent); }
.battle-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 14px; }
.battle-back { display: flex; justify-content: center; margin-top: 14px; }

.room-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.room-code { font-weight: 800; font-size: 16px; }

.battle-lobby .bl-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.bl-code b { font-size: 20px; letter-spacing: 2px; color: var(--accent); }
.bl-players { display: grid; gap: 8px; margin-bottom: 16px; }
.bp-row {
  display: flex; align-items: center; gap: 10px;
  background: #f8faff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.bp-row.is-me { background: #eef3ff; border-color: #bcd0ff; }
.bp-avatar { font-size: 24px; }
.bp-name { font-weight: 700; flex: 1; }
.bp-host { font-style: normal; font-size: 11px; font-weight: 800; color: #fff; background: var(--amber); border-radius: 999px; padding: 2px 8px; }
.bp-answered { font-size: 11px; font-weight: 800; color: var(--green); }
.bp-score { font-weight: 800; color: var(--accent); }

.bl-settings { border-top: 1px dashed var(--line); padding-top: 14px; }
.bl-settings h3 { margin: 0 0 10px; font-size: 15px; }
.bl-units { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.bu-chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.bu-chip input { accent-color: var(--accent); }
.bu-chip span { font-size: 13px; font-weight: 600; background: #f1f4fb; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; }
.bu-chip input:checked + span { background: #eef3ff; border-color: var(--accent); color: var(--accent); }
.bl-wait { text-align: center; color: var(--muted); padding: 20px; font-size: 15px; }

.battle-scoreboard { display: grid; gap: 8px; margin-bottom: 12px; }

.battle-quiz .q-top { margin-bottom: 6px; }
.battle-timer { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.battle-timer span { font-weight: 800; color: var(--accent); font-size: 14px; min-width: 32px; }
.bt-bar { flex: 1; height: 8px; background: #edf1f9; border-radius: 999px; overflow: hidden; }
.bt-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 999px; transition: width .5s linear; }
.battle-banner { margin-top: 14px; background: #ecfbf3; border: 1px solid #b9ecd4; border-radius: 12px; padding: 12px 14px; font-weight: 800; color: #12855a; }
.battle-banner .bb-explain { font-weight: 400; font-size: 14px; color: var(--ink); margin-top: 6px; line-height: 1.7; }
.opt.is-chosen { border-color: var(--accent); background: #eef3ff; }
.opt.is-chosen .opt-letter { background: var(--accent); color: #fff; }

.battle-ended { text-align: center; }
.be-head { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.be-winner { font-size: 20px; font-weight: 800; color: #b7791f; margin-bottom: 16px; }
.be-rank { display: grid; gap: 10px; margin-bottom: 18px; text-align: left; }
.rank-row {
  display: flex; align-items: center; gap: 10px;
  background: #f8faff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.rank-row.is-win { background: #fff8e8; border-color: #ffe3a6; }
.rank-medal { font-size: 22px; min-width: 34px; text-align: center; }
.rank-avatar { font-size: 24px; }
.rank-name { font-weight: 700; flex: 1; }
.rank-score { font-weight: 800; color: var(--accent); }
.be-actions { margin-top: 6px; }

@media (max-width: 560px) {
  .game-shell { padding: 12px 12px 40px; }
  .question-card { padding: 18px; }
  .q-text { font-size: 17px; }
  .opt { padding: 12px 13px; font-size: 15px; }
  .result-stats { gap: 10px; }
  .rstat { min-width: 82px; padding: 12px 10px; }
  .battle-avatar-grid { grid-template-columns: repeat(4, 1fr); }
}