/* ========== 双人 PK 模式 ========== */

.pk-container {
  max-width: 1600px;
  margin: 0 auto;
}

/* ---------- 顶部：返回 + 倒计时 ---------- */
.pk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.pk-header-placeholder { width: 92px; }

.pk-timer {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 26px;
  background: var(--bg-white);
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(45, 52, 54, 0.12);
  font-size: clamp(2rem, 3.4vw, 3rem);
  font-weight: 900;
  color: var(--text-dark);
}
.pk-timer-icon { font-size: 0.7em; }
.pk-timer-unit { font-size: 0.45em; color: var(--text-gray); font-weight: 800; }
.pk-timer.warning {
  color: var(--error);
  animation: pkBlink 1s ease-in-out infinite;
}
@keyframes pkBlink { 50% { opacity: 0.45; } }

/* ---------- 左右两个答题区 ---------- */
.pk-board {
  display: flex;
  gap: clamp(20px, 4vw, 90px);
  justify-content: center;
  align-items: stretch;
}
.pk-side {
  flex: 1;
  min-width: 0;
  max-width: 700px;
  background: var(--bg-white);
  border-radius: 24px;
  padding: 22px 20px;
  box-shadow: 0 14px 40px rgba(45, 52, 54, 0.14);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pk-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pk-name {
  flex: 1;
  min-width: 0;
  font-size: clamp(1.3rem, 2.2vw, 2.2rem);
  font-weight: 900;
  color: var(--primary-red);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 连击徽章 ---------- */
.pk-combo {
  /* 始终 inline-block 占一位，用 visibility 显隐 —— 出现时不再撑开行高（原来 display:none↔inline-block 会顶动下方键盘） */
  display: inline-block;
  visibility: hidden;
  padding: 4px 12px;
  font-size: clamp(0.85rem, 1.5vw, 1.5rem);
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #ff8a3d 0%, #ff5a7a 100%);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(255, 120, 90, 0.45);
  white-space: nowrap;
}
.pk-combo.show { visibility: visible; }
.pk-combo.pulse { animation: comboPulse 0.5s ease-out; }
@keyframes comboPulse {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

/* 连击越高，卡片光晕越夸张 */
.pk-side.combo-1 {
  box-shadow: 0 0 0 4px rgba(255, 180, 60, 0.55), 0 14px 40px rgba(255, 150, 60, 0.25);
}
.pk-side.combo-2 {
  box-shadow: 0 0 0 5px rgba(255, 140, 40, 0.7), 0 16px 46px rgba(255, 120, 40, 0.35);
  animation: comboGlow 1.2s ease-in-out infinite;
}
.pk-side.combo-3 {
  box-shadow: 0 0 0 6px rgba(255, 90, 120, 0.8), 0 18px 54px rgba(255, 90, 120, 0.45);
  animation: comboGlow 0.85s ease-in-out infinite;
}
@keyframes comboGlow {
  50% { box-shadow: 0 0 0 9px rgba(255, 165, 60, 0.85), 0 20px 60px rgba(255, 120, 60, 0.5); }
}
#pk-side-2 .pk-name { color: #2f88c5; }
.pk-correct {
  font-size: clamp(1rem, 1.6vw, 1.7rem);
  font-weight: 800;
  color: var(--success);
  white-space: nowrap;
}

.pk-question {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 10px;
  background: var(--bg-cream);
  border-radius: 18px;
  font-size: clamp(2.2rem, 4.4vw, 4.2rem);
  font-weight: 900;
}
.pk-question .pk-op,
.pk-question .pk-eq { color: var(--primary-teal); }
.pk-question .pk-ans { color: var(--warning); }

.pk-input {
  /* 固定高度（含内边距）：显示答案时高度不变，键盘位置稳定 */
  height: clamp(3rem, 5vw, 4.4rem);
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(1.6rem, 3vw, 2.8rem);
  font-weight: 900;
  color: var(--text-dark);
  background: var(--bg-light-blue);
  border-radius: 14px;
  word-break: break-all;
}
.pk-tip {
  /* 固定高度：提示文字（含 emoji/大字号连击）出现时不再改变布局，避免顶动下方键盘 */
  height: clamp(1.6rem, 2.8vw, 2.6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
  text-align: center;
  font-size: clamp(0.9rem, 1.4vw, 1.5rem);
  font-weight: 800;
}
.pk-tip.good { color: var(--success); }
.pk-tip.bad { color: var(--error); }
.pk-tip.combo {
  color: #ff8a3d;
  font-size: clamp(1rem, 1.9vw, 2rem);
  animation: tipPop 0.45s ease-out;
}
@keyframes tipPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- 数字键盘 ---------- */
.pk-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: auto;
}
.pk-key {
  padding: 15px 0;
  font-family: inherit;
  font-size: clamp(1.2rem, 2vw, 2rem);
  font-weight: 800;
  color: var(--text-dark);
  background: var(--bg-light-blue);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  touch-action: none;   /* 多点触碰：禁掉双击缩放/滑动手势，避免与多指按键竞争 */
  user-select: none;
  -webkit-user-select: none;
}
.pk-key:active,
.pk-key.is-down { transform: translateY(2px); background: #dbeafe; }
.pk-key.pk-ok {
  grid-column: span 3;
  color: #fff;
  background: var(--success);
}
.pk-key.pk-clear { color: var(--warning); }
.pk-key.pk-del { color: var(--error); }

/* ---------- 名字输入弹窗 ---------- */
.pk-name-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0;
}
.pk-name-field { display: flex; align-items: center; gap: 12px; }
.pk-name-field span {
  width: 4.5em;
  font-weight: 800;
  color: var(--text-gray);
}
.pk-name-field input {
  flex: 1;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
  border: 2px solid #dfe6ed;
  border-radius: 12px;
  outline: none;
}
.pk-name-field input:focus { border-color: var(--primary-teal); }

/* ---------- 开场倒计时 ---------- */
.pk-countdown {
  font-size: clamp(9rem, 22vw, 22rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  animation: pkCdPop 0.9s ease-out;
}
@keyframes pkCdPop {
  0% { transform: scale(0.35); opacity: 0; }
  35% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- 排行榜 ---------- */
.pk-rank-modal-body {
  margin: 10px 0 4px;
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
}
.pk-rank-head,
.pk-rank-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 10px;
}
.pk-rank-head {
  font-size: 0.9rem;
  font-weight: 800;
  color: #98a2b3;
  border-bottom: 2px solid #edf2f7;
  margin-bottom: 4px;
}
.pk-rank-row { font-size: 1.05rem; border-radius: 10px; }
.pk-rank-row:nth-child(odd) { background: #f4f8fc; }
.pk-rank-no { width: 34px; text-align: center; font-weight: 900; color: #e5940b; }
.pk-rank-name {
  flex: 1;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pk-rank-num {
  min-width: 4em;
  text-align: right;
  font-weight: 800;
  color: var(--text-gray);
}
.pk-empty { margin: 16px 0; color: #98a2b3; text-align: center; }
.pk-result-rank { margin-top: 8px; }
.pk-rank-more { margin-top: 8px; text-align: center; font-size: 0.85rem; color: #98a2b3; }

/* ---------- 排行榜分页 ---------- */
.pk-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid #edf2f7;
}
.pk-page-btn {
  padding: 10px 18px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  background: var(--primary-teal);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.pk-page-btn:active { transform: translateY(2px); }
.pk-page-btn[disabled] { opacity: 0.35; cursor: default; }
.pk-page-info {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-gray);
  white-space: nowrap;
}

/* 清空按钮放右上角，远离底部的「关闭」 */
#pk-rank-modal .modal-content { position: relative; }
.pk-rank-clear {
  position: absolute;
  top: 12px;
  right: 14px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: #b6c2d0;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.pk-rank-clear:hover { color: var(--error); background: #fdf1ed; }

/* ---------- 首页 PK 入口按钮 ---------- */
.mode-btn.pk-mode-btn {
  background: linear-gradient(135deg, #ff8a3d 0%, #ff5a7a 100%);
  box-shadow: 0 6px 18px rgba(255, 120, 90, 0.35);
}
.mode-btn.pk-mode-btn .btn-icon,
.mode-btn.pk-mode-btn .btn-title,
.mode-btn.pk-mode-btn .btn-desc,
.mode-btn.pk-mode-btn .btn-arrow { color: #fff; }

/* ---------- 大屏（会议室触屏） ---------- */
@media (min-width: 1400px) {
  .pk-container { max-width: 1700px; }
  .pk-board { gap: 110px; }
  .pk-side { padding: 32px 28px; border-radius: 28px; }
  .pk-numpad { gap: 18px; }
  .pk-key { padding: 26px 0; }
  .pk-rank-clear { font-size: 1.05rem; top: 18px; right: 22px; }
  .pk-page-btn { font-size: 1.3rem; padding: 14px 28px; }
  .pk-page-info { font-size: 1.2rem; }
  .pk-pager { gap: 24px; }
}

/* ---------- 小屏：上下排列 ---------- */
@media (max-width: 700px) {
  .pk-board { flex-direction: column; align-items: center; }
  .pk-side { width: 100%; max-width: 520px; }
}
