@import url("https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,500;0,600;1,500&family=Manrope:wght@400;500;600;700&family=Noto+Sans+Hebrew:wght@400;500;600;700&family=Noto+Serif+Hebrew:wght@500;600&display=swap");

/* =====================================================================
   MargoStory design system — warm paper, golden-brown titles, plum accents.
   Loaded last on every page. Games keep their own screens; only the
   shell (background, header, footer, back links) comes from here.
   ===================================================================== */

:root {
  /* Paper */
  --paper: #f5ede0;
  --paper-2: #efe4d3;
  --card: #fffaf3;
  --line: #e6d8c2;
  --line-soft: rgba(230, 216, 194, 0.6);
  /* Warm ink: headings, text, secondary text */
  --title: #6b4a2e;
  --ink: #4b3d2f;
  --ink-2: #7a644e;
  /* Warm dark (footer, Pix workshop) — names kept for older rules */
  --dark: #2e2430;
  --graphite: #2e2430;
  --graphite-2: #3a2d3c;
  /* Accents */
  --plum: #58304f;
  --plum-2: #6e3f63;
  --plum-soft: #efe2ea;
  --gold: #b48b43;
  --gold-line: #c9a86a;
  --violet: #8e5cf0;
  --violet-soft: #c9b2ff;
  --amber: #b48b43;
  /* On dark */
  --on-dark: #f6eee4;
  --on-dark-2: #c9b9b0;
  --line-dark: rgba(246, 238, 228, 0.14);
  /* Shape and depth */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(75, 61, 47, 0.06);
  --shadow: 0 1px 2px rgba(75, 61, 47, 0.06), 0 14px 34px rgba(75, 61, 47, 0.1);
  --shadow-lift: 0 2px 4px rgba(75, 61, 47, 0.06), 0 22px 46px rgba(75, 61, 47, 0.14);
  /* Type */
  --serif: "Lora", "Noto Serif Hebrew", Georgia, serif;
  --sans: "Manrope", "Noto Sans Hebrew", system-ui, sans-serif;
  /* Layout */
  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --ms-content: min(var(--wrap), 100% - 2 * var(--gutter));
  /* Paper: warm base, soft uneven light, and a fine fibre layer blended on top */
  --grain: url("../images/paper-grain.webp");
  --paper-light:
    radial-gradient(110% 70% at 0% 0%, rgba(255, 252, 246, 0.9), transparent 62%),
    radial-gradient(90% 60% at 100% 35%, rgba(236, 228, 216, 0.55), transparent 70%),
    radial-gradient(70% 50% at 20% 100%, rgba(233, 224, 212, 0.5), transparent 70%),
    radial-gradient(50% 40% at 85% 8%, rgba(201, 178, 255, 0.07), transparent 70%);
  /* Old names still used by page stylesheets */
  --ms-ink: var(--title);
  --ms-muted: var(--ink-2);
  --ms-paper: var(--card);
  --ms-line: var(--line);
  --ms-shadow: var(--shadow);
  --ms-title: var(--serif);
  --ms-text: var(--sans);
}

/* ---------- Page surface ---------- */
html {
  background-color: var(--paper);
  background-image: var(--grain), var(--paper-light);
  background-blend-mode: overlay, normal, normal, normal, normal;
  background-size: 420px 420px, 100% 100vh, 100% 100vh, 100% 100vh, 100% 100vh;
  background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-attachment: scroll, fixed, fixed, fixed, fixed;
  color-scheme: light;
}

html body {
  margin: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html body.sandspiel-body,
html body.draw-body,
html body.wiggly-body,
html body.playroom-body,
html body.dc-body {
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
}

::selection { background: rgba(110, 63, 99, 0.18); color: var(--ink); }
:focus-visible { outline: 2px solid var(--plum-2); outline-offset: 3px; }

.ms-wrap { width: var(--ms-content); margin-inline: auto; }

/* Secondary paper and dark surfaces */
.ms-surface-alt {
  background-color: var(--paper-2);
  background-image: var(--grain), radial-gradient(80% 60% at 0% 0%, rgba(255, 252, 246, 0.6), transparent 70%);
  background-blend-mode: overlay, normal;
  background-size: 420px 420px, 100% 100%;
}

.ms-dark {
  color: var(--on-dark);
  background:
    radial-gradient(42% 60% at 28% 58%, rgba(142, 92, 240, 0.3), transparent 68%),
    radial-gradient(30% 40% at 90% 10%, rgba(217, 179, 207, 0.1), transparent 70%),
    linear-gradient(180deg, #33283a 0%, #241c27 100%);
}

/* ---------- Type ---------- */
.ms-label {
  margin: 0 0 14px;
  font: 700 12px/1.2 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
html[dir="rtl"] .ms-label { letter-spacing: 0.02em; }
.ms-dark .ms-label { color: var(--violet-soft); }

.ms-display {
  margin: 0;
  font: 600 clamp(40px, 6vw, 74px)/1.03 var(--serif);
  letter-spacing: -0.025em;
  color: var(--ink);
}

.ms-h1 {
  margin: 0;
  font: 600 clamp(34px, 4.6vw, 56px)/1.06 var(--serif);
  letter-spacing: -0.02em;
  color: var(--ink);
}

.ms-h2 {
  margin: 0;
  font: 600 clamp(28px, 3.3vw, 42px)/1.1 var(--serif);
  letter-spacing: -0.015em;
  color: inherit;
}

.ms-h3 { margin: 0; font: 600 21px/1.25 var(--serif); color: inherit; }

.ms-lead {
  margin: 0;
  max-width: 36em;
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.6;
  color: var(--ink-2);
}
.ms-dark .ms-lead { color: var(--on-dark-2); }

.ms-meta { font: 600 13px/1.35 var(--sans); color: var(--ink-2); }

/* ---------- Buttons and links ---------- */
.ms-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: 700 15px/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.ms-btn svg, .ms-more svg { width: 18px; height: 18px; flex: none; }
html[dir="rtl"] .ms-btn svg, html[dir="rtl"] .ms-more svg { transform: scaleX(-1); }
.ms-btn-primary { background: var(--ink); color: var(--card); }
.ms-btn-primary:hover { background: var(--plum); }
.ms-btn-ghost { border-color: rgba(75, 61, 47, 0.25); color: var(--ink); background: transparent; }
.ms-btn-ghost:hover { border-color: var(--ink); }
.ms-dark .ms-btn-primary { background: var(--card); color: var(--ink); }
.ms-dark .ms-btn-primary:hover { background: var(--violet-soft); }
.ms-dark .ms-btn-ghost { border-color: var(--line-dark); color: var(--on-dark); }
.ms-dark .ms-btn-ghost:hover { border-color: var(--violet-soft); }

.ms-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid currentColor;
  font: 700 15px/1 var(--sans);
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

/* ---------- Header ---------- */
.ms-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 241, 230, 0.86);
  backdrop-filter: saturate(1.3) blur(12px);
  -webkit-backdrop-filter: saturate(1.3) blur(12px);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
}

.ms-header-row { display: flex; align-items: center; gap: 24px; min-height: 74px; }

.ms-lockup { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; flex: none; }
.ms-emblem {
  display: block;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(75, 61, 47, 0.18), 0 0 0 4px var(--paper), 0 0 0 5px rgba(75, 61, 47, 0.12);
}
.ms-word { display: flex; flex-direction: column; line-height: 1; }
.ms-word b { font: 600 23px/1 var(--serif); letter-spacing: -0.015em; }
.ms-word b span { color: var(--plum-2); }
.ms-word small { margin-top: 5px; font: 700 10px/1 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-2); }
html[dir="rtl"] .ms-word small { letter-spacing: 0.06em; }

.ms-nav { display: flex; gap: 24px; margin-inline-start: auto; }
.ms-nav a,
.ms-mobile-nav a {
  color: var(--ink-2);
  font: 600 15px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
}
.ms-nav a { padding: 8px 0; border-bottom: 1px solid transparent; }
.ms-nav a:hover { color: var(--ink); border-color: var(--ink); }
.ms-nav a[aria-current="page"] { color: var(--ink); border-color: var(--plum-2); }

.ms-langs { display: inline-flex; flex: none; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.ms-langs button {
  min-width: 40px;
  height: 32px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: 700 12px/1 var(--sans);
  cursor: pointer;
}
.ms-langs button:hover { color: var(--ink); }
.ms-langs button[aria-pressed="true"] { background: var(--ink); color: var(--card); }

.ms-menu-btn { display: none; width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); cursor: pointer; }
.ms-menu-btn span { display: block; width: 18px; height: 1.5px; margin: 4px auto; background: var(--ink); transition: transform 0.2s ease; }
.ms-menu-btn[aria-expanded="true"] span:first-child { transform: translateY(2.75px) rotate(45deg); }
.ms-menu-btn[aria-expanded="true"] span:last-child { transform: translateY(-2.75px) rotate(-45deg); }
.ms-mobile-nav { display: none; }

/* ---------- Footer ---------- */
.ms-footer {
  margin-top: clamp(56px, 8vw, 100px);
  padding-block: 60px 30px;
  background: var(--ink);
  color: var(--on-dark-2);
  font: 400 15px/1.6 var(--sans);
}
.ms-footer .ms-lockup { color: var(--on-dark); }
.ms-footer .ms-emblem { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 0 4px var(--ink), 0 0 0 5px rgba(201, 178, 255, 0.35); }
.ms-footer .ms-word b span { color: var(--violet-soft); }
.ms-footer .ms-word small { color: var(--on-dark-2); }
.ms-footer-grid { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 32px; }
.ms-footer-about { margin: 18px 0 0; max-width: 26em; }
.ms-footer-title { margin: 0 0 14px; font: 700 12px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--on-dark); }
html[dir="rtl"] .ms-footer-title { letter-spacing: 0.04em; }
.ms-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ms-footer a { color: inherit; text-decoration: none; }
.ms-footer a:hover { color: #fff; }
.ms-social { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ms-footer .ms-social a { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-dark); border-radius: 999px; color: var(--on-dark); font-size: 14px; font-weight: 600; transition: background-color 0.2s ease; }
.ms-footer .ms-social a:hover, .ms-footer .ms-social a:focus-visible { background: rgba(255, 255, 255, 0.12); color: #fff; }
.ms-footer-base { display: flex; justify-content: space-between; gap: 16px; margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--line-dark); font-size: 13px; }

/* ---------- Old shell pieces replaced by the new header and footer ---------- */
.header .logo,
.header .language,
.header .gold-line,
header.top.ms-head .brand,
header.top.ms-head .langs,
body > footer:not(.ms-footer),
#margo-feedback-root { display: none !important; }
.header.ms-head:not(:has(.title)):not(:has(.ms-title)) { display: none !important; }

/* Old page titles become a quiet page head */
html body .header {
  display: block;
  width: var(--ms-content);
  max-width: var(--ms-content);
  margin: clamp(36px, 5vw, 64px) auto 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  text-align: start;
}
html body .header .title { display: block; width: auto; max-width: none; margin: 0; padding: 0; text-align: start; background: none; }
html body .header .title h1,
html body .ms-title,
html body .dc-title {
  margin: 0;
  font: 600 clamp(34px, 4.6vw, 56px)/1.06 var(--serif);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: start;
  text-shadow: none;
}
html body .header .title p,
html body .ms-lead,
html body .dc-tagline {
  margin: 14px 0 0;
  max-width: 40em;
  font: 400 clamp(17px, 1.5vw, 19px)/1.6 var(--sans);
  color: var(--ink-2);
  text-align: start;
}
html body header.top.ms-head { display: block; width: var(--ms-content); margin: clamp(32px, 5vw, 56px) auto 0; padding: 0; }

/* Back links: quiet text links, not pills */
html body button.back-arrow.back-arrow,
html body a.back-home.back-home,
html body a.back-link.back-link,
html body a.back-btn.back-btn,
html body a.mystery-back.mystery-back,
html body a.dc-back.dc-back,
html body a.hs-back.hs-back,
html body button#back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-height: 40px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--ink-2);
  font: 600 14px/1.2 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  cursor: pointer;
  transform: none;
}
html body button.back-arrow.back-arrow:hover,
html body a.back-home.back-home:hover,
html body a.back-link.back-link:hover,
html body a.back-btn.back-btn:hover,
html body a.dc-back.dc-back:hover,
html body button#back:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; transform: none; box-shadow: none; }

/* ---------- Shared content widths ---------- */
.comics-page,
.freebies-page,
.stickers-page,
.page-read,
.rules-page,
.playroom-page,
.draw-page,
.seo-comic-page,
.cards {
  width: var(--ms-content);
  max-width: var(--ms-content);
  margin-inline: auto;
  box-sizing: border-box;
}
html body main { padding-top: 0; }
html body .page-read,
html body .comics-page,
html body .freebies-page,
html body .stickers-page,
html body .rules-page,
html body .playroom-page,
html body .seo-comic-page {
  margin-top: clamp(20px, 3vw, 36px);
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.page-read h1, .page-read h2, .comics-page h1, .comics-page h2,
.freebies-page h1, .freebies-page h2, .stickers-page h1, .stickers-page h2 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.comics-intro, .freebies-intro, .stickers-intro { color: var(--ink-2); font-family: var(--sans); line-height: 1.6; }

/* ---------- Cards (old markup) ---------- */
html body .card,
html body .comics-catalog-card,
html body .playroom-game-card,
html body .freebies-page .freebies-categories .card,
html body .stickers-page .sticker-collections .card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
html body .card:hover,
html body .comics-catalog-card:hover,
html body .playroom-game-card:hover,
html body .freebies-page .freebies-categories .card:hover,
html body .stickers-page .sticker-collections .card:hover {
  transform: translateY(-2px);
  border-color: rgba(75, 61, 47, 0.35);
  box-shadow: var(--shadow-lift);
}
html body .card-content h2,
html body .playroom-game-card h2 {
  font: 600 21px/1.25 var(--serif);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
html body .card-content p,
html body .playroom-game-card p { color: var(--ink-2); font: 400 15px/1.55 var(--sans); }

/* ---------- Comics catalog ---------- */
html body .comics-page h1 { margin: 0 0 clamp(24px, 3vw, 36px); font: 600 clamp(34px, 4.6vw, 56px)/1.06 var(--serif); letter-spacing: -0.02em; }
html body .comics-catalog-grid { gap: clamp(20px, 3vw, 36px); }
html body .comics-catalog-card { background: transparent; border: 0; box-shadow: none; border-radius: 0; overflow: visible; }
html body .comics-catalog-card:hover { transform: none; box-shadow: none; }
html body .comics-catalog-card .card-image {
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--paper-2);
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s ease;
}
html body .comics-catalog-card:hover .card-image { box-shadow: var(--shadow-lift); }
html body .comics-catalog-card .card-content { padding: 14px 2px 0; background: none; text-align: start; }
html body .comics-catalog-card .card-content h2 { margin: 0 0 4px; font: 600 22px/1.2 var(--serif); }
html body .comics-catalog-card .card-content p { margin: 0; }

/* Story hub and dialogs */
html body .comics-story { gap: clamp(24px, 4vw, 56px); padding: 0; background: none; border: 0; box-shadow: none; }
html body .comics-story-cover img { border-radius: var(--r-sm); box-shadow: var(--shadow-lift); }
html body .comics-story-body h2 { font: 600 clamp(30px, 4vw, 48px)/1.08 var(--serif); letter-spacing: -0.02em; }
html body .comics-story-lead { color: var(--ink-2); font-size: 18px; }
html body .comics-btn,
html body .seo-comic-btn,
html body .coloring-download-btn,
html body .sticker-btn,
html body a.playroom-open,
html body .playroom-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--card);
  font: 700 15px/1 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
html body .comics-btn:hover,
html body .seo-comic-btn:hover,
html body .coloring-download-btn:hover,
html body .sticker-btn:hover,
html body .playroom-open:hover { background: var(--plum); border-color: var(--plum); transform: none; box-shadow: none; }
html body .comics-btn-secondary,
html body .seo-comic-btn-secondary { background: transparent; color: var(--ink); border-color: rgba(75, 61, 47, 0.3); }
html body .comics-btn-secondary:hover,
html body .seo-comic-btn-secondary:hover { background: transparent; color: var(--ink); border-color: var(--ink); }
html body .comics-dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-lift); }

/* ---------- Comic landing pages (DOG, Black Hole) ---------- */
html body .seo-comic-crumbs { font: 600 14px/1.4 var(--sans); color: var(--ink-2); }
html body .seo-comic-crumbs a { color: var(--ink-2); }
html body .seo-comic-hero { gap: clamp(24px, 5vw, 64px); align-items: center; padding: 0; background: none; border: 0; box-shadow: none; }
html body .seo-comic-cover img { border-radius: var(--r-sm); box-shadow: var(--shadow-lift); }
html body .seo-comic-intro h2 { font: 600 clamp(28px, 3.4vw, 42px)/1.1 var(--serif); color: var(--ink); letter-spacing: -0.015em; }
html body .seo-comic-intro p,
html body .seo-comic-section li,
html body .seo-comic-section p { color: var(--ink-2); font-size: 17px; line-height: 1.65; }
html body .seo-comic-section {
  margin-top: clamp(28px, 4vw, 48px);
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 253, 249, 0.72);
  box-shadow: none;
}
html body .seo-comic-section h3 { font: 600 24px/1.2 var(--serif); color: var(--ink); }
html body .seo-comic-trailer { border-radius: var(--r-sm); }
html body .seo-comic-links a { color: var(--ink); font-weight: 600; text-underline-offset: 4px; }

/* ---------- Stickers & coloring ---------- */
html body .freebies-page .freebies-categories { gap: clamp(20px, 3vw, 32px); }
html body .freebies-page .freebies-categories .card-image,
html body .stickers-page .sticker-collections .card-image { background: var(--paper-2); }
html body .freebies-page .freebies-categories .card-content,
html body .stickers-page .sticker-collections .card-content { padding: 18px 20px 22px; text-align: start; background: none; }
html body .freebies-page .freebies-categories .card-content h2,
html body .stickers-page .sticker-collections .card-content h2 { font: 600 22px/1.2 var(--serif); text-transform: none; letter-spacing: 0; }
html body .freebies-page .freebies-categories .freebies-card-cta,
html body .stickers-page .sticker-collections .sticker-collection-cta {
  display: inline-flex;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 3px;
  border-bottom: 1px solid currentColor;
  color: var(--ink);
  font: 700 14px/1 var(--sans);
  letter-spacing: 0;
  text-transform: none;
}
html body .freebies-card-meta,
html body .sticker-collection-meta { color: var(--ink-2); font: 600 13px/1.4 var(--sans); }

html body .coloring-book-panel {
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 253, 249, 0.78);
  box-shadow: var(--shadow-sm);
}
html body .coloring-book-panel h2 { font: 600 clamp(24px, 2.6vw, 32px)/1.15 var(--serif); color: var(--ink); }
html body .coloring-book-cover img { border-radius: var(--r-sm); box-shadow: var(--shadow); }

html body .sticker-detail-head h2 { font: 600 clamp(28px, 3.4vw, 40px)/1.1 var(--serif); color: var(--ink); }
html body .sticker-detail-head p,
html body .sticker-note { color: var(--ink-2); }
html body .sticker-pack-sheet { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); box-shadow: var(--shadow-sm); }
html body .sticker-pack-group-title { font: 700 12px/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }

/* ---------- Playroom and drawing ---------- */
html body .playroom-gallery { gap: clamp(18px, 2.4vw, 28px); }
html body .playroom-card-image { background: var(--paper-2); }
html body .playroom-card-image img { filter: saturate(0.9); }
html body .playroom-card-body { padding: 18px 20px 22px; text-align: start; }
html body .playroom-open { margin-top: 12px; min-height: 42px; padding: 0 18px; font-size: 14px; }
html body .memory-overlay {
  background-color: var(--paper);
  background-image: var(--grain), var(--paper-light);
  background-blend-mode: overlay, normal, normal, normal, normal;
  background-size: 420px 420px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
}
html body .memory-frame { width: min(950px, 100%); margin: 0 auto; }
html body .memory-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
html body .memory-brand img { display: block; width: 46px; height: 46px; object-fit: cover; border-radius: 50%; }
html body .draw-studio iframe { border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }

/* ---------- Rules and privacy ---------- */
html body .rules-page { max-width: min(860px, 100% - 2 * var(--gutter)); }
html body .rules-updated { color: var(--ink-2); font: 600 13px/1.4 var(--sans); }
html body .rules-intro h2,
html body .rules-serious h2 { font: 600 26px/1.2 var(--serif); color: var(--ink); }
html body .rules-intro p,
html body .rules-body,
html body .rules-body li,
html body .rules-disclaimer { color: var(--ink-2); font-size: 17px; line-height: 1.7; }
html body .rules-list details {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: none;
  box-shadow: none;
}
html body .rules-list details:last-child { border-bottom: 1px solid var(--line); }
html body .rules-list summary { padding: 20px 4px; font: 600 20px/1.3 var(--serif); color: var(--ink); }
html body .rules-body { padding: 0 4px 22px; }
html body .rules-serious,
html body .rules-intro { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--line); border-radius: var(--r-md); background: rgba(255, 253, 249, 0.72); box-shadow: none; }

/* ---------- Games: page head only ---------- */
.dc-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
html body .dc-brand { display: none; }
html body #app .top { display: block; }
html body #app .top .ms-title { flex: none; }

/* ---------- Tablets and phones ---------- */
@media (max-width: 980px) {
  .ms-nav { display: none; }
  .ms-menu-btn { display: block; }
  .ms-langs { margin-inline-start: auto; }
  .ms-mobile-nav { display: none; padding: 6px 0 18px; border-top: 1px solid var(--line); }
  .ms-mobile-nav.is-open { display: block; }
  .ms-mobile-nav a { display: block; padding: 13px 2px; border-bottom: 1px solid var(--line-soft); font-size: 17px; color: var(--ink); }
  .ms-mobile-nav a[aria-current="page"] { color: var(--plum-2); }
  .ms-footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  html body { font-size: 16px; }
  .ms-header-row { gap: 10px; min-height: 64px; }
  .ms-lockup { gap: 9px; }
  .ms-emblem { width: 38px; height: 38px; }
  .ms-word b { font-size: 19px; }
  .ms-word small { display: none; }
  .ms-langs button { min-width: 34px; padding: 0 8px; }
  .ms-footer-grid { grid-template-columns: 1fr; }
  .ms-footer-base { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { background-attachment: scroll; }
  .ms-header *, .ms-footer *, html body .card, html body .comics-catalog-card .card-image { transition: none !important; }
}

/* Old page CSS centres every <footer>; the site footer reads from the start edge. */
html body footer.ms-footer { text-align: start; }

/* ---------- Refinements after the first full review ---------- */
html body footer.ms-footer { margin-top: clamp(56px, 8vw, 100px); padding: 60px 0 30px; border-top: 0; color: var(--on-dark-2); font-size: 15px; }
body[data-page="pix"] footer.ms-footer { margin-top: 0; }

/* Text in old cards reads from the start edge, no capitals */
html body .card-content,
html body .card-content h2,
html body .card-content p,
html body .playroom-card-body,
html body .playroom-card-body h2 { text-align: start; text-transform: none; letter-spacing: 0; }

/* Comics catalog: covers first, teasers as a quieter second row */
html body .comics-catalog-stack { max-width: none; gap: clamp(40px, 6vw, 72px); margin: 0 0 20px; }
html body .comics-catalog-grid { max-width: none; margin: 0; gap: clamp(22px, 3vw, 40px); }
html body .comics-catalog-grid--ready { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 340px)); }
html body .comics-catalog-grid--ready .card-image { height: auto; aspect-ratio: 2 / 3; }
html body .comics-catalog-grid--ready .card-image img { width: 100%; height: 100%; object-fit: cover; }
html body .comics-catalog-grid--anons { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); padding-top: clamp(28px, 4vw, 40px); border-top: 1px solid var(--line); opacity: 1; }
html body .comics-catalog-grid--anons::before { content: attr(aria-label); grid-column: 1 / -1; margin-bottom: -8px; font: 700 12px/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
html body .comics-catalog-grid--anons .card-image { height: auto; aspect-ratio: 16 / 10; }
html body .comics-catalog-grid--anons video { width: 100%; height: 100%; object-fit: cover; }
html body .comics-catalog-card .card-content p { margin-top: 4px; color: var(--ink-2); font-size: 15px; line-height: 1.5; }

/* Comic landing pages already show a breadcrumb trail (Home / Comics / …), so their extra back link stays hidden */
html body .seo-comic-page .back-home { display: none; }

/* The Memory game opens as a full-screen layer: it must sit above the sticky site header */
html body .memory-overlay { z-index: 60; }

/* Back link on the dark Pix page */
html body .ms-dark a.back-home.back-home { color: var(--on-dark-2); }
html body .ms-dark a.back-home.back-home:hover { color: #fff; }

/* Coloring books */
html body .coloring-books { gap: clamp(20px, 3vw, 32px); }
html body .coloring-book-panel h2 { text-align: start; text-transform: none; letter-spacing: -0.01em; }
html body .coloring-book-panel,
html body .coloring-book-panel p { text-align: start; }

/* Freebies cards */
html body .freebies-page .freebies-categories { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
html body .freebies-page .freebies-categories .card-image { height: auto; aspect-ratio: 4 / 3; }
html body .freebies-page .freebies-categories .card-image img { object-fit: contain; padding: 18px; }
html body .stickers-page .sticker-collections .card-image { height: auto; aspect-ratio: 4 / 3; }
html body .stickers-page .sticker-collections .card-image img { object-fit: contain; padding: 18px; }
.nf-page { padding-block: clamp(64px, 12vw, 140px) clamp(24px, 4vw, 48px); }
.ms-header, .ms-header *, .ms-footer, .ms-footer *, .nf-page, .nf-page * { box-sizing: border-box; }
/* Freebies and coloring pages exist in English only: keep their text left-to-right in Hebrew. */
html[dir="rtl"] .freebies-page,
html[dir="rtl"] body:has(.freebies-page) > .header { direction: ltr; text-align: left; }
/* Rules and privacy: the reading column lines up with the page title */
html body .rules-page { width: var(--ms-content); max-width: var(--ms-content); }
html body .rules-page > * { max-width: 820px; }
html body .comics-catalog-card { align-items: stretch; text-align: start; }
html body .comics-catalog-card .card-content { align-self: stretch; width: 100%; }
html body .comics-catalog-grid--ready .comics-catalog-card .card-content p { display: block; }
html body .comics-catalog-card .card-content h2 { display: block; width: 100%; margin-inline: 0; text-align: start; }

/* Coloring books: open the PDF to look through it, or download it */
html body .coloring-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
html body .coloring-actions .coloring-download-btn { margin: 0; }
html body .coloring-view-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px;
  border: 1px solid rgba(75, 61, 47, 0.3); border-radius: var(--r-sm);
  background: transparent; color: var(--ink);
  font: 700 15px/1 var(--sans); text-decoration: none;
  transition: border-color 0.2s ease;
}
html body .coloring-view-btn:hover { border-color: var(--ink); }

/* =====================================================================
   Refinement 2 — lighter type, larger logo, more tactile paper.
   ===================================================================== */
:root {
  --paper: #f5ede0;
  --fibre: url("../images/paper-fibre.webp");
  --tone: url("../images/paper-tone.webp");
}

/* Paper lives on its own fixed layer behind the page: a neutral light from the
   top left, a soft taupe shade at the bottom right, gentle tonal clouds and fine fibres.
   Both textures are pre-mixed transparent images, so no blend modes are needed (Safari-safe). */
html { background: var(--paper); }
html body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--paper);
  background-image:
    var(--fibre),
    var(--tone),
    radial-gradient(120% 80% at 0% 0%, rgba(255, 252, 245, 0.85), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(222, 203, 173, 0.45), transparent 65%),
    radial-gradient(60% 50% at 100% 0%, rgba(110, 63, 99, 0.05), transparent 70%),
    linear-gradient(180deg, #f8f1e6 0%, #efe4d2 100%);
  background-blend-mode: normal;
  background-size: 440px 440px, 1100px 1100px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
}

.ms-surface-alt {
  background-color: #efe4d3;
  background-image: var(--fibre), var(--tone), linear-gradient(180deg, rgba(255, 252, 246, 0.35), transparent 40%);
  background-blend-mode: normal;
  background-size: 440px 440px, 1100px 1100px, 100% 100%;
}

html body .memory-overlay {
  background-color: var(--paper);
  background-image: var(--fibre), var(--tone), radial-gradient(110% 75% at 0% 0%, rgba(255, 254, 251, 0.78), transparent 60%);
  background-blend-mode: normal;
  background-size: 440px 440px, 1100px 1100px, 100% 100%;
}

/* Cards sit just above the paper */
:root {
  --shadow-sm: 0 1px 2px rgba(91, 64, 38, 0.06), 0 6px 18px rgba(91, 64, 38, 0.05);
  --shadow: 0 1px 2px rgba(91, 64, 38, 0.06), 0 10px 28px rgba(91, 64, 38, 0.08);
  --shadow-lift: 0 2px 4px rgba(91, 64, 38, 0.07), 0 18px 40px rgba(91, 64, 38, 0.12);
}

/* ---------- Type: lighter Lora, calmer sizes ---------- */
.ms-display {
  max-width: 14em;
  font: 500 clamp(34px, 4.2vw, 56px)/1.12 var(--serif);
  letter-spacing: -0.015em;
}
.ms-h1,
html body .comics-page h1,
html body .header .title h1,
html body .ms-title,
html body .dc-title {
  font: 500 clamp(30px, 3.6vw, 46px)/1.12 var(--serif);
  letter-spacing: -0.012em;
}
.ms-h2,
html body .comics-story-body h2,
html body .seo-comic-intro h2,
html body .sticker-detail-head h2 {
  font: 500 clamp(26px, 2.8vw, 36px)/1.16 var(--serif);
  letter-spacing: -0.01em;
}
.ms-h3,
html body .card-content h2,
html body .playroom-game-card h2,
html body .comics-catalog-card .card-content h2,
html body .coloring-book-panel h2,
html body .rules-list summary,
html body .seo-comic-section h3 { font-weight: 500; }
.ms-h3 { font-size: 20px; }
html body .comics-catalog-card .card-content h2 { font-size: 20px; }
html body .header .title p, html body .ms-lead, .ms-lead { font-size: clamp(17px, 1.4vw, 19px); line-height: 1.65; }

/* ---------- Logo and header ---------- */
.ms-header-row { min-height: 92px; gap: 28px; }
.ms-lockup { gap: 14px; }
.ms-emblem { width: 64px; height: 64px; }
.ms-word b { font: 500 30px/1 var(--serif); letter-spacing: -0.01em; }
.ms-word small { margin-top: 7px; font-size: 11px; }
.ms-nav { gap: 26px; }
.ms-footer .ms-emblem { width: 56px; height: 56px; }
.ms-footer .ms-word b { font-size: 26px; }

@media (max-width: 980px) {
  .ms-header-row { min-height: 80px; }
  .ms-emblem { width: 56px; height: 56px; }
  .ms-word b { font-size: 27px; }
}
@media (max-width: 560px) {
  .ms-header-row { min-height: 68px; gap: 10px; }
  .ms-lockup { gap: 10px; }
  .ms-emblem { width: 46px; height: 46px; }
  .ms-word b { font-size: 22px; }
}
@media (max-width: 360px) {
  .ms-word b { font-size: 19px; }
  .ms-emblem { width: 40px; height: 40px; }
}
@media (max-width: 560px) {
  .ms-word b { font-size: 20px; }
  .ms-langs button { min-width: 30px; height: 30px; padding: 0 7px; font-size: 11px; }
  .ms-menu-btn { width: 42px; height: 42px; }
}

/* =====================================================================
   Design system v3 — the original MargoStory character in one set of
   rules: warm paper, golden-brown titles, plum accents, clear emblem.
   ===================================================================== */
:root { --r-md: 14px; --r-lg: 20px; }

/* ---------- Titles: warm golden-brown ---------- */
.ms-display, .ms-h1, .ms-h2, .ms-h3,
html body .header .title h1, html body .ms-title, html body .dc-title,
html body .page-read h1, html body .page-read h2,
html body .comics-page h1, html body .comics-page h2,
html body .freebies-page h1, html body .freebies-page h2,
html body .stickers-page h1, html body .stickers-page h2,
html body .card-content h2, html body .playroom-game-card h2, html body .playroom-card-body h2,
html body .comics-story-body h2, html body .seo-comic-intro h2, html body .seo-comic-section h3,
html body .coloring-book-panel h2, html body .sticker-detail-head h2,
html body .rules-intro h2, html body .rules-serious h2, html body .rules-list summary,
.about-block h2, .game-card h2, .about-row blockquote, .about-hero .about-hello,
.hero-art figcaption b, .work .ms-h3, .book .ms-h3 { color: var(--title); }
html body .ms-dark :is(.ms-display, .ms-h1, .ms-h2, .ms-h3) { color: var(--on-dark); }

html body .header .title p, html body .ms-lead, .ms-lead, html body .dc-tagline { color: var(--ink); }
.ms-dark .ms-lead, html body .ms-dark .ms-lead { color: var(--on-dark-2); }
.ms-label { color: #9a7335; }
.ms-dark .ms-label { color: #d9b3cf; }

/* ---------- Logo: one file, one set of sizes ---------- */
.ms-header-row { min-height: 104px; }
.ms-lockup { gap: 17px; color: var(--title); }
.ms-emblem {
  width: 77px;
  height: 77px;
  box-shadow: 0 0 0 1.5px var(--gold-line), 0 4px 12px rgba(91, 64, 38, 0.12);
}
.ms-word b { font: 500 36px/1 var(--serif); letter-spacing: -0.01em; color: var(--title); }
.ms-word b span { color: var(--plum-2); }
.ms-word small { margin-top: 8px; font: 600 13px/1 var(--sans); letter-spacing: 0.2em; color: var(--ink-2); }
html[dir="rtl"] .ms-word small { letter-spacing: 0.06em; }

/* ---------- Header navigation ---------- */
.ms-nav a, .ms-mobile-nav a { color: var(--ink); font-weight: 500; }
.ms-nav a:hover { color: var(--title); border-color: var(--gold-line); }
.ms-nav a[aria-current="page"] { color: var(--title); border-color: var(--gold-line); border-bottom-width: 2px; }
.ms-langs button { color: var(--ink-2); }
.ms-langs button:hover { color: var(--title); }
.ms-langs button[aria-pressed="true"] { background: var(--title); color: #fff; }
.ms-menu-btn span { background: var(--title); }

/* ---------- Footer: warm dark ---------- */
.ms-footer, html body footer.ms-footer { background: var(--dark); color: var(--on-dark-2); }
.ms-footer .ms-lockup { color: var(--on-dark); }
.ms-footer .ms-emblem { width: 67px; height: 67px; box-shadow: 0 0 0 1.5px rgba(201, 168, 106, 0.7); }
.ms-footer .ms-word b { font-size: 31px; color: var(--on-dark); }
.ms-footer .ms-word b span { color: #d9b3cf; }
.ms-footer .ms-word small { color: var(--on-dark-2); }
.ms-footer a:hover { color: #fff; }

/* ---------- Buttons and links ---------- */
.ms-btn-primary,
html body .comics-btn, html body .seo-comic-btn, html body .coloring-download-btn,
html body .sticker-btn, html body a.playroom-open, html body .playroom-open {
  background: var(--title); border-color: var(--title); color: var(--card);
}
.ms-btn-primary:hover,
html body .comics-btn:hover, html body .seo-comic-btn:hover, html body .coloring-download-btn:hover,
html body .sticker-btn:hover, html body .playroom-open:hover { background: var(--plum-2); border-color: var(--plum-2); color: var(--card); }
.ms-btn-ghost,
html body .comics-btn-secondary, html body .seo-comic-btn-secondary, html body .coloring-view-btn {
  background: transparent; border-color: rgba(107, 74, 46, 0.35); color: var(--title);
}
.ms-btn-ghost:hover,
html body .comics-btn-secondary:hover, html body .seo-comic-btn-secondary:hover, html body .coloring-view-btn:hover {
  background: transparent; border-color: var(--title); color: var(--title);
}
.ms-dark .ms-btn-primary { background: var(--card); border-color: var(--card); color: var(--title); }
.ms-dark .ms-btn-primary:hover { background: #f0dfe9; border-color: #f0dfe9; color: var(--plum); }
.ms-dark .ms-btn-ghost { border-color: var(--line-dark); color: var(--on-dark); }
.ms-dark .ms-btn-ghost:hover { border-color: #d9b3cf; color: #fff; }
.ms-more { color: var(--plum-2); border-bottom-color: var(--gold-line); }
.ms-more:hover { color: var(--title); }
.ms-dark .ms-more { color: var(--on-dark); border-bottom-color: currentColor; }
html body .freebies-page .freebies-categories .freebies-card-cta,
html body .stickers-page .sticker-collections .sticker-collection-cta { color: var(--plum-2); border-bottom-color: var(--gold-line); }
html body .seo-comic-links a { color: var(--plum-2); }
html body .seo-comic-crumbs a:hover { color: var(--title); }

/* Cards: a gold edge on hover instead of a dark one */
html body .card:hover,
html body .playroom-game-card:hover,
html body .freebies-page .freebies-categories .card:hover,
html body .stickers-page .sticker-collections .card:hover,
.print:hover, .work:hover { border-color: var(--gold-line); }
.lego-dots button.is-on { background: var(--title); }
.lego-arrow { color: var(--title); }
.lego-arrow:hover { border-color: var(--gold-line); }

/* ---------- Back links: one soft pill everywhere ---------- */
html body button.back-arrow.back-arrow,
html body a.back-home.back-home,
html body a.back-link.back-link,
html body a.back-btn.back-btn,
html body a.mystery-back.mystery-back,
html body a.dc-back.dc-back,
html body a.hs-back.hs-back,
html body button#back,
html body a#back.back-home {
  gap: 8px;
  min-height: 40px;
  margin: 0 0 20px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.8);
  box-shadow: none;
  color: var(--ink-2);
  font: 600 15px/1 var(--sans);
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
html body button.back-arrow.back-arrow:hover,
html body a.back-home.back-home:hover,
html body a.back-link.back-link:hover,
html body a.back-btn.back-btn:hover,
html body a.dc-back.dc-back:hover,
html body a.hs-back.hs-back:hover,
html body button#back:hover,
html body a#back.back-home:hover {
  color: var(--title);
  border-color: var(--gold-line);
  background: var(--card);
  text-decoration: none;
}
html body .ms-dark a.back-home.back-home { color: var(--on-dark-2); border-color: var(--line-dark); background: rgba(255, 255, 255, 0.04); }
html body .ms-dark a.back-home.back-home:hover { color: #fff; border-color: rgba(201, 168, 106, 0.6); background: rgba(255, 255, 255, 0.07); }

/* ---------- Tablets and phones ---------- */
@media (max-width: 980px) {
  .ms-header-row { min-height: 92px; }
  .ms-emblem { width: 67px; height: 67px; }
  .ms-word b { font-size: 32px; }
  .ms-mobile-nav a { color: var(--ink); }
}
@media (max-width: 560px) {
  .ms-header-row { min-height: 76px; gap: 8px; }
  .ms-lockup { gap: 11px; }
  .ms-emblem { width: 55px; height: 55px; }
  .ms-word b { font-size: 25px; }
  .ms-word small { display: none; }
  .ms-footer .ms-emblem { width: 55px; height: 55px; }
  .ms-footer .ms-word b { font-size: 25px; }
}
/* Narrow phones: the header must hold the emblem, name, three languages and the menu in one row */
@media (max-width: 420px) {
  .ms-header-row { gap: 6px; }
  .ms-lockup { gap: 9px; }
  .ms-emblem { width: 50px; height: 50px; }
  .ms-word b { font-size: 22px; }
  .ms-langs button { min-width: 28px; padding: 0 6px; }
  .ms-menu-btn { width: 40px; height: 40px; }
}
@media (max-width: 355px) {
  .ms-emblem { width: 40px; height: 40px; }
  .ms-word b { font-size: 18px; }
  .ms-lockup { gap: 7px; }
  .ms-langs button { min-width: 26px; padding: 0 5px; }
}
/* Coloring cards: contents line up with the start edge, whatever the title length */
html body .coloring-book-panel { align-items: stretch; }
/* Guess the Word: its own stylesheet sizes #back as a 52px square icon; the shared pill needs its natural size */
html body a#back.back-home { width: auto; height: auto; align-self: flex-start; justify-self: start; font-family: var(--sans); font-size: 15px; line-height: 1; }
/* Some game stylesheets set a font on every element (*); the site header and footer keep the system fonts */
.ms-header *, .ms-footer * { font-family: inherit; }
/* Game titles that keep their own size inside the game layout: same weight and colour as the rest of the site */
html body h1.cs-title, html body h1.ck-title, html body h1#title.ms-title { font-weight: 500; color: var(--title); }
/* Some game stylesheets use content-box sizing; the back pill is the same height everywhere */
html body a.back-home.back-home, html body a.dc-back.dc-back, html body a#back.back-home { box-sizing: border-box; }

/* Sand Lab is switched off on phones (touch screens whose shorter side is under 600px).
   Computers and tablets keep them. The same query is used in the pages' scripts. */
html body .ms-phone-note { display: none; }
@media (hover: none) and (pointer: coarse) and (max-width: 599px), (hover: none) and (pointer: coarse) and (max-height: 599px) {
  html body .ms-phone-hide { display: none !important; }
  html body .ms-phone-note {
    display: block;
    margin: 8px 0 0;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--card);
    color: var(--ink);
    font: 500 17px/1.55 var(--sans);
  }
}

/* ---------- Four menu items (with Desktop Widgets) ---------- */
/* Between 981 and 1240 px the four links, the logo and the language switch don't fit on one row,
   so the menu goes under the button there too — the same as on tablets. */
@media (min-width: 981px) and (max-width: 1240px) {
  .ms-nav { display: none; }
  .ms-menu-btn { display: block; }
  .ms-langs { margin-inline-start: auto; }
  .ms-mobile-nav { display: none; padding: 6px 0 18px; border-top: 1px solid var(--line); }
  .ms-mobile-nav.is-open { display: block; }
  .ms-mobile-nav a { display: block; padding: 13px 2px; border-bottom: 1px solid var(--line-soft); font-size: 17px; color: var(--ink); }
  .ms-mobile-nav a[aria-current="page"] { color: var(--plum-2); }
}
