:root {
  --bg: #f0f4f8;
  --bg-soft: #e8eef5;
  --card: #ffffff;
  --card-2: #fafbfc;
  --text: #1a202c;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --good: #10b981;
  --good-bg: rgba(16, 185, 129, 0.12);
  --line: #e2e8f0;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%) fixed;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 760px;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

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

.logo {
  font-size: 22px;
}

.brand h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 1px;
  font-weight: 700;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(59, 130, 246, 0.08);
}

/* Stage */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Round header */
.round-head {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pick-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 112px;
  flex-shrink: 0;
  padding: 6px 14px;
  background: #ffffff;
  color: #1d4ed8;
  border: 1px solid #3b82f6;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-sizing: border-box;
}

.counter-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 18px;
}

.pc-num {
  flex: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.round-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}

.round-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(99, 102, 241, 0.12));
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
}

.progress {
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* Match card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px;
}

.card-title {
  text-align: center;
  font-size: 17px;
  color: var(--muted);
  margin: 0 0 6px;
  letter-spacing: 1px;
}

.card-sub {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 22px;
  opacity: 0.7;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.choice {
  position: relative;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 16px;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.choice:focus,
.choice:focus-visible {
  outline: none;
}

.choice:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.12);
}

/* 新卡片渲染后先禁用 hover，避免鼠标停留位置残留蓝色 hover 框；
   鼠标真正移动后才恢复 hover 反馈 */
body.freeze-hover .choice:hover {
  border-color: var(--line);
  background: var(--card-2);
  transform: none;
  box-shadow: none;
}

.choice:active {
  transform: translateY(0);
}

.choice.selected {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  cursor: default;
  transform: none;
  box-shadow: none;
}

.choice .seed {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
}

/* Advanced list */
.advanced {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.advanced-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--good-bg);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #059669;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
}

/* Champion card & final bracket */
.champion-card {
  padding: 22px 18px;
}

.champion-title {
  text-align: center;
  font-size: 22px;
  margin: 0 0 18px;
  font-weight: 700;
}

.bracket-final {
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 16px 0;
}

.bracket-side {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex-shrink: 0;
}

.bf-col {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  align-self: stretch;
  min-width: 88px;
}

/* 列内：space-around 让每对/每场垂直居中分布，
   配对中心与下一列节点中心水平对齐；
   space-around 在每对上下产生的空白即"空行" */
.bf-col-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
}

.bf-match {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card-2);
  padding: 4px 8px;
}

.bf-p {
  padding: 2px 2px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
}

.bf-p.winner {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
  font-weight: 600;
}

/* 配对：space-around 使两节点中心精确落在 25% / 75%，
   上下各留空行，中点(50%)对齐下一列节点。
   不设 min-height:0 —— 让 pair 保持内容最小高度，
   使最密的列(小组赛)撑开总高，其余列 stretch 对齐 */
.bf-pair {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
}

/* === 左侧连接线（向右指向中心） === */
.bracket-left .bf-col { padding: 0 22px 0 0; }

/* 1to1：每场一条直横线到下一列 */
.bracket-left .conn-1to1 .bf-match::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  width: 22px;
  border-top: 2px solid var(--line);
  transform: translateY(-1px);
}

/* 2to1：每场横线 + 配对竖线（连接两场）+ 中点出头到下一列 */
.bracket-left .conn-2to1 .bf-match::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  width: 11px;
  border-top: 2px solid var(--line);
  transform: translateY(-1px);
}
.bracket-left .conn-2to1 .bf-pair::after {
  content: '';
  position: absolute;
  left: calc(100% + 11px);
  top: 25%;
  bottom: 25%;
  border-left: 2px solid var(--line);
}
.bracket-left .conn-2to1 .bf-pair::before {
  content: '';
  position: absolute;
  left: calc(100% + 11px);
  top: 50%;
  width: 11px;
  border-top: 2px solid var(--line);
  transform: translateY(-1px);
}

/* === 右侧连接线（向左指向中心） === */
.bracket-right .bf-col { padding: 0 0 0 22px; }

.bracket-right .conn-1to1 .bf-match::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  width: 22px;
  border-top: 2px solid var(--line);
  transform: translateY(-1px);
}

.bracket-right .conn-2to1 .bf-match::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  width: 11px;
  border-top: 2px solid var(--line);
  transform: translateY(-1px);
}
.bracket-right .conn-2to1 .bf-pair::before {
  content: '';
  position: absolute;
  right: calc(100% + 11px);
  top: 25%;
  bottom: 25%;
  border-right: 2px solid var(--line);
}
.bracket-right .conn-2to1 .bf-pair::after {
  content: '';
  position: absolute;
  right: calc(100% + 11px);
  top: 50%;
  width: 11px;
  border-top: 2px solid var(--line);
  transform: translateY(-1px);
}

/* 中间冠军（高亮） */
.bf-center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 110px;
  padding: 0 12px;
  flex-shrink: 0;
}

.bf-champion {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

/* Footer */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 28px;
  opacity: 0.7;
}

.stages {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  white-space: nowrap;
}

.stage-item {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.stage-sep {
  color: var(--muted);
  font-size: 12px;
  opacity: 0.5;
}

/* Enter animation */
.card, .advanced {
  animation: rise 0.3s ease;
}

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

@media (max-width: 480px) {
  .choice { font-size: 17px; padding: 22px 10px; min-height: 72px; }
  .bf-col { min-width: 72px; }
  .bf-center { min-width: 110px; padding: 12px; }
  .bf-match .bf-p { padding: 6px 8px; font-size: 12px; }
  .bf-match.group .bf-p { font-size: 10px; padding: 2px 1px; }
  .bf-champion { font-size: 16px; }
  .brand h1 { font-size: 17px; }
}