:root {
  --paper: #f7f0df;
  --paper-deep: #eadbbd;
  --card: #fffaf0;
  --ink: #241b13;
  --muted: #6d604d;
  --line: #d7c5a0;
  --accent: #783024;
  --accent-dark: #4f1e17;
  --gold: #a9782d;
  --shadow: 0 14px 36px rgba(36, 27, 19, 0.11);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Tahoma, "Noto Sans Thai", "Segoe UI", Arial, sans-serif;
  line-height: 1.62;
  background:
    radial-gradient(circle at top left, rgba(169, 120, 45, 0.16), transparent 34rem),
    linear-gradient(180deg, var(--paper), #f2e6cc);
  color: var(--ink);
}

a {
  color: inherit;
}

.archive-hero,
.lesson-header,
.archive-main,
.stage-shell,
.site-footer {
  width: min(1180px, calc(100% - 44px));
  margin: 0 auto;
}

.archive-hero {
  padding: 58px 0 24px;
}

.hero-inner {
  border-bottom: 1px solid var(--line);
  padding-bottom: 26px;
}

.lesson-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 34px 0 18px;
}

.archive-mark {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.2;
}

.hero-subtitle,
.english-title {
  color: var(--muted);
  font-weight: 700;
}

.hero-subtitle {
  margin-bottom: 24px;
  font-size: clamp(1.08rem, 2vw, 1.45rem);
}

.english-title {
  margin-bottom: 10px;
  font-size: 1.04rem;
}

.lesson-summary,
.preservation-note,
.intro-grid,
.site-footer {
  color: var(--muted);
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  max-width: 1040px;
  margin-bottom: 18px;
  font-size: 1.02rem;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button-link,
.start-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 15px;
  background: var(--accent);
  color: #fffaf0;
  font-weight: 700;
  text-decoration: none;
}

.button-link.secondary {
  border-color: var(--line);
  background: var(--card);
  color: var(--ink);
}

.button-link:hover,
.button-link:focus,
.start-link:hover,
.start-link:focus {
  background: var(--accent-dark);
  color: #fffaf0;
}

.button-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.archive-main {
  padding: 18px 0 58px;
}

.section-heading {
  margin-bottom: 16px;
}

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

.lesson-card {
  display: flex;
  min-height: 245px;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.lesson-card p {
  color: var(--muted);
}

.lesson-number {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 250, 240, 0.5);
  border-radius: 50%;
  background: var(--accent);
  color: #fffaf0;
  font-weight: 700;
}

.stage-shell {
  padding: 8px 0 46px;
}

.stage-card {
  display: grid;
  place-items: center;
  min-height: 650px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.ruffle-stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 590px;
}

.ruffle-stage ruffle-player,
.ruffle-stage object,
.ruffle-stage embed {
  display: block;
  width: min(100%, 980px);
  height: min(75vh, 735px);
  min-height: 560px;
  border-radius: 8px;
  background: #000;
}

.lesson-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 250, 240, 0.62);
}

.lesson-note p,
.site-footer p {
  margin-bottom: 0;
}

.loading-message,
.error-message {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.error-message {
  color: var(--accent-dark);
  font-weight: 700;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  font-size: 0.95rem;
}

@media (max-width: 860px) {
  .archive-hero,
  .lesson-header,
  .archive-main,
  .stage-shell,
  .site-footer {
    width: min(100% - 28px, 1180px);
  }

  .lesson-header,
  .intro-grid,
  .lesson-note {
    grid-template-columns: 1fr;
  }

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

  .page-nav {
    justify-content: flex-start;
  }

  .stage-card {
    min-height: 470px;
    padding: 10px;
  }

  .ruffle-stage {
    min-height: 430px;
  }

  .ruffle-stage ruffle-player,
  .ruffle-stage object,
  .ruffle-stage embed {
    height: 68vh;
    min-height: 390px;
  }
}

@media (max-width: 560px) {
  .archive-hero {
    padding-top: 34px;
  }

  .button-link,
  .start-link {
    width: 100%;
  }

  .lesson-card {
    min-height: 220px;
  }
}
