:root {
  --bg: #0d1117;
  --panel: rgba(20, 26, 36, 0.92);
  --panel2: rgba(30, 40, 55, 0.85);
  --text: #eef2f7;
  --muted: #9aa7b8;
  --accent: #ffb400;
  --good: #22c55e;
  --bad: #ef4444;
  --line: rgba(255, 255, 255, 0.1);
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input { font-family: inherit; outline: none; }

.screen { position: fixed; inset: 0; display: none; flex-direction: column; z-index: 1; }
.screen.active { display: flex; }

/* ===== 顶栏 HUD ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 54px;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.25));
  backdrop-filter: blur(8px); z-index: 40;
}
.topbar .logo { font-weight: 800; font-size: 17px; letter-spacing: 1px; color: var(--accent); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .nick { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); background: var(--panel2); padding: 6px 12px; border-radius: 20px; cursor: pointer; }
.topbar .nick .devid { color: var(--muted); font-size: 11px; }
.topbar .iconbtn { width: 38px; height: 38px; border-radius: 50%; background: var(--panel2); color: var(--text); font-size: 18px; display: flex; align-items: center; justify-content: center; }

/* ===== 通用按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 26px; border-radius: 12px; font-size: 16px; font-weight: 700;
  color: #1a1a1a; background: linear-gradient(135deg, #ffd34d, #ffb400);
  box-shadow: 0 6px 20px rgba(255, 180, 0, 0.35); transition: transform .12s;
}
.btn:active { transform: scale(0.96); }
.btn.ghost { background: var(--panel2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.danger { background: linear-gradient(135deg, #ff7a7a, #ef4444); color: #fff; box-shadow: 0 6px 20px rgba(239,68,68,0.3); }
.btn.big { padding: 16px 40px; font-size: 19px; border-radius: 16px; }

/* ===== 启动屏 ===== */
#screen-home { align-items: center; justify-content: center; gap: 18px; text-align: center; background:
  radial-gradient(1200px 600px at 50% -10%, rgba(255,180,0,0.18), transparent 60%),
  radial-gradient(900px 500px at 80% 110%, rgba(41,182,246,0.15), transparent 60%), #0d1117; padding: 20px; }
#screen-home .title { font-size: 52px; font-weight: 900; letter-spacing: 4px; background: linear-gradient(135deg, #ffd34d, #ff7a00); -webkit-background-clip: text; background-clip: text; color: transparent; }
#screen-home .subtitle { color: var(--muted); font-size: 15px; letter-spacing: 2px; }
.home-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 30px; width: min(92vw, 420px); display: flex; flex-direction: column; gap: 14px; text-align: left; margin-top: 8px; }
.home-card .row { display: flex; flex-direction: column; gap: 6px; }
.home-card label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.home-card input { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; color: var(--text); }
.home-card .devidbox { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); word-break: break-all; background: rgba(0,0,0,0.25); padding: 8px 10px; border-radius: 8px; }

/* ===== 关卡选择屏 ===== */
#screen-levels { align-items: center; padding: 80px 16px 40px; overflow-y: auto; background:
  radial-gradient(1200px 600px at 50% -10%, rgba(255,180,0,0.10), transparent 60%), #0d1117; }
.screen-head { text-align: center; margin-bottom: 24px; }
.screen-head h1 { font-size: 30px; font-weight: 900; letter-spacing: 2px; }
.screen-head p { color: var(--muted); margin-top: 6px; font-size: 14px; }
.level-grid { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; max-width: 1000px; }
.level-card {
  width: 270px; padding: 22px 20px; border-radius: 18px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.level-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.level-card .lvnum { font-size: 12px; letter-spacing: 2px; color: var(--muted); }
.level-card h2 { font-size: 22px; margin: 6px 0 4px; }
.level-card .lvcolor { position: absolute; top: 0; left: 0; right: 0; height: 5px; }
.level-card .meta { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.6; }
.level-card .progress { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; margin-top: 14px; overflow: hidden; }
.level-card .progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.level-card.locked { opacity: 0.5; cursor: not-allowed; }

/* ===== 小关卡选择 ===== */
#screen-sub { align-items: center; padding: 80px 16px 40px; overflow-y: auto; background: #0d1117; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; width: min(94vw, 880px); }
.sub-card {
  aspect-ratio: 1 / 1; border-radius: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); position: relative; overflow: hidden;
  transition: transform .14s;
}
.sub-card:hover { transform: scale(1.04); }
.sub-card .star { position: absolute; top: 10px; right: 10px; font-size: 13px; color: var(--muted); }
.sub-card .num { font-size: 26px; font-weight: 900; color: var(--accent); }
.sub-card .nm { font-size: 14px; font-weight: 700; }
.sub-card .best { font-size: 11px; color: var(--muted); }
.sub-card.locked { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.6); }
.sub-card.locked .num { color: var(--muted); }
.sub-card.cleared { border-color: rgba(34,197,94,0.5); }

/* ===== 游戏屏 ===== */
#screen-game { background: #0d1117; overflow: hidden; }
#screen-game[data-theme="desert"] { background: radial-gradient(1200px 600px at 50% -10%, rgba(224,165,58,0.25), transparent 60%), linear-gradient(180deg, #1a1206, #241a08 55%, #0d1117); }
#screen-game[data-theme="jungle"] { background: radial-gradient(1200px 600px at 50% -10%, rgba(76,175,80,0.25), transparent 60%), linear-gradient(180deg, #061a0c, #0a2411 55%, #0d1117); }
#screen-game[data-theme="urban"] { background: radial-gradient(1200px 600px at 50% -10%, rgba(41,182,246,0.25), transparent 60%), linear-gradient(180deg, #061018, #0a1a28 55%, #0d1117); }
#screen-game[data-theme="night"] { background: radial-gradient(1200px 600px at 50% -10%, rgba(171,71,188,0.25), transparent 60%), linear-gradient(180deg, #120622, #1c0a2e 55%, #0d1117); }
#screen-game[data-theme="final"] { background: radial-gradient(1200px 600px at 50% -10%, rgba(239,83,80,0.30), transparent 60%), linear-gradient(180deg, #200608, #2a0a0c 55%, #0d1117); }

.game-hud {
  position: absolute; top: 54px; left: 0; right: 0; display: flex; gap: 10px;
  padding: 10px 14px; align-items: center; justify-content: center; z-index: 30; pointer-events: none;
}
.game-hud .chip {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 7px 14px; font-size: 14px; display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.game-hud .chip b { font-size: 17px; }
.game-hud .score { color: var(--accent); }
.game-hud .combo { color: #7dd3fc; }

#word-stage { position: absolute; inset: 110px 0 160px 0; display: flex; align-items: center; justify-content: center; z-index: 20; }
.word-big {
  font-size: clamp(56px, 14vw, 140px); font-weight: 900; letter-spacing: 2px;
  text-align: center; padding: 10px 30px; color: #fff;
  text-shadow: 0 0 40px rgba(255,255,255,0.5), 0 8px 24px rgba(0,0,0,0.6);
  animation: popIn .35s ease;
}
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.word-pos { text-align: center; color: var(--muted); font-size: 16px; margin-top: 2px; }

/* 靶子 */
#targets { position: absolute; inset: 110px 0 170px 0; z-index: 21; }
.target {
  position: absolute; transform: translate(-50%, -50%); cursor: crosshair;
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 132px; height: 132px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 12%, #f87171 12% 28%, #fff 28% 40%, #f87171 40% 56%, #fff 56% 68%, #f87171 68% 84%, #fff 84% 100%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.55), inset 0 0 0 2px rgba(0,0,0,0.3);
  animation: targetIn .3s cubic-bezier(.2,1.6,.4,1);
}
.target .label {
  background: rgba(20, 20, 30, 0.92); border-radius: 10px; padding: 6px 10px;
  font-size: 15px; font-weight: 700; color: #fff; max-width: 116px; line-height: 1.3;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.target.correct-hit { background: radial-gradient(circle, #86efac 0 20%, #22c55e 20% 100%); box-shadow: 0 0 40px rgba(34,197,94,0.9); }
.target.wrong-hit { background: radial-gradient(circle, #fca5a5 0 20%, #ef4444 20% 100%); box-shadow: 0 0 40px rgba(239,68,68,0.9); animation: shake .3s; }
.target.reveal-correct { background: radial-gradient(circle, #86efac 0 20%, #22c55e 20% 100%); box-shadow: 0 0 40px rgba(34,197,94,0.9); }
@keyframes targetIn { from { transform: translate(-50%, -50%) scale(0); } to { transform: translate(-50%, -50%) scale(1); } }
@keyframes shake { 0%,100% { transform: translate(-50%,-50%) translateX(0); } 25% { transform: translate(-50%,-50%) translateX(-8px); } 75% { transform: translate(-50%,-50%) translateX(8px); } }

/* 倒计时条 */
#timer-wrap { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); width: min(86vw, 520px); z-index: 30; pointer-events: none; }
#timer-bar { height: 8px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden; }
#timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #22c55e, #ffd34d, #ef4444); border-radius: 4px; transition: width .05s linear; }

/* 反馈提示 */
#feedback { position: absolute; top: 130px; left: 50%; transform: translateX(-50%); z-index: 35; font-size: 30px; font-weight: 900; pointer-events: none; opacity: 0; }
#feedback.show { animation: fbPop .6s ease; opacity: 1; }
@keyframes fbPop { 0% { opacity: 0; transform: translateX(-50%) scale(0.5); } 30% { opacity: 1; transform: translateX(-50%) scale(1.15); } 100% { opacity: 1; transform: translateX(-50%) scale(1); } }

/* AK47 */
#gun-area { position: absolute; bottom: 0; left: 0; right: 0; height: 150px; display: flex; align-items: flex-end; justify-content: center; z-index: 25; pointer-events: none; }
#gun { width: 92px; height: auto; transition: transform .06s; transform-origin: 50% 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5)); }
#gun.recoil { transform: translateY(10px) rotate(-2deg); }
.muzzle { position: fixed; width: 52px; height: 52px; border-radius: 50%; background: radial-gradient(circle, #fff 0 22%, #ffd34d 42%, #ff7a00 70%, transparent 100%); opacity: 0; pointer-events: none; transform: translate(-50%, -50%); }
.muzzle.show { opacity: 1; animation: muzzle .12s; }
@keyframes muzzle { from { transform: translate(-50%, -50%) scale(0.6); opacity: 1; } to { transform: translate(-50%, -50%) scale(2); opacity: 0; } }

/* 子弹轨迹 */
.tracer { position: fixed; height: 3px; background: linear-gradient(90deg, #ffd34d, transparent); transform-origin: left center; z-index: 24; pointer-events: none; border-radius: 2px; }

/* ===== 结算屏 ===== */
#screen-result { align-items: center; justify-content: center; padding: 20px; text-align: center; background: rgba(5,8,14,0.96); z-index: 50; }
.result-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 30px; width: min(92vw, 480px); display: flex; flex-direction: column; gap: 14px; }
.result-card h1 { font-size: 30px; font-weight: 900; }
.big-acc { font-size: 64px; font-weight: 900; background: linear-gradient(135deg, #ffd34d, #ff7a00); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-stats { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 6px 0; }
.result-stats .s { background: var(--panel2); border-radius: 12px; padding: 12px 18px; min-width: 90px; }
.result-stats .s b { display: block; font-size: 22px; }
.result-stats .s span { color: var(--muted); font-size: 12px; }
.badge-award { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; border-radius: 16px; background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,180,0,0.05)); border: 1px solid rgba(255,215,0,0.4); }
.badge-icon { font-size: 54px; filter: drop-shadow(0 0 18px rgba(255,215,0,0.7)); }
.medal-icon { font-size: 70px; filter: drop-shadow(0 0 24px rgba(255,215,0,0.9)); }

/* ===== 错题本 ===== */
#screen-wrong { padding: 80px 16px 30px; overflow-y: auto; align-items: center; background: #0d1117; }
.wrong-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; justify-content: center; }
.wrong-list { width: min(94vw, 720px); display: flex; flex-direction: column; gap: 8px; }
.wrong-item { display: flex; align-items: center; gap: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.wrong-item .en { font-size: 18px; font-weight: 800; min-width: 110px; }
.wrong-item .zh { color: var(--muted); flex: 1; }
.wrong-item .cnt { background: var(--bad); color: #fff; border-radius: 20px; padding: 3px 11px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.wrong-item .cnt.zero { background: var(--good); }

/* ===== 徽章墙 ===== */
#screen-badges { padding: 80px 16px 30px; overflow-y: auto; align-items: center; background: radial-gradient(1200px 600px at 50% -10%, rgba(255,215,0,0.12), transparent 60%), #0d1117; }
.badge-grid { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; max-width: 900px; }
.badge-card { width: 150px; padding: 20px 14px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.badge-card .ic { font-size: 52px; filter: grayscale(1) opacity(0.4); }
.badge-card.earned .ic { filter: none; }
.badge-card .nm { font-size: 14px; font-weight: 700; margin-top: 8px; }
.badge-card .dsc { font-size: 11px; color: var(--muted); margin-top: 4px; }
.badge-card.earned { border-color: rgba(255,215,0,0.5); box-shadow: 0 0 20px rgba(255,215,0,0.15); }

/* ===== 海报 ===== */
#poster-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 90; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px; padding: 20px; }
#poster-overlay.show { display: flex; }
#poster-canvas { border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.7); max-width: 92vw; max-height: 70vh; }
.poster-actions { display: flex; gap: 12px; }

/* ===== 庆祝粒子 ===== */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
#fx-canvas { width: 100%; height: 100%; }

/* ===== 设置 ===== */
#screen-settings { padding: 80px 16px 30px; overflow-y: auto; align-items: center; background: #0d1117; }
.set-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: min(92vw, 460px); display: flex; flex-direction: column; gap: 18px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row label { font-size: 14px; }
.set-row input[type=text] { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); font-size: 15px; flex: 1; }
.set-row input[type=range] { flex: 1; accent-color: var(--accent); }
.toggle { width: 48px; height: 26px; border-radius: 14px; background: #333; position: relative; transition: .2s; }
.toggle.on { background: var(--good); }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on::after { left: 25px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

@media (max-width: 560px) {
  #screen-home .title { font-size: 38px; }
  .level-card { width: 100%; max-width: 340px; }
  .sub-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .target { width: 104px; height: 104px; }
  .target .label { font-size: 13px; max-width: 92px; }
}

/* ===== 账号列表 ===== */
.user-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.user-item { display: flex; align-items: center; gap: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; transition: .12s; }
.user-item.current { border-color: rgba(255,180,0,0.6); box-shadow: 0 0 14px rgba(255,180,0,0.15); }
.user-item:hover { background: rgba(255,255,255,0.05); }
.ava { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #ffd34d, #ff7a00); color: #1a1a1a; font-weight: 900; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.unfo { flex: 1; min-width: 0; }
.uname { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.uname .tag { font-size: 10px; background: var(--accent); color: #1a1a1a; padding: 1px 6px; border-radius: 8px; font-weight: 700; }
.umeta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn.mini { padding: 7px 14px; font-size: 13px; border-radius: 9px; flex-shrink: 0; }

/* ===== 弹层 ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(92vw, 400px); display: flex; flex-direction: column; gap: 14px; }
.modal-title { font-size: 18px; font-weight: 800; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { padding: 10px 18px; font-size: 14px; }
.mfield { display: flex; flex-direction: column; gap: 6px; }
.mfield label { font-size: 12px; color: var(--muted); }
.mfield input { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; color: var(--text); }

/* ===== 排行榜 ===== */
.rank-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.rank-tab { padding: 8px 18px; border-radius: 20px; background: var(--panel2); color: var(--muted); font-size: 14px; font-weight: 700; border: 1px solid var(--line); }
.rank-tab.active { background: var(--accent); color: #1a1a1a; border-color: transparent; }
.rank-list { width: min(94vw, 640px); display: flex; flex-direction: column; gap: 8px; }
.rank-item { display: flex; align-items: center; gap: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.rank-item.current { border-color: rgba(255,180,0,0.6); background: rgba(255,180,0,0.08); }
.rank-item .rk { font-size: 22px; font-weight: 900; width: 40px; text-align: center; flex-shrink: 0; }
.rnk-info { flex: 1; min-width: 0; }
.rnk-val { font-size: 20px; font-weight: 900; color: var(--accent); }
.rnk-val span { font-size: 12px; color: var(--muted); margin-left: 2px; }

/* ===== 词库分类 ===== */
.lib-panels { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; width: min(94vw, 900px); }
.lib-card { flex: 1 1 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.lib-card h3 { font-size: 16px; margin-bottom: 14px; }
.lib-bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-name { width: 80px; font-size: 13px; color: var(--text); flex-shrink: 0; }
.bar { flex: 1; height: 14px; background: rgba(255,255,255,0.08); border-radius: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 7px; }
.bar-num { width: 44px; text-align: right; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.lib-note { margin-top: 18px; width: min(94vw, 640px); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ===== 错题分类筛选 ===== */
.wrong-filter { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wtag { padding: 5px 13px; border-radius: 16px; background: var(--panel2); color: var(--muted); font-size: 13px; border: 1px solid var(--line); }
.wtag.active { background: var(--accent); color: #1a1a1a; border-color: transparent; font-weight: 700; }
.pos-tag { font-size: 11px; color: var(--accent); background: rgba(255,180,0,0.12); border-radius: 8px; padding: 1px 7px; margin-left: 6px; }

