/* ===== 游戏中心 & 键盘小游戏 ===== */

.game-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #E3F2FD 0%, #F0F4F8 100%);
}

/* ===== 游戏中心 hub ===== */
.game-hub {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  overflow-y: auto;
}

.game-hub-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.game-hub-header h2 {
  font-size: var(--font-xl);
  color: var(--primary-dark);
  margin-bottom: var(--space-xs);
}

.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
  width: 100%;
  max-width: 820px;
}

.game-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: center;
  border: 3px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--game-color);
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--game-color);
}

.game-card-icon {
  font-size: 56px;
  margin-bottom: var(--space-md);
  animation: bounce 2s ease-in-out infinite;
}

.game-card-title {
  font-size: var(--font-lg);
  font-weight: 800;
  margin-bottom: var(--space-sm);
  color: var(--text);
}

.game-card-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-md);
}

.game-card-best {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--accent-dark);
}

/* ===== 游戏内 HUD ===== */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  z-index: 5;
}

.game-hud-title {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--primary-dark);
}

.game-hud-score {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--accent-dark);
  min-width: 80px;
  text-align: right;
}

.btn-exit {
  background: var(--surface-alt);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-exit:hover {
  background: var(--border);
}

/* ===== 游戏舞台 ===== */
.game-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ===== 通用结束遮罩 ===== */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(244, 247, 250, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.game-overlay.hidden {
  display: none;
}

.go-title {
  font-size: 40px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: var(--space-md);
  animation: celebrate 0.5s ease;
}

.go-score {
  font-size: var(--font-lg);
  margin-bottom: var(--space-sm);
}

.go-score b {
  font-size: 44px;
  color: var(--accent-dark);
}

.go-best {
  font-size: var(--font-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
}

.go-actions {
  display: flex;
  gap: var(--space-md);
}

/* ===== 共享键盘可视化 ===== */
.bubble-keyboard,
.whack-keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-md);
}

.kb-row {
  display: flex;
  gap: 6px;
}

.kb-key {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  box-shadow: 0 2px 0 var(--border);
  transition: transform 0.1s, background 0.1s, color 0.1s;
  user-select: none;
}

.kb-key-target {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 0 3px rgba(255, 183, 77, 0.4);
  animation: pulse-glow 1s ease-in-out infinite;
}

.kb-key-lit {
  background: var(--primary);
  color: white;
  transform: translateY(2px);
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.4);
}

.kb-key-hit {
  background: var(--success);
  color: white;
  transform: scale(1.15);
}

.kb-key-miss {
  background: var(--error);
  color: white;
  animation: shake 0.3s;
}

/* ===== 字母泡泡 ===== */
.bubble-hud {
  position: absolute;
  top: var(--space-md);
  left: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  font-size: var(--font-lg);
}

.bubble-lives .life-empty {
  opacity: 0.3;
}

.bubble-combo {
  font-weight: 800;
  color: var(--accent-dark);
  font-size: var(--font-base);
}

.bubble-field {
  position: absolute;
  left: 0;
  right: 0;
  top: 70px;
  bottom: 150px;
  overflow: hidden;
}

.bubble-field.shake {
  animation: shake 0.3s;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: white;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 35%), linear-gradient(135deg, #4FC3F7, #2196F3);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.35);
  will-change: bottom;
}

.bubble.pop {
  animation: bubblePop 0.22s ease forwards;
}

@keyframes bubblePop {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ===== 键位快打 ===== */
.whack-top {
  position: absolute;
  top: var(--space-md);
  left: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  font-size: var(--font-lg);
}

.whack-lives .life-empty {
  opacity: 0.3;
}

.whack-round {
  font-weight: 700;
  color: var(--accent-dark);
}

.whack-target {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  color: var(--primary-dark);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 4;
}

.whack-target.target-ok {
  color: var(--success);
  animation: celebrate 0.22s ease;
}

.whack-target.target-miss {
  color: var(--error);
  animation: shake 0.3s;
}

.whack-timer {
  position: absolute;
  top: calc(18% + 140px);
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 14px;
  background: var(--border);
  border-radius: 7px;
  overflow: hidden;
  z-index: 4;
}

.whack-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #66BB6A, #FFEE58);
  border-radius: 7px;
  transition: width 0.05s linear;
}

.whack-keyboard {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.whack-keyboard .kb-key {
  width: 40px;
  height: 40px;
  font-size: 17px;
}

.whack-hint {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* ===== 方向贪吃蛇 ===== */
.snake-top {
  position: absolute;
  top: var(--space-md);
  left: 0;
  right: 0;
  text-align: center;
  z-index: 4;
}

.snake-hint {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 600;
}

.snake-speed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: var(--space-sm);
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.snake-speed input[type="range"] {
  width: 40%;
  max-width: 200px;
  accent-color: var(--accent, #2A96E3);
  cursor: pointer;
}

.snake-speed-val {
  min-width: 2.4em;
  font-weight: 700;
  color: var(--accent, #2A96E3);
}

.snake-board {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(86vw, 56vh);
  aspect-ratio: 1 / 1;
  display: grid;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  box-shadow: var(--shadow-lg);
}

.sc {
  background: #ECEFF1;
  border-radius: 3px;
}

.sc-body {
  background: #81C784;
}

.sc-head {
  background: #2E7D32;
  border-radius: 4px;
}

.sc-food {
  background: #EF5350;
  border-radius: 50%;
  animation: pulse-glow 0.8s ease-in-out infinite;
}

/* ===== 猫抓老鼠 ===== */
.cm-start {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
  text-align: center;
}
.cm-start-title { font-size: var(--font-xl); font-weight: 800; color: var(--primary-dark); }
.cm-start-sub { font-size: var(--font-base); color: var(--text-secondary); margin-top: -8px; }
.cm-diff-list {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-md);
}
.cm-diff {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 150px;
  padding: var(--space-lg) var(--space-md);
  background: var(--surface);
  border: 3px solid transparent;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.cm-diff:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.cm-diff-icon { font-size: 40px; line-height: 1; }
.cm-diff-label { font-size: 18px; font-weight: 800; color: var(--primary-dark); }
.cm-diff-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }

.cm-top {
  position: absolute;
  top: var(--space-md);
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 4;
  font-weight: 700;
  color: var(--text-secondary);
}

.cm-round { font-size: 18px; }
.cm-speed { font-size: var(--font-sm); color: var(--accent, #2A96E3); }

/* 居中纵向布局，避免元素相互重叠 */
.cm-wrap {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: 0 var(--space-md);
}

.cm-track {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: 72px;
  background: linear-gradient(180deg, #E3F2FD 0%, #C5E1F5 100%);
  border-radius: 999px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.12), var(--shadow);
  overflow: visible;
}

.cm-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44%;
  background: linear-gradient(180deg, rgba(129,199,132,0), rgba(129,199,132,0.4));
  border-bottom-left-radius: 999px;
  border-bottom-right-radius: 999px;
}

.cm-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,138,101,0.25), rgba(255,138,101,0.55));
  border-radius: 999px;
  transition: width 0.28s cubic-bezier(.34,1.2,.5,1);
}

/* 用 margin 做水平居中，把 transform 留给动画（奔跑/扑抓/摇晃） */
.cm-cat, .cm-mouse {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  margin-left: -22px;
  font-size: 44px;
  line-height: 1;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.25));
  z-index: 2;
}

.cm-cat { left: 7%; transition: left 0.28s cubic-bezier(.34,1.3,.5,1); }
.cm-mouse {
  left: 93%;
  z-index: 1;
  animation: cm-mouse-idle 0.5s ease-in-out infinite;
}

@keyframes cm-mouse-idle {
  0%, 100% { transform: translateY(-50%) rotate(-7deg); }
  50% { transform: translateY(-50%) rotate(7deg); }
}

.cm-cat.cm-step { animation: cm-step 0.28s ease; }
@keyframes cm-step {
  0% { transform: translateY(-50%) scale(1, 1); }
  40% { transform: translateY(-72%) scale(1.08, 0.92); }
  100% { transform: translateY(-50%) scale(1, 1); }
}

.cm-cat.cm-shake { animation: cm-shake 0.2s ease; }
@keyframes cm-shake {
  0%, 100% { margin-left: -22px; }
  25% { margin-left: -29px; }
  75% { margin-left: -15px; }
}

.cm-cat.cm-catch { animation: cm-pounce 0.55s cubic-bezier(.3,1.5,.5,1); z-index: 3; }
@keyframes cm-pounce {
  0% { transform: translateY(-50%) scale(1, 1); }
  35% { transform: translateY(-96%) scale(1.3, 0.9); }
  70% { transform: translateY(-50%) scale(0.9, 1.12); }
  100% { transform: translateY(-50%) scale(1, 1); }
}

.cm-mouse.cm-caught { animation: cm-dizzy 0.55s linear infinite; }
@keyframes cm-dizzy { to { transform: translateY(-50%) rotate(360deg); } }

.cm-mouse.cm-run { animation: cm-runaway 0.6s ease-in forwards; }
@keyframes cm-runaway {
  to { transform: translateY(-50%) translateX(80px); opacity: 0; }
}

.cm-cat.cm-sad { filter: grayscale(0.65) drop-shadow(0 3px 3px rgba(0,0,0,0.25)); }

/* 爪印拖尾 */
.cm-paw {
  position: absolute;
  top: 60%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
  animation: cm-paw-fade 0.65s ease forwards;
}
@keyframes cm-paw-fade {
  0% { opacity: 0.55; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(0.7); }
}

.cm-phrase {
  width: 100%;
  max-width: 600px;
  text-align: center;
  font-size: clamp(18px, 4.4vw, 26px);
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.7;
  word-break: break-word;
  user-select: none;
}

.cm-char { color: var(--text-secondary); opacity: 0.5; }
.cm-char.correct { color: #2E7D32; opacity: 1; }
.cm-char.incorrect { color: #E53935; opacity: 1; text-decoration: underline; }
.cm-char.current {
  color: var(--accent, #2A96E3);
  opacity: 1;
  border-bottom: 3px solid var(--accent, #2A96E3);
  animation: cm-blink 1s step-start infinite;
}
@keyframes cm-blink { 50% { border-color: transparent; } }

.cm-timer {
  width: 100%;
  max-width: 540px;
  height: 12px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.cm-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #66BB6A, #FFB74D, #EF5350);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.cm-hint {
  text-align: center;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  max-width: 600px;
}

.cm-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 20px;
  border-radius: 14px;
  font-size: var(--font-lg);
  font-weight: 800;
  z-index: 6;
  pointer-events: none;
  animation: cm-flash-pop 0.9s ease forwards;
}
.cm-flash-ok { background: rgba(102,187,106,0.95); color: #fff; }
.cm-flash-bad { background: rgba(239,83,53,0.95); color: #fff; }
@keyframes cm-flash-pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.9); }
}

/* ===== 键位熟悉练习 ===== */
.kf-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kf-tip {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  min-height: 28px;
  color: #333;
}
.kf-big {
  font-size: 22px;
  background: #2A96E3;
  color: #fff;
  border-radius: 8px;
  padding: 2px 10px;
  margin: 0 2px;
}
.kf-hands {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  justify-content: center;
  font-size: 13px;
  color: #6b7280;
}
.kf-bump {
  color: #FF8A65;
  font-weight: 700;
}
.kf-board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  background: #f5f7fa;
  border-radius: 16px;
  padding: 18px 12px;
}
.kf-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.kf-key {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid #e2e6ea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #333;
  box-shadow: 0 3px 0 #d4d8dd;
  transition: transform 0.12s ease, background 0.12s ease;
}
.kf-key::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 5px;
  border-radius: 3px;
  background: var(--fk, #ccc);
}
.kf-home::before {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 2px;
  background: #333;
  border-radius: 2px;
}
.kf-target {
  transform: translateY(-6px) scale(1.12);
  background: #FFF8E1;
  border-color: var(--fk, #2A96E3);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.18);
  animation: kf-bounce 0.8s ease-in-out infinite;
}
.kf-done {
  background: #E8F5E9;
  border-color: #66BB6A;
  color: #2E7D32;
}
.kf-done::after {
  background: #66BB6A;
}
.kf-wrong {
  animation: kf-shake 0.3s ease;
}
@keyframes kf-bounce {
  0%, 100% { transform: translateY(-6px) scale(1.12); }
  50% { transform: translateY(-12px) scale(1.16); }
}
@keyframes kf-shake {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -6px; }
  75% { margin-left: 6px; }
}
.kf-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.kf-progress {
  font-weight: 800;
  color: #2A96E3;
  font-size: 16px;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  .game-cards {
    grid-template-columns: 1fr;
    max-width: 360px;
  }
  .kb-key {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  .whack-keyboard .kb-key {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .whack-target {
    width: 92px;
    height: 92px;
    font-size: 48px;
  }
}
