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

body {
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #FFF0F0 0%, #F0F4FF 50%, #F0FFF4 100%);
  min-height: 100vh;
  color: #2D3436;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

#backBtn {
  background: none;
  border: none;
  font-size: 24px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: #666;
}

#backBtn:hover {
  background: #f0f0f0;
}

#title {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #2D3436;
  letter-spacing: 1px;
}

#headerRight {
  width: 40px;
}

#app {
  padding-top: 72px;
  padding-bottom: 24px;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Home */
.home-greeting {
  text-align: center;
  padding: 16px 20px 8px;
}

.home-greeting h2 {
  font-size: 26px;
  font-weight: 700;
  color: #2D3436;
}

.home-greeting p {
  font-size: 16px;
  color: #888;
  margin-top: 4px;
}

.home-progress {
  margin: 12px 20px 20px;
  background: white;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.progress-bar-bg {
  height: 12px;
  background: #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #6BCB77, #4D96FF);
  transition: width 0.5s ease;
}

.progress-stats {
  display: flex;
  justify-content: space-around;
  margin-top: 12px;
  font-size: 14px;
  color: #666;
}

.progress-stats span {
  text-align: center;
}

.progress-stats strong {
  display: block;
  font-size: 20px;
  color: #2D3436;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0 20px;
}

.category-card {
  background: white;
  border-radius: 20px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 3px solid transparent;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.category-card:active {
  transform: scale(0.96);
}

.category-card .cat-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
}

.category-card .cat-name {
  font-size: 18px;
  font-weight: 600;
  color: #2D3436;
}

.category-card .cat-progress {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

.category-card .cat-bar {
  height: 4px;
  background: #f0f0f0;
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.category-card .cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Category Page */
.category-header {
  text-align: center;
  padding: 8px 20px 16px;
}

.category-header .cat-icon-big {
  font-size: 48px;
  display: block;
  margin-bottom: 4px;
}

.category-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.category-header .cat-stats {
  font-size: 14px;
  color: #999;
  margin-top: 4px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 20px;
}

.char-card {
  background: white;
  border-radius: 16px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: relative;
  border: 2px solid transparent;
}

.char-card:active {
  transform: scale(0.95);
}

.char-card .char-display {
  font-size: 42px;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.char-card .char-pinyin {
  font-size: 14px;
  color: #999;
  margin-top: 4px;
}

.char-card .char-emoji {
  font-size: 24px;
  display: block;
  margin-top: 4px;
}

.char-card .char-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 14px;
}

.char-card.learned {
  border-color: #6BCB77;
}

.char-card.mastered {
  border-color: #4D96FF;
  background: #f8fffb;
}

/* Learn Page */
.learn-container {
  padding: 0 20px;
  text-align: center;
}

.learn-category-badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: white;
  margin-bottom: 16px;
}

.learn-char-box {
  background: white;
  border-radius: 24px;
  padding: 40px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.learn-char {
  font-size: 96px;
  font-weight: 700;
  display: block;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.3s;
  user-select: none;
}

.learn-char:active {
  transform: scale(0.95);
}

.learn-pinyin {
  font-size: 28px;
  color: #666;
  margin-top: 8px;
  letter-spacing: 2px;
}

.learn-emoji-box {
  font-size: 72px;
  padding: 16px 0;
  cursor: pointer;
  transition: transform 0.3s;
}

.learn-emoji-box:active {
  transform: scale(0.95);
}

.learn-hint {
  font-size: 16px;
  color: #bbb;
  margin-top: 8px;
}

.learn-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.learn-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  color: white;
}

.learn-btn:active {
  transform: scale(0.95);
}

.learn-btn.sound {
  background: #4D96FF;
}

.learn-btn.learned {
  background: #6BCB77;
}

.learn-btn.quiz {
  background: #FF6B6B;
}

.learn-btn.prev {
  background: #bbb;
}

.learn-btn.next {
  background: #A66CFF;
}

.learn-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  gap: 12px;
}

.learn-nav-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  color: #666;
}

.learn-nav-btn:active {
  transform: scale(0.95);
}

/* Quiz Page */
.quiz-container {
  padding: 0 20px;
}

.quiz-header {
  text-align: center;
  padding: 8px 0 16px;
}

.quiz-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.quiz-score {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 8px 0 4px;
  font-size: 18px;
  font-weight: 600;
}

.quiz-score .correct {
  color: #6BCB77;
}

.quiz-score .wrong {
  color: #FF6B6B;
}

.quiz-question {
  text-align: center;
  margin: 12px 0 24px;
}

.quiz-prompt {
  font-size: 18px;
  color: #888;
  margin-bottom: 12px;
}

.quiz-emoji-display {
  font-size: 80px;
  display: block;
  padding: 16px 0;
}

.quiz-char-display {
  font-size: 80px;
  font-weight: 700;
  display: block;
  padding: 16px 0;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quiz-option {
  padding: 20px 12px;
  border: 3px solid #eee;
  border-radius: 16px;
  background: white;
  font-size: 36px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.3s, background 0.3s;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.quiz-option.char-opt {
  font-size: 36px;
}

.quiz-option.emoji-opt {
  font-size: 48px;
}

.quiz-option:active {
  transform: scale(0.95);
}

.quiz-option.correct {
  border-color: #6BCB77;
  background: #f0fff4;
  animation: pop 0.3s ease;
}

.quiz-option.wrong {
  border-color: #FF6B6B;
  background: #fff0f0;
  animation: shake 0.4s ease;
}

.quiz-results {
  text-align: center;
  padding: 20px;
}

.quiz-results .result-stars {
  font-size: 48px;
  margin: 12px 0;
}

.quiz-results .result-text {
  font-size: 20px;
  color: #666;
  margin: 8px 0;
}

.quiz-results .result-score {
  font-size: 36px;
  font-weight: 700;
}

.quiz-btn {
  padding: 14px 40px;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
  color: white;
  margin: 8px;
}

.quiz-btn:active {
  transform: scale(0.95);
}

.quiz-btn.primary {
  background: #FF6B6B;
}

.quiz-btn.secondary {
  background: #4D96FF;
}

.quiz-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 18px;
}

/* Matching Game */
.matching-game {
  max-width: 500px;
  margin: 0 auto;
}

.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.match-char {
  flex: 1;
  padding: 16px;
  border: 3px solid #eee;
  border-radius: 14px;
  background: white;
  font-size: 36px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.3s;
}

.match-char:active {
  transform: scale(0.95);
}

.match-char.selected {
  border-color: #4D96FF;
  background: #f0f6ff;
}

.match-char.matched {
  border-color: #6BCB77;
  background: #f0fff4;
  opacity: 0.6;
}

.match-emoji {
  flex: 1;
  padding: 16px;
  border: 3px solid #eee;
  border-radius: 14px;
  background: white;
  font-size: 40px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.3s;
}

.match-emoji:active {
  transform: scale(0.95);
}

.match-emoji.selected {
  border-color: #FFB347;
  background: #fffbf0;
}

.match-emoji.matched {
  border-color: #6BCB77;
  background: #f0fff4;
  opacity: 0.6;
}

.match-emoji.wrong {
  border-color: #FF6B6B;
  background: #fff0f0;
  animation: shake 0.4s ease;
}

.match-connector {
  font-size: 20px;
  color: #ddd;
  flex-shrink: 0;
}

/* Animations */
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

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

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

.fade-in {
  animation: fadeInUp 0.4s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.bounce {
  animation: bounce 0.5s ease;
}

@keyframes starSpin {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(180deg); }
  100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

.star-spin {
  animation: starSpin 0.5s ease forwards;
}

/* Mode Selection */
.mode-select {
  text-align: center;
  padding: 12px 0 8px;
}

.mode-select p {
  font-size: 16px;
  color: #888;
  margin-bottom: 16px;
}

.mode-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 16px 24px;
  border: 3px solid #eee;
  border-radius: 16px;
  background: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  text-align: center;
}

.mode-btn:active {
  transform: scale(0.95);
}

.mode-btn .mode-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

/* Responsive */
@media (min-width: 600px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .char-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 768px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
  .char-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
