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

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
  line-height: 1.8;
}

.screen { display: none; }
.screen.active { display: block; }

/* ===== Mute Button ===== */
.mute-btn {
  background: none;
  border: 1px solid #444;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
}
.mute-btn:hover { border-color: #f5af19; background: rgba(245,175,25,0.1); }

.home-mute {
  position: absolute;
  top: 20px;
  right: 20px;
}

/* ===== Home Header ===== */
.home-header {
  text-align: center;
  padding: 50px 20px 30px;
  position: relative;
}
.home-header h1 {
  font-size: 2.2rem;
  background: linear-gradient(135deg, #f5af19, #f12711);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.subtitle { color: #777; font-size: 1rem; }

/* ===== Gate Section (Quiz + Unlock) ===== */
.gate-section { max-width: 800px; margin: 20px auto; padding: 0 20px; }
.gate-section.hidden { display: none; }
.gate-card {
  background: linear-gradient(135deg, rgba(245,175,25,0.1), rgba(241,39,17,0.05));
  border: 2px solid #f5af19;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
}
.gate-card h2 { color: #f5af19; margin-bottom: 10px; }
.gate-card p { color: #aaa; margin-bottom: 20px; }
.gate-complete { border-color: #4caf50; }
.gate-emoji { font-size: 3rem; margin-bottom: 12px; }

/* ===== Lesson Grid ===== */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}
.lesson-card {
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
  background: #16162a;
  border: 2px solid #2a2a4a;
}
.lesson-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 40px rgba(245,175,25,0.25);
  border-color: #f5af19;
}
.lesson-card.locked { opacity: 0.5; cursor: default; filter: grayscale(0.5); }
.lesson-card.locked:hover { transform: none; box-shadow: none; border-color: #2a2a4a; }

.lesson-card-img { position: relative; aspect-ratio: 2/3; overflow: hidden; }
.lesson-card-img img { width: 100%; height: 100%; object-fit: cover; }

.lock-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #888;
  backdrop-filter: blur(4px);
}

.done-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(76,175,80,0.9);
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.done-badge-toggle {
  background: rgba(255,255,255,0.2);
  color: #ccc;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0;
  border: 1px solid rgba(255,255,255,0.3);
}
.lesson-card:hover .done-badge-toggle {
  opacity: 1;
}
.done-badge-toggle:hover {
  background: rgba(76,175,80,0.9);
  color: #fff;
  border-color: #4caf50;
}

.lesson-card-info { padding: 12px; display: flex; align-items: center; gap: 8px; }
.lesson-card-num {
  background: #f5af19; color: #000;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.lesson-card-name { flex: 1; font-size: 0.95rem; font-weight: 600; }
.badge-free {
  background: rgba(76,175,80,0.2); color: #4caf50;
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.75rem; font-weight: 600;
}

/* ===== Quiz Entry (old - kept for reference) ===== */
.btn-quiz-start {
  background: linear-gradient(135deg, #f5af19, #f12711);
  border: none; color: #fff;
  padding: 14px 32px; border-radius: 25px;
  font-size: 1.1rem; font-weight: 600;
  cursor: pointer; transition: all 0.3s;
}
.btn-quiz-start:hover { transform: scale(1.05); }

/* ===== Lesson Header ===== */
.lesson-header {
  position: sticky; top: 0;
  background: rgba(15,15,26,0.95);
  backdrop-filter: blur(10px);
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 100;
  border-bottom: 1px solid #1a1a2e;
}
.back-btn {
  background: none; border: 1px solid #444; color: #ccc;
  padding: 8px 16px; border-radius: 20px;
  cursor: pointer; font-size: 0.9rem; transition: all 0.2s;
}
.back-btn:hover { border-color: #f5af19; color: #f5af19; }
.lesson-progress { color: #666; font-size: 0.85rem; }

/* ===== Lesson Container ===== */
.lesson-container, .quiz-container {
  max-width: 640px; margin: 0 auto; padding: 30px 20px 100px;
}

/* ===== Step: Intro ===== */
.card-hero { text-align: center; margin-bottom: 24px; }
.card-hero img {
  width: 200px; border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  border: 3px solid #f5af19;
}
.card-hero.small img { width: 120px; }
.card-title { text-align: center; font-size: 2rem; color: #f5af19; margin-bottom: 4px; }
.card-subtitle { text-align: center; color: #666; font-size: 0.95rem; margin-bottom: 16px; }
.keywords { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; }
.keyword { background: rgba(245,175,25,0.15); color: #f5af19; padding: 5px 14px; border-radius: 20px; font-size: 0.85rem; }
.story-text {
  background: rgba(255,255,255,0.04); border-radius: 12px;
  padding: 20px; border-left: 3px solid #f5af19;
  font-size: 1.05rem; line-height: 2;
}

/* ===== Step: Section ===== */
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.section-icon { font-size: 2rem; }
.section-header h2 { font-size: 1.4rem; color: #f5af19; }
.story-block {
  background: rgba(255,255,255,0.04); border-radius: 12px;
  padding: 20px; margin-bottom: 24px;
  font-size: 1.05rem; line-height: 2;
  border-left: 3px solid #4a4a6a;
}

/* ===== Question Block ===== */
.question-block {
  background: linear-gradient(135deg, rgba(245,175,25,0.08), rgba(241,39,17,0.05));
  border-radius: 16px; padding: 24px; text-align: center;
  margin-bottom: 20px;
  border: 1px dashed rgba(245,175,25,0.3);
}
.question-icon { font-size: 2rem; margin-bottom: 12px; }
.question-text { font-size: 1.1rem; line-height: 1.9; margin-bottom: 16px; color: #ddd; }
.btn-reveal {
  background: linear-gradient(135deg, #f5af19, #f12711);
  border: none; color: #fff;
  padding: 12px 28px; border-radius: 25px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(245,175,25,0.3);
}
.btn-reveal:hover { transform: scale(1.05); }

/* ===== Answer Block ===== */
.answer-block {
  background: rgba(255,255,255,0.06); border-radius: 16px;
  padding: 24px; margin-bottom: 24px;
  border-left: 4px solid #4caf50;
  animation: fadeInUp 0.4s ease-out;
}
.answer-block.hidden { display: none; }
.answer-icon { font-size: 1.5rem; margin-bottom: 8px; }
.answer-text { font-size: 1.05rem; line-height: 2; margin-bottom: 12px; }
.keyword-badge {
  display: inline-block;
  background: rgba(245,175,25,0.15); color: #f5af19;
  padding: 4px 14px; border-radius: 15px; font-size: 0.85rem;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Step: Advice ===== */
.step-advice { text-align: center; }
.advice-icon { font-size: 3rem; margin-bottom: 16px; }
.advice-text {
  background: linear-gradient(135deg, rgba(245,175,25,0.1), rgba(241,39,17,0.05));
  border-radius: 16px; padding: 24px; margin: 24px 0;
  font-size: 1.1rem; line-height: 2;
  border-left: 4px solid #f5af19;
  text-align: left;
}

/* ===== Step Nav ===== */
.step-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 32px; padding-top: 24px;
  border-top: 1px solid #1a1a2e;
}
.btn-next {
  background: linear-gradient(135deg, #f5af19, #f12711);
  border: none; color: #fff;
  padding: 12px 28px; border-radius: 25px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: all 0.3s;
}
.btn-next:hover { transform: scale(1.05); }
.btn-back {
  background: none; border: 1px solid #444; color: #aaa;
  padding: 10px 20px; border-radius: 20px;
  cursor: pointer; font-size: 0.9rem; transition: all 0.2s;
}
.btn-back:hover { border-color: #888; color: #fff; }
.btn-home {
  background: rgba(255,255,255,0.1); border: 1px solid #444; color: #ccc;
  padding: 12px 24px; border-radius: 25px;
  cursor: pointer; font-size: 1rem; transition: all 0.2s;
}
.btn-home:hover { background: rgba(255,255,255,0.15); }

/* ===== Quiz ===== */
.quiz-question { text-align: center; }
.quiz-num { color: #666; font-size: 0.9rem; margin-bottom: 12px; }
.quiz-q-text { font-size: 1.3rem; color: #f5af19; margin-bottom: 28px; line-height: 1.7; }
.quiz-choices { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.quiz-choice {
  background: rgba(255,255,255,0.05);
  border: 2px solid #2a2a4a;
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  transition: all 0.2s;
  font-size: 1rem;
  color: #e0e0e0;
}
.quiz-choice:hover:not(:disabled) {
  border-color: #f5af19;
  background: rgba(245,175,25,0.08);
}
.quiz-choice:disabled { cursor: default; opacity: 0.8; }
.quiz-choice.correct {
  border-color: #4caf50;
  background: rgba(76,175,80,0.15);
}
.quiz-choice.wrong {
  border-color: #f44336;
  background: rgba(244,67,54,0.15);
}
.choice-letter {
  background: #2a2a4a;
  color: #f5af19;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.quiz-choice.correct .choice-letter { background: #4caf50; color: #fff; }
.quiz-choice.wrong .choice-letter { background: #f44336; color: #fff; }

.quiz-feedback {
  margin-top: 20px; padding: 16px;
  border-radius: 12px; text-align: left;
}
.quiz-feedback.hidden { display: none; }
.fb-correct { color: #4caf50; font-weight: 700; font-size: 1.1rem; }
.fb-wrong { color: #f44336; font-weight: 700; font-size: 1.1rem; }
.quiz-feedback p { color: #aaa; margin-top: 8px; line-height: 1.7; }

.quiz-nav { margin-top: 24px; text-align: center; }
.quiz-nav.hidden { display: none; }

/* ===== Quiz Result ===== */
.quiz-result-container {
  max-width: 640px; margin: 0 auto; padding: 40px 20px;
}
.quiz-result { text-align: center; }
.result-emoji { font-size: 4rem; margin-bottom: 16px; }
.quiz-result h2 { font-size: 2rem; color: #f5af19; margin-bottom: 8px; }
.result-message { color: #aaa; font-size: 1.1rem; margin-bottom: 40px; }

.result-actions { margin-bottom: 40px; }
.result-actions h3 { color: #f5af19; margin-bottom: 20px; font-size: 1.3rem; }
.action-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.action-card {
  background: rgba(255,255,255,0.05);
  border: 2px solid #2a2a4a;
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s;
}
.action-card:hover { border-color: #f5af19; }
.action-icon { font-size: 2.5rem; margin-bottom: 12px; }
.action-card h4 { color: #e0e0e0; margin-bottom: 8px; }
.action-card p { color: #888; font-size: 0.9rem; margin-bottom: 12px; }
.action-price {
  font-size: 1.5rem; font-weight: 700; color: #f5af19;
  margin-bottom: 16px;
}
.btn-action {
  border: none; padding: 12px 24px; border-radius: 25px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: all 0.3s; width: 100%;
}
.btn-pay {
  background: linear-gradient(135deg, #f5af19, #f12711);
  color: #fff;
}
.btn-referral {
  background: rgba(76,175,80,0.2);
  color: #4caf50;
  border: 1px solid #4caf50;
}
.btn-action:hover { transform: scale(1.03); }

.result-review {
  display: flex; flex-direction: column; gap: 12px;
  align-items: center;
}

/* ===== Quiz Review ===== */
.quiz-review-item {
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: left;
}
.quiz-review-item.review-correct { border-left: 4px solid #4caf50; }
.quiz-review-item.review-wrong { border-left: 4px solid #f44336; }
.review-num { font-weight: 700; margin-bottom: 8px; }
.review-q { color: #ddd; margin-bottom: 8px; }
.review-your { color: #888; }
.review-correct-ans { color: #4caf50; }
.review-explain { color: #666; margin-top: 8px; font-size: 0.9rem; }

/* ===== Footer ===== */
.home-footer {
  text-align: center; padding: 40px 20px;
  color: #444; font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .home-header h1 { font-size: 1.6rem; }
  .lesson-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 14px; }
  .card-hero img { width: 160px; }
  .card-title { font-size: 1.6rem; }
  .story-text, .story-block { padding: 16px; font-size: 1rem; }
  .question-text { font-size: 1rem; }
  .action-cards { grid-template-columns: 1fr; }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(22, 22, 42, 0.98);
  border: 1px solid #f5af19;
  border-radius: 16px;
  padding: 16px 24px;
  color: #e0e0e0;
  font-size: 0.95rem;
  z-index: 9999;
  max-width: 90%;
  text-align: center;
  animation: toastIn 0.3s ease-out;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0f0f1a; }
::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #f5af19; }
