/* Querykeep. Cloth banners over a pixel kingdom (from Coinfall), and the tome: an open book over it. */
:root {
  --night: #141428;
  --night-2: #1f1d3d;
  --cloth: #23214a;
  --cloth-edge: #3b3870;
  --gold: #f2c14e;
  --gold-deep: #c98a2b;
  --gold-ink: #3a2408;
  --olive: #8f9c35;
  --olive-deep: #5f6a1f;
  --blood: #c8574a;
  --text: #f6ecd2;
  --muted: #b9b4d8;
  --px: 3px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); overflow: hidden; }
body {
  font-family: "Pixelify Sans", ui-rounded, system-ui, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
::selection { background: var(--gold); color: var(--gold-ink); }
a { color: var(--gold); text-underline-offset: 0.25em; text-decoration-thickness: 1px; }
a:hover { color: #ffe08a; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

#stage { position: fixed; inset: 0; display: grid; place-items: center; }
#view, #ui { grid-area: 1 / 1; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#ui { pointer-events: none; image-rendering: auto; }

/* ---------- loading */
.loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 18px; background: var(--night); z-index: 50; }
.loading[hidden] { display: none; }
.loading-word { margin: 0; font-family: "Jacquard 24", serif; font-size: clamp(48px, 9vw, 96px); color: var(--gold); text-align: center; line-height: 1; }
.loading-track { width: min(60vw, 280px); height: 6px; background: var(--night-2); }
.loading-bar { height: 100%; width: 100%; background: var(--gold); transform: scaleX(0); transform-origin: left; transition: transform 0.2s ease-out; }

/* ---------- screens and cloth */
.screen { position: absolute; inset: 0; display: grid; justify-items: center; align-items: start; z-index: 20; overflow-y: auto; padding: 0 16px 24px; }
.screen[hidden] { display: none; }
.screen-top { z-index: 30; background: rgba(12, 10, 26, 0.55); }

/* a banner hung from the top edge, swallowtail at the bottom, notched pixel corners */
.cloth {
  position: relative;
  width: min(92vw, 380px);
  padding: 34px 28px 54px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px calc(100% - 2px), rgba(0, 0, 0, 0.25) calc(100% - 2px)),
    linear-gradient(var(--cloth), #1b1a3c);
  box-shadow: inset 4px 0 0 var(--olive), inset -4px 0 0 var(--olive);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 26px), 0 100%);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
  text-align: center;
  animation: unfurl 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.cloth::before {
  /* the pole the cloth hangs from */
  content: "";
  position: absolute; left: -10px; right: -10px; top: 0; height: 8px;
  background: linear-gradient(#a8692f, #6e3f1d);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.cloth::after {
  /* gold trim along the swallowtail */
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 30px;
  background: var(--gold-deep);
  clip-path: polygon(0 calc(100% - 4px), 50% 0, 100% calc(100% - 4px), 100% 100%, 50% 4px, 0 100%);
  opacity: 0.85;
}
.cloth-wide { width: min(94vw, 620px); }
.cloth-red { background: linear-gradient(#4a1e2a, #2a1220); box-shadow: inset 4px 0 0 var(--blood), inset -4px 0 0 var(--blood); }
@keyframes unfurl { from { clip-path: polygon(0 0, 100% 0, 100% 8px, 50% 8px, 0 8px); } }

.title-word { margin: 6px 0 4px; font-family: "Jacquard 24", serif; font-weight: 400; font-size: clamp(64px, 12vw, 104px); line-height: 0.9; color: var(--gold); text-shadow: 0 3px 0 var(--gold-ink), 0 0 24px rgba(242, 193, 78, 0.25); letter-spacing: 0; }
.title-line { margin: 0 auto 22px; max-width: 28ch; color: var(--muted); font-size: 15px; line-height: 1.45; }
.cloth-h { margin: 4px 0 6px; font-family: "Jacquard 24", serif; font-weight: 400; font-size: clamp(34px, 6vw, 46px); line-height: 1; color: var(--gold); text-wrap: balance; }
.cloth-sub { margin: 0 auto 18px; max-width: 40ch; color: var(--muted); font-size: 15px; line-height: 1.45; text-wrap: pretty; }
.title-foot { margin: 20px 0 0; font-size: 13px; color: var(--muted); display: flex; justify-content: center; align-items: center; gap: 10px; }
.title-foot .dot { width: 4px; height: 4px; background: var(--olive); }

.stack { display: grid; gap: 10px; justify-items: stretch; max-width: 240px; margin: 0 auto; }

/* buttons: struck coins and plain cloth tabs */
.btn {
  font: 600 16px/1 "Pixelify Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--night-2);
  border: 0;
  padding: 12px 18px;
  cursor: pointer;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.12s ease-out, background-color 0.12s ease-out;
}
.btn:hover { background: var(--cloth-edge); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); color: var(--gold-ink); box-shadow: inset 0 -3px 0 var(--gold-deep), inset 0 2px 0 #ffe7a3; }
.btn-gold:hover { background: #ffd56b; }
.btn-quiet { background: transparent; color: var(--muted); box-shadow: none; margin-top: 14px; }
.btn-quiet:hover { background: rgba(255, 255, 255, 0.06); }
.btn[aria-pressed="false"] { color: var(--muted); }

/* how to play */
.how { text-align: left; }
.how .cloth-h { text-align: center; }
.how-list { margin: 10px 0 14px; padding: 0 0 0 1.4em; display: grid; gap: 9px; font-size: 15px; line-height: 1.45; color: var(--text); }
.how-list li::marker { color: var(--gold); font-weight: 600; }
.how-list b { color: var(--gold); font-weight: 600; }
.how-phone { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.how .btn { display: block; margin: 0 auto; }

.won-stats { font-size: 14px; color: var(--text); line-height: 1.5; margin: 0 auto 18px; max-width: 44ch; font-variant-numeric: tabular-nums; }

/* ---------- in-game overlays */
#hud { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 10; display: flex; gap: 10px; align-items: center; }
#hud[hidden] { display: none; }
.chip { font: 600 13px/1 "Pixelify Sans", sans-serif; color: var(--text); background: rgba(20, 20, 40, 0.72); border: 0; padding: 8px 12px; cursor: pointer; clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px); }
.chip:hover { background: var(--cloth-edge); }

#toast {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 12;
  transform: translate(-50%, 20px); opacity: 0;
  max-width: min(86vw, 460px); margin: 0; padding: 10px 16px;
  background: rgba(20, 20, 40, 0.86); color: var(--text); font-size: 15px; line-height: 1.4; text-align: center;
  border-bottom: 3px solid var(--olive);
  pointer-events: none;
  transition: opacity 0.25s ease-out, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (pointer: coarse) {
  #toast { bottom: auto; top: calc(56px + env(safe-area-inset-top)); transform: translate(-50%, -12px); font-size: 14px; }
  #toast.show { transform: translate(-50%, 0); }
}

#banner { position: absolute; left: 0; right: 0; top: 16%; z-index: 11; text-align: center; pointer-events: none; }
#banner[hidden] { display: none; }
#bannerBig { margin: 0; font-family: "Jacquard 24", serif; font-size: clamp(40px, 8vw, 76px); line-height: 1; color: var(--gold); text-shadow: 0 3px 0 var(--gold-ink), 0 0 18px rgba(0, 0, 0, 0.6); }
#bannerSmall { margin: 6px 0 0; font-size: 15px; color: var(--text); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
#banner.show #bannerBig { animation: stamp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
#banner.show #bannerSmall { animation: rise 0.8s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes stamp { from { opacity: 0; transform: scale(1.3); filter: blur(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.isle-card { position: absolute; inset: 0; z-index: 15; display: grid; place-content: center; text-align: center; background: radial-gradient(ellipse at center, rgba(14, 12, 30, 0.82), rgba(14, 12, 30, 0.35) 70%, transparent); pointer-events: none; animation: card 3.6s ease-in-out both; }
.isle-card[hidden] { display: none; }
.isle-num { margin: 0; font-size: 13px; letter-spacing: 0.08em; color: var(--olive); }
.isle-card h2 { margin: 4px 0 6px; font-family: "Jacquard 24", serif; font-weight: 400; font-size: clamp(52px, 10vw, 96px); line-height: 1; color: var(--gold); text-shadow: 0 3px 0 var(--gold-ink); }
.isle-card p:last-child { margin: 0; color: var(--text); font-size: 16px; }
@keyframes card { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }

.fade { position: absolute; inset: 0; background: #07060f; opacity: 0; z-index: 40; transition: opacity 1.2s ease-in-out; pointer-events: none; }
.fade.on { opacity: 1; }
.fade[hidden] { display: none; }

/* ---------- phone pad */
#pad { position: absolute; inset: auto 0 0 0; z-index: 14; display: flex; justify-content: space-between; padding: 0 calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); pointer-events: none; }
#pad[hidden] { display: none; }
#pad > div { display: flex; gap: 12px; pointer-events: auto; }
#pad button {
  width: 64px; height: 64px; border: 0; padding: 0;
  display: grid; place-items: center;
  background: rgba(20, 20, 40, 0.5); color: var(--text);
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  touch-action: none;
}
#pad button.on { background: rgba(242, 193, 78, 0.45); }
#pad svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
#pad .pad-coin { width: 76px; height: 76px; background: rgba(242, 193, 78, 0.35); color: var(--gold); }
#pad .pad-coin.on { background: rgba(242, 193, 78, 0.7); color: var(--gold-ink); }

.rotate { display: none; }
#stage.portrait .rotate { display: grid; place-content: center; position: absolute; inset: 0; z-index: 60; margin: 0; padding: 24px; background: var(--night); color: var(--gold); text-align: center; font-family: "Jacquard 24", serif; font-size: 34px; line-height: 1.1; }

/* live badge, mirrors the back link on the title cloth */
.vim-live--querykeep { margin-top: 10px; justify-content: center; font-size: 12px; color: var(--muted); width: 100%; }

@media (max-height: 520px) {
  .cloth { padding: 22px 22px 44px; }
  .title-word { font-size: 64px; }
  .title-line { margin-bottom: 12px; font-size: 13px; }
  .btn { padding: 9px 14px; font-size: 14px; }
  .stack { gap: 7px; }
  .title-foot { margin-top: 12px; }
  .how-list { gap: 5px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .cloth, #banner.show #bannerBig, #banner.show #bannerSmall, .isle-card { animation: none; }
  .btn, .plank, #toast { transition: none; }
}

/* hover names */
#tip {
  position: absolute; z-index: 16; pointer-events: none;
  max-width: 240px; padding: 7px 10px 8px;
  background: rgba(20, 20, 40, 0.92); color: var(--text);
  border-top: 2px solid var(--gold);
  font-size: 13px; line-height: 1.35;
  display: grid; gap: 2px;
}
#tip[hidden] { display: none; }
#tip b { font-weight: 600; color: var(--gold); font-size: 14px; }
#tip span { color: var(--muted); }

/* orders for selected workers */
#jobs {
  position: absolute; z-index: 13; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: min(94vw, 560px); padding: 10px 12px 12px;
  background: rgba(20, 20, 40, 0.94); border-top: 3px solid var(--olive);
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
}
#jobs[hidden] { display: none; }
.jobs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#jobsTitle { margin: 0; font: 400 26px/1 "Jacquard 24", serif; color: var(--gold); }
#jobsWho { margin: 2px 0 8px; color: var(--muted); font-size: 13px; }
.jobs-x { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.jobs-x:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.jobs-x svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.jobs-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.job {
  display: grid; gap: 2px; text-align: left; padding: 7px 9px; border: 0; cursor: pointer;
  background: var(--night-2); color: var(--text); font: 600 14px/1.2 "Pixelify Sans", sans-serif;
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
}
.job small { font: 400 12px/1.2 "Pixelify Sans", sans-serif; color: var(--muted); }
.job:hover:not(:disabled) { background: var(--cloth-edge); }
.job:disabled { cursor: not-allowed; opacity: 0.45; }
.job-cost { color: var(--gold) !important; }
@media (max-width: 520px) { .jobs-list { grid-template-columns: repeat(2, 1fr); } }
@media (max-height: 520px) { #jobs { top: calc(44px + env(safe-area-inset-top)); padding: 6px 10px 8px; } #jobsWho { display: none; } .job { padding: 5px 8px; } }

/* ---------- menus: wooden planks hung over the kingdom (Kingdom style) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.screen-menu {
  align-items: center; justify-items: start; align-content: center;
  padding: 24px 16px 24px calc(max(28px, 5vw) + env(safe-area-inset-left));
  grid-auto-rows: min-content; gap: 12px;
}
.planks { display: grid; gap: calc(var(--px) * 3); width: clamp(220px, calc(var(--px) * 110), 380px); container-type: inline-size; }
/* the board is drawn behind the label (::before), so the words can use the whole width of the plank */
.plank {
  position: relative; isolation: isolate;
  /* the words sit in the middle of the board, both ways */
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-sizing: border-box; width: 100%;
  min-height: calc(var(--px) * 19);
  padding: calc(var(--px) * 5) calc(var(--px) * 4);
  border: 0;
  background: none;
  font: 700 clamp(16px, 7.2cqi, 30px) / 1 Silkscreen, "Pixelify Sans", system-ui, sans-serif;
  letter-spacing: 0; text-transform: uppercase; text-align: center; text-decoration: none;
  color: #2c1608;
  text-shadow: 0 1px 0 rgba(255, 214, 160, 0.35);
  cursor: pointer;
  outline: none;
}
.plank::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-style: solid;
  border-width: calc(var(--px) * 5) calc(var(--px) * 14);
  border-image: url("/querykeep/assets/ui-plank.png?v=b4c2a5a8d8") 5 14 fill / calc(var(--px) * 5) calc(var(--px) * 14) / 0 stretch;
  image-rendering: pixelated;
  filter: saturate(0.5) brightness(0.72);
  transition: filter 0.14s ease-out;
}
.plank[hidden] { display: none; }
/* selected: the board lights up and its own edges turn white, following the wood, pegs included */
.plank:hover::before, .plank:focus-visible::before {
  filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff);
}
.plank:active::before { filter: brightness(0.9) drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff); }
.plank[aria-pressed="false"] { color: #4a3424; }
.menu-head { margin: 0 0 2px; font: 400 calc(var(--px) * 13) / 1 "Jacquard 24", serif; color: var(--gold); text-shadow: 0 3px 0 var(--gold-ink); }
.menu-note { margin: 4px 0 0; font: 400 8px/1.3 Silkscreen, "Pixelify Sans", sans-serif; font-size: 16px; letter-spacing: 0.02em; text-transform: uppercase; color: #cfc8e6; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.menu-note a { color: inherit; }
.menu-live { justify-content: flex-start; width: auto; margin: 0; }
@media (max-height: 520px) {
  .screen-menu { padding-top: 10px; padding-bottom: 10px; gap: 6px; }
  .planks { gap: calc(var(--px) * 2); }
}

/* first visit: the canvas draws the screen, this is the way out */
.front-foot {
  position: absolute; z-index: 21; left: calc(16px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: #77748c;
}
.front-foot[hidden] { display: none; }
.front-foot a { color: #8d8aa6; }
.front-foot a:hover { color: var(--text); }
.front-foot .dot { width: 3px; height: 3px; background: #4b4960; }
.front-foot .vim-live { margin: 0; width: auto; justify-content: flex-start; color: #77748c; }

/* ---------- shared site menu (/assets/menu.js) dressed as planks, 2026-10-01 */
.planks[hidden] { display: none; }
.title-menu, .pause-settings { margin-inline: 0; max-width: none; --vm-gap: calc(var(--px) * 3); --vm-accent: var(--gold); --vm-muted: #cfc8e6; --vm-danger: #f08a78; }
.title-menu .vm-list, .title-menu .vm-panel, .pause-settings .vm-panel { gap: calc(var(--px) * 3); }
.title-menu:not([data-vm-view="main"]) { width: clamp(260px, 44vw, 440px); }
.pause-settings { width: clamp(250px, 36vw, 340px); }
.title-menu [data-vm="feedback"] .vm-label { font-size: 0.86em; letter-spacing: 0; }
.title-menu .plank.vm-item, .pause-settings .plank.vm-item { display: flex; min-height: calc(var(--px) * 19); }
.title-menu .plank .vm-label { display: block; width: 100%; text-align: center; }
.title-menu .plank .vm-sub { display: block; margin-top: 4px; font: 600 13px/1.2 "Pixelify Sans", sans-serif; letter-spacing: 0; text-transform: none; opacity: 0.85; }
.title-menu .plank[disabled], .title-menu .plank[disabled]:hover { cursor: not-allowed; opacity: 0.6; }
.title-menu .plank[disabled]::before, .title-menu .plank[disabled]:hover::before { filter: saturate(0.2) brightness(0.5); }
.title-menu .vm-slot { flex-wrap: nowrap; gap: calc(var(--px) * 2); }
.title-menu .vm-slot > .vm-slot-btn { text-align: left; align-items: flex-start; }
.title-menu .vm-slot > .vm-slot-btn .vm-label { text-align: left; font-size: 0.8em; }
.title-menu .vm-slot .vm-slotnum { opacity: 0.75; }
.title-menu .vm-del { min-height: 0; border-radius: 0; background: rgba(12, 10, 26, 0.75); font: 700 12px/1 Silkscreen, "Pixelify Sans", sans-serif; text-transform: uppercase; }
.title-menu .vm-row { gap: calc(var(--px) * 2); }
.vm-menu .vm-h { margin: 0 0 2px; text-align: left; font: 400 max(26px, calc(var(--px) * 11)) / 1 "Jacquard 24", serif; color: var(--gold); text-shadow: 0 3px 0 var(--gold-ink); }
.vm-menu .vm-note { text-align: left; color: #cfc8e6; font-size: 14px; opacity: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.vm-menu .vm-note a { color: var(--gold); }
.vm-credits .vm-maker, .vm-credits .vm-role { text-align: left; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.vm-credits .vm-maker { font: 400 max(28px, calc(var(--px) * 10)) / 1 "Jacquard 24", serif; color: var(--text); }
.vm-credits .vm-role { color: #cfc8e6; }
.vm-menu .vm-slider { color: var(--text); font-size: 15px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.vm-menu .vm-slider output { color: var(--gold); }
/* the title menu works upright too; only riding needs the phone sideways */
#stage.portrait:has(> #title:not([hidden])) .rotate,
#stage.portrait:has(> #how:not([hidden])) .rotate { display: none; }
@media (max-height: 520px) {
  .title-menu .vm-list, .title-menu .vm-panel, .pause-settings .vm-panel { gap: calc(var(--px) * 2); }
  .title-menu .plank.vm-item { min-height: calc(var(--px) * 16); }
  .title-menu .plank .vm-sub { font-size: 10px; margin-top: 0; }
  .vm-menu .vm-slider { padding: 0; }
}

/* =====================================================================================================
   The tome (ledger.js): an open book over the paused kingdom. Parchment pages, headings in rubric red,
   a night-indigo writing slate for SQL, a wax seal for a right answer.
   ===================================================================================================== */
:root {
  --parch: #efe3c4;
  --parch-2: #e3d2a6;
  --parch-3: #d6c28f;
  --ink: #2a1c13;
  --ink-2: #5b4633;
  --rubric: #9a2a1c;
  --leaf-green: #2f6a35;
  --leather: #3b2216;
  --leather-2: #24130c;
  --slate: #191833;
  --slate-2: #232147;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
.tome {
  position: absolute; inset: 0; z-index: 35;
  display: grid; place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  /* light: the island backdrops drift by behind the book (game.js, the dream) */
  background: radial-gradient(ellipse at 50% 45%, rgba(10, 8, 22, 0.12), rgba(6, 5, 14, 0.5));
  user-select: text; -webkit-user-select: text;
}
.tome[hidden] { display: none; }
.tome.in { animation: tome-dim 0.35s ease-out both; }
@keyframes tome-dim { from { background-color: transparent; opacity: 0.4; } }

.book {
  position: relative;
  width: min(1180px, 100%); height: min(760px, calc(100vh - 20px)); height: min(760px, calc(100dvh - 20px));
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr); grid-template-rows: minmax(0, 1fr);
  padding: 10px;
  background:
    linear-gradient(90deg, transparent calc(50% - 46px), rgba(0, 0, 0, 0.35) calc(50% - 46px) calc(50% - 44px), transparent calc(50% - 44px)),
    linear-gradient(var(--leather), var(--leather-2));
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.55));
}
.book::before {
  /* gold tooling around the cover */
  content: ""; position: absolute; inset: 4px; pointer-events: none;
  border: 1px solid rgba(242, 193, 78, 0.35);
}
.page {
  position: relative; min-height: 0; overflow: hidden;
  color: var(--ink);
  font: 400 16px/1.5 "Pixelify Sans", system-ui, sans-serif;
  font-variant-ligatures: none;
  background:
    repeating-linear-gradient(0deg, rgba(90, 60, 30, 0.035) 0 1px, transparent 1px 4px),
    linear-gradient(var(--parch), var(--parch-2));
}
.page-l { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); padding: 20px 30px 14px 26px; box-shadow: inset -22px 0 26px -18px rgba(70, 40, 15, 0.55); }
.page-r { display: grid; grid-template-rows: auto minmax(120px, 0.9fr) auto auto minmax(0, 1.25fr) auto; gap: 8px; padding: 20px 26px 14px 30px; box-shadow: inset 22px 0 26px -18px rgba(70, 40, 15, 0.55); }
.tome.in .page-l { animation: leaf-l 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.tome.in .page-r { animation: leaf-r 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes leaf-l { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes leaf-r { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.page ::selection, .tome ::selection { background: rgba(154, 42, 28, 0.25); color: inherit; }
.page :focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; }
.page *, .page { scrollbar-width: thin; scrollbar-color: var(--parch-3) transparent; }
.page code { font: 500 0.86em/1 var(--mono); background: rgba(91, 70, 51, 0.12); padding: 0.12em 0.32em; white-space: nowrap; }

/* running head and the question tabs */
.run-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 6px; border-bottom: 1px solid rgba(91, 70, 51, 0.35); font: 700 11px/1.2 Silkscreen, "Pixelify Sans", sans-serif; text-transform: uppercase; color: var(--ink-2); letter-spacing: 0.02em; }
.run-head #tqBook { color: var(--rubric); }
.run-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pips { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 2px; padding: 0; list-style: none; }
.pip {
  width: 26px; height: 26px; padding: 0; border: 0; cursor: pointer;
  display: grid; place-items: center; position: relative;
  font: 700 10px/1 Silkscreen, sans-serif; color: var(--ink-2);
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.6);
}
.pip.extra { box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.35); color: rgba(91, 70, 51, 0.8); background: repeating-linear-gradient(135deg, rgba(91, 70, 51, 0.08) 0 2px, transparent 2px 5px); }
.pip:hover { background: rgba(91, 70, 51, 0.12); }
.pip.done { background: var(--ink); color: var(--parch); box-shadow: none; }
.pip.done.extra { background: var(--ink-2); }
.pip.paid::after { content: ""; position: absolute; right: 2px; top: 2px; width: 4px; height: 4px; background: var(--gold); }
.pip.on { box-shadow: inset 0 0 0 2px var(--rubric); color: var(--rubric); background: rgba(154, 42, 28, 0.08); }
.pip.on.done { background: var(--rubric); color: var(--parch); }
/* answered but not practised three times yet; locked until the ones before it are learned */
.pip.learning { background: linear-gradient(to top, var(--parch-3) 0 50%, transparent 50%); box-shadow: inset 0 0 0 2px var(--ink-2); color: var(--ink); }
.pip.on.learning { box-shadow: inset 0 0 0 2px var(--rubric); color: var(--rubric); }
.pip.locked { cursor: not-allowed; color: rgba(91, 70, 51, 0.35); box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.2); background: repeating-linear-gradient(135deg, rgba(91, 70, 51, 0.06) 0 2px, transparent 2px 5px); }
.pip.locked:hover { background: repeating-linear-gradient(135deg, rgba(91, 70, 51, 0.06) 0 2px, transparent 2px 5px); }

/* the tomes: one tab each along the top of the left page */
.tomes { display: flex; flex-wrap: wrap; gap: 3px; margin: 0 0 10px; }
.tomes[hidden] { display: none; }
.tome-tab {
  min-width: 30px; height: 24px; padding: 0 6px; border: 0; cursor: pointer; position: relative;
  font: 700 10px/1 Silkscreen, sans-serif; color: var(--ink-2); background: transparent;
  box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.6);
}
.tome-tab:hover:not(:disabled) { background: rgba(91, 70, 51, 0.12); }
.tome-tab.done { background: var(--ink); color: var(--parch); box-shadow: none; }
.tome-tab.here::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 4px; height: 2px; margin-left: -2px; background: var(--ink-2); }
.tome-tab.on { box-shadow: inset 0 0 0 2px var(--rubric); color: var(--rubric); background: rgba(154, 42, 28, 0.08); }
.tome-tab.on.done { background: var(--rubric); color: var(--parch); }
.tome-tab.locked { cursor: not-allowed; color: rgba(91, 70, 51, 0.45); box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.25); background: repeating-linear-gradient(135deg, rgba(91, 70, 51, 0.07) 0 2px, transparent 2px 5px); }
.page-l > .leaf { grid-row: 4; }

/* self practice: a fresh query on the same idea, one coin each */
.prac-tag { display: inline-block; margin-left: 0.3em; padding: 0.3em 0.45em; font: 700 0.36em/1 Silkscreen, sans-serif; color: var(--parch); background: var(--leaf-green); vertical-align: 0.45em; letter-spacing: 0.02em; }
.ink-prac { color: var(--leaf-green); box-shadow: inset 0 0 0 2px var(--leaf-green); }
.ink-prac:hover:not(:disabled) { background: var(--leaf-green); color: var(--parch); }
.prac-pay { font-weight: 400; font-size: 12px; opacity: 0.85; }
.ink-prac-due { background: var(--leaf-green); color: var(--parch); }
.ink-prac-due:hover:not(:disabled) { background: #245429; }
#tqNext:disabled { opacity: 0.35; }

/* the dawn quiz: one parchment leaf in place of the open book */
.tome[data-mode="quiz"] .book { display: none; }
.tome:not([data-mode="quiz"]) .quiz { display: none; }
.quiz {
  position: relative; width: min(760px, 100%); max-height: calc(100dvh - 20px); overflow-y: auto;
  padding: 22px 30px 20px; display: grid; gap: 10px; outline: none;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.55));
  box-shadow: inset 0 0 0 6px var(--leather), inset 0 0 0 7px rgba(242, 193, 78, 0.35);
}
.tome.in .quiz { animation: leaf-r 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.qz-from { margin: 0; font-size: 13px; color: var(--ink-2); }
.qz-from:empty { display: none; }
.qz-prompt { margin: 0; font: 600 clamp(20px, 2.2vw, 26px)/1.2 "Pixelify Sans", system-ui, sans-serif; color: var(--rubric); text-wrap: balance; }
.qz-ask { display: block; margin-top: 6px; font-size: 0.7em; line-height: 1.4; color: var(--ink); text-wrap: pretty; }
.qz-sql { margin: 0; }
.qz-opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.qz-opts.qz-nums { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.qz-opt {
  width: 100%; display: flex; align-items: flex-start; gap: 10px; text-align: left; cursor: pointer;
  padding: 9px 12px; border: 0; color: var(--ink); background: rgba(214, 194, 143, 0.45);
  box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.35); font: 600 15px/1.3 "Pixelify Sans", sans-serif;
  transition: background-color 0.12s ease-out;
}
.qz-opt:hover:not(:disabled), .qz-opt:focus-visible { background: rgba(214, 194, 143, 0.9); }
.qz-opt:disabled { cursor: default; }
.qz-opt.right { background: rgba(47, 106, 53, 0.22); box-shadow: inset 0 0 0 2px var(--leaf-green); }
.qz-opt.wrong { background: rgba(154, 42, 28, 0.14); box-shadow: inset 0 0 0 2px var(--rubric); }
.qz-key { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; font: 700 10px/1 Silkscreen, sans-serif; color: var(--parch); background: var(--ink-2); }
.qz-opt.right .qz-key { background: var(--leaf-green); }
.qz-opt.wrong .qz-key { background: var(--rubric); }
.quiz .qz-code { font: 400 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; background: none; padding: 0; color: var(--ink); }
.qz-code .t-k { color: var(--rubric); }
.qz-code .t-f { color: #8a4b16; }
.qz-code .t-s { color: var(--leaf-green); }
.qz-code .t-n { color: #2b5c86; }
.answer i, .quiz .qz-code i { font-style: normal; }
.answer .t-c, .quiz .qz-code .t-c { font-style: italic; }
.qz-n { font: 700 18px/22px "Pixelify Sans", sans-serif; }
.qz-foot { display: flex; justify-content: flex-end; min-height: 36px; }
.qz-foot .run-btn[hidden] { display: none; }
.ink-btn[hidden] { display: none; }
.to-gem { color: var(--ink-2); }
.gem-note { color: var(--leaf-green); font-weight: 600; }
.tome[data-prac="1"] .q-task { background: rgba(47, 106, 53, 0.13); }
.tome[data-prac="1"] .q-task::before { color: var(--leaf-green); }

/* the left leaf: the lesson */
.leaf { overflow-y: auto; min-height: 0; padding: 4px 6px 4px 0; }
.q-title { margin: 14px 0 8px; font: 600 clamp(24px, 2.4vw, 31px)/1.05 "Pixelify Sans", system-ui, sans-serif; color: var(--rubric); text-wrap: balance; }
.q-num { display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; margin-right: 0.4em; padding: 0 0.2em; font: 700 0.5em/1 Silkscreen, sans-serif; color: var(--parch); background: var(--rubric); vertical-align: 0.25em; }
.q-teach { margin: 0 0 12px; max-width: 62ch; color: var(--ink); text-wrap: pretty; }
.q-task { margin: 0 0 12px; padding: 10px 12px 10px 30px; position: relative; background: rgba(214, 194, 143, 0.45); }
.q-task::before { content: "\00B6"; position: absolute; left: 10px; top: 8px; font: 400 22px/1 "Jacquard 24", serif; color: var(--rubric); }
.q-task #tqAsk { margin: 0; font-weight: 600; font-size: 17px; line-height: 1.45; max-width: 60ch; text-wrap: pretty; }
.ordered { font-weight: 400; color: var(--rubric); white-space: nowrap; }
.q-pay[hidden] { display: none; }
.q-pay { margin: 6px 0 0; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.q-pay .coin { width: 14px; height: 14px; image-rendering: pixelated; }
.q-help { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.q-help[hidden] { display: none; }
.q-reveal { margin: 0 0 12px; padding: 10px 12px; background: rgba(214, 194, 143, 0.6); font-size: 15px; }
.q-reveal[hidden] { display: none; }
.q-reveal b { color: var(--rubric); font-weight: 600; }
.q-reveal .small { display: block; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.q-reveal .ink-btn { margin-top: 8px; }
.answer { margin: 8px 0 0; padding: 10px 12px; background: var(--slate); color: #ece6ff; font: 400 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }

.ink-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: 0; cursor: pointer;
  font: 600 14px/1 "Pixelify Sans", system-ui, sans-serif; color: var(--ink);
  background: transparent; box-shadow: inset 0 0 0 2px var(--ink-2);
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition: background-color 0.12s ease-out, color 0.12s ease-out;
}
.ink-btn:hover:not(:disabled) { background: var(--ink); color: var(--parch); }
.ink-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ink-btn svg, .run-btn svg, .tome-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.ink-quiet { box-shadow: none; color: var(--ink-2); padding-inline: 6px; }
.ink-quiet:hover:not(:disabled) { background: rgba(91, 70, 51, 0.14); color: var(--ink); }

/* the tables the question uses */
.q-tables { margin-top: 6px; border-top: 1px solid rgba(91, 70, 51, 0.35); padding-top: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tab { border: 0; cursor: pointer; padding: 4px 9px; font: 600 13px/1.2 var(--mono); color: var(--ink-2); background: transparent; box-shadow: inset 0 -2px 0 transparent; }
.tab:hover { color: var(--ink); background: rgba(91, 70, 51, 0.1); }
.tab.on { color: var(--rubric); box-shadow: inset 0 -2px 0 var(--rubric); }
.schema .about { margin: 0 0 6px; font-size: 14px; color: var(--ink-2); max-width: 62ch; }
.cols { margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 14px; }
.cols div { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.cols dt { font: 600 13px/1.4 var(--mono); color: var(--rubric); flex: none; }
.cols dd { margin: 0; font-size: 13px; line-height: 1.35; color: var(--ink-2); min-width: 0; }
.peek { font-size: 13px; }
.peek-out .scroll { margin-top: 6px; max-height: 200px; }
.wait { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.q-src { margin: 14px 0 0; font-size: 12px; color: var(--ink-2); }
.q-src a { color: var(--rubric); }
.q-src:empty { display: none; }

/* the Watch's ready-made orders */
.q-examples { display: grid; gap: 6px; margin: 0 0 12px; }
.q-examples[hidden] { display: none; }
.ex-h { margin: 0; font: 700 11px/1.2 Silkscreen, sans-serif; text-transform: uppercase; color: var(--ink-2); }
.ex { display: grid; gap: 2px; text-align: left; border: 0; cursor: pointer; padding: 7px 10px; background: rgba(214, 194, 143, 0.45); color: var(--ink); font: 600 14px/1.2 "Pixelify Sans", sans-serif; }
.ex code { white-space: normal; background: none; padding: 0; color: var(--ink-2); font-size: 12px; }
.ex:hover { background: rgba(214, 194, 143, 0.85); }

/* the right leaf: slate, verdict, result */
.slate-label { font: 700 11px/1.2 Silkscreen, sans-serif; text-transform: uppercase; color: var(--ink-2); padding-bottom: 6px; border-bottom: 1px solid rgba(91, 70, 51, 0.35); padding-right: 40px; }
.slate {
  position: relative; min-height: 0;
  background: linear-gradient(var(--slate-2), var(--slate));
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(242, 193, 78, 0.18);
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
}
.slate-hl, .slate-in {
  position: absolute; inset: 0; margin: 0; border: 0;
  padding: 12px 14px;
  font: 400 14px/1.6 var(--mono); letter-spacing: 0; tab-size: 2;
  white-space: pre; overflow: auto; word-wrap: normal;
}
.slate-hl { color: #e9e4fb; pointer-events: none; overflow: hidden; }
.slate-in { background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--gold); resize: none; outline: none; scrollbar-color: #4a4680 transparent; }
.slate-in::selection { background: rgba(242, 193, 78, 0.32); }
.slate:focus-within { box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 2px var(--gold); }
.slate-hl i { font-style: normal; }
.t-k { color: #f2c14e; font-weight: 600; }
.t-f { color: #f0a46a; }
.t-s { color: #b5d07a; }
.t-n { color: #94c9ee; }
.t-c { color: #8c88b5; font-style: italic !important; }
.slate-bar { display: flex; align-items: center; gap: 10px; }
.run-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border: 0; cursor: pointer;
  font: 600 16px/1 "Pixelify Sans", system-ui, sans-serif;
  background: var(--gold); color: var(--gold-ink);
  box-shadow: inset 0 -3px 0 var(--gold-deep), inset 0 2px 0 #ffe7a3;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: transform 0.12s ease-out, background-color 0.12s ease-out;
}
.run-btn svg { fill: currentColor; stroke: none; }
.run-btn:hover:not(:disabled) { background: #ffd56b; transform: translateY(-1px); }
.run-btn:active { transform: translateY(1px); }
.run-btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.keys { font: 700 11px/1 Silkscreen, sans-serif; color: var(--ink-2); text-transform: uppercase; }
.slate-bar .ink-quiet { margin-left: auto; }

.verdict { min-height: 1.5em; font-size: 15px; line-height: 1.4; color: var(--ink); display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.verdict b { font-weight: 600; }
.verdict.bad b { color: var(--rubric); }
.verdict.good { color: var(--leaf-green); }
.verdict.good b { color: var(--leaf-green); }
.verdict.quiet { color: var(--ink-2); }
.verdict .order { padding: 7px 12px; font-size: 15px; }
.tick { width: 7px; height: 12px; margin: 0 4px 0 2px; border: solid currentColor; border-width: 0 3px 3px 0; transform: rotate(40deg) translateY(-2px); flex: none; }
.verdict.quiet .tick { color: var(--leaf-green); }
.quill { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink-2); border-top-color: transparent; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); outline: none; }
.result:empty { display: none; }
.result-empty { margin: 0; align-self: start; padding: 14px 12px; color: var(--ink-2); font-size: 14px; box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.25); background: repeating-linear-gradient(0deg, rgba(91, 70, 51, 0.07) 0 1px, transparent 1px 24px); min-height: 120px; }
.result:focus-visible { outline: 2px solid var(--rubric); }
.count { margin: 0 0 4px; font: 700 11px/1.2 Silkscreen, sans-serif; text-transform: uppercase; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.scroll { overflow: auto; min-height: 0; max-height: 100%; box-shadow: inset 0 0 0 1px rgba(91, 70, 51, 0.3); background: rgba(255, 250, 235, 0.35); }
.page table { border-collapse: collapse; width: max-content; min-width: 100%; font: 400 13px/1.35 var(--mono); font-variant-numeric: tabular-nums; }
.page th { position: sticky; top: 0; z-index: 1; text-align: left; padding: 5px 10px; background: var(--parch-2); color: var(--rubric); font-weight: 600; border-bottom: 1px solid var(--ink-2); white-space: nowrap; }
.page td { padding: 3px 10px; border-bottom: 1px solid rgba(91, 70, 51, 0.15); white-space: nowrap; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; }
.page tr:nth-child(even) td { background: rgba(214, 194, 143, 0.22); }
.page th.r, .page td.r { text-align: right; }
.page td .null { color: var(--ink-2); opacity: 0.7; }
.page td.empty { color: var(--ink-2); font-style: italic; }
.page td.mk { background: rgba(242, 193, 78, 0.55) !important; font-weight: 600; }
.page table.small { font-size: 12px; }
.leaf-foot { display: flex; justify-content: space-between; gap: 8px; padding-top: 6px; border-top: 1px solid rgba(91, 70, 51, 0.35); }
.leaf-foot[hidden] { display: none; }
.leaf-foot .nudge:not(:disabled) { color: var(--rubric); box-shadow: inset 0 0 0 2px var(--rubric); }

.tome-x {
  position: absolute; top: 14px; right: 16px; z-index: 3;
  width: 34px; height: 34px; border: 0; cursor: pointer; display: grid; place-items: center;
  color: var(--ink-2); background: transparent;
}
.tome-x svg { width: 18px; height: 18px; }
.tome-x:hover { color: var(--rubric); background: rgba(154, 42, 28, 0.1); }
.tome-x:focus-visible { outline: 2px solid var(--rubric); }

/* the wax seal for a right answer */
.seal {
  position: absolute; z-index: 40; left: 84%; top: 68%;
  width: 124px; height: 124px; margin: -62px 0 0 -62px;
  display: grid; place-content: center; text-align: center; pointer-events: none;
  background: radial-gradient(circle at 38% 34%, #c8412f, #8e1d16 62%, #6b1410);
  clip-path: polygon(50% 0, 61% 4%, 72% 3%, 80% 11%, 90% 15%, 93% 27%, 100% 38%, 97% 50%, 100% 62%, 93% 73%, 90% 85%, 79% 89%, 70% 97%, 58% 96%, 48% 100%, 38% 95%, 27% 97%, 18% 89%, 9% 84%, 7% 72%, 0 61%, 3% 49%, 0 37%, 7% 27%, 11% 15%, 21% 10%, 30% 3%, 40% 4%);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
  transform: rotate(-9deg);
}
.seal[hidden] { display: none; }
.seal::before { content: ""; position: absolute; inset: 16px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 210, 190, 0.28), inset 0 2px 3px rgba(0, 0, 0, 0.35); }
.seal-n { font: 400 50px/0.9 "Jacquard 24", serif; color: #ffdccc; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.18); }
.seal-w { font: 700 11px/1 Silkscreen, sans-serif; text-transform: uppercase; color: #f6c4b4; margin-top: 2px; }
.seal.on { animation: seal 1.9s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes seal {
  0% { opacity: 0; transform: rotate(-24deg) scale(1.9); filter: blur(4px) drop-shadow(0 24px 20px rgba(0, 0, 0, 0.3)); }
  16% { opacity: 1; transform: rotate(-9deg) scale(1); filter: blur(0) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45)); }
  80% { opacity: 1; transform: rotate(-9deg) scale(1); }
  100% { opacity: 0; transform: rotate(-9deg) scale(0.96); }
}

.tome.busy .slate { box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(242, 193, 78, 0.55); }

/* short screens (phones on their side): the book fills the screen, both leaves scroll */
@media (max-height: 560px) {
  .tome { padding: 4px; }
  .book { height: calc(100vh - 8px); height: calc(100dvh - 8px); padding: 6px; }
  .page-l { padding: 12px 20px 8px 16px; }
  .page-r { padding: 12px 16px 8px 20px; gap: 6px; grid-template-rows: auto minmax(90px, 0.9fr) auto auto minmax(0, 1fr) auto; }
  .q-title { font-size: 28px; margin-top: 8px; }
  .page { font-size: 14px; }
  .q-task #tqAsk { font-size: 15px; }
  .pip { width: 22px; height: 22px; }
  .tomes { gap: 2px; margin-bottom: 7px; }
  .tome-tab { min-width: 0; height: 20px; padding: 0 4px; font-size: 8px; flex: 1 1 0; }
  .slate-hl, .slate-in { font-size: 13px; padding: 8px 10px; }
  .run-btn { padding: 7px 12px; font-size: 14px; }
}
/* upright phones: one leaf above the other, the whole book scrolls */
@media (max-width: 760px) {
  .tome { overflow-y: auto; place-items: start center; }
  .book { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; background: linear-gradient(var(--leather), var(--leather-2)); }
  .page-l .run-head { padding-right: 34px; }
  .page-l, .page-r { overflow: visible; box-shadow: none; }
  .page-l { grid-template-rows: auto auto auto auto; padding: 16px 16px 10px; }
  .page-l .tomes { padding-right: 34px; }
  .leaf { overflow: visible; }
  .page-r { grid-template-rows: auto 190px auto auto auto auto; padding: 10px 16px 14px; border-top: 2px dashed rgba(91, 70, 51, 0.35); }
  .result .scroll { max-height: 300px; }
  .keys { display: none; }
  .seal { left: 50%; top: 60%; }
}
#stage.portrait:has(> .tome:not([hidden])) .rotate { display: none; }
@media (prefers-reduced-motion: reduce) {
  .tome.in, .tome.in .page-l, .tome.in .page-r { animation: none; }
  .seal.on { animation: seal-calm 1.9s linear both; }
  @keyframes seal-calm { 0%, 90% { opacity: 1; } 100% { opacity: 0; } }
}

/* Pixelify Sans joins f and i into a shape that reads as an A; keep every letter apart */
*, *::before, *::after { font-variant-ligatures: none !important; }
@media (pointer: coarse) { .keys { display: none; } }

/* the book's close mark stays out of the mute button's corner wherever the book reaches the top right of the screen
   (phones, tablets, small windows; 2026-10-11 bug test, as in Pyrefall: a tap on the X muted the sound and the book
   stayed open) */
@media (max-width: 1260px) and (max-height: 850px), (max-width: 760px) {
  .tome-x { right: 64px; }
  #qzCard .run-head { padding-right: 52px; }   /* the dawn quiz's count keeps clear of the mute button */
}
@media (max-width: 760px) { .page-l .tomes { padding-right: 82px; } }   /* the tome tabs keep clear of the moved X */

/* vm-mute room (2026-10-04): the site-wide mute button from /assets/menu.js sits in the top right corner. */
#hud{right:calc(60px + env(safe-area-inset-right))}
