:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --left-primary: #ff5a36;
  --left-dark: #dc3a17;
  --left-soft: #fff2ee;
  --left-border: #ffc9ba;

  --right-primary: #2563eb;
  --right-dark: #1d4ed8;
  --right-soft: #eff6ff;
  --right-border: #bfdbfe;

  --green: #10b981;
  --green-dark: #059669;
  --amber: #f59e0b;
  --amber-dark: #d97706;
  --danger: #ef4444;

  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font-main: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.app-root {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  display: none;
  width: 100%;
}

.screen.active {
  display: flex;
}

/* ==================== 通用按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, background 0.15s ease;
  user-select: none;
}

.btn:active {
  transform: translateY(2px);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 6px 0 #1e40af, 0 10px 20px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #1e40af;
}

.btn-amber {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #451a03;
  box-shadow: 0 5px 0 #d97706;
}

.btn-amber:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #d97706;
}

.btn-soft {
  background: #ffffff;
  color: var(--text);
  border: 2px solid var(--border);
  box-shadow: 0 3px 0 #cbd5e1;
}

.btn-soft:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.9rem;
  border-radius: 12px;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 1.12rem;
  border-radius: 16px;
}

.btn-hero {
  padding: 16px 42px;
  font-size: clamp(1.15rem, 1.8vw, 1.45rem);
  border-radius: 18px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--right-primary);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.92rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

/* ==================== 1. 赛前设置页面 ==================== */
.screen-setup {
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(14px, 2vw, 26px) clamp(16px, 3vw, 40px);
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand h1 {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill-count {
  background: #e0f2fe;
  color: #0369a1;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.setup-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.players-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  background: linear-gradient(90deg, #fff6f3 0%, #ffffff 45%, #ffffff 55%, #f2f7ff 100%);
}

.player-setup-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-setup-box.right {
  justify-content: flex-end;
}

.mascot {
  flex-shrink: 0;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mascot-left {
  background: #ffe4dc;
}

.mascot-right {
  background: #dbeafe;
}

.player-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  max-width: 280px;
}

.player-setup-box.right .player-input-wrap {
  align-items: flex-end;
}

.team-tag {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  width: fit-content;
}

.team-tag.left {
  background: #ffe4dc;
  color: var(--left-dark);
}

.team-tag.right {
  background: #dbeafe;
  color: var(--right-dark);
}

.player-input-wrap input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.player-setup-box.left input:focus {
  border-color: var(--left-primary);
}

.player-setup-box.right input {
  text-align: right;
}

.player-setup-box.right input:focus {
  border-color: var(--right-primary);
}

.vs-center-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.vs-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.28);
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.setting-group {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-group h2 {
  font-size: 1.08rem;
  font-weight: 800;
  color: #0f172a;
}

.option-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  flex: 1 1 175px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  padding: 11px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s ease;
}

.pill small {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.pill:hover {
  border-color: #93c5fd;
  background: #ffffff;
}

.pill.active {
  border-color: var(--right-primary);
  background: #eff6ff;
  color: #1e40af;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.pill.active small {
  color: #3b82f6;
}

.option-pills.compact .pill {
  flex: 0 1 auto;
  padding: 8px 14px;
  font-size: 0.92rem;
}

.sub-setting-row,
.sub-setting-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.sub-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.tip-box {
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  color: #166534;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  margin-top: auto;
}

.setup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 20px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}

.setup-summary {
  font-size: 0.98rem;
  font-weight: 700;
  color: #334155;
}

/* ==================== 2. 课堂大屏双人 PK 战场 ==================== */
.screen-arena {
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  background: #eef2f8;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  position: relative;
}

.arena-topbar {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 34%) 1fr;
  align-items: center;
  gap: clamp(8px, 1.5vw, 18px);
  padding: clamp(8px, 1.2vh, 14px) clamp(12px, 1.8vw, 24px);
  background: #ffffff;
  border-bottom: 2px solid #e2e8f0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  z-index: 5;
  flex-shrink: 0;
}

.player-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 18px;
}

.player-hud.left {
  background: var(--left-soft);
  border: 2px solid var(--left-border);
}

.player-hud.right {
  background: var(--right-soft);
  border: 2px solid var(--right-border);
  justify-content: flex-end;
}

.hud-avatar {
  width: clamp(40px, 4.2vw, 54px);
  height: clamp(40px, 4.2vw, 54px);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  background: #ffffff;
  flex-shrink: 0;
}

.hud-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.hud-info.right {
  align-items: flex-end;
}

.hud-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-name-row.right {
  justify-content: flex-end;
}

.hud-name {
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.hud-sub {
  font-size: clamp(0.78rem, 1vw, 0.9rem);
  font-weight: 700;
  color: var(--text-muted);
}

.combo-badge {
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  animation: popIn 0.2s ease;
}

.hud-score-box {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 6px 14px;
  border-radius: 14px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.hud-score-box.left {
  background: var(--left-primary);
}

.hud-score-box.right {
  background: var(--right-primary);
}

.hud-score {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  font-weight: 900;
  line-height: 1;
}

.hud-unit {
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0.92;
}

.arena-center-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.teacher-mini-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-btn {
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.mini-btn:hover {
  background: #e2e8f0;
}

.arena-clock {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  line-height: 1.1;
}

.arena-clock.urgent {
  color: #ef4444;
  animation: pulseUrgent 0.7s infinite alternate;
}

/* 视觉赛道 / 拔河进度条 */
.visual-track-wrap {
  width: 100%;
}

.tug-bar {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: visible;
  display: flex;
  border: 2px solid #cbd5e1;
}

.tug-fill-left {
  height: 100%;
  background: linear-gradient(90deg, #ff5a36, #fb923c);
  border-radius: 999px 0 0 999px;
  transition: width 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tug-fill-right {
  height: 100%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  border-radius: 0 999px 999px 0;
  flex: 1;
}

.tug-knot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #facc15;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
  transition: left 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sprint-tracks {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.sprint-lane {
  position: relative;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.sprint-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.sprint-fill.left {
  background: linear-gradient(90deg, #fb923c, #ff5a36);
}

.sprint-fill.right {
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}

/* 同题抢答横幅 */
.shared-question-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: clamp(8px, 1.2vh, 14px) 20px;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-bottom: 2px solid #fde68a;
  flex-shrink: 0;
}

.shared-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shared-hint {
  font-size: 0.95rem;
  font-weight: 800;
  color: #b45309;
}

.screen-arena.mode-race .question-card {
  min-height: clamp(64px, 11vh, 105px);
  padding: 8px 14px;
}

.equation-display.side-status {
  font-size: clamp(1.35rem, 2.5vw, 2.1rem);
  color: #475569;
}

.equation-display.shared {
  font-size: clamp(2.3rem, 4.6vw, 4.2rem);
}

/* 主双人对战区 */
.arena-playfield {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  padding: clamp(10px, 1.5vh, 18px) clamp(10px, 1.6vw, 22px);
  gap: 0;
}

.side-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.5vh, 16px);
  padding: clamp(12px, 1.6vw, 20px);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
}

.side-panel.left {
  border: 3px solid var(--left-border);
  background: linear-gradient(180deg, #fffaf8 0%, #ffffff 38%);
}

.side-panel.right {
  border: 3px solid var(--right-border);
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 38%);
}

.arena-divider {
  width: clamp(16px, 2.2vw, 34px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}

.divider-line {
  flex: 1;
  width: 3px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    to bottom,
    #cbd5e1 0px,
    #cbd5e1 8px,
    transparent 8px,
    transparent 16px
  );
}

.divider-tag {
  writing-mode: vertical-rl;
  font-size: 0.72rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.14em;
}

/* 题目展示卡片 */
.question-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(12px, 1.8vh, 22px) 16px;
  border-radius: 20px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  min-height: clamp(115px, 22vh, 200px);
  flex-shrink: 0;
}

.question-card.left {
  background: #fff6f3;
  border-color: #ffd7cb;
}

.question-card.right {
  background: #f2f7ff;
  border-color: #cfe2ff;
}

.q-meta-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.q-badge {
  font-size: 0.88rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}

.q-badge.left {
  background: #ffe1d7;
  color: var(--left-dark);
}

.q-badge.right {
  background: #dbeafe;
  color: var(--right-dark);
}

.q-sub-meta {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.equation-display {
  font-size: clamp(2.4rem, 4.8vw, 4.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.2em;
  line-height: 1.15;
}

.blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55em;
  padding: 0 0.25em;
  height: 1.25em;
  border-radius: 14px;
  border: 3px dashed #94a3b8;
  background: #ffffff;
  color: #2563eb;
}

.blank-slot.filled {
  border-style: solid;
  border-color: #2563eb;
  background: #eff6ff;
}

.blank-slot.left-slot.filled {
  border-color: var(--left-primary);
  color: var(--left-dark);
  background: #fff5f2;
}

.feedback-toast {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 1.15rem;
  font-weight: 900;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.18s ease;
}

.feedback-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback-toast.ok {
  color: var(--green-dark);
}

.feedback-toast.err {
  color: var(--danger);
}

/* 输入按钮区（占下部大面积，方便小学生够到） */
.input-zone {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.choices-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: clamp(10px, 1.5vw, 20px);
}

.choice-btn {
  width: 100%;
  height: 100%;
  min-height: 76px;
  border: 3px solid #cbd5e1;
  border-radius: 22px;
  background: #ffffff;
  color: #0f172a;
  font-family: inherit;
  font-size: clamp(2.1rem, 4.4vw, 3.8rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: 0 7px 0 #cbd5e1, 0 8px 18px rgba(15, 23, 42, 0.08);
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.12s ease, border-color 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.side-panel.left .choice-btn {
  border-color: #fdba74;
  box-shadow: 0 7px 0 #fb923c, 0 8px 18px rgba(255, 90, 54, 0.1);
}

.side-panel.right .choice-btn {
  border-color: #93c5fd;
  box-shadow: 0 7px 0 #60a5fa, 0 8px 18px rgba(37, 99, 235, 0.1);
}

.choice-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #94a3b8 !important;
}

.choice-btn.is-correct {
  background: #10b981 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 0 #047857 !important;
}

.choice-btn.is-wrong {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 0 #b91c1c !important;
}

/* 数字键盘模式 */
.keypad-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(8px, 1.2vw, 14px);
}

.key-btn {
  width: 100%;
  height: 100%;
  min-height: 52px;
  border: 2.5px solid #cbd5e1;
  border-radius: 18px;
  background: #ffffff;
  color: #0f172a;
  font-family: inherit;
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: 0 5px 0 #cbd5e1;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.key-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #94a3b8;
}

.key-btn.key-backspace {
  background: #fff7ed;
  border-color: #fdba74;
  color: #c2410c;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  box-shadow: 0 5px 0 #fb923c;
}

.key-btn.key-submit {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #047857;
  color: #ffffff;
  font-size: clamp(1.15rem, 2.1vw, 1.65rem);
  box-shadow: 0 5px 0 #065f46;
}

/* 冷却锁遮罩 */
.cooldown-overlay {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background: rgba(254, 242, 242, 0.84);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  border: 2.5px dashed #fca5a5;
}

.cooldown-text {
  background: #ffffff;
  color: #dc2626;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.16);
}

.side-panel.shake {
  animation: panelShake 0.36s ease;
}

/* 全屏遮罩：倒计时 & 暂停 */
.arena-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.countdown-box {
  text-align: center;
  color: #ffffff;
}

.countdown-players {
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  font-weight: 800;
  color: #fde047;
  margin-bottom: 10px;
}

.countdown-num {
  font-size: clamp(5rem, 14vw, 10rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  animation: popIn 0.35s ease;
}

.countdown-tip {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  margin-top: 16px;
  opacity: 0.92;
}

.pause-box {
  background: #ffffff;
  border-radius: 28px;
  padding: 34px 42px;
  text-align: center;
  max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.pause-box h2 {
  font-size: 1.8rem;
  font-weight: 900;
}

.pause-box p {
  color: var(--text-muted);
  margin: 8px 0 24px;
}

.pause-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* ==================== 3. 赛后颁奖与错题讲评 ==================== */
.screen-result {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(16px, 2.5vw, 32px);
  justify-content: center;
  overflow-y: auto;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.result-container {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 1120px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.result-hero {
  text-align: center;
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 55%, #eff6ff 100%);
  border-radius: 26px;
  padding: 24px 20px;
  box-shadow: var(--shadow-card);
  border: 2px solid #fde68a;
}

.result-trophy {
  font-size: 3.4rem;
  line-height: 1.1;
}

.result-hero h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 900;
  margin-top: 6px;
  color: #0f172a;
}

.result-hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  background: #ffffff;
  border-radius: 22px;
  padding: 18px 22px;
  box-shadow: var(--shadow-card);
  border: 2.5px solid var(--border);
}

.stat-card.left {
  border-color: var(--left-border);
}

.stat-card.right {
  border-color: var(--right-border);
}

.stat-card.winner {
  box-shadow: 0 12px 30px rgba(245, 158, 11, 0.22);
  border-color: #fbbf24;
}

.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-player-name {
  font-size: 1.25rem;
  font-weight: 900;
}

.winner-crown {
  background: #fef3c7;
  color: #b45309;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
}

.stat-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.metric-box {
  background: #f8fafc;
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
}

.metric-val {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.metric-lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* 错题讲评区 */
.mistake-review-card {
  padding: 20px 22px;
}

.mistake-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.mistake-header h3 {
  font-size: 1.18rem;
  font-weight: 900;
}

.mistake-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.mistake-filters {
  display: flex;
  gap: 8px;
}

.filter-pill {
  border: 1.5px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-pill.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.mistake-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 4px;
}

.mistake-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 26px;
  background: #f0fdf4;
  border-radius: 16px;
  color: #166534;
  font-weight: 800;
  font-size: 1.05rem;
}

.mistake-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
}

.mistake-left-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mistake-team-pill {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  width: fit-content;
}

.mistake-team-pill.left {
  background: #ffe4dc;
  color: var(--left-dark);
}

.mistake-team-pill.right {
  background: #dbeafe;
  color: var(--right-dark);
}

.mistake-eq {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.mistake-ans-row {
  font-size: 0.85rem;
  font-weight: 700;
}

.wrong-txt {
  color: #dc2626;
  margin-right: 10px;
}

.right-txt {
  color: #059669;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-bottom: 12px;
}

/* ==================== 4 & 5. 弹窗与竖式讲解 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-card.modal-explain {
  max-width: 760px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1.5px solid var(--border);
}

.modal-header h3 {
  font-size: 1.18rem;
  font-weight: 900;
}

.btn-close {
  border: none;
  background: #f1f5f9;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.modal-body {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
}

#roster-textarea {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--border);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
}

.roster-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  margin-left: auto;
  cursor: pointer;
}

.roster-pool-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  background: #f8fafc;
  border-top: 1.5px solid var(--border);
}

/* 黑板竖式组件 */
.explain-banner {
  font-size: 1.6rem;
  font-weight: 900;
  text-align: center;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
}

.explain-conversion {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.96rem;
}

.explain-content-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

.chalkboard-panel {
  background: #14532d;
  border: 6px solid #b45309;
  border-radius: 18px;
  padding: 14px 16px 18px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chalkboard-label {
  font-size: 0.8rem;
  color: #bbf7d0;
  margin-bottom: 8px;
  letter-spacing: 0.1em;
}

.vertical-board {
  font-size: 2.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.vb-grid {
  display: grid;
  grid-template-columns: 36px repeat(3, 44px);
  align-items: center;
  justify-items: center;
}

.vb-grid.cols-2 {
  grid-template-columns: 36px repeat(2, 48px);
}

.vb-mark-row {
  font-size: 0.95rem;
  height: 22px;
  color: #fde047;
}

.vb-borrow-dot {
  color: #fb7185;
  font-size: 1.3rem;
  line-height: 1;
}

.vb-carry-badge {
  color: #fb923c;
  font-size: 1rem;
  font-weight: 900;
}

.vb-line {
  grid-column: 1 / -1;
  width: 100%;
  height: 3px;
  background: #ffffff;
  margin: 6px 0;
  border-radius: 3px;
}

.vb-result-cell {
  color: #fde047;
}

.steps-panel {
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px 18px;
  border: 1.5px solid var(--border);
}

.steps-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.explain-steps {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.5;
  color: #1e293b;
}

/* ==================== 动画与响应式 ==================== */
@keyframes popIn {
  0% {
    transform: scale(0.75);
    opacity: 0.4;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pulseUrgent {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

@keyframes panelShake {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  45% {
    transform: translateX(8px);
  }
  70% {
    transform: translateX(-5px);
  }
}

@media (max-width: 960px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
  .players-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .player-setup-box,
  .player-setup-box.right {
    justify-content: center;
  }
  .player-setup-box.right .player-input-wrap {
    align-items: flex-start;
  }
  .player-setup-box.right input {
    text-align: left;
  }
  .result-stats-grid,
  .explain-content-grid {
    grid-template-columns: 1fr;
  }
  .arena-topbar {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .arena-center-hud {
    grid-column: 1 / -1;
    order: -1;
  }
}
