:root {
  --bg: #f6f8fc;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --surface: #ffffff;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --green: #16a34a;
  --pill: #f1f5f9;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 10px;
  display: grid;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  font-weight: 800;
}

h2 {
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.25;
  font-weight: 800;
}

.lede {
  color: var(--muted);
  line-height: 1.6;
  margin-top: 6px;
  max-width: 800px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--pill);
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}

.progress-shell {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff 0%, #eef2ff 100%);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.progress-meta,
.score-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--text);
}

.progress-meta {
  margin-bottom: 8px;
}

.progress-label {
  color: #475569;
  font-weight: 700;
  font-size: 13px;
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-bottom: 10px;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 250ms ease;
}

.score-meta {
  font-size: 14px;
  color: #1f2937;
}

.lesson-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 20px 32px;
}

.lesson {
  display: grid;
  gap: 14px;
}

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

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#lesson-title {
  margin-top: 4px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  position: relative;
}

.card-title {
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  margin-bottom: 6px;
}

.card-sub {
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.option:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.option.active {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
  background: #eef2ff;
}

.output {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: #f8fafc;
  font-weight: 600;
  color: var(--text);
}

.output.muted {
  color: var(--muted);
}

.flip-grid {
  display: grid;
  gap: 8px;
}

.flip {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #f8fafc;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.flip:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.flip .front,
.flip .back {
  transition: opacity 200ms ease;
}

.flip .back {
  display: none;
}

.flip.flipped .front {
  display: none;
}

.flip.flipped .back {
  display: block;
}


/* Large Single Flip Card */
/* Large Single Flip Card */
.flip-stack {
  display: flex;
  flex-direction: column;
  /* Allow button below */
  justify-content: center;
  align-items: center;
  min-height: 380px;
  /* Increased for button space */
  perspective: 1000px;
  padding: 10px;
}

.action-bar {
  margin-top: 30px;
  min-height: 50px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.flip.large {
  width: 100%;
  max-width: 420px;
  height: 280px;
  position: relative;
  /* Removed padding/bg from wrapper, these belong to faces now to fix "tiny button" look */
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

/* Common Face Styles */
.flip .front,
.flip .back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  backface-visibility: hidden;
  transition: transform 0.8s ease-in-out;
  /* Gentle */
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.15), 0 5px 15px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px;
  text-align: center;
}

/* Front Face */
.flip .front {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transform: rotateX(0deg);
  z-index: 2;
}

.flip.large .flip-title {
  color: #ffffff;
  font-size: 1.8rem;
  margin-bottom: 16px;
  line-height: 1.2;
}

.flip.large .flip-text {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.25rem;
  font-weight: 500;
}

/* Back Face */
.flip .back {
  background: #ffffff;
  border: 1px solid var(--border);
  transform: rotateX(180deg);
  z-index: 1;
}

.flip .back .flip-title {
  color: var(--text);
  font-size: 1.4rem;
}

.flip .back .flip-text {
  color: var(--muted);
  font-size: 1.1rem;
}

/* Flipped State */
.flip.flipped .front {
  transform: rotateX(-180deg);
}

.flip.flipped .back {
  transform: rotateX(0deg);
  z-index: 3;
}

/* Animation */
.flip.fly-away {
  animation: flyAway 0.5s ease-in forwards;
  pointer-events: none;
  opacity: 0;
}

@keyframes flyAway {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  to {
    transform: translateY(-50px) scale(0.8);
    opacity: 0;
  }
}

/* Bucket Grid */
.bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.bucket-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.bucket-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
  color: var(--text);
}

/* Completion Card Styles */
.completion-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  animation: fadeIn 0.5s ease;
}

.completion-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
  max-width: 400px;
  width: 90%;
  position: relative;
  overflow: hidden;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.completion-card h2 {
  font-size: 1.8rem;
  margin: 10px 0;
  color: var(--text);
  background: linear-gradient(90deg, #1e293b, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sub-text {
  color: var(--muted);
  margin-bottom: 30px;
  font-size: 1rem;
}

.confetti {
  font-size: 3rem;
  margin-bottom: 10px;
  animation: bounce 2s infinite;
}

.score-breakdown {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 30px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: var(--muted);
}

.score-row strong {
  color: var(--text);
}

.score-row.highlight {
  color: var(--accent);
  font-weight: 500;
}

.score-row.highlight strong {
  color: var(--accent);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 15px 0;
}

.score-row.total {
  margin-bottom: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

/* ChatBot Interface */
.chat-interface {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 500px;
  position: relative;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #cbd5e1;
}

.chat-header h3 {
  font-size: 1rem;
  margin: 0;
}

.status {
  font-size: 0.75rem;
  color: #10b981;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fff;
}

.msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  animation: slideUp 0.3s ease;
}

.msg.buyer {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg.seller {
  align-self: flex-end;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg.typing span {
  display: inline-block;
  animation: bounce 1s infinite;
  margin: 0 1px;
}

.chat-controls {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 80px;
}

.chat-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.chat-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Report Card */
.report-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  background: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  z-index: 10;
  text-align: center;
  animation: popIn 0.4s ease;
}

.report-card.hidden {
  display: none;
}

.feedback-item {
  text-align: left;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  border-left: 4px solid #cbd5e1;
}

.feedback-item.good {
  border-left-color: #10b981;
}

.feedback-item.avg {
  border-left-color: #f59e0b;
}

.feedback-item.bad {
  border-left-color: #ef4444;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* Modal Popup Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

.modal-box {
  background: #ffffff;
  padding: 24px 32px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 320px;
  width: 90%;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-box h3 {
  margin: 0 0 8px 0;
  color: var(--text);
}

.modal-box p {
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.modal-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}

.modal-actions button:active {
  transform: scale(0.95);
}

.btn-cancel {
  background: #f1f5f9;
  color: var(--text);
}

.btn-confirm {
  background: var(--accent);
  color: #ffffff;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Next Button in Card */
.flip-action {
  margin-top: 24px;
  animation: fadeIn 0.3s ease 0.2s forwards;
  opacity: 0;
}

.flip.flipped .flip-action {
  opacity: 1;
}

/* Base Flip Styles (retained) */
.flip-title {
  font-weight: 800;
}

.flip-text {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.quiz-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  background: #f8fafc;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-dark {
  background: linear-gradient(120deg, #0f172a, #1f2a44);
  color: #ffffff;
  border-color: #0f172a;
}

.btn-dark:hover {
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
}

.summary {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 14px;
  grid-template-columns: 2fr 1fr;
  align-items: center;
}

.scorecard {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #eef2ff, #e0f2fe);
  text-align: center;
}

.score-label {
  font-weight: 700;
  color: var(--muted);
}

.score-value {
  font-size: 28px;
  font-weight: 800;
  margin: 6px 0;
}

.score-note {
  color: var(--muted);
  font-size: 14px;
}

.nav-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.muted {
  color: #64748b;
}

.quiz-block {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.quiz-question {
  font-weight: 700;
  margin-bottom: 8px;
}

.seller {
  font-weight: 700;
  margin-bottom: 4px;
}

.judge {
  font-weight: 700;
}

.judge.good {
  color: #15803d;
}

.judge.bad {
  color: #b91c1c;
}

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

@media (max-width: 768px) {
  .hero {
    padding: 20px 18px 8px;
  }

  .lesson-header {
    flex-direction: column;
    align-items: flex-start;
  }

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