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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航栏 */
.header {
  background: rgba(255, 255, 255, 0.95);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
  font-size: 1.5rem;
  color: #333;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.header-controls a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.header-controls select {
  padding: 0.5rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
  cursor: pointer;
}

.header-controls select:hover {
  border-color: #667eea;
}

/* 使用说明 */
.usage-instruction {
  background: rgba(255, 255, 255, 0.95);
  padding: 0.75rem 2rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.usage-instruction p {
  color: #4a5568;
  font-size: 0.95rem;
  margin: 0;
}

/* 按钮样式 */
.btn {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

.btn-secondary:hover {
  background: #cbd5e0;
}

.btn-danger {
  background: #fc8181;
  color: white;
}

.btn-danger:hover {
  background: #f56565;
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  padding: 2rem;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* 练习区域 */
.practice-container {
  flex: 2;
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#practiceArea {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 开始屏幕 */
.start-screen {
  text-align: center;
}

.start-screen h2 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 1rem;
}

.start-screen p {
  color: #666;
  margin-bottom: 2rem;
}

.start-screen .btn {
  padding: 1rem 3rem;
  font-size: 1.1rem;
}

/* 题目显示 */
.question {
  text-align: center;
  width: 100%;
}

.radical-image {
  margin-bottom: 1.5rem;
}

.radical-image img {
  max-width: 300px;
  max-height: 300px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 反馈信息 */
.feedback {
  font-size: 1.5rem;
  font-weight: bold;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  min-height: 60px;
}

.feedback.correct {
  background: #c6f6d5;
  color: #22543d;
}

.feedback.wrong {
  background: #fed7d7;
  color: #742a2a;
}

.hint {
  color: #718096;
  font-size: 0.9rem;
  margin-top: 1rem;
}

/* 暂停遮罩 */
.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.pause-overlay h3 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 0.5rem;
}

/* 无题目消息 */
.no-questions {
  text-align: center;
}

.no-questions h3 {
  font-size: 1.8rem;
  color: #333;
  margin-bottom: 1rem;
}

.no-questions p {
  color: #666;
  margin-bottom: 1.5rem;
}

/* 统计面板 */
.stats-panel {
  flex: 1;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 350px;
}

.stats-panel h3 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e2e8f0;
}

/* 统计卡片 */
.stat-card {
  background: #f7fafc;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.stat-card .label {
  font-size: 0.85rem;
  color: #718096;
  margin-bottom: 0.25rem;
}

.stat-card .value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #2d3748;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* 错误列表 */
.error-list {
  margin-top: 1rem;
}

.error-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #fff5f5;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.error-item .key {
  background: #fc8181;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

.error-item .name {
  flex: 1;
  margin-left: 0.75rem;
  color: #2d3748;
}

.error-item .count {
  color: #e53e3e;
  font-size: 0.85rem;
  font-weight: 600;
}

.error-list .empty {
  text-align: center;
  color: #718096;
  padding: 1rem;
}

/* 掌握状态 */
.mastery-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
}

.mastery-item {
  text-align: center;
  padding: 1rem;
  border-radius: 8px;
}

.mastery-item.mastered {
  background: #c6f6d5;
}

.mastery-item.need-review {
  background: #fed7d7;
}

.mastery-item .count {
  font-size: 1.8rem;
  font-weight: bold;
}

.mastery-item .label {
  font-size: 0.8rem;
  color: #4a5568;
}

/* 重置按钮 */
.reset-section {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.reset-section .btn {
  width: 100%;
}

/* 工具栏 */
.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* 游戏页面样式 */

/* 游戏容器 */
.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

/* 游戏头部 */
.game-header {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.game-info {
  display: flex;
  gap: 2rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.info-item .label {
  font-size: 0.85rem;
  color: #718096;
  margin-bottom: 0.25rem;
}

.info-item .value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #2d3748;
}

.game-controls {
  display: flex;
  gap: 0.5rem;
}

/* 游戏画布 */
.game-canvas {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  min-height: 400px;
  position: relative;
  overflow: hidden;
}

.game-area {
  width: 100%;
  height: 600px;
  background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

/* 开始屏幕 */
.game-canvas .start-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 20px;
  background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
  z-index: 10;
}

.game-canvas .start-screen h2 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 0.5rem;
}

.game-canvas .start-screen p {
  color: #666;
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* 配置面板 */
.config-panel {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 480px;
}

.config-item {
  display: grid;
  grid-template-columns: 160px 70px 80px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.config-item:last-of-type {
  margin-bottom: 0.5rem;
}

.config-item label {
  font-size: 0.95rem;
  color: #2d3748;
  font-weight: 600;
}

.config-item input[type="number"] {
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1rem;
  text-align: center;
  width: 100%;
}

.config-item input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.config-item input[type="range"] {
  width: 100%;
  margin: 0;
}

.config-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0 auto;
  display: block;
  cursor: pointer;
}

.config-item .config-hint {
  font-size: 0.8rem;
  color: #718096;
}

.btn-small {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

.btn-large {
  padding: 1rem 3rem;
  font-size: 1.2rem;
}

/* 掉落字根 */
.falling-radical {
  position: absolute;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  z-index: 5;
}

.falling-radical .radical-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.falling-radical .key-hint {
  position: absolute;
  bottom: -20px;
  background: #667eea;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

/* 消除动画 */
.falling-radical.eliminated {
  animation: eliminate 0.3s ease-out forwards;
}

@keyframes eliminate {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* 触底效果 */
.falling-radical.hit-bottom {
  background: #fed7d7;
  border: 2px solid #e53e3e;
}

/* 暂停遮罩 */
.game-canvas .pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.game-canvas .pause-overlay h3 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 0.5rem;
}

.game-canvas .pause-overlay p {
  color: #666;
}

/* 结果面板 */
.result-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 2rem;
  overflow-y: auto;
}

.result-panel h2 {
  font-size: 2.5rem;
  color: #333;
  margin-bottom: 2rem;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
  width: 100%;
  max-width: 600px;
}

.result-stat {
  background: #f7fafc;
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}

.result-stat .stat-label {
  font-size: 0.9rem;
  color: #718096;
  margin-bottom: 0.5rem;
}

.result-stat .stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  color: #2d3748;
}

.result-stat .stat-value.grade-a {
  color: #48bb78;
}

.result-stat .stat-value.grade-b {
  color: #68d391;
}

.result-stat .stat-value.grade-c {
  color: #63b3ed;
}

.result-stat .stat-value.grade-d {
  color: #ed8936;
}

.result-stat .stat-value.grade-f {
  color: #f56565;
}

.result-details {
  width: 100%;
  max-width: 600px;
  margin-bottom: 2rem;
}

.result-details h3 {
  font-size: 1.2rem;
  color: #2d3748;
  margin: 1.5rem 0 0.75rem;
}

.result-details h3:first-child {
  margin-top: 0;
}

.error-list-scroll {
  max-height: 200px;
  overflow-y: auto;
  background: #f7fafc;
  border-radius: 8px;
  padding: 1rem;
}

.error-list-scroll .error-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem;
  background: white;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.error-list-scroll .error-item:last-child {
  margin-bottom: 0;
}

.error-item .error-type {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.error-item .error-type.wrong {
  background: #fed7d7;
  color: #c53030;
}

.error-item .error-type.missed {
  background: #feebc8;
  color: #c05621;
}

.error-item .key-badge {
  background: #667eea;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
}

.error-item .radical-name {
  color: #2d3748;
}

.error-item .error-count,
.error-item .error-time {
  color: #718096;
  font-size: 0.85rem;
}

.top-error-radicals .error-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: white;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.result-actions {
  display: flex;
  gap: 1rem;
}

.result-actions .btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
}

/* 隐藏类 */
.hidden {
  display: none !important;
}


/* 页脚友情链接 */
.footer {
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem 2rem;
  margin-top: auto;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.links-section {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.links-section h4 {
  color: #333;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.friend-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.friend-link {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  background: #667eea;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s;
}

.friend-link:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 响应式设计 */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
    padding: 1rem;
  }
  
  .stats-panel {
    max-width: 100%;
  }
  
  .radical-image img {
    max-width: 200px;
    max-height: 200px;
  }
}

@media (max-width: 600px) {
  .header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .header-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .btn {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
  }
}
