/* 字母认知子应用样式 */

.letter-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 400px) {
  .letter-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 768px) {
  .letter-grid {
    grid-template-columns: repeat(7, 1fr);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
}

.letter-cell {
  aspect-ratio: 1;
  border-radius: 14px;
  border: none;
  font-size: 1.8rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
  padding: 4px;
}

.letter-cell:active {
  transform: scale(0.9);
}

.letter-cell .lower {
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 2px;
}

/* 字母颜色循环 */
.letter-cell:nth-child(6n+1) { background: linear-gradient(135deg, #FFE66D, #FFF5CC); }
.letter-cell:nth-child(6n+2) { background: linear-gradient(135deg, #FF8A9E, #FFD4DC); }
.letter-cell:nth-child(6n+3) { background: linear-gradient(135deg, #4ECDC4, #A8E6E0); }
.letter-cell:nth-child(6n+4) { background: linear-gradient(135deg, #A29BFE, #DDD6FE); }
.letter-cell:nth-child(6n+5) { background: linear-gradient(135deg, #55EFC4, #B8F5E0); }
.letter-cell:nth-child(6n+6) { background: linear-gradient(135deg, #74B9FF, #D4ECFF); }

/* ===== 学习进度条 ===== */
.learn-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px auto 0;
  max-width: 600px;
}

.learn-progress .progress-bar-bg {
  flex: 1;
  height: 14px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.learn-progress .progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #FF8E8E);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.learn-progress .progress-text {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--primary);
  white-space: nowrap;
}

/* ===== 已学标记 ===== */
.learned-mark {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  color: var(--secondary);
  opacity: 0;
  transition: opacity 0.2s;
}

.letter-cell {
  position: relative;
}

.letter-cell.learned .learned-mark {
  opacity: 1;
}

.letter-cell.learned {
  box-shadow: var(--shadow), 0 0 0 3px var(--secondary);
}

/* ===== 模式入口按钮 ===== */
.mode-entry {
  display: block;
  margin: 20px auto 0;
  min-width: 200px;
}

/* ===== 学习页面 ===== */
.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.score {
  font-size: 1rem;
  font-weight: bold;
  color: var(--primary);
  background: #fff;
  padding: 4px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.letter-learn-stage {
  text-align: center;
}

.letter-display {
  width: 160px;
  height: 160px;
  margin: 16px auto;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), #FF8E8E);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  position: relative;
}

.letter-display .upper {
  font-size: 5rem;
  color: #fff;
  font-weight: bold;
  line-height: 1;
}

.letter-display .lower {
  font-size: 2.4rem;
  color: rgba(255,255,255,0.7);
  position: absolute;
  bottom: 16px;
  right: 24px;
  font-weight: bold;
}

.speak-btn {
  font-size: 1.1rem;
  margin: 12px 0;
}

.speak-btn.large {
  font-size: 1.3rem;
  padding: 14px 32px;
}

.word-examples {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.word-card {
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 80px;
  cursor: pointer;
  transition: transform 0.15s;
}

.word-card:active {
  transform: scale(0.95);
}

.word-card .emoji {
  font-size: 1.6rem;
  display: block;
}

.word-card .word {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--text);
}

.word-card .zh {
  font-size: 0.75rem;
  color: #888;
}

/* ===== 描红区域 ===== */
.trace-area {
  margin: 16px auto;
  max-width: 300px;
  aspect-ratio: 1;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  touch-action: none;
}

#traceCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.trace-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 12px 0;
}

/* ===== 拼读游戏 ===== */
.question {
  text-align: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--primary);
  margin: 16px 0;
}

.phonics-stage {
  text-align: center;
}

.phonics-options {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.phonics-options .option {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  border: none;
  font-size: 1.8rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  font-family: inherit;
}

.phonics-options .option:active {
  transform: scale(0.9);
}

.phonics-options .option:nth-child(1) { background: linear-gradient(135deg, #FFE66D, #FFF5CC); }
.phonics-options .option:nth-child(2) { background: linear-gradient(135deg, #FF8A9E, #FFD4DC); }
.phonics-options .option:nth-child(3) { background: linear-gradient(135deg, #4ECDC4, #A8E6E0); }
.phonics-options .option:nth-child(4) { background: linear-gradient(135deg, #A29BFE, #DDD6FE); }
.phonics-options .option:nth-child(5) { background: linear-gradient(135deg, #55EFC4, #B8F5E0); }

.feedback {
  text-align: center;
  font-size: 1.3rem;
  font-weight: bold;
  min-height: 32px;
  margin-top: 8px;
}

.feedback.ok { color: var(--secondary); }
.feedback.no { color: var(--primary); }

/* TV 端适配 */
@media (min-width: 1600px) {
  .letter-grid {
    grid-template-columns: repeat(10, 1fr);
    max-width: 900px;
  }
  
  .letter-cell {
    font-size: 2.4rem;
  }
  
  .letter-display {
    width: 240px;
    height: 240px;
  }
  
  .letter-display .upper {
    font-size: 8rem;
  }
  
  .letter-display .lower {
    font-size: 3.5rem;
  }
  
  .trace-area {
    max-width: 400px;
  }
}
