:root {
  --bg-1: #0f1226;
  --bg-2: #1b1f3a;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f7ff;
  --text-dim: #a7adcf;
  --accent: #5b8cff;
  --accent-2: #7b68ee;
  --good: #2ecc71;
  --bad: #ff5c5c;
  --warn: #f5b942;
  --violet: #b06bff;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 700px at 20% -10%, #2a3263 0%, var(--bg-1) 55%) fixed, var(--bg-1);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
.hidden { display: none !important; }
.center-flex { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }

/* 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.card.wide { max-width: 960px; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: 1px; background: linear-gradient(90deg, var(--accent), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { display: block; font-size: 13px; font-weight: 500; color: var(--text-dim); letter-spacing: 3px; -webkit-text-fill-color: var(--text-dim); }
.subtitle { color: var(--text-dim); margin: 8px 0 20px; font-size: 14px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: 12px; font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: 0 6px 18px rgba(91, 140, 255, 0.35);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--panel-strong); box-shadow: none; border: 1px solid var(--line); }
.btn.big { padding: 18px 30px; font-size: 20px; }
.btn.good { background: linear-gradient(135deg, #2ecc71, #27ae60); box-shadow: 0 6px 18px rgba(46, 204, 113, 0.3); }
.btn.bad { background: linear-gradient(135deg, #ff5c5c, #d63b3b); box-shadow: 0 6px 18px rgba(255, 92, 92, 0.3); }
.btn.warn { background: linear-gradient(135deg, var(--warn), #e29a1f); box-shadow: 0 6px 18px rgba(245, 185, 66, 0.3); }

/* 输入框 */
.field {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08); color: var(--text); font-size: 17px; text-align: center; outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.25); }

/* 顶部状态条 */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px; background: rgba(15, 18, 38, 0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .name { font-weight: 700; }
.topbar .score { color: var(--text-dim); font-size: 14px; }
.chip { padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--panel-strong); border: 1px solid var(--line); }
.chip.good { color: #7ef0ae; border-color: rgba(46,204,113,.4); }
.chip.bad { color: #ff9c9c; border-color: rgba(255,92,92,.4); }
.chip.warn { color: #ffd97e; border-color: rgba(245,185,66,.4); }

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

/* 题目 */
.q-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.q-text { font-size: 22px; font-weight: 800; line-height: 1.5; margin-bottom: 22px; min-height: 66px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt {
  padding: 18px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  font-size: 16px; font-weight: 600; transition: all .12s ease; position: relative; overflow: hidden;
}
.opt .key { display: inline-block; width: 26px; height: 26px; line-height: 26px; border-radius: 8px; background: var(--panel-strong); font-size: 13px; margin-right: 8px; font-weight: 800; }
.opt:active { transform: scale(0.97); }
.opt.picked { border-color: var(--accent); background: rgba(91,140,255,.22); }
.opt.correct { border-color: var(--good); background: rgba(46,204,113,.22); }
.opt.wrong { border-color: var(--bad); background: rgba(255,92,92,.22); }
.opt:disabled { opacity: 0.55; cursor: not-allowed; }

/* 大字屏状态 */
.state-box { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.state-box .icon { font-size: 52px; }
.state-box h2 { font-size: 24px; }
.big-word { font-size: 72px; font-weight: 900; letter-spacing: 8px; margin: 10px 0 24px; }
.big-number { font-size: 74px; font-weight: 900; letter-spacing: 12px; font-variant-numeric: tabular-nums; }
.go-circle {
  width: 200px; height: 200px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; transition: background .15s ease, transform .1s ease; user-select: none; -webkit-user-select: none;
}
.go-circle.ready { background: rgba(255,92,92,.25); border: 4px solid var(--bad); color: #ffb3b3; }
.go-circle.go { background: rgba(46,204,113,.3); border: 4px solid var(--good); color: #b8ffd8; animation: pulse 0.5s infinite alternate; }
.go-circle.tapped { background: rgba(91,140,255,.25); border-color: var(--accent); color: #cfe0ff; animation: none; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.05); } }

/* 数字键盘 */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.keypad button { padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 22px; font-weight: 800; }
.keypad button:active { transform: scale(0.95); background: var(--panel-strong); }
.keypad button.func { background: var(--panel-strong); color: var(--text-dim); font-size: 16px; }
.answer-display { min-height: 52px; font-size: 30px; font-weight: 900; letter-spacing: 8px; padding: 8px; border-bottom: 2px solid var(--line); margin-bottom: 6px; }

/* 结果浮层 */
.result-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(10,12,28,.78); backdrop-filter: blur(6px); padding: 20px; text-align: center; }
.result-box { padding: 30px 40px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.result-box .r-icon { font-size: 64px; }
.result-box h2 { font-size: 30px; margin: 10px 0 6px; }
.result-box.ok h2 { color: #7ef0ae; }
.result-box.no h2 { color: #ff9c9c; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 大屏 */
.screen { min-height: 100vh; padding: 26px 30px; display: flex; flex-direction: column; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.screen-title { font-size: 30px; font-weight: 900; }
.screen-title small { display: block; font-size: 14px; color: var(--text-dim); font-weight: 500; }
.screen-count { font-size: 18px; color: var(--text-dim); }
.screen-count strong { color: var(--accent); font-size: 28px; margin-right: 4px; }
.screen-main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.big-q { font-size: 40px; font-weight: 900; line-height: 1.4; text-align: center; }
.big-q .trial { display: block; font-size: 18px; color: var(--text-dim); font-weight: 600; margin-bottom: 12px; }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 26px; height: 300px; padding: 0 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 110px; }
.bar-track { width: 100%; height: 240px; background: rgba(255,255,255,.06); border-radius: 12px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-fill { width: 100%; border-radius: 12px; transition: height .2s ease; background: linear-gradient(180deg, var(--accent), var(--violet)); min-height: 0; }
.bar-fill.hot { background: linear-gradient(180deg, var(--warn), #ff5c5c); }
.bar-label { font-size: 17px; font-weight: 800; }
.bar-num { font-size: 26px; font-weight: 900; }
.elim-ticker { text-align: center; color: #ffb3b3; font-size: 20px; font-weight: 700; min-height: 32px; }
.elim-ticker span { display: inline-block; margin: 0 10px; }
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.match-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 18px; font-weight: 700; }
.match-card .vs { color: var(--bad); font-weight: 900; font-size: 15px; }
.rank-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.rank-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 17px; }
.rank-row .no { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 900; background: var(--panel-strong); }
.rank-row.top { border-color: rgba(245,185,66,.55); background: rgba(245,185,66,.12); }
.rank-row.advance { border-color: rgba(91,140,255,.5); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 26px; margin: 30px 0; }
.podium .p { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.podium .p .avatar { width: 84px; height: 84px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--violet)); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; border: 3px solid var(--line); }
.podium .p .avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.podium .p.one .avatar { width: 110px; height: 110px; font-size: 34px; border-color: var(--warn); box-shadow: 0 0 40px rgba(245,185,66,.5); }
.podium .p .name { font-weight: 800; font-size: 18px; }
.podium .p .score { color: var(--text-dim); font-size: 14px; }
.podium .p .medal { font-size: 34px; }

/* 主持台 */
.admin { max-width: 620px; margin: 0 auto; padding: 24px 16px; }
.admin h1 { font-size: 24px; margin-bottom: 4px; }
.admin .phase { display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 800; margin: 10px 0 18px; background: linear-gradient(135deg, var(--accent), var(--violet)); }
.admin .phase.wait { background: var(--panel-strong); color: var(--text-dim); }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.controls .btn { font-size: 15px; padding: 15px 10px; }
.controls .span2 { grid-column: span 2; }
.admin-log { margin-top: 18px; background: rgba(0,0,0,.35); border-radius: 12px; padding: 12px; font-size: 13px; color: #9fb0d8; max-height: 240px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.stat-row { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.stat { flex: 1; min-width: 90px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 26px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--text-dim); }

/* 动画 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .4s ease both; }
@keyframes blink { 50% { opacity: .4; } }
.blink { animation: blink 1s infinite; }
.qr-box { background: #fff; padding: 16px; border-radius: 16px; display: inline-block; }
.qr-box img { width: 260px; height: 260px; display: block; }

/* 底部滚动排名条 */
.rank-ticker {
  position: fixed; left: 0; right: 0; bottom: 0; height: 46px;
  background: rgba(12, 15, 34, 0.9); border-top: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden; display: flex; align-items: center; z-index: 60;
}
.rank-ticker.hidden { display: none; }
.rank-ticker-track { display: inline-flex; white-space: nowrap; animation: ticker-scroll 40s linear infinite; will-change: transform; }
.rank-ticker-track span { padding: 0 20px; font-size: 17px; color: var(--text-dim); }
.rank-ticker-track span b { color: var(--text); font-weight: 700; }
.rank-ticker-track span.gold b { color: #ffd54a; }
.rank-ticker-track span.dead { opacity: 0.4; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* 海选环节区（大屏上部）：轮次/题目进度/统一题展示 */
.stage {
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px; padding: 16px 26px;
  display: flex; align-items: center; justify-content: center; gap: 20px;
  min-height: 96px;
}
.stage .icon { font-size: 44px; line-height: 1; }
.stage-text { text-align: center; }
.stage-text h2 { font-size: 30px; margin: 0; }
.stage-text .subtitle { margin: 6px 0 0; font-size: 17px; }
.stage .progress { font-size: 17px; color: var(--text-dim); margin-top: 8px; }
.stage .progress b { color: var(--accent); font-size: 24px; }
.stage-summary { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

/* 中央实时滚动排名榜（海选主视觉，两列紧凑展示全部玩家） */
.rank-board {
  flex: 1; min-height: 0; overflow: hidden;
  column-count: 2; column-gap: 14px;
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px; padding: 10px 14px;
}
.board-empty { color: var(--text-dim); font-size: 22px; text-align: center; padding: 40px 0; column-span: all; }
.rank-board .rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 3px 10px; border-radius: 8px;
  font-size: 14px; line-height: 1.2; break-inside: avoid;
}
.rank-board .rank-row:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.rank-board .rank-row .no { width: 34px; font-weight: 800; color: var(--text-dim); flex: none; }
.rank-board .rank-row .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-board .rank-row .score { color: var(--text-dim); flex: none; }
.rank-board .rank-row.top { background: linear-gradient(90deg, rgba(255, 213, 74, 0.16), transparent); }
.rank-board .rank-row.top .no { color: #ffd54a; }
.rank-board .rank-row.dead { opacity: 0.45; }
.rank-board .rank-row.rise { animation: rank-flash 1.2s ease; background: rgba(46, 204, 113, 0.18); }
.rank-board .rank-row.fall { animation: rank-flash 1.2s ease; background: rgba(255, 92, 92, 0.14); }
.rank-board .rank-row.new { animation: rank-new 0.8s ease; }
@keyframes rank-flash { from { background-color: rgba(46, 204, 113, 0.35); } to { background-color: transparent; } }
@keyframes rank-new { from { transform: scale(1.08); } to { transform: scale(1); } }

/* 问早热身（大屏） */
.greet-screen { text-align: center; padding: 10px 0; }
.greet-brand { font-size: 30px; font-weight: 900; color: #ffd54a; letter-spacing: 4px; }
.greet-line { font-size: 52px; font-weight: 900; margin: 22px 0 6px; line-height: 1.35; }
.greet-call { font-size: 24px; color: var(--accent); margin-bottom: 18px; }
.greet-bar { max-width: 760px; margin: 0 auto; height: 34px; border-radius: 17px; background: rgba(255, 255, 255, 0.08); overflow: hidden; display: flex; align-items: center; }
.greet-bar-fill { height: 100%; width: 0; border-radius: 17px; background: linear-gradient(90deg, #ffd54a, #ff9f43); transition: width .3s ease; font-size: 16px; font-weight: 800; display: flex; align-items: center; justify-content: center; color: #1a1a2e; }
.greet-bar-fill.full { background: linear-gradient(90deg, #2ecc71, #f1c40f); }
.greet-count { font-size: 26px; font-weight: 800; color: #ffd54a; margin-top: 10px; }
.voice-board { margin-top: 16px; }
.voice-title { font-size: 22px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px; }
.voice-bars { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
.voice-row { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.voice-name { width: 200px; text-align: right; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-track { flex: 1; height: 22px; background: rgba(255, 255, 255, 0.08); border-radius: 11px; overflow: hidden; }
.voice-fill { height: 100%; border-radius: 11px; background: linear-gradient(90deg, var(--violet), var(--accent)); transition: width .25s ease; }
.voice-vol { width: 56px; font-weight: 800; color: var(--accent); }
.star-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* 问早热身（玩家端） */
.greet-line { font-size: 30px; margin: 14px 0 4px; }
.greet-call { font-size: 16px; color: var(--accent); margin-bottom: 12px; }
.greet-btn { font-size: 22px; padding: 22px; border-radius: 18px; }
.greet-btn.greet-shout { background: linear-gradient(135deg, #ff9f43, #e74c3c); }
.greet-btn.pressed { transform: scale(0.96); filter: brightness(1.25); }
.greet-btn.done { background: var(--good); border: none; }

/* 淘汰弹幕墙（大屏） */
.danmaku-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 70; }
.danmaku {
  position: absolute; left: 100%; white-space: nowrap;
  font-size: 26px; font-weight: 800; color: #ff9c9c;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  animation: danmaku-fly linear forwards;
}
.danmaku-koi { color: #ffd54a; font-size: 30px; }
@keyframes danmaku-fly {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(calc(-100vw - 100%)); opacity: 0.9; }
}

/* 星光时刻（大屏收尾）：全员头像化作星空 */
.star-layer {
  position: fixed; inset: 0; z-index: 80; cursor: pointer;
  background: radial-gradient(1200px 700px at 50% 30%, #12183f 0%, #05060f 72%);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.star-field { position: absolute; inset: 0; }
.star {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transform: translate(-50%, -50%); opacity: 0;
  animation: star-rise 6s ease forwards;
}
.star-avatar {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  border: 2px solid rgba(255, 213, 74, 0.85);
  box-shadow: 0 0 18px rgba(255, 213, 74, 0.5), 0 0 42px rgba(91, 140, 255, 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #ffd54a;
  background: rgba(255, 255, 255, 0.06);
}
.star-avatar img { width: 100%; height: 100%; object-fit: cover; }
.star-avatar.fallback { background: linear-gradient(135deg, #2b3370, #1b1f3a); }
.star-name {
  font-size: 12px; color: rgba(245, 247, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); white-space: nowrap;
}
.star-head {
  position: absolute; top: 22px; left: 0; right: 0; text-align: center;
  font-size: 24px; font-weight: 800; color: #a7adcf; letter-spacing: 2px; z-index: 2;
}
.star-theme {
  position: relative; z-index: 3; text-align: center;
  font-size: 64px; font-weight: 900; color: #ffd54a;
  text-shadow: 0 0 30px rgba(255, 213, 74, 0.6), 0 4px 20px rgba(0, 0, 0, 0.6);
  letter-spacing: 6px; opacity: 0; transform: translateY(16px);
  transition: opacity 1.2s ease, transform 1.2s ease;
}
.star-sub {
  position: relative; z-index: 3; text-align: center;
  font-size: 30px; color: #f5f7ff; margin-top: 18px; letter-spacing: 3px;
  opacity: 0; transform: translateY(16px);
  transition: opacity 1.2s ease 0.3s, transform 1.2s ease 0.3s;
}
.star-tip {
  position: absolute; bottom: 18px; left: 0; right: 0; text-align: center;
  font-size: 14px; color: rgba(167, 173, 207, 0.7); z-index: 2;
}
.star-layer.theme-on .star-theme { opacity: 1; transform: translateY(0); }
.star-layer.theme-on .star-sub { opacity: 1; transform: translateY(0); }
@keyframes star-rise {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(40px) scale(0.6); }
  25% { opacity: 1; }
  60% { opacity: 1; transform: translate(-50%, -50%) translateY(-6px) scale(1); }
  100% { opacity: 0.55; transform: translate(-50%, -50%) translateY(-18px) scale(0.95); }
}
