:root {
  color-scheme: light dark;
  --ink: #222e28; --muted: #576053; --paper: #f7f3e8; --white: #fdfaf1; --line: #c7c7b7;
  --violet: #345a45; --accent-ink: #fffef2; --sage: #dbe1c9; --blue: #dbe5e7; --ochre: #f3dfb8;
  --diagram: #f0eddb; --rule: #afb39d; --gutter: clamp(1.1rem, 5vw, 5rem);
  font: 100%/1.48 system-ui, sans-serif; color: var(--ink); background: var(--paper);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #f1efdd; --muted: #bdc3af; --paper: #1e2622; --white: #272f28; --line: #526054; --violet: #bfd6af; --accent-ink: #1b3124; --sage: #394b3f; --blue: #33474b; --ochre: #514736; --diagram: #303b32; --rule: #65735e; }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, h4, p, figure { margin: 0; }
a { color: inherit; text-underline-offset: .25em; }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 4px; }
.shell { width: min(100% - 2 * var(--gutter), 76rem); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: fixed; z-index: 2; top: .5rem; left: .5rem; padding: .65rem; background: var(--white); }
.masthead, .brand, .shelf-heading, .plate-top, .plate-caption, .footer, .footer nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.masthead { min-height: 4.5rem; border-bottom: 1px solid var(--ink); }
.brand { font: bold 1.45rem/1 Georgia, serif; text-decoration: none; letter-spacing: -.05em; gap: .55rem; }
.brand-mark { width: 1.5rem; display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; }
.brand, .imprint, #turn-example { white-space: nowrap; }
.brand-mark i { aspect-ratio: 1; background: var(--ink); }
.brand-mark i:nth-child(2) { background: #97a784; border-radius: 50% 50% 0 0; }
.brand-mark i:nth-child(3) { background: #c8923f; }
.imprint, .eyebrow, #plate-id, .facts, #plate-count, #book-count { font: 600 .68rem/1.5 ui-monospace, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
.imprint, .eyebrow, #plate-count, #book-count { color: var(--muted); }
.imprint b, .footer b { color: #9a865c; padding-inline: .45rem; }
.intro { display: grid; grid-template-columns: 1.04fr 1fr; align-items: center; gap: clamp(2rem, 5vw, 5rem); padding-block: clamp(2rem, 4.4vw, 4.1rem); }
.eyebrow i { display: inline-block; width: .55rem; height: .55rem; background: #99a780; margin-right: .5rem; }
.cover-copy h1, .shelf-heading h2, .card-text h3, .colophon h2, .play-title h2 { font: normal clamp(2.15rem, 4vw, 3.7rem)/1 Georgia, 'Times New Roman', serif; letter-spacing: -.055em; }
.cover-copy h1 { font-size: clamp(3.6rem, 7.7vw, 7.25rem); line-height: 1.06; margin: .36rem 0 .65rem; }
.cover-copy em { color: var(--violet); }
.cover-copy p { font-size: clamp(1rem, 1.5vw, 1.22rem); max-width: 35ch; color: var(--muted); }
.cover-action { display: inline-flex; gap: 1.3rem; align-items: center; background: var(--violet); color: var(--accent-ink); padding: .72rem 1rem; border-radius: .3rem; margin-top: 1.35rem; font-weight: 650; text-decoration: none; }
.cover-action:hover, .contribute:hover { text-decoration: underline; }
.plate { background: var(--diagram); border: 1px solid var(--rule); border-radius: .35rem; box-shadow: 3px 4px 0 var(--paper), 4px 5px 0 var(--rule); }
.plate-top, .plate-caption { padding: .65rem 1rem; }
.plate-top { border-bottom: 1px solid var(--rule); }
.plate-pair, .card-art { background-image: radial-gradient(circle, color-mix(in srgb, var(--ink) 17%, transparent) 1px, transparent 1px); background-size: 9px 9px; }
.plate-pair { min-height: 11rem; display: grid; grid-template-columns: 1fr auto 1fr; place-items: center; gap: .6rem; padding: .8rem 1.2rem; }
.plate-pair figure { width: 100%; display: flex; flex-direction: column-reverse; align-items: center; gap: .3rem; }
.plate-pair .static-grid { width: min(100%, calc(1.35rem * var(--w)), calc(7rem * var(--w) / var(--h))); }
.plate-pair .static-grid .cell { font-size: clamp(.49rem, 1vw, .64rem); }
.plate-pair .grid-figure figcaption { margin: 0; font-size: .69rem; }
.diagram-arrow { font: 1.8rem Georgia, serif; }
.plate-caption { background: var(--white); border-top: 1px solid var(--rule); }
#plate-title { font: bold 1.15rem Georgia, serif; text-decoration: none; }
#plate-title:hover { text-decoration: underline; }
#plate-count { display: block; margin-top: .18rem; font-size: .61rem; }
#turn-example, .copy-link { border: 0; background: transparent; color: var(--violet); font-size: .8rem; font-weight: 650; padding: .55rem 0; }
#turn-example:hover, .copy-link:hover { text-decoration: underline; }
#turn-example { flex: none; }
#jump-answer { display: none; }
.load-status, #empty-book, #route-status { padding: 1.4rem; }
.shelf-heading { align-items: end; border-top: 1px solid var(--ink); padding-block: 1.3rem 1.1rem; }
.shelf-heading h2 { font-size: clamp(2rem, 3.3vw, 3rem); margin-top: .2rem; }
.riddle-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.5rem), 1fr)); gap: 1.35rem; list-style: none; margin: 0; padding: 0; }
.riddle-card { background: var(--white); border: 1px solid var(--line); border-radius: .3rem; display: flex; flex-direction: column; }
.card-link { display: block; text-decoration: none; }
.card-link:hover h3 { color: var(--violet); text-decoration: underline; text-decoration-thickness: 1px; }
.card-art { display: grid; position: relative; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 1.3rem 1.6rem; min-height: 9.5rem; border-bottom: 1px solid var(--line); background-color: var(--sage); border-radius: .3rem .3rem 0 0; }
.riddle-card:nth-child(3n+2) .card-art { background-color: var(--blue); }
.riddle-card:nth-child(3n) .card-art { background-color: var(--ochre); }
.open-mark { position: absolute; top: .35rem; right: .5rem; }
.card-text { padding: .85rem 1rem .55rem; }
.card-text h3 { font-size: 1.9rem; margin-block: .24rem; }
.card-meta, #riddle-meta, .colophon p { color: var(--muted); }
.card-meta { font-size: .85rem; }
.facts { font-size: .7rem; letter-spacing: .02em; margin: auto 1rem 0; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.share { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.riddle-card .share { padding-inline: 1rem; }
.share-status { font-size: .8rem; }
.copy-field { width: 100%; }
.colophon { margin-top: clamp(2.5rem, 5vw, 4.5rem); padding-block: 1.4rem; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(9rem, 17rem) 1fr; gap: clamp(1.2rem, 4vw, 3rem); align-items: center; }
.colophon img { width: 100%; height: auto; border-radius: .25rem; }
.colophon h2 { font-size: clamp(1.8rem, 3vw, 2.55rem); margin: .35rem 0 .6rem; }
.colophon p { max-width: 60ch; }
.contribute { display: inline-block; padding-block: .65rem; color: var(--violet); font-weight: 650; }
.footer { margin-block: 1rem 0; padding-block: 1.2rem 2rem; border-top: 1px solid var(--ink); font-size: .78rem; }
.footer nav { flex-wrap: wrap; }
@media (max-width: 44rem) {
  .intro { grid-template-columns: 1fr; gap: 1.45rem; }
  .cover-copy h1 { font-size: clamp(3.65rem, 13vw, 5rem); }
  .colophon { grid-template-columns: 1fr; }
  .colophon img { max-width: 20rem; }
  .footer { flex-direction: column; align-items: start; }
}
@media (prefers-reduced-motion: no-preference) {
  .cover-action span, .open-mark { transition: transform .16s ease; }
  .cover-action:hover span { transform: translateX(3px); }
  .card-link:hover .open-mark { transform: translate(2px,-2px); }
}

.book-link, .next-link { display: inline-block; color: var(--violet); font-weight: 700; font-size: .88rem; }
.book-link { margin-top: 1.35rem; scroll-margin-top: 1.35rem; }
.play-title { margin-block: 1.15rem 1.6rem; overflow-wrap: anywhere; }
.play-title h2 { font-size: clamp(2.3rem, 6vw, 4.5rem); }
.play-title p { margin-top: .8rem; font-size: .9rem; }
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .88fr);
  gap: clamp(1rem, 3vw, 2rem);
}
.play-layout h3 {
  border-top: 1px solid var(--line);
  padding-block: .82rem;
}
.examples { display: grid; gap: .65rem; list-style: none; margin: 0; padding: 0; }
.example, .solve-body {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: clamp(.7rem, 2vw, 1rem);
}
.example h4 { font-size: .85rem; font-weight: 750; margin-bottom: .5rem; }
.example-pair { display: grid; grid-template-columns: minmax(0, 1fr) 1rem minmax(0, 1fr); gap: .45rem; }
.grid-figure figcaption { margin-bottom: .36rem; font-size: .79rem; font-weight: 650; }
.grid-size { font-size: .74rem; font-weight: 500; white-space: nowrap; }
.mini-figure { display: grid; place-items: center; width: 100%; }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--w), minmax(0, 1fr));
  grid-template-rows: repeat(var(--h), minmax(0, 1fr));
  aspect-ratio: var(--w) / var(--h);
  border: 1px solid var(--ink);
  background: #e3ddea;
}
.static-grid { width: min(100%, calc(1.55rem * var(--w)), calc(8rem * var(--w) / var(--h))); }
.mini-grid { width: min(100%, calc(.9rem * var(--w)), calc(7.25rem * var(--w) / var(--h))); }
.cell, .swatch {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 0;
  background: var(--cell-bg, #f3eeff);
  color: var(--cell-ink, #18251f);
  font-weight: 770;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 .5px rgb(33 27 50 / 24%);
}
.static-grid .cell { font-size: clamp(.53rem, 1.6vw, .73rem); }
[data-colour="0"] { --cell-bg: #34413d; --cell-ink: #fff; }
[data-colour="1"] { --cell-bg: #72a2ff; }
[data-colour="2"] { --cell-bg: #f88283; }
[data-colour="3"] { --cell-bg: #a6d487; }
[data-colour="4"] { --cell-bg: #ffcf62; }
[data-colour="5"] { --cell-bg: #a8acbf; }
[data-colour="6"] { --cell-bg: #f3a9d3; }
[data-colour="7"] { --cell-bg: #ffad78; }
[data-colour="8"] { --cell-bg: #7fdbca; }
[data-colour="9"] { --cell-bg: #a794e7; }
[data-colour=" "] { --cell-bg: #f3efdF; }

.editor { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.editor h4 { font-size: 1rem; }
.editor h4 span { color: var(--muted); font-size: .85rem; font-weight: 500; white-space: nowrap; }
#answer-help { color: var(--muted); font-size: .83rem; max-width: 39ch; margin-top: .35rem; }
.palette {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 2.5rem));
  gap: .45rem;
  margin-block: .9rem 1rem;
}
.swatch { min-height: 2.15rem; border-radius: .38rem; font-size: .85rem; }
.swatch[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.answer-grid { width: min(100%, calc(2.3rem * var(--w))); }
.answer-grid .cell { touch-action: manipulation; font-size: clamp(.67rem, 2vw, .89rem); }
.answer-grid .cell:hover { box-shadow: inset 0 0 0 2px var(--ink); }
.answer-grid .cell:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 4px #fff;
  forced-color-adjust: none;
}
.actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .95rem; }
.actions button {
  min-height: 2.65rem;
  padding: .4rem .8rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .45rem;
  font-size: .86rem;
  font-weight: 700;
}
.actions button:hover { border-color: var(--violet); }
.actions .primary { color: var(--accent-ink); background: var(--violet); border-color: var(--violet); }
.actions .primary:hover { text-decoration: underline; }
.answer-status { min-height: 1.2em; margin-top: .65rem; font-size: .88rem; }
.answer-status[data-result="correct"] { color: var(--violet); font-weight: 800; }
.answer-status[data-result="retry"] { color: var(--ink); font-weight: 700; }
.next-link { margin-top: 1rem; }

@media (max-width: 44rem) {
  .play-layout { grid-template-columns: minmax(0, 1fr); }
  .masthead { min-height: 4rem; }
  .imprint { font-size: .6rem; letter-spacing: .04em; }
  .imprint b { padding-inline: .12rem; }
  #jump-answer { display: inline-block; text-decoration: underline; }
}
@media (forced-colors: active) {
  .cell, .swatch { forced-color-adjust: none; }
}

@media (max-width: 44rem) {
  .static-grid { width: min(100%, calc(1.55rem * var(--w))); }
  .static-grid .cell { font-size: .85rem; }
  .example-pair.wide { grid-template-columns: minmax(0, 1fr); }
  .example-pair.wide .pair-arrow { justify-self: start; transform: rotate(90deg); }
  .answer-scroll { overflow-x: auto; }
  .answer-grid { min-width: calc(24px * var(--w) + 2px); }
}
