/* ============================================================
   Typing Game Styles（打字游戏 - 品牌蓝透明玻璃风格）
   与首页 / 键盘测试保持一致：白底、品牌蓝 #2D9CDB、
   半透明玻璃质感（backdrop-filter blur）、圆角卡片
   ============================================================ */

.tg-page {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(960px, calc(100vw - 64px));
  padding: 8px 0 40px;
}

/* ===== 玻璃外壳 ===== */
.tg-crt {
  position: relative;
  background: linear-gradient(180deg, #f3faff 0%, #ffffff 100%);
  border: 1px solid #e6e9ed;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 32px rgba(45, 156, 219, 0.08);
}

/* ===== 顶部 HUD ===== */
.tg-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(45, 156, 219, 0.22);
  border-radius: 12px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  color: #6a7684;
}

.tg-hud-group {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.tg-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: #6a7684;
}

.tg-stat strong {
  font-size: 22px;
  font-weight: 700;
  color: #2c3e50;
  font-variant-numeric: tabular-nums;
}

.tg-stat strong#tg-combo {
  color: #2d9cdb;
}

.tg-stat.tg-danger strong {
  color: #e05555;
}

/* 生命值：品牌蓝小方块 */
.tg-lives {
  display: flex;
  gap: 5px;
  align-items: center;
}

.tg-life {
  width: 14px;
  height: 14px;
  background: linear-gradient(180deg, #4fb3e8 0%, #2d9cdb 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 2px 6px rgba(45, 156, 219, 0.35);
  border-radius: 4px;
}

.tg-life.lost {
  background: rgba(45, 156, 219, 0.1);
  box-shadow: inset 0 0 0 1px rgba(45, 156, 219, 0.18);
}

/* ===== 速度选择 + 控制按钮 ===== */
.tg-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

.tg-speed-label {
  color: #6a7684;
  font-size: 13px;
  letter-spacing: 0.1em;
}

/* 透明玻璃按钮（与键帽质感一致） */
.tg-speed-btn {
  border: 1px solid rgba(45, 156, 219, 0.28);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(243, 250, 255, 0.78) 45%,
    rgba(228, 240, 250, 0.68) 100%
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #2c3e50;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 3px 0 -1px #c3d2de,
    0 4px 0 -1px #9fb4c4,
    0 6px 12px rgba(30, 60, 90, 0.12);
  transition: all 0.15s ease;
}

.tg-speed-btn:hover {
  border-color: rgba(45, 156, 219, 0.55);
  color: #2d9cdb;
}

.tg-speed-btn.active {
  background: linear-gradient(
    180deg,
    rgba(45, 156, 219, 0.85) 0%,
    rgba(45, 140, 204, 0.92) 100%
  );
  color: #ffffff;
  border-color: rgba(45, 156, 219, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 -1px #1f7cb0,
    0 4px 0 -1px #1a6a97,
    0 6px 16px rgba(45, 156, 219, 0.35);
}

.tg-btn {
  border: 1px solid rgba(45, 156, 219, 0.35);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(243, 250, 255, 0.78) 45%,
    rgba(228, 240, 250, 0.68) 100%
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #2d8bcc;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 9px 24px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 3px 0 -1px #c3d2de,
    0 4px 0 -1px #9fb4c4,
    0 6px 12px rgba(30, 60, 90, 0.12);
  transition: all 0.15s ease;
}

.tg-btn:hover {
  background: linear-gradient(
    180deg,
    rgba(45, 156, 219, 0.85) 0%,
    rgba(45, 140, 204, 0.92) 100%
  );
  color: #ffffff;
  border-color: rgba(45, 156, 219, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 -1px #1f7cb0,
    0 4px 0 -1px #1a6a97,
    0 6px 16px rgba(45, 156, 219, 0.35);
  transform: translateY(-1px);
}

/* ===== 游戏区域（浅色玻璃屏幕） ===== */
.tg-screen {
  position: relative;
  height: 460px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(45, 156, 219, 0.08), transparent 60%),
    linear-gradient(180deg, #f8fcff 0%, #eef6fd 100%);
  border: 1px solid rgba(45, 156, 219, 0.3);
  border-radius: 12px;
  box-shadow:
    inset 0 2px 8px rgba(45, 156, 219, 0.08),
    inset 0 -1px 2px rgba(255, 255, 255, 0.9);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* 底部危险线 */
.tg-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    rgba(224, 85, 85, 0.75) 0px,
    rgba(224, 85, 85, 0.75) 12px,
    transparent 12px,
    transparent 20px
  );
  box-shadow: 0 0 10px rgba(224, 85, 85, 0.3);
  z-index: 2;
}

/* ===== 掉落的字母（品牌蓝 + 辉光） ===== */
.tg-letter {
  position: absolute;
  top: -40px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  color: #2d8bcc;
  text-shadow:
    0 0 1px rgba(45, 156, 219, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: pointer;
  z-index: 3;
  will-change: transform;
}

/* 击中：蓝色爆开消失 */
.tg-letter.hit {
  animation: tg-hit 0.28s ease-out forwards;
  pointer-events: none;
}

@keyframes tg-hit {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.6);
    color: #2d9cdb;
    text-shadow:
      0 0 14px rgba(45, 156, 219, 0.75),
      0 0 30px rgba(45, 156, 219, 0.35);
  }
  100% {
    opacity: 0;
    transform: scale(2.3) translateY(-14px);
  }
}

/* 漏接：坠落变红 */
.tg-letter.miss {
  animation: tg-miss 0.32s ease-in forwards;
  pointer-events: none;
}

@keyframes tg-miss {
  0% {
    opacity: 1;
    color: #e05555;
  }
  100% {
    opacity: 0;
    transform: translateY(26px) scaleY(0.4);
    color: #e05555;
  }
}

/* ===== 单词模式 ===== */
.tg-word {
  font-size: 26px;
  letter-spacing: 2px;
  white-space: nowrap;
}

.tg-word span {
  margin: 0 1px;
  transition: color 0.12s ease;
}

/* 已输入字母：绿色 */
.tg-word span.done {
  color: #28a745;
  text-shadow: 0 0 8px rgba(40, 167, 69, 0.35);
}

/* 当前待输入字母：品牌蓝 + 下划线 */
.tg-word span.next {
  color: #2d9cdb;
  font-weight: 800;
  border-bottom: 3px solid #2d9cdb;
  text-shadow: 0 0 10px rgba(45, 156, 219, 0.5);
}

/* 未输入字母：淡蓝 */
.tg-word span.todo {
  color: rgba(45, 139, 204, 0.45);
}

/* 模式选择按钮（开始界面） */
.tg-modes {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.tg-mode-btn {
  border: 1px solid rgba(45, 156, 219, 0.28);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(243, 250, 255, 0.78) 45%,
    rgba(228, 240, 250, 0.68) 100%
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #2c3e50;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 10px 24px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 3px 0 -1px #c3d2de,
    0 4px 0 -1px #9fb4c4,
    0 6px 12px rgba(30, 60, 90, 0.12);
  transition: all 0.15s ease;
}

.tg-mode-btn:hover {
  border-color: rgba(45, 156, 219, 0.55);
  color: #2d9cdb;
}

.tg-mode-btn.active {
  background: linear-gradient(
    180deg,
    rgba(45, 156, 219, 0.85) 0%,
    rgba(45, 140, 204, 0.92) 100%
  );
  color: #ffffff;
  border-color: rgba(45, 156, 219, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 -1px #1f7cb0,
    0 4px 0 -1px #1a6a97,
    0 6px 16px rgba(45, 156, 219, 0.35);
}

/* ===== 得分飘字 ===== */
.tg-pop {
  position: absolute;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  color: #2d8bcc;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 4;
  animation: tg-pop 0.7s ease-out forwards;
}

.tg-pop.tg-pop-bad {
  color: #e05555;
}

@keyframes tg-pop {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-34px);
  }
}

/* ===== 覆盖层（开始 / 暂停 / 结束）：磨砂玻璃 ===== */
.tg-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  text-align: center;
  padding: 24px;
}

.tg-overlay[hidden] {
  display: none;
}

.tg-title {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #2d9cdb;
  text-shadow: 0 2px 12px rgba(45, 156, 219, 0.25);
  margin: 0;
}

.tg-subtitle {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 14px;
  color: #6a7684;
  line-height: 1.9;
  margin: 0;
  max-width: 480px;
}

.tg-subtitle strong {
  color: #2d8bcc;
}

.tg-final {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 16px;
  color: #6a7684;
  line-height: 2;
  margin: 0;
}

.tg-final strong {
  color: #2d9cdb;
  font-size: 20px;
}

/* 闪烁提示 */
.tg-blink {
  animation: tg-blink 1.1s step-end infinite;
}

@keyframes tg-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* ===== 连击高亮（10 连击以上金色发光） ===== */
.tg-stat strong#tg-combo.hot {
  color: #f5a623;
  text-shadow: 0 0 12px rgba(245, 166, 35, 0.55);
}

.tg-stat strong#tg-level {
  color: #f5a623;
}

/* ===== 粒子爆炸 ===== */
.tg-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  animation: tg-particle 0.55s ease-out forwards;
}

@keyframes tg-particle {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.3);
  }
}

/* ===== 屏幕震动（漏接 / 炸弹） ===== */
.tg-screen.tg-shake {
  animation: tg-shake 0.35s ease;
}

@keyframes tg-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ===== 全屏大字（连击称号 / 升级） ===== */
.tg-big {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #2d9cdb;
  text-shadow:
    0 2px 16px rgba(45, 156, 219, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
  animation: tg-big 1.05s ease-out forwards;
}

.tg-big.tg-big-combo {
  color: #f5a623;
  text-shadow:
    0 2px 16px rgba(245, 166, 35, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

.tg-big.tg-big-level {
  color: #28a745;
  text-shadow:
    0 2px 16px rgba(40, 167, 69, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

@keyframes tg-big {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
  25% {
    transform: translate(-50%, -50%) scale(1);
  }
  75% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(1.05);
  }
}

/* ===== 掉落道具 ===== */
.tg-powerup {
  position: absolute;
  top: -56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 3;
  will-change: transform;
}

.tg-powerup .tg-pu-icon {
  font-size: 30px;
  line-height: 1.2;
  filter: drop-shadow(0 2px 6px rgba(45, 156, 219, 0.35));
  animation: tg-pu-bounce 0.9s ease-in-out infinite;
}

.tg-powerup .tg-pu-key {
  margin-top: 3px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(180deg, #4fb3e8 0%, #2d9cdb 100%);
  border-radius: 5px;
  padding: 1px 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 2px 6px rgba(45, 156, 219, 0.4);
}

@keyframes tg-pu-bounce {
  0%, 100% { transform: scale(1) rotate(-6deg); }
  50% { transform: scale(1.15) rotate(6deg); }
}

/* 道具被击中 / 落底：复用字母的 hit / miss 动画 */
.tg-powerup.hit {
  animation: tg-hit 0.28s ease-out forwards;
  pointer-events: none;
}

.tg-powerup.miss {
  animation: tg-miss 0.32s ease-in forwards;
  pointer-events: none;
}

/* ===== 炸弹全屏闪光 ===== */
.tg-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0.9;
  pointer-events: none;
  z-index: 8;
  animation: tg-flash 0.4s ease-out forwards;
}

@keyframes tg-flash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ===== 道具激活状态条（屏幕左上角） ===== */
.tg-pu-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}

.tg-pu-chip {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: tg-chip-in 0.25s ease-out;
}

.tg-pu-chip-slow {
  color: #2d8bcc;
  border: 1px solid rgba(45, 156, 219, 0.45);
  box-shadow: 0 0 10px rgba(45, 156, 219, 0.25);
}

.tg-pu-chip-double {
  color: #d98a0d;
  border: 1px solid rgba(245, 166, 35, 0.5);
  box-shadow: 0 0 10px rgba(245, 166, 35, 0.3);
}

@keyframes tg-chip-in {
  0% { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== 慢速 / 双倍激活时的屏幕滤镜 ===== */
.tg-screen.tg-slowmo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(45, 156, 219, 0.07);
  box-shadow: inset 0 0 40px rgba(45, 156, 219, 0.18);
  pointer-events: none;
  z-index: 1;
}

.tg-screen.tg-double::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(245, 166, 35, 0.06);
  box-shadow: inset 0 0 40px rgba(245, 166, 35, 0.16);
  pointer-events: none;
  z-index: 1;
}

/* ===== 音效开关按钮 ===== */
.tg-sound-btn {
  padding: 8px 12px;
  font-size: 15px;
  line-height: 1;
}

.tg-sound-btn.muted {
  opacity: 0.55;
}

/* ===== 开始界面：道具说明 ===== */
.tg-pu-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.tg-pu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 13px;
  color: #6a7684;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(45, 156, 219, 0.25);
  border-radius: 8px;
}

.tg-pu-item kbd {
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(180deg, #4fb3e8 0%, #2d9cdb 100%);
  border-radius: 4px;
  padding: 1px 7px;
  box-shadow: 0 2px 4px rgba(45, 156, 219, 0.35);
}

/* ===== 开始界面：最高分 ===== */
.tg-best-line {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 14px;
  color: #6a7684;
  margin: 0;
}

.tg-best-line strong {
  color: #f5a623;
  font-size: 18px;
}

/* ===== 使用说明 ===== */
.tg-usage {
  margin-top: 22px;
  padding: 16px 20px;
  border-left: 3px solid #2d9cdb;
  background: #f8f9fa;
  border-radius: 0 10px 10px 0;
  color: #6a7684;
  font-size: 14px;
  line-height: 1.8;
}

.tg-usage strong {
  color: #2c3e50;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .tg-screen {
    height: 380px;
  }

  .tg-letter {
    font-size: 24px;
  }

  .tg-title {
    font-size: 26px;
  }

  .tg-hud-group {
    gap: 14px;
  }

  .tg-stat strong {
    font-size: 18px;
  }

  .tg-big {
    font-size: 26px;
  }

  .tg-powerup .tg-pu-icon {
    font-size: 24px;
  }

  .tg-pu-legend {
    gap: 6px;
  }

  .tg-pu-item {
    font-size: 12px;
    padding: 4px 9px;
  }
}
