:root {
  --bg: #f8f4ef;
  --panel: #ffffff;
  --text: #2f251f;
  --muted: #6f6258;
  --line: #ddcec0;
  --brand: #c30000;
  --brand-soft: #f9dddd;
  --accent: #7a6f60;
  --success: #2f7d4f;
  --success-soft: #e3f3e8;
  --danger: #b33632;
  --danger-soft: #f7dcd9;
  --highlight: #fff1c2;
  --highlight-line: #e2b53f;
  --star: #d99a00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #fffbf6, var(--bg) 55%);
  min-height: 100vh;
}

h1, h2, p {
  margin: 0;
}

button {
  font: inherit;
  cursor: pointer;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #faf6f0);
  box-shadow: 0 4px 20px rgba(195, 0, 0, 0.08);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.master-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.topbar h1 {
  font-size: 1.4rem;
}

.topbar p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- Layout ---- */
.layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 16px 60px;
}

.screen-title {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 20px;
  color: var(--brand);
}

.screen-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.center-row {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

/* ---- Buttons (shared) ---- */
.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 22px;
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(195, 0, 0, 0.25);
}

.primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.primary:disabled {
  opacity: 0.45;
  box-shadow: none;
}

.primary.success {
  background: var(--success);
  box-shadow: 0 6px 16px rgba(47, 125, 79, 0.28);
}

.secondary {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 20px;
  font-weight: 600;
}

.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  color: var(--muted);
}

.ghost.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.speak-btn {
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
}

.speak-btn.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.icon-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 1.1rem;
  line-height: 1;
}

.icon-btn:hover,
.speak-btn:hover,
.ghost:hover {
  border-color: var(--brand);
}

/* ---- Grade select ---- */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 520px) {
  .grade-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grade-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 14px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(195, 0, 0, 0.08);
}

.grade-card:hover:not(:disabled) {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.grade-card .grade-big {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand);
  line-height: 1.1;
}

.grade-card .grade-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

.grade-card:disabled {
  opacity: 0.55;
  box-shadow: none;
}

.grade-card:disabled .grade-big {
  color: var(--accent);
}

.soon-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}

/* ---- Skill select ---- */
.skill-group {
  margin-bottom: 26px;
}

.skill-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px 4px;
}

.skill-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 520px) {
  .skill-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.skill-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  box-shadow: 0 4px 14px rgba(195, 0, 0, 0.06);
}

.skill-card:hover {
  border-color: var(--brand);
}

.skill-icon {
  font-size: 1.7rem;
  line-height: 1;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.skill-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.skill-name {
  font-weight: 700;
  font-size: 1rem;
}

.skill-stars {
  font-size: 0.85rem;
  color: var(--muted);
}

.skill-stars.has-stars {
  color: var(--star);
  font-size: 1rem;
  letter-spacing: 0.05em;
}

/* ---- Lesson ---- */
.lesson-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 6px 20px rgba(195, 0, 0, 0.08);
}

.lesson-icon {
  font-size: 2.4rem;
  text-align: center;
}

.lesson-title {
  text-align: center;
  color: var(--brand);
  font-size: 1.5rem;
  margin: 6px 0 12px;
}

.lesson-intro {
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.45;
}

.lesson-points {
  margin: 0 0 18px;
  padding-left: 22px;
  line-height: 1.55;
}

.lesson-points li {
  margin-bottom: 8px;
}

.lesson-subhead {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.lesson-examples {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.example {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.example-text {
  font-size: 1.1rem;
  line-height: 1.5;
}

.example-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 4px;
}

mark {
  background: var(--highlight);
  border-bottom: 2px solid var(--highlight-line);
  border-radius: 4px;
  padding: 0 3px;
  color: inherit;
}

.teacher-note {
  margin-top: 18px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

/* ---- Practice ---- */
.practice-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.practice-title {
  font-weight: 700;
  color: var(--brand);
  text-align: center;
  flex: 1;
  min-width: 0;
}

.practice-count {
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.progress-track {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 6px 20px rgba(195, 0, 0, 0.08);
}

.prompt-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.question-prompt {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
}

.question-text {
  font-size: 1.2rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.blank {
  display: inline-block;
  min-width: 70px;
  border-bottom: 3px solid var(--brand);
  margin: 0 2px;
}

/* multiple choice */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  font-size: 1.05rem;
  line-height: 1.4;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--brand);
}

.choice-btn.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* tap the words */
.tap-sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 1.25rem;
  line-height: 1.3;
}

.tap-word {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 1.2rem;
}

.tap-word:hover:not(:disabled) {
  border-color: var(--brand);
}

.tap-word.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

/* sort into buckets */
.sort-hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 52px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  margin-bottom: 14px;
}

.word-bank.empty::after {
  content: "All sorted!";
  color: var(--muted);
  font-size: 0.9rem;
  align-self: center;
}

.chip {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 1.02rem;
  text-align: left;
}

.chip:hover:not(:disabled) {
  border-color: var(--brand);
}

.chip.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(195, 0, 0, 0.15);
}

.bucket-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 520px) {
  .bucket-row.cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .bucket-row.cols-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.bucket {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  text-align: left;
}

@media (max-width: 519px) {
  .bucket {
    min-height: 72px;
  }
}

.bucket.ready {
  border-color: var(--brand);
  background: #fff7f5;
}

.bucket-title {
  font-weight: 700;
  color: var(--brand);
  font-size: 0.95rem;
  text-align: center;
}

.bucket-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* checked states (shared by all activity types) */
.is-correct {
  border-color: var(--success) !important;
  background: var(--success-soft) !important;
  color: var(--success) !important;
  font-weight: 700;
}

.is-wrong {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  text-decoration: line-through;
}

.is-missed {
  border-color: var(--success) !important;
  border-style: dashed !important;
  color: var(--success) !important;
  font-weight: 700;
}

.chip-fix {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}

.check-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.check-row .primary {
  min-width: 180px;
}

.feedback {
  margin-top: 18px;
  border-radius: 18px;
  padding: 18px 20px;
  border: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.feedback.good {
  background: var(--success-soft);
  border-color: var(--success);
}

.feedback.bad {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.feedback-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.feedback.good .feedback-title {
  color: var(--success);
}

.feedback.bad .feedback-title {
  color: var(--danger);
}

.feedback-why {
  line-height: 1.5;
}

.feedback .primary {
  align-self: flex-end;
  margin-top: 6px;
}

/* ---- Summary ---- */
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 20px;
  text-align: center;
  margin-bottom: 22px;
  box-shadow: 0 6px 20px rgba(195, 0, 0, 0.08);
}

.summary-stars {
  font-size: 2.4rem;
  letter-spacing: 0.1em;
  color: var(--star);
}

.summary-score {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand);
  margin-top: 6px;
}

.summary-sub {
  color: var(--muted);
  margin-top: 6px;
}

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

.summary-actions button {
  width: 100%;
  max-width: 320px;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 24px 20px 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--brand);
}
