
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: radial-gradient(ellipse at 50% 38%, #45403a 0%, #2e2a26 55%, #1d1a17 100%);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
#flipbook { position: relative; }
#flipbook.open { box-shadow: 0 22px 60px rgba(0,0,0,.55), 0 4px 14px rgba(0,0,0,.4); }

/* ---------- hard covers ---------- */
.cover {
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255,255,255,.09), rgba(255,255,255,0) 55%),
    linear-gradient(135deg, #142e56 0%, #24487f 46%, #142e56 100%);
  box-shadow: inset 0 0 40px rgba(0,0,0,.35);
}
.cover-front::before, .cover-back::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 12%;
  pointer-events: none; z-index: 2;
}
.cover-front::before { left: 0;  background: linear-gradient(to right, rgba(0,0,0,.5), rgba(0,0,0,.14) 55%, rgba(0,0,0,0)); }
.cover-back::before  { right: 0; background: linear-gradient(to left,  rgba(0,0,0,.5), rgba(0,0,0,.14) 55%, rgba(0,0,0,0)); }
.cover-inner { position: absolute; inset: 0; }
.cover-frame {
  position: absolute; inset: 7%;
  border: 3px double #c9a84c; border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: #e7c96f;
  font-family: Georgia, 'Palatino Linotype', serif;
  padding: 0 6%;
}
.cover-title {
  font-variant: small-caps; letter-spacing: .1em;
  font-size: 2em; line-height: 1.25;
  text-shadow: 0 2px 3px rgba(0,0,0,.55);
}
.cover-orn { color: #b89a4e; font-size: 1.5em; margin-top: 1.1em; }
.cover-orn.big { font-size: 2.4em; }
.cover-sub { letter-spacing: .5em; font-size: .68em; margin-top: 1em; color: #cdb069; text-indent: .5em; }
.cover-author { margin-top: 2.4em; font-variant: small-caps; letter-spacing: .18em; font-size: 1.02em; color: #e2c26a; }

/* ---------- endpapers ---------- */
.endpaper {
  background:
    repeating-linear-gradient(45deg, rgba(120,96,58,.05) 0 3px, rgba(0,0,0,0) 3px 6px),
    linear-gradient(#e8dfc8, #dcd2b6);
  box-shadow: inset 0 0 55px rgba(96,74,40,.25);
}

/* ---------- paper pages ---------- */
.paper {
  background:
    radial-gradient(ellipse at 50% 45%, #faf5e9 55%, #f1e8d4 92%, #eadfc7 100%);
  color: #33291f;
}
/* inner spine shadow — the fold between the two pages of a spread */
.pg-right::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 9%;
  background: linear-gradient(to right, rgba(62,44,16,.30), rgba(62,44,16,.10) 52%, rgba(62,44,16,0));
  pointer-events: none; z-index: 3;
}
.pg-left::before {
  content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 9%;
  background: linear-gradient(to left, rgba(62,44,16,.26), rgba(62,44,16,.09) 52%, rgba(62,44,16,0));
  pointer-events: none; z-index: 3;
}
.pg-single::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 6%;
  background: linear-gradient(to right, rgba(62,44,16,.18), rgba(62,44,16,0));
  pointer-events: none; z-index: 3;
}
/* outer edge — hint of the closed page stack */
.pg-right::after, .pg-left::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 7px;
  pointer-events: none; z-index: 3; opacity: .5;
}
.pg-right::after { right: 0; background: repeating-linear-gradient(to left, rgba(90,70,40,.16) 0 1px, rgba(0,0,0,0) 1px 3px); }
.pg-left::after  { left: 0;  background: repeating-linear-gradient(to right, rgba(90,70,40,.16) 0 1px, rgba(0,0,0,0) 1px 3px); }

/* ---------- text ---------- */
.textenv {
  font-family: Georgia, 'Palatino Linotype', 'Book Antiqua', 'Times New Roman', serif;
  line-height: 1.55; text-align: justify;
  hyphens: auto; -webkit-hyphens: auto; -ms-hyphens: auto;
  text-rendering: optimizeLegibility;
  color: #33291f;
}
.textenv p { margin: 0; text-indent: 1.5em; }
.textenv p.noind { text-indent: 0; }
.chead { margin-bottom: 1.25em; }
.cnum {
  text-align: center; font-variant: small-caps;
  letter-spacing: .24em; font-size: 1.26em;
  padding-top: 1em; text-indent: .24em; color: #4a3b28;
}
.corn { text-align: center; color: #8a744a; margin-top: .4em; font-size: 1em; }
.brk { text-align: center; margin: 1.1em 0; color: #8a744a; font-size: .78em; letter-spacing: .5em; text-indent: .5em; }
.theend { text-align: center; margin-top: 2.6em; letter-spacing: .4em; text-indent: .4em; font-size: 1.02em; color: #5a4a33; }
.folio { text-align: center; font-size: .66em; letter-spacing: .18em; color: #8d7b5f; font-family: Georgia, serif; }

/* ---------- title page ---------- */
.titlepage {
  position: absolute; inset: 10% 12%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-family: Georgia, 'Palatino Linotype', serif; color: #3d3020;
}
.tp-title { font-variant: small-caps; font-size: 1.85em; letter-spacing: .1em; line-height: 1.3; }
.tp-rule { width: 42%; height: 1px; background: #a08c5a; margin: 1.4em 0; }
.tp-sub { letter-spacing: .45em; font-size: .72em; color: #6a583c; text-indent: .45em; }
.tp-by { margin-top: 2.2em; font-style: italic; font-size: .85em; color: #6a583c; }
.tp-author { margin-top: .5em; font-variant: small-caps; letter-spacing: .16em; font-size: 1.12em; }
.tp-orn { margin-top: 2.2em; color: #8a744a; font-size: 1.3em; }

/* ---------- chrome ---------- */
.nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  z-index: 60; cursor: pointer;
  font: 46px/1 Georgia, serif; color: rgba(255,255,255,.30);
  padding: 26px 14px; transition: color .2s;
}
.nav:hover { color: rgba(255,255,255,.75); }
#nav-prev { left: 4px; }
#nav-next { right: 4px; }

#hint {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%);
  z-index: 60; font: 12.5px/1.4 Georgia, serif; letter-spacing: .06em;
  color: rgba(255,255,255,.45); background: rgba(0,0,0,.25);
  padding: 6px 14px; border-radius: 20px; white-space: nowrap;
  transition: opacity 1.2s; pointer-events: none;
}
#hint.gone { opacity: 0; }

#loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(24,21,18,.82);
  font: 15px Georgia, serif; letter-spacing: .08em; color: #d8c9a6;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
#loader.show { opacity: 1; pointer-events: auto; }
#loader .spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(216,201,166,.25); border-top-color: #d8c9a6;
  animation: lspin .9s linear infinite;
}
@keyframes lspin { to { transform: rotate(360deg); } }

/* ---------- embossed cover tooling ---------- */
.cover-inner::before {
  content: ''; position: absolute; inset: 2.2%;
  pointer-events: none; opacity: .9;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='28'%20height='28'%3E%20%3Cg%20fill='none'%20stroke-width='1.4'%3E%20%3Cg%20transform='translate(0.9,0.9)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.6,-0.6)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='28'%20height='28'%3E%20%3Cg%20fill='none'%20stroke-width='1.4'%3E%20%3Cg%20transform='translate(0.9,0.9)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.6,-0.6)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='28'%20height='28'%3E%20%3Cg%20fill='none'%20stroke-width='1.4'%3E%20%3Cg%20transform='translate(0.9,0.9)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.6,-0.6)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='28'%20height='28'%3E%20%3Cg%20fill='none'%20stroke-width='1.4'%3E%20%3Cg%20transform='translate(0.9,0.9)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.6,-0.6)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Cpath%20d='M14%206%20L22%2014%20L14%2022%20L6%2014%20Z'/%3E%3Ccircle%20cx='14'%20cy='14'%20r='1.8'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E");
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-position: left top, left bottom, left top, right top;
  background-size: 28px 28px;
}
.cover-inner::after {
  content: ''; position: absolute; inset: 1.4%;
  pointer-events: none; opacity: .95;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='56'%20height='56'%3E%20%3Cg%20fill='none'%20stroke-width='1.5'%3E%20%3Cg%20transform='translate(1,1)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.7,-0.7)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='56'%20height='56'%3E%20%3Cg%20fill='none'%20stroke-width='1.5'%3E%20%3Cg%20transform='translate(1,1)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.7,-0.7)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='56'%20height='56'%3E%20%3Cg%20fill='none'%20stroke-width='1.5'%3E%20%3Cg%20transform='translate(1,1)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.7,-0.7)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='56'%20height='56'%3E%20%3Cg%20fill='none'%20stroke-width='1.5'%3E%20%3Cg%20transform='translate(1,1)'%20stroke='rgba(0,0,0,0.50)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.7,-0.7)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Ccircle%20cx='28'%20cy='28'%20r='16'/%3E%3Ccircle%20cx='28'%20cy='28'%20r='9'/%3E%20%3Cpath%20d='M28%2012%20Q31%2020%2028%2024%20Q25%2020%2028%2012%20Z%20M28%2044%20Q31%2036%2028%2032%20Q25%2036%2028%2044%20Z%20M12%2028%20Q20%2031%2024%2028%20Q20%2025%2012%2028%20Z%20M44%2028%20Q36%2031%2032%2028%20Q36%2025%2044%2028%20Z'/%3E%20%3C/g%3E%20%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left top, right top, left bottom, right bottom;
  background-size: 52px 52px;
}

/* ---------- illustration captions & display lines ---------- */
.illus {
  margin: 1.15em 5%; padding: .5em 3%;
  text-align: center; font-style: italic;
  font-size: .84em; line-height: 1.45; color: #6b5a3e;
  border-top: 1px solid rgba(122,100,60,.4);
  border-bottom: 1px solid rgba(122,100,60,.4);
}
.disp {
  text-align: center; margin: 1em 8%;
  font-variant: small-caps; letter-spacing: .12em;
  font-size: .95em; color: #4a3b28;
}

/* ---- The Haunted House: midnight binding, animated gilt title ---- */
.cover {
  background:
    radial-gradient(ellipse at 30% 22%, rgba(180,160,220,.10), rgba(0,0,0,0) 55%),
    linear-gradient(135deg, #151022 0%, #2a2140 46%, #151022 100%);
  box-shadow: inset 0 0 46px rgba(0,0,0,.5);
}
.cover-frame { border-color: #9c8a58; color: #d9c88f; overflow: hidden; }
.cover-orn { color: #8d7c4e; } .cover-sub { color: #af9e6d; } .cover-author { color: #d3c184; }
.endpaper {
  background:
    repeating-linear-gradient(45deg, rgba(90,70,110,.05) 0 3px, rgba(0,0,0,0) 3px 6px),
    linear-gradient(#ddd3d8, #cec2c8);
  box-shadow: inset 0 0 55px rgba(60,40,70,.28);
}
.cover-front .cover-title {
  display: flex; flex-direction: column; line-height: 1.1;
  animation: hh-glow 7s ease-in-out infinite;
}
.t-the { font-size: .4em; letter-spacing: .62em; text-indent: .62em; color: #b7a468; margin-bottom: .7em; }
.t-word { display: block; letter-spacing: .06em; }
.cover-front .cover-title i {
  font-style: normal; display: inline-block;
  background: linear-gradient(105deg, #8f7c46 25%, #e8d28f 40%, #fff7d6 50%, #e8d28f 60%, #8f7c46 75%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: hh-shimmer 5.5s linear infinite, hh-float 6s ease-in-out infinite;
  animation-delay: calc(var(--d) * .22s), calc(var(--d) * -.7s);
}
@keyframes hh-shimmer { 0% { background-position: 140% 0; } 100% { background-position: -140% 0; } }
@keyframes hh-float { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-.055em) rotate(.5deg); } }
@keyframes hh-glow {
  0%,100% { filter: drop-shadow(0 0 5px rgba(220,200,140,.10)); }
  50% { filter: drop-shadow(0 0 13px rgba(225,250,200,.30)); }
}
.cover-front .cover-frame::before {
  content: ''; position: absolute; top: 11%; left: 20%; width: 60%; height: 34%;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(200,255,215,.15), rgba(200,255,215,0) 68%);
  filter: blur(4px);
  animation: hh-ghost 11s ease-in-out infinite alternate;
}
@keyframes hh-ghost {
  0% { transform: translate(-9%,-2%) scale(.95); opacity: .45; }
  45% { opacity: .95; }
  100% { transform: translate(9%,7%) scale(1.12); opacity: .55; }
}
.cover-front .cover-frame::after {
  content: ''; position: absolute; left: 50%; bottom: 5.5%;
  width: 36%; height: 23%; transform: translateX(-50%);
  background: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20140%2090'%3E%20%3Cg%20fill='none'%20stroke-width='2'%3E%20%3Cg%20transform='translate(1,1)'%20stroke='rgba(0,0,0,0.55)'%3E%20%3Cpath%20d='M12%2080%20H128%20M22%2080%20V52%20L38%2034%20L54%2052%20V80%20M58%2080%20V40%20H74%20V80%20M56%2040%20L66%2027%20L76%2040%20M78%2080%20V52%20L94%2034%20L110%2052%20V80'/%3E%20%3Cpath%20d='M30%2040%20v-9%20h5%20v7%20M100%2042%20v-10%20h5%20v8%20M32%2060%20h10%20v11%20h-10%20z%20M62%2048%20h8%20v8%20h-8%20z%20M62%2066%20h8%20v14%20h-8%20M94%2060%20h10%20v11%20h-10%20z'/%3E%20%3Ccircle%20cx='124'%20cy='16'%20r='6'/%3E%20%3C/g%3E%20%3Cg%20transform='translate(-0.7,-0.7)'%20stroke='rgba(255,255,255,0.13)'%3E%20%3Cpath%20d='M12%2080%20H128%20M22%2080%20V52%20L38%2034%20L54%2052%20V80%20M58%2080%20V40%20H74%20V80%20M56%2040%20L66%2027%20L76%2040%20M78%2080%20V52%20L94%2034%20L110%2052%20V80'/%3E%20%3Cpath%20d='M30%2040%20v-9%20h5%20v7%20M100%2042%20v-10%20h5%20v8%20M32%2060%20h10%20v11%20h-10%20z%20M62%2048%20h8%20v8%20h-8%20z%20M62%2066%20h8%20v14%20h-8%20M94%2060%20h10%20v11%20h-10%20z'/%3E%20%3Ccircle%20cx='124'%20cy='16'%20r='6'/%3E%20%3C/g%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  opacity: .95; pointer-events: none;
}

