:root {
  --bg: #f4ead7;
  --bg-deep: #d7c29b;
  --surface: rgba(255, 248, 236, 0.76);
  --surface-strong: #f8f1e3;
  --ink: #23180d;
  --muted: #6d5741;
  --accent: #ad5c2b;
  --accent-deep: #6c2d13;
  --line: rgba(74, 44, 15, 0.15);
  --shadow: 0 18px 50px rgba(60, 35, 11, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Noto Serif SC", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 243, 213, 0.95), transparent 34%),
    linear-gradient(180deg, #ead8b5 0%, var(--bg) 32%, #efe6d8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(80, 52, 22, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 52, 22, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 90%);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 72px;
}

.hero {
  padding: 18px 0 36px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Cinzel", serif;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.48);
}

.topbar-links {
  display: flex;
  gap: 20px;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar-links a {
  position: relative;
  color: var(--muted);
}

.topbar-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease;
}

.topbar-links a:hover::after {
  transform: scaleX(1);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 28px;
  align-items: stretch;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: 28px;
  padding: 42px;
}

.eyebrow,
.route-tag,
.palace-label {
  margin: 0 0 10px;
  font-family: "Cinzel", serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--accent-deep);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2.6rem, 5vw, 4.9rem);
  max-width: 10ch;
}

.lede,
.summary,
.section-heading p:last-child,
.step-card p,
.story-grid p,
.example-grid p,
.memory-output p,
.quiz-panel p {
  color: var(--muted);
  line-height: 1.75;
}

.lede {
  font-size: 1.08rem;
  margin: 22px 0 10px;
  max-width: 58ch;
}

.summary {
  margin: 0 0 28px;
  max-width: 58ch;
}

.hero-actions,
.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  font: inherit;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #fff8f0;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  box-shadow: 0 12px 24px rgba(109, 44, 18, 0.24);
}

.button-secondary {
  color: var(--accent-deep);
  background: rgba(255, 249, 242, 0.8);
  border: 1px solid rgba(109, 44, 18, 0.15);
}

.button-success {
  color: #f7fff8;
  background: linear-gradient(135deg, #1f6a3c, #3f995f);
  box-shadow: 0 12px 24px rgba(31, 106, 60, 0.2);
}

.button-danger {
  color: #fff7f4;
  background: linear-gradient(135deg, #8d3424, #c7613d);
  box-shadow: 0 12px 24px rgba(141, 52, 36, 0.2);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 34px 0 0;
}

.hero-stats li {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(93, 57, 21, 0.08);
}

.hero-stats strong {
  display: block;
  font-family: "Cinzel", serif;
  font-size: 1.55rem;
  margin-bottom: 6px;
}

.hero-card {
  position: relative;
  border-radius: 36px;
  overflow: hidden;
  min-height: 100%;
}

.constellation {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.6) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 12%, rgba(255, 255, 255, 0.5) 0 2px, transparent 3px),
    radial-gradient(circle at 83% 42%, rgba(255, 255, 255, 0.5) 0 2px, transparent 3px),
    linear-gradient(180deg, rgba(52, 27, 9, 0.08), rgba(52, 27, 9, 0.2));
}

.palace-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100%;
  padding: 34px;
  background:
    linear-gradient(180deg, rgba(69, 31, 13, 0.08), rgba(35, 20, 8, 0.62)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M0 60h120M60 0v120' stroke='rgba(255,248,236,0.08)'/%3E%3C/svg%3E");
  color: #fff4e4;
}

.palace-card h2 {
  margin-bottom: 18px;
  font-size: 2rem;
}

.palace-card ol {
  padding-left: 20px;
  line-height: 1.75;
}

.palace-card p {
  color: rgba(255, 244, 228, 0.82);
}

main {
  display: grid;
  gap: 24px;
}

.panel {
  border-radius: 28px;
  padding: 34px;
}

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

.story-grid,
.example-grid,
.steps {
  display: grid;
  gap: 18px;
}

.story-grid,
.example-grid {
  grid-template-columns: repeat(3, 1fr);
}

.steps {
  grid-template-columns: repeat(4, 1fr);
}

.story-grid article,
.example-grid article,
.step-card,
.room-card,
.quiz-panel,
.reward-panel,
.result-panel {
  border-radius: 22px;
  background: rgba(255, 251, 245, 0.64);
  border: 1px solid rgba(93, 57, 21, 0.09);
}

.story-grid article,
.example-grid article,
.step-card {
  padding: 22px;
}

.step-card span {
  display: inline-block;
  margin-bottom: 14px;
  font-family: "Cinzel", serif;
  color: var(--accent);
}

.workshop-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.memory-form,
.memory-output {
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 252, 246, 0.7);
  border: 1px solid rgba(93, 57, 21, 0.09);
}

.memory-form {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 700;
}

textarea,
select {
  width: 100%;
  border: 1px solid rgba(93, 57, 21, 0.15);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
  color: var(--ink);
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.route-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.room-list {
  display: grid;
  gap: 14px;
}

.room-card {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.room-number {
  font-family: "Cinzel", serif;
  color: var(--accent);
}

.room-title {
  font-size: 1.15rem;
}

.room-scene {
  font-size: 0.98rem;
}

.quiz-panel {
  margin-top: 20px;
  padding: 24px;
}

.quiz-panel:focus-visible,
.reward-panel:focus-visible,
.result-panel:focus-visible {
  outline: 2px solid rgba(109, 44, 18, 0.42);
  outline-offset: 4px;
}

.reward-panel {
  display: grid;
  grid-template-columns: 0.8fr 1.1fr;
  gap: 20px;
  align-items: center;
  margin-top: 20px;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(207, 159, 93, 0.22), transparent 32%),
    linear-gradient(135deg, rgba(255, 250, 243, 0.94), rgba(247, 233, 214, 0.92));
}

.reward-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 18px 36px rgba(38, 21, 8, 0.22);
}

.result-panel {
  margin-top: 20px;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(182, 100, 58, 0.14), transparent 32%),
    linear-gradient(135deg, rgba(255, 247, 242, 0.96), rgba(245, 228, 216, 0.92));
}

.quiz-status {
  min-height: 32px;
  margin: 16px 0 0;
  color: var(--muted);
}

.quiz-answer {
  min-height: 32px;
  margin-bottom: 0;
  font-weight: 700;
  color: var(--accent-deep);
}

@media (max-width: 980px) {
  .hero-grid,
  .workshop-layout,
  .story-grid,
  .example-grid,
  .steps,
  .reward-panel {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 18px, 1200px);
  }

  .hero-copy,
  .panel,
  .memory-form,
  .memory-output {
    padding: 22px;
  }

  .topbar,
  .route-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-links {
    gap: 14px;
    flex-wrap: wrap;
  }
}
