/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, "Helvetica Neue", "PingFang SC", Arial, sans-serif;
  background: linear-gradient(135deg, #fdf6e3 0%, #e8f5e9 50%, #e3f2fd 100%);
  min-height: 100vh;
  color: #333;
}

/* ===== Header / Nav Bar ===== */
.app-header {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: #5b8fd4;
  font-size: 15px;
  font-weight: 500;
  margin-right: 16px;
  padding: 6px 10px;
  border-radius: 10px;
  transition: background .2s;
}

.back-btn:hover { background: rgba(91,143,212,0.1); }

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.app-subtitle {
  font-size: 13px;
  color: #999;
  margin-left: 8px;
}

/* ===== Container ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ===== Lesson List (Home) ===== */
.page-title {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: #2c2c2c;
}

.page-desc {
  text-align: center;
  color: #999;
  font-size: 14px;
  margin-bottom: 32px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.lesson-card {
  position: relative;
  border-radius: 20px;
  padding: 28px 24px;
  text-decoration: none;
  color: #fff;
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease;
  cursor: pointer;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.lesson-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.15);
}

.lesson-card:active { transform: translateY(-2px); }

.lesson-card-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.lesson-card-meta {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 12px;
}

.lesson-card-count {
  display: inline-block;
  background: rgba(255,255,255,0.25);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* Card gradient palette */
.lesson-bg-0 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.lesson-bg-1 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.lesson-bg-2 { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.lesson-bg-3 { background: linear-gradient(135deg, #fa709a, #fee140); }
.lesson-bg-4 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.lesson-bg-5 { background: linear-gradient(135deg, #fccb90, #d57eeb); }

/* ===== Word Cards (Lesson Detail) ===== */
.lesson-header {
  text-align: center;
  margin-bottom: 28px;
}

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

.lesson-header p {
  color: #999;
  font-size: 14px;
  margin-top: 4px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  perspective: 800px;
}

/* 3D Flip Card */
.flip-card {
  height: 160px;
  cursor: pointer;
  perspective: 800px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.flip-card-front {
  background: #fff;
}

.flip-card-front .word-en {
  font-size: 22px;
  font-weight: 700;
  color: #333;
}

.flip-card-front .flip-hint {
  font-size: 11px;
  color: #bbb;
  margin-top: 10px;
}

.flip-card-back {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  transform: rotateY(180deg);
}

.flip-card-back .word-zh {
  font-size: 22px;
  font-weight: 700;
}

.flip-card-back .word-context {
  font-size: 13px;
  margin-top: 8px;
  opacity: 0.85;
  text-align: center;
  line-height: 1.4;
}

/* Soft color accents for card fronts */
.flip-card-front.card-color-0 { border-left: 5px solid #f093fb; }
.flip-card-front.card-color-1 { border-left: 5px solid #4facfe; }
.flip-card-front.card-color-2 { border-left: 5px solid #43e97b; }
.flip-card-front.card-color-3 { border-left: 5px solid #fa709a; }
.flip-card-front.card-color-4 { border-left: 5px solid #a18cd1; }
.flip-card-front.card-color-5 { border-left: 5px solid #fccb90; }
.flip-card-front.card-color-6 { border-left: 5px solid #f5576c; }
.flip-card-front.card-color-7 { border-left: 5px solid #00f2fe; }

/* Quiz Button */
.quiz-btn-wrap {
  text-align: center;
  margin-top: 36px;
}

.quiz-btn {
  display: inline-block;
  padding: 14px 48px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}

.quiz-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(102,126,234,0.35);
}

.quiz-btn:active { transform: translateY(-1px); }

/* ===== Quiz Mode ===== */
.quiz-container {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.quiz-progress {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.quiz-progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 28px;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 4px;
  transition: width .4s ease;
}

.quiz-prompt-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 6px;
}

.quiz-prompt {
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 32px;
  color: #2c2c2c;
  line-height: 1.3;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.quiz-option {
  padding: 18px 14px;
  font-size: 17px;
  font-weight: 500;
  border: 2px solid #e0e0e0;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  transition: border-color .2s, transform .15s, background .2s, color .2s;
  color: #333;
}

.quiz-option:hover {
  border-color: #667eea;
  transform: scale(1.03);
}

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

.quiz-option.correct {
  border-color: #43e97b;
  background: #e8f9ef;
  color: #2d8a4e;
  animation: pop 0.35s ease;
}

.quiz-option.wrong {
  border-color: #f5576c;
  background: #fde8e8;
  color: #c0392b;
  animation: shake 0.4s ease;
}

.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.55;
}

/* ===== Quiz Result ===== */
.quiz-result {
  text-align: center;
  padding-top: 40px;
}

.result-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

.result-score {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea, #f5576c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-label {
  font-size: 15px;
  color: #999;
  margin-top: 4px;
  margin-bottom: 12px;
}

.result-message {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 32px;
}

.result-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.result-btn {
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  text-decoration: none;
}

.result-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.result-btn.primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.result-btn.secondary {
  background: #f0f0f0;
  color: #555;
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

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

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

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
  font-size: 15px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .container {
    padding: 20px 14px 40px;
  }

  .page-title { font-size: 22px; }

  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .word-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }

  .flip-card { height: 140px; }

  .flip-card-front .word-en { font-size: 18px; }
  .flip-card-back .word-zh { font-size: 18px; }

  .quiz-prompt { font-size: 24px; }

  .quiz-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .quiz-option { padding: 14px 12px; font-size: 16px; }
}
