/* ==========================================================================
   打字星球 (Type.fun) - 核心样式表
   ========================================================================== */

:root {
  --bg-primary: #070b19;
  --bg-secondary: rgba(15, 23, 42, 0.75);
  --bg-card: rgba(30, 41, 59, 0.65);
  --border-color: rgba(56, 189, 248, 0.2);
  --border-hover: rgba(56, 189, 248, 0.6);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #00f0ff;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  --accent-green: #22c55e;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;

  /* 指法色彩分区 (10指颜色) */
  --finger-pinky-l: #ec4899;   /* 粉色 (左小指) */
  --finger-ring-l: #a855f7;    /* 紫色 (左无名) */
  --finger-mid-l: #3b82f6;     /* 蓝色 (左中指) */
  --finger-index-l: #06b6d4;   /* 青色 (左食指) */
  --finger-thumb: #10b981;     /* 绿色 (双手大拇指) */
  --finger-index-r: #14b8a6;   /* 蓝绿 (右食指) */
  --finger-mid-r: #3b82f6;     /* 蓝色 (右中指) */
  --finger-ring-r: #a855f7;    /* 紫色 (右无名) */
  --finger-pinky-r: #ec4899;   /* 粉色 (右小指) */

  --key-bg: rgba(30, 41, 59, 0.85);
  --key-shadow: 0 4px 0 rgba(15, 23, 42, 0.9), 0 6px 12px rgba(0, 0, 0, 0.4);
  --key-active-shadow: 0 1px 0 rgba(15, 23, 42, 0.9), 0 2px 4px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

#cosmic-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* 页面容器 */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1300px;
  margin: 0 auto;
  padding: 16px 24px;
  position: relative;
  z-index: 1;
}

/* 顶部导航栏 */
.header-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  margin-bottom: 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon-spin {
  font-size: 28px;
  display: inline-block;
  animation: orbit-rotate 12s linear infinite;
}

@keyframes orbit-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #00f0ff 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.brand-slogan {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.nav-menu {
  display: flex;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(168, 85, 247, 0.2));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
}

.header-settings {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.select-styled {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.select-styled:focus {
  border-color: var(--accent-cyan);
}

/* 主内容视区 */
.main-view-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.3s ease;
}

.hidden {
  display: none !important;
}

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

/* 1. 行星闯关关卡地图 (Planets Grid) */
.planets-header {
  text-align: center;
  margin-bottom: 10px;
}

.section-main-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-sub-title {
  font-size: 14px;
  color: var(--text-muted);
}

.planets-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.planet-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px 20px;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.planet-card.unlocked:hover {
  transform: translateY(-6px);
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 30px rgba(0, 240, 255, 0.2);
  cursor: pointer;
}

.planet-card.locked {
  opacity: 0.55;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

.planet-badge-orbit {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px dashed rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  position: relative;
}

.planet-sphere {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: inset -6px -6px 12px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.5);
  transition: transform 0.5s ease;
}

.planet-card:hover .planet-sphere {
  transform: scale(1.1);
}

.planet-sphere-mercury { background: radial-gradient(circle at 35% 35%, #93c5fd, #1e3a8a); }
.planet-sphere-venus   { background: radial-gradient(circle at 35% 35%, #fde047, #ca8a04); }
.planet-sphere-earth   { background: radial-gradient(circle at 35% 35%, #38bdf8, #059669); }
.planet-sphere-mars    { background: radial-gradient(circle at 35% 35%, #f87171, #991b1b); }
.planet-sphere-jupiter { background: radial-gradient(circle at 35% 35%, #fdba74, #c2410c); }
.planet-sphere-saturn  { background: radial-gradient(circle at 35% 35%, #fef08a, #a16207); }
.planet-sphere-uranus  { background: radial-gradient(circle at 35% 35%, #67e8f9, #0e7490); }
.planet-sphere-neptune { background: radial-gradient(circle at 35% 35%, #818cf8, #3730a3); }
.planet-sphere-sun     { background: radial-gradient(circle at 35% 35%, #fde047, #ea580c); box-shadow: 0 0 25px #f59e0b; }

.planet-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.planet-level-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.planet-diff-tag {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.planet-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.planet-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
  height: 34px;
}

.planet-stars {
  color: #fbbf24;
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.planet-play-btn {
  width: 100%;
  padding: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.planet-card.unlocked .planet-play-btn:hover {
  background: var(--accent-cyan);
  color: #0f172a;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
}

/* 2. 打字练习工作区 (Practice Workspace) */
.practice-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px 18px;
  backdrop-filter: blur(12px);
}

.category-tabs-group {
  display: flex;
  gap: 6px;
}

.category-tab {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.category-tab.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--border-color);
  color: var(--accent-cyan);
}

.subcategory-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

.sub-pill {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.sub-pill.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.practice-actions {
  display: flex;
  gap: 8px;
}

.btn-icon-action {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon-action:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent-cyan);
}

/* 实时 HUD 仪表盘 */
.hud-dashboard {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 16px;
  backdrop-filter: blur(12px);
  position: relative;
}

.hud-progress-line {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #00f0ff, #a855f7);
  transition: width 0.15s ease;
  border-radius: 0 0 14px 14px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-item:last-child {
  border-right: none;
}

.hud-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  letter-spacing: 0.5px;
}

.hud-val {
  font-size: 22px;
  font-weight: 800;
  font-family: 'Fira Code', Consolas, monospace;
}

.color-wpm { color: var(--accent-cyan); }
.color-acc { color: var(--accent-green); }
.color-cpm { color: var(--accent-yellow); }
.color-time { color: var(--accent-purple); }
.color-combo { color: #f43f5e; }

/* 核心打字展示卡片 */
.typing-board-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 24px 30px;
  min-height: 180px;
  max-height: 240px;
  overflow-y: auto;
  position: relative;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.practice-current-title {
  position: absolute;
  top: 10px;
  right: 18px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
}

.typing-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chinese-preview-line {
  font-size: 18px;
  color: #e2e8f0;
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.chinese-icon {
  color: var(--accent-yellow);
  font-size: 14px;
}

.typing-letters-container {
  font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
  font-size: 22px;
  line-height: 1.7;
  letter-spacing: 1px;
  word-break: break-all;
  white-space: pre-wrap;
}

.type-char {
  color: #64748b;
  position: relative;
  transition: color 0.1s, background 0.1s;
}

.type-char.correct {
  color: #f8fafc;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.type-char.incorrect {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.25);
  border-radius: 3px;
  text-decoration: underline wavy #ef4444;
}

.type-char.current {
  color: #00f0ff;
  border-bottom: 3px solid #00f0ff;
  animation: cursor-blink 1s ease-in-out infinite;
}

@keyframes cursor-blink {
  0%, 100% { border-color: #00f0ff; }
  50% { border-color: transparent; }
}

.shake {
  animation: shake-anim 0.25s ease-in-out;
}

@keyframes shake-anim {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* 连击气泡弹窗 */
.combo-toast {
  position: fixed;
  top: 100px;
  right: 40px;
  background: linear-gradient(135deg, #f43f5e, #f59e0b);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 0 25px rgba(244, 63, 94, 0.6);
  opacity: 0;
  transform: scale(0.7) translateY(-20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 100;
}

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

/* ==========================================================================
   双手手指指法引导 (Hands Finger Guide)
   ========================================================================== */
.hands-guide-container {
  margin-top: 4px;
}

.hands-guide-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 24px;
  backdrop-filter: blur(12px);
}

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

.hand-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.fingers {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 60px;
}

.finger {
  width: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px 10px 4px 4px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  transition: all 0.2s ease;
}

.finger .f-tip {
  font-size: 9px;
  color: var(--text-muted);
  writing-mode: vertical-lr;
}

/* 手指高度比例 */
.f-0, .f-8 { height: 42px; border-color: var(--finger-pinky-l); }
.f-1, .f-7 { height: 52px; border-color: var(--finger-ring-l); }
.f-2, .f-6 { height: 58px; border-color: var(--finger-mid-l); }
.f-3, .f-5 { height: 50px; border-color: var(--finger-index-l); }
.f-4 { height: 32px; border-color: var(--finger-thumb); }

.finger.active-finger {
  background: var(--accent-cyan) !important;
  border-color: #fff !important;
  box-shadow: 0 0 16px var(--accent-cyan);
  transform: translateY(-6px);
}

.finger.active-finger .f-tip {
  color: #0f172a;
  font-weight: 800;
}

.finger-prompt-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--border-color);
  padding: 8px 20px;
  border-radius: 12px;
}

.target-indicator-text {
  font-size: 11px;
  color: var(--text-muted);
}

.target-char-display {
  font-size: 26px;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  color: var(--accent-cyan);
}

.target-finger-desc {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-yellow);
}

/* ==========================================================================
   虚拟拟物键盘 (Virtual Keyboard)
   ========================================================================== */
.keyboard-container {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.keyboard-board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
  width: 100%;
  max-width: 960px;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.key {
  height: 46px;
  min-width: 44px;
  background: var(--key-bg);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Fira Code', Consolas, sans-serif;
  color: #e2e8f0;
  box-shadow: var(--key-shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s, border-color 0.15s;
  cursor: default;
}

.key.pressed {
  transform: translateY(3px);
  box-shadow: var(--key-active-shadow);
  background: rgba(56, 189, 248, 0.4) !important;
  color: #fff;
}

/* 目标按键脉冲高亮 */
.key.target-key-pulse {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.45), rgba(168, 85, 247, 0.45)) !important;
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 16px var(--accent-cyan), var(--key-shadow);
  color: #ffffff;
  animation: key-pulse-glow 1.2s infinite alternate;
}

.key.target-shift-pulse {
  background: rgba(236, 72, 153, 0.35) !important;
  border-color: #ec4899 !important;
  box-shadow: 0 0 12px #ec4899;
}

@keyframes key-pulse-glow {
  from { box-shadow: 0 0 8px var(--accent-cyan), var(--key-shadow); }
  to { box-shadow: 0 0 20px var(--accent-cyan), 0 0 30px rgba(0, 240, 255, 0.4); }
}

/* 指法色彩边缘 */
.finger-0 { border-bottom: 2.5px solid var(--finger-pinky-l); }
.finger-1 { border-bottom: 2.5px solid var(--finger-ring-l); }
.finger-2 { border-bottom: 2.5px solid var(--finger-mid-l); }
.finger-3 { border-bottom: 2.5px solid var(--finger-index-l); }
.finger-4 { border-bottom: 2.5px solid var(--finger-thumb); }
.finger-5 { border-bottom: 2.5px solid var(--finger-index-r); }
.finger-6 { border-bottom: 2.5px solid var(--finger-mid-r); }
.finger-7 { border-bottom: 2.5px solid var(--finger-ring-r); }
.finger-8 { border-bottom: 2.5px solid var(--finger-pinky-r); }

/* 特殊按键宽度 */
.key-backspace { min-width: 80px; font-size: 11px; }
.key-tab       { min-width: 65px; font-size: 11px; }
.key-slash     { min-width: 58px; }
.key-caps      { min-width: 78px; font-size: 11px; }
.key-enter     { min-width: 82px; font-size: 11px; background: rgba(59, 130, 246, 0.25); }
.key-lshift    { min-width: 96px; font-size: 11px; }
.key-rshift    { min-width: 104px; font-size: 11px; }
.key-ctrl, .key-alt { min-width: 55px; font-size: 11px; }
.key-space     { flex: 1; max-width: 380px; font-size: 12px; }

/* F 和 J 键凸起小点 */
.home-bump {
  width: 12px;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 2px;
  position: absolute;
  bottom: 4px;
}

.shift-char {
  font-size: 9px;
  opacity: 0.6;
  margin-bottom: -2px;
}

/* ==========================================================================
   太空防御打字小游戏 (Space Asteroid Game)
   ========================================================================== */
.game-screen-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-hud-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px 12px 0 0;
  padding: 10px 20px;
  backdrop-filter: blur(12px);
}

.game-hud-block {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.game-hud-title {
  color: var(--text-muted);
  font-size: 12px;
}

.game-canvas-box {
  width: 100%;
  max-width: 800px;
  height: 480px;
  background: radial-gradient(circle at 50% 100%, #1e1b4b, #090d1f);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 16px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.game-overlay-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 11, 25, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.game-big-title {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 20px var(--accent-cyan);
}

.game-instruction {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 440px;
  text-align: center;
  line-height: 1.5;
}

.btn-primary-glow {
  padding: 12px 36px;
  background: linear-gradient(135deg, #00f0ff, #3b82f6);
  border: none;
  border-radius: 12px;
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6);
  transition: all 0.2s;
}

.btn-primary-glow:hover {
  transform: scale(1.05);
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.8);
}

/* ==========================================================================
   战绩看板、弱键分析与成就 (Stats & Analytics)
   ========================================================================== */
.stats-overview-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  backdrop-filter: blur(12px);
}

.stat-m-num {
  font-size: 28px;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  margin-top: 6px;
}

.stats-double-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(12px);
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.weak-keys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.weak-key-card {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.weak-key-card .key-box {
  font-size: 18px;
  font-weight: 800;
  color: #f87171;
  font-family: 'Fira Code', monospace;
}

.weak-key-card .err-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.achievements-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.ach-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ach-card.unlocked {
  background: rgba(245, 158, 11, 0.1);
  border-color: #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.ach-icon { font-size: 28px; margin-bottom: 4px; }
.ach-title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.ach-desc { font-size: 11px; color: var(--text-muted); line-height: 1.3; margin-bottom: 6px; }
.ach-status { font-size: 10px; font-weight: 600; color: var(--accent-cyan); }

.history-table-box {
  overflow-x: auto;
  margin-top: 10px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th, .history-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-table th {
  color: var(--text-muted);
  font-size: 12px;
}

/* ==========================================================================
   模态弹窗 (Modals)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 240, 255, 0.3);
  animation: modalScale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

@keyframes modalScale {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-header-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 18px;
}

.result-rank-banner {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-yellow);
  margin-bottom: 20px;
}

.result-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.res-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.res-val {
  font-size: 20px;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  color: var(--accent-cyan);
}

.res-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.custom-textarea {
  width: 100%;
  height: 140px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 16px;
  outline: none;
}

.custom-textarea:focus {
  border-color: var(--accent-cyan);
}

.unlocked-ach-title {
  font-size: 12px;
  color: #f59e0b;
  font-weight: 700;
  margin-bottom: 6px;
}

.ach-badge-pill {
  font-size: 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid #f59e0b;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
}

/* 底部标语 */
.footer-bar {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 24px;
}
