/* The Leaning Stack: stylesheet.
   Palette: kraft #d9c7a7 · timber #54422e · spine green #37502d · sticker orange #e07020 */

:root {
  --kraft: #d9c7a7;
  --kraft-light: #e6d8ba;
  --kraft-deep: #c9b592;
  --paper: #efe6d1;
  --cream: #f2e9d5;
  --timber: #54422e;
  --timber-ink: #3a2d1e;
  --timber-soft: rgba(84, 66, 46, 0.72);
  --timber-faint: rgba(84, 66, 46, 0.38);
  --green: #37502d;
  --orange: #e07020;
  --ink: #2f2517;
  --ink-soft: #4b3d2c;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-swing: cubic-bezier(0.34, 1.45, 0.44, 1);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);

  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.012 0.28' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23g)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.65 'Work Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--timber); color: var(--cream); }

h1, h2, h3 { font-family: 'Domine', serif; color: var(--timber-ink); text-wrap: balance; margin: 0; }
p { margin: 0; }

a { color: var(--green); text-decoration-color: rgba(55, 80, 45, 0.4); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color 180ms var(--ease-out), color 180ms var(--ease-out); }
a:hover { text-decoration-color: var(--green); }

button { font: inherit; }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; border-radius: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute; top: 10px; left: 10px; z-index: 100;
  background: var(--timber); color: var(--cream); padding: 10px 16px;
  border-radius: 4px; text-decoration: none;
  font: 500 14px 'Work Sans', sans-serif;
  transform: translateY(-260%);
  transition: transform 240ms var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* ---------------- Masthead ---------------- */

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  padding: 54px 6vw 30px;
  max-width: 1500px;
  margin: 0 auto;
}

.eyebrow {
  font: 500 12px/1 'Oswald', sans-serif;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--timber-soft);
  margin-bottom: 16px;
}

.masthead h1 {
  font-size: clamp(2.7rem, 5.6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.012em;
}

.tagline {
  margin-top: 18px;
  max-width: 54ch;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.masthead-aside { text-align: right; padding-bottom: 6px; }

.hours { font-size: 14px; line-height: 1.5; color: var(--timber-soft); }
.hours-label {
  font: 500 11px 'Oswald', sans-serif; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--green); margin-right: 6px;
}

.guide-link {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px;
  font: 500 12px 'Oswald', sans-serif; letter-spacing: 0.16em;
  text-transform: uppercase; text-decoration: none;
  color: var(--timber);
  border-bottom: 1px solid var(--timber-faint);
  padding-bottom: 4px;
  transition: color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}
.guide-link svg { width: 14px; height: 14px; transition: transform 220ms var(--ease-swing); }
.guide-link:hover { color: var(--green); border-color: var(--green); }
.guide-link:hover svg { transform: translateX(4px); }

/* ---------------- Toolbar ---------------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px 28px;
  max-width: 1500px; margin: 0 auto;
  padding: 10px 6vw 18px;
}

.sortbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.sortbar-label {
  font: 500 11px 'Oswald', sans-serif; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--timber-soft); margin-right: 6px;
}

.sort-btn {
  font: 500 13px 'Oswald', sans-serif; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--timber);
  background: rgba(242, 233, 213, 0.5);
  border: 1px solid var(--timber-faint);
  border-radius: 5px;
  padding: 8px 15px 7px;
  cursor: pointer;
  transition: background-color 170ms var(--ease-out), border-color 170ms var(--ease-out), color 170ms var(--ease-out);
}
.sort-btn:hover { border-color: var(--timber); background: var(--cream); }
.sort-btn[aria-pressed="true"] { background: var(--timber); border-color: var(--timber); color: var(--cream); }
.sort-btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }

.toolbar-right { display: flex; align-items: center; gap: 20px; }

.toolbar-hint { font-size: 13px; font-style: italic; color: var(--timber-soft); }

.shelve-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 13px 'Oswald', sans-serif; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--cream); background: var(--green);
  border: 1px solid var(--green); border-radius: 5px;
  padding: 8px 16px 7px; cursor: pointer;
  transition: background-color 190ms var(--ease-out), border-color 190ms var(--ease-out);
}
.shelve-btn svg { width: 15px; height: 15px; transition: transform 260ms var(--ease-swing); }
.shelve-btn:hover { background: #2c4124; border-color: #2c4124; }
.shelve-btn:hover svg { transform: rotate(-7deg); }
.shelve-btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }

/* ---------------- Stage ---------------- */

.stage {
  position: relative;
  border-top: 1px solid rgba(84, 66, 46, 0.4);
  border-bottom: 1px solid rgba(84, 66, 46, 0.5);
  background: var(--kraft);
}

.shelf-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(84, 66, 46, 0.45) rgba(84, 66, 46, 0.08);
}
.shelf-scroll::-webkit-scrollbar { height: 10px; }
.shelf-scroll::-webkit-scrollbar-track { background: rgba(84, 66, 46, 0.08); }
.shelf-scroll::-webkit-scrollbar-thumb { background: rgba(84, 66, 46, 0.45); border-radius: 5px; }

.world {
  position: relative;
  height: 560px;
  user-select: none;
  -webkit-user-select: none;
  /* wall light falls from the upper left; floor is timber */
  background:
    var(--noise) repeat,
    repeating-linear-gradient(90deg, rgba(58, 42, 20, 0.05) 0 1px, rgba(58, 42, 20, 0) 1px 328px),
    radial-gradient(120% 90% at 26% -12%, rgba(255, 248, 230, 0.55), rgba(255, 248, 230, 0) 58%),
    linear-gradient(to bottom, #e0cfae 0%, var(--kraft) 46%, #cdb890 100%);
  background-blend-mode: soft-light, normal, normal, normal;
}

/* timber floor painted on the world's lower band */
.world::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--floor-h, 84px);
  background:
    var(--grain) repeat,
    repeating-linear-gradient(90deg, transparent 0 148px, rgba(20, 12, 4, 0.22) 148px 150px),
    linear-gradient(to bottom, #6b543a 0%, #5c472f 18%, var(--timber) 100%);
  background-blend-mode: overlay, normal, normal;
  border-top: 1px solid rgba(30, 20, 8, 0.5);
  box-shadow: inset 0 6px 10px -6px rgba(20, 12, 4, 0.55);
}

.shadow-canvas, .mote-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.shadow-canvas { z-index: 1; }
.mote-canvas { z-index: 6; }

/* ---------------- Books ---------------- */

.inventory {
  list-style: none; margin: 0; padding: 0;
  position: absolute; inset: 0; z-index: 2;
}

.book {
  position: absolute; top: 0; left: 0;
  will-change: transform;
}
.book:hover { z-index: 30; }
.book.is-dragging { z-index: 40; }
.book:has(.spine:focus-visible) { z-index: 45; }

.spine {
  display: block; width: 100%; height: 100%;
  padding: 0; border: 0; background: none;
  cursor: grab; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.spine:active { cursor: grabbing; }
.spine:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }

.spine-face {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--wear-r, 3px);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0) 32%, rgba(0, 0, 0, 0.07) 74%, rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, rgba(255, 255, 255, 0.02) 1px 3px),
    var(--base);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    inset 3px 0 4px -2px rgba(0, 0, 0, 0.28),
    inset -3px 0 4px -2px rgba(0, 0, 0, 0.28);
  transition: transform 190ms var(--ease-swing), filter 190ms var(--ease-out);
}

/* head and tail cloth bands */
.v-bands .spine-face, .v-gilt .spine-face {
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0) 32%, rgba(0, 0, 0, 0.07) 74%, rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, rgba(255, 255, 255, 0.02) 1px 3px),
    linear-gradient(90deg, var(--band) 0 11px, transparent 11px calc(100% - 11px), var(--band) calc(100% - 11px)),
    var(--base);
}

/* the book's own underside: reads as contact shadow on whatever it rests on */
.spine-face::before {
  content: '';
  position: absolute; left: 3%; right: 3%; bottom: 0; height: 5px;
  background: linear-gradient(to top, rgba(26, 17, 6, 0.32), rgba(26, 17, 6, 0));
  border-radius: inherit;
  pointer-events: none;
}

/* scuff and grime, proportional to handling */
.spine-face::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--noise);
  mix-blend-mode: soft-light;
  opacity: var(--wear-o, 0.08);
  pointer-events: none;
}

.wear-0 { --wear-o: 0.07; --wear-r: 2px; }
.wear-1 { --wear-o: 0.16; --wear-r: 3px; }
.wear-2 { --wear-o: 0.26; --wear-r: 4px; }
.wear-3 { --wear-o: 0.38; --wear-r: 6px; }

.spine:hover .spine-face,
.spine:focus-visible .spine-face { transform: translateY(-2.5px); filter: brightness(1.06); }
.book.is-dragging .spine-face { filter: brightness(1.09); }

.spine-text {
  display: flex; align-items: baseline; gap: 9px;
  max-width: calc(100% - 26px);
  padding: 1px 8px;
  position: relative; z-index: 2;
  white-space: nowrap;
}
.spine.has-sticker .spine-text { margin-right: 46px; }

.v-label .spine-text {
  background: var(--label);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(40, 26, 10, 0.16), 0 1px 1px rgba(0, 0, 0, 0.12);
  padding: 2px 12px 3px;
}

.spine-title { color: var(--ink-c); line-height: 1.1; }
.f-garamond .spine-title { font-family: 'EB Garamond', serif; font-weight: 600; letter-spacing: 0.015em; }
.f-oswald .spine-title { font-family: 'Oswald', sans-serif; font-weight: 500; text-transform: uppercase; letter-spacing: 0.09em; }
.f-domine .spine-title { font-family: 'Domine', serif; font-weight: 600; letter-spacing: 0.005em; }

.v-gilt .spine-title {
  border-top: 1px solid var(--ink-c);
  border-bottom: 1px solid var(--ink-c);
  padding: 2px 6px;
}

.spine-author {
  font: 400 9px 'Oswald', sans-serif;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-c); opacity: 0.75;
}

.spine-sticker {
  position: absolute; right: var(--stick-x, 9px); top: 50%;
  transform: translateY(-50%) rotate(var(--stick-r, -4deg));
  min-width: 21px; height: 21px; padding: 0 4px;
  border-radius: 11px;
  background: var(--orange);
  color: #fff6e8;
  font: 600 11px/21px 'Caveat', cursive;
  text-align: center;
  box-shadow: 0 1px 2px rgba(40, 20, 4, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  z-index: 3;
  pointer-events: none;
}

/* ---------------- Pile furniture ---------------- */

.pile-labels { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

.pile-label {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
  background: var(--kraft-light);
  border: 1px solid rgba(84, 66, 46, 0.4);
  border-radius: 3px;
  padding: 7px 14px 8px;
  box-shadow: 0 2px 3px rgba(30, 18, 6, 0.22);
  opacity: 1;
  transition: opacity 320ms var(--ease-out), transform 420ms var(--ease-out);
}
.pile-label.is-entering { opacity: 0; transform: translate(-50%, 9px); }

.pl-name {
  display: block;
  font: 500 11px 'Oswald', sans-serif;
  letter-spacing: 0.17em; text-transform: uppercase;
  color: var(--timber-ink);
}
.pl-count {
  display: block;
  font: 400 11px 'Work Sans', sans-serif;
  color: var(--timber-soft);
  margin-top: 2px;
}
.pl-tag {
  display: block;
  font: 600 16px/1 'Caveat', cursive;
  color: var(--orange);
  transform: rotate(-2.5deg);
  margin-top: 5px;
}

.bench {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}
.bench-top {
  position: absolute; top: 0; left: 0; right: 0; height: 16px;
  background:
    var(--grain) repeat,
    linear-gradient(to bottom, #816849 0%, #6d5638 55%, #5a4630 100%);
  background-blend-mode: overlay, normal;
  border-radius: 3px 3px 1px 1px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -2px 0 rgba(26, 16, 6, 0.35);
}
.bench-apron {
  position: absolute; top: 16px; left: 7px; right: 7px; height: 11px;
  background: linear-gradient(to bottom, #5c4830, #4d3b26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 3px rgba(30, 18, 6, 0.3);
}
.bench-leg {
  position: absolute; top: 25px; bottom: 2px; width: 14px;
  background: linear-gradient(90deg, #6b543a 0%, #5a4630 55%, #48371f 100%);
  box-shadow: inset 0 -9px 10px -6px rgba(0, 0, 0, 0.5);
}
.bench-leg.bl-l { left: 18px; }
.bench-leg.bl-c { left: 50%; margin-left: -7px; }
.bench-leg.bl-r { right: 18px; }
.bench-shade {
  position: absolute; left: 4px; right: 4px; bottom: -3px; height: 12px;
  background: radial-gradient(52% 100% at 50% 0%, rgba(28, 18, 6, 0.32), rgba(28, 18, 6, 0) 78%);
}

/* the shop cat sleeps against the bench leg; rule 4 applies */
.cat {
  position: absolute;
  width: 78px; height: 42px;
  z-index: 1;
  pointer-events: none;
}
.cat svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cat-body {
  transform-origin: 50% 100%;
  animation: cat-breathe 3.4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
.cat-head {
  transform-origin: 24% 80%;
  transition: transform 340ms var(--ease-swing);
}
.cat.cat-alert .cat-head { transform: rotate(-12deg) translateY(-3px); }
@keyframes cat-breathe {
  from { transform: scaleY(1); }
  to { transform: scaleY(1.038); }
}

.wall-note {
  position: absolute;
  top: 52px; right: 92px; z-index: 1;
  width: 128px;
  padding: 20px 14px 16px;
  background: #eee1c1;
  box-shadow: 0 3px 7px rgba(40, 24, 8, 0.16);
  font: 600 19px/1.25 'Caveat', cursive;
  color: var(--timber);
  text-align: center;
  transform: rotate(1.8deg);
}
.wall-note-tape {
  position: absolute;
  top: -9px; left: 50%;
  width: 58px; height: 19px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(244, 236, 214, 0.65);
  border: 1px solid rgba(60, 40, 16, 0.08);
}

.pan-hint {
  position: absolute;
  left: 50%; bottom: 14px; z-index: 7;
  transform: translateX(-50%);
  display: none;
  align-items: center; gap: 7px;
  font: 500 12px 'Work Sans', sans-serif;
  color: var(--cream);
  background: rgba(58, 45, 30, 0.78);
  padding: 8px 14px;
  border-radius: 20px;
  opacity: 1;
  transition: opacity 500ms var(--ease-out);
}
.pan-hint svg { width: 13px; height: 13px; }
.pan-hint.is-hidden { opacity: 0; }

.noscript-note {
  max-width: 640px; margin: 40px auto;
  padding: 0 6vw;
  font-style: italic; color: var(--timber-soft);
  text-align: center;
}

/* ---------------- Keeper section ---------------- */

.keeper {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.9fr);
  gap: 70px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 100px 6vw 84px;
}

.keeper h2, .legend h2 {
  font-size: clamp(1.75rem, 2.6vw, 2.15rem);
  font-weight: 600;
}
.keeper h2::before, .legend h2::before {
  content: '';
  display: block;
  width: 46px; height: 3px;
  border-radius: 2px;
  background: var(--green);
  opacity: 0.75;
  margin-bottom: 20px;
}

.keeper-note p { max-width: 58ch; text-wrap: pretty; }
.keeper-note h2 { margin-bottom: 26px; }
.keeper-note p + p { margin-top: 18px; }

.keeper-sign {
  font: 600 30px/1 'Caveat', cursive;
  color: var(--green);
  transform: rotate(-2deg);
  transform-origin: left center;
  margin-top: 30px;
}

.house-rules {
  align-self: start;
  background: rgba(230, 216, 186, 0.55);
  border: 1px solid rgba(84, 66, 46, 0.28);
  border-radius: 8px 8px 8px 2px;
  padding: 30px 32px 26px;
  margin-top: 54px;
}
.house-rules h3 {
  font: 500 12px 'Oswald', sans-serif;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--timber-soft);
  margin-bottom: 18px;
}
.house-rules ol {
  margin: 0; padding: 0;
  list-style: none;
  counter-reset: rules;
}
.house-rules li {
  counter-increment: rules;
  position: relative;
  padding-left: 34px;
  font-size: 15.5px;
  color: var(--ink-soft);
}
.house-rules li + li { margin-top: 12px; }
.house-rules li::before {
  content: counter(rules);
  position: absolute; left: 0; top: 1px;
  font: 600 17px/22px 'Caveat', cursive;
  color: var(--orange);
  width: 22px; height: 22px;
  text-align: center;
  border: 1px solid rgba(224, 112, 32, 0.45);
  border-radius: 50%;
}

/* ---------------- Legend ---------------- */

.legend {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 6vw 120px;
}
.legend h2 { margin-bottom: 44px; }

.legend-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 70px;
  align-items: center;
}

.legend-pile { margin: 0; text-align: center; }
.legend-books {
  position: relative;
  height: 150px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
}
.lb {
  display: block;
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 3px rgba(0, 0, 0, 0.25),
    0 2px 2px rgba(30, 18, 6, 0.22);
}
.lb + .lb { margin-top: -1px; }
.lb-1 { width: 190px; height: 30px; background: var(--timber); }
.lb-2 { width: 166px; height: 26px; background: var(--green); transform: translateX(-8px) rotate(-0.8deg); transform-origin: bottom center; }
.lb-3 { width: 148px; height: 28px; background: #96473a; transform: translateX(10px) rotate(0.9deg); transform-origin: bottom center; }
.lb-4 { width: 118px; height: 22px; background: #33455c; transform: translateX(-3px) rotate(-1.6deg); transform-origin: bottom center; }
.legend-pile figcaption {
  margin-top: 16px;
  font: 600 17px 'Caveat', cursive;
  color: var(--timber-soft);
}

.legend-keys { margin: 0; }
.legend-key + .legend-key { margin-top: 30px; }
.legend-key dt {
  display: flex; align-items: center; gap: 13px;
  font: 600 19px 'Domine', serif;
  color: var(--timber-ink);
}
.legend-num {
  flex: none;
  width: 24px; height: 24px;
  border: 1px solid rgba(224, 112, 32, 0.55);
  border-radius: 50%;
  color: var(--orange);
  font: 600 15px/24px 'Caveat', cursive;
  text-align: center;
}
.legend-key dd {
  margin: 8px 0 0 37px;
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 52ch;
  text-wrap: pretty;
}

/* ---------------- Colophon ---------------- */

.colophon {
  border-top: 1px solid rgba(84, 66, 46, 0.3);
  padding: 48px 6vw 76px;
  text-align: center;
}
.colophon-address {
  font: 500 12px 'Oswald', sans-serif;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--timber-soft);
}
.colophon-fiction {
  margin-top: 14px;
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
}
.colophon-guide { margin-top: 10px; font-size: 15px; color: var(--ink-soft); }

/* ---------------- Plate dialog ---------------- */

.plate {
  border: 1px solid rgba(84, 66, 46, 0.35);
  border-radius: 10px 10px 10px 3px;
  padding: 0;
  background: var(--cream);
  max-width: min(580px, calc(100vw - 36px));
  width: 100%;
  box-shadow: 0 24px 70px -18px rgba(30, 18, 4, 0.5);
}
.plate::backdrop {
  background: rgba(52, 38, 20, 0.46);
}
.plate[open] { animation: plate-in 360ms var(--ease-out); }
.plate[open]::backdrop { animation: backdrop-in 360ms var(--ease-out); }
.plate.is-closing { animation: plate-out 200ms var(--ease-inout) forwards; }
.plate.is-closing::backdrop { animation: backdrop-out 200ms var(--ease-inout) forwards; }

@keyframes plate-in {
  from { transform: translateY(28px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes plate-out {
  to { transform: translateY(14px) scale(0.98); opacity: 0; }
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { to { opacity: 0; } }

.plate-card {
  position: relative;
  padding: 34px 42px 30px;
  background: var(--noise) repeat, var(--cream);
  background-blend-mode: soft-light, normal;
}

.plate-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.plate-section {
  font: 500 11px 'Oswald', sans-serif;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--green);
  background: rgba(55, 80, 45, 0.12);
  border-radius: 3px;
  padding: 5px 10px 4px;
}
.plate-code {
  font: 500 11px 'Oswald', sans-serif;
  letter-spacing: 0.18em;
  color: var(--timber-faint);
}

.plate-title {
  font-size: clamp(1.55rem, 4.6vw, 1.95rem);
  font-weight: 700;
  line-height: 1.14;
}
.plate-byline { margin-top: 8px; font-size: 15px; color: var(--timber-soft); }

.plate-rule {
  width: 58px; height: 2px;
  background: var(--timber-faint);
  margin: 22px 0;
  position: relative;
}
.plate-rule::after {
  content: '';
  position: absolute; left: 66px; top: -1px;
  width: 4px; height: 4px;
  background: var(--orange);
  border-radius: 50%;
}

.plate-note { font-size: 16.5px; line-height: 1.68; color: var(--ink); text-wrap: pretty; }

.plate-staff {
  margin-top: 18px;
  padding: 4px 0 4px 18px;
  border-left: 3px solid rgba(224, 112, 32, 0.55);
  font: 600 20px/1.4 'Caveat', cursive;
  color: var(--green);
}

.plate-meta {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 26px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px dashed rgba(84, 66, 46, 0.3);
}
.plate-meta-label {
  font: 500 10.5px 'Oswald', sans-serif;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--timber-soft);
  margin-bottom: 7px;
}
.plate-meta p { font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); text-wrap: pretty; }

.plate-foot {
  display: flex; align-items: center; gap: 16px;
  margin-top: 28px;
}
.plate-price {
  flex: none;
  min-width: 66px; height: 66px;
  padding: 0 10px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff6e8;
  font: 600 26px/66px 'Caveat', cursive;
  text-align: center;
  transform: rotate(-5deg);
  box-shadow: 0 2px 5px rgba(40, 20, 4, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.plate-price-note {
  font: 600 16px/1.3 'Caveat', cursive;
  color: var(--timber-soft);
  max-width: 170px;
}
.plate-close {
  margin-left: auto;
  background: var(--timber);
  color: var(--cream);
  border: 0; border-radius: 6px;
  padding: 12px 20px;
  font: 500 13px 'Oswald', sans-serif;
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer;
  transition: background-color 190ms var(--ease-out), transform 190ms var(--ease-swing);
}
.plate-close:hover { background: var(--green); transform: translateY(-1px); }

.plate-hint {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--timber-faint);
}

/* ---------------- Responsive ---------------- */

@media (max-width: 1100px) {
  .keeper { grid-template-columns: 1fr; gap: 44px; padding-top: 80px; }
  .house-rules { margin-top: 0; max-width: 480px; }
  .legend-grid { grid-template-columns: 1fr; gap: 48px; }
  .legend-pile { max-width: 300px; margin: 0 auto; }
}

@media (max-width: 900px) {
  .masthead { grid-template-columns: 1fr; gap: 20px; padding-top: 40px; }
  .masthead-aside { text-align: left; display: flex; align-items: baseline; gap: 26px; flex-wrap: wrap; }
  .guide-link { margin-top: 0; }
  .toolbar-hint { display: none; }
  .world { height: 500px; }
  .pan-hint { display: inline-flex; }
}

@media (max-width: 480px) {
  .masthead { padding-top: 34px; }
  .tagline { font-size: 15.5px; }
  .sortbar-label { display: none; }
  .sort-btn { padding: 7px 11px 6px; font-size: 12px; }
  .shelve-btn { padding: 7px 12px 6px; font-size: 12px; }
  .keeper { padding: 64px 7vw 56px; }
  .legend { padding-bottom: 84px; }
  .plate-card { padding: 26px 24px 24px; }
  .plate-foot { flex-wrap: wrap; }
  .plate-close { margin-left: 0; width: 100%; }
  .plate-hint { display: none; }
}

/* ---------------- Reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .plate[open], .plate[open]::backdrop { animation-duration: 1ms; }
  .plate.is-closing, .plate.is-closing::backdrop { animation-duration: 1ms; }
  .spine-face, .guide-link svg, .shelve-btn svg, .pile-label { transition-duration: 1ms; }
  .cat-body { animation: none; }
  .cat-head { transition-duration: 1ms; }
}
html.motion-off .plate[open], html.motion-off .plate[open]::backdrop { animation-duration: 1ms; }
html.motion-off .spine { cursor: pointer; }
html.motion-off .spine-face { transition-duration: 1ms; }
html.motion-off .cat-body { animation: none; }
html.motion-off .cat-head { transition-duration: 1ms; }
