/* ===== 打字练习页样式 ===== */

.typing-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

/* 顶部信息栏 */
.typing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.typing-header .level-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.typing-header .level-name {
  font-size: var(--font-lg);
  font-weight: 700;
}

.typing-header .live-stats {
  display: flex;
  gap: var(--space-lg);
}

.live-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.live-stat .label {
  font-size: var(--font-xs);
  color: var(--text-secondary);
}

.live-stat .value {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

.live-stat.accuracy .value {
  color: var(--success);
}

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

.typing-header .btn-exit:hover {
  background: var(--error);
  color: white;
}

/* 打字区域 */
.typing-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  overflow-y: auto;
}

.text-display {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', Consolas, monospace;
  font-size: 28px;
  line-height: 1.8;
  letter-spacing: 1px;
  max-width: 800px;
  width: 100%;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  word-break: break-all;
  white-space: pre-wrap;
}

.text-display .char {
  position: relative;
  transition: background 0.15s, color 0.15s;
  border-radius: 3px;
  padding: 0 1px;
}

.text-display .char.correct {
  color: var(--success);
}

.text-display .char.incorrect {
  color: var(--error);
  background: rgba(239, 83, 80, 0.1);
}

.text-display .char.current {
  background: var(--primary-light);
  border-radius: 3px;
}

.text-display .char.current::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 3px;
  background: var(--primary-dark);
  border-radius: 2px;
  animation: cursor-blink 1s ease-in-out infinite;
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.text-display .char.incorrect.current {
  background: rgba(239, 83, 80, 0.2);
}

.text-display .char.incorrect.current::after {
  background: var(--error);
}

/* 隐藏输入框 */
.typing-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

/* 底部进度 */
.typing-footer {
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.typing-footer .progress-info {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.typing-footer .progress-bar {
  flex: 1;
  height: 10px;
}

/* 开始覆盖层 */
.start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(240, 244, 248, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  gap: var(--space-lg);
}

.start-overlay .level-preview {
  font-size: var(--font-xl);
  font-weight: 700;
}

.start-overlay .hint {
  font-size: var(--font-lg);
  color: var(--text-secondary);
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* 结果覆盖层 */
.result-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(240, 244, 248, 0.95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  gap: var(--space-md);
}

.result-overlay.show {
  display: flex;
  animation: fadeIn 0.4s ease;
}

.result-overlay .result-title {
  font-size: var(--font-xl);
  font-weight: 700;
}

.result-overlay .result-stars {
  margin: var(--space-md) 0;
}

.result-overlay .result-stars .star {
  font-size: 48px;
  animation: starPop 0.5s ease;
}

.result-overlay .result-stars .star:nth-child(2) { animation-delay: 0.15s; }
.result-overlay .result-stars .star:nth-child(3) { animation-delay: 0.3s; }

@keyframes starPop {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-overlay .result-details {
  display: flex;
  gap: var(--space-xl);
  margin: var(--space-md) 0;
}

.result-detail {
  text-align: center;
}

.result-detail .value {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--primary-dark);
}

.result-detail .label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

.result-overlay .result-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

/* 目标提示 */
.target-hint {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  font-weight: 600;
  margin-bottom: var(--space-md);
}
