:root {
  --bg-gradient: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --text-typed: #4ade80;  /* 绿色：正确 */
  --text-error: #f87171;  /* 红色：错误 */
  --text-cursor: #60a5fa; /* 光标色 */
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-main);
  background: var(--bg-gradient);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Win7/旧电脑小屏幕适配：内容高过屏幕时允许下拉，而不是被切掉 */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 0;
}
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.app-container {
  width: 95%;
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  /* 弹性高度兼容 */
  min-height: 660px;
  height: calc(100vh - 40px);
}
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}
.glass-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.settings-nav {
  display: flex;
  gap: 12px;
}
.glass-select, .glass-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  outline: none;
  transition: all 0.3s ease;
}
.glass-select option {
  background: #203a43;
  color: #fff;
}
.glass-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.primary-btn {
  background: var(--primary-color);
  border: none;
}
.primary-btn:hover {
  background: var(--primary-hover);
}
.typing-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}
.stats-bar {
  display: flex;
  justify-content: space-around;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}
.stat-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stat-item .label {
  color: var(--text-secondary);
  font-size: 1.1rem;
}
.stat-item .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  display: inline-block;
  text-align: right;
}
.stat-item .unit {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.text-display {
  font-size: 1.6rem;
  line-height: 2;
  color: var(--text-secondary);
  flex: 1;
  overflow-y: auto;
  user-select: none; /* 防止选中文本复制 */
  position: relative;
  letter-spacing: 1.5px;
  padding-right: 15px;
}
/* 隐藏滚动条但保留滚动效果 */
.text-display::-webkit-scrollbar {
  width: 8px;
}
.text-display::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

/* 拟物化键盘按键图片样式 */
kbd {
  display: inline-block;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: bold;
  color: #333;
  background-color: #f7f7f7;
  border: 1px solid #ccc;
  border-bottom-color: #aaa;
  border-radius: 6px;
  box-shadow: 0 4px 0 #bbb, 0 5px 5px rgba(0,0,0,0.2), inset 0 1px 0 #fff;
  text-shadow: 0 1px 0 #fff;
  margin: 0 4px;
  transform: translateY(-2px);
  will-change: transform;
}

kbd.dark-kbd {
  color: #f7f7f7;
  background-color: #333;
  border: 1px solid #222;
  border-bottom-color: #111;
  box-shadow: 0 4px 0 #111, 0 5px 5px rgba(0,0,0,0.4), inset 0 1px 0 #555;
  text-shadow: 0 1px 0 #000;
}

.text-display span {
  transition: color 0.1s;
  border-radius: 3px;
  padding: 2px 0;
}
.text-display .correct {
  color: var(--text-typed);
}
.text-display .incorrect {
  color: var(--text-error);
  background: rgba(248, 113, 113, 0.2);
}
.text-display .current {
  color: var(--text-primary);
  border-bottom: 3px solid var(--text-cursor);
  animation: blink 1s infinite alternate;
}
/* 空格错误特殊样式 */
.text-display .incorrect.space-char {
  background: var(--text-error);
}
@keyframes blink {
  50% { border-color: transparent; }
}
.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  top: 0;
  left: 0;
}
.glass-footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1rem;
}
.glass-footer strong {
  color: #fca5a5;
}
/* 结算弹窗展示 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  width: 450px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.result-stats {
  display: flex;
  justify-content: space-around;
  margin: 20px 0;
  padding: 15px 0;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
}
.result-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-title {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.result-value {
  font-size: 2.2rem;
  font-weight: 700;
}
.grade-s { color: #f59e0b; text-shadow: 0 0 15px rgba(245, 158, 11, 0.6); font-size: 2.8rem;}
.grade-a { color: #4ade80; }
.grade-b { color: #60a5fa; }
.grade-c { color: #f472b6; }
.grade-d { color: #f87171; }
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 1000;
}
.toast {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 14px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-weight: bold;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show {
  transform: translateX(0);
}
