/* ============================================================
   Bell's Library — by candlelight
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Candlelit overrides on top of design system tokens */
  --candle-flame:   #ffb866;
  --candle-core:    #ffe4b0;
  --candle-glow:    #ff8a2a;
  --candle-deep:    #c4540a;
  --night:          #07050a;
  --night-warm:     #0d0906;
  --paper:          #f3e9d6;
  --paper-warm:     #ead9bc;
  --ink:            #2b1d10;
  --ink-soft:       #5a4632;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--fg-inverse);
  cursor: none;
}

/* ============================================================
   STAGE
   ============================================================ */
.stage {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 110%, #1a0e07 0%, #07050a 40%, #050308 100%);
  overflow: hidden;
}

/* Wood-textured backdrop (only visible where candle lights it) */
.wall {
  position: absolute;
  inset: 0;
  background:
    /* horizontal plank seams */
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 119px,
      rgba(0, 0, 0, 0.5) 119px,
      rgba(0, 0, 0, 0.5) 121px,
      transparent 121px,
      transparent 240px
    ),
    /* warm vertical grain streaks */
    repeating-linear-gradient(
      90deg,
      rgba(120, 62, 28, 0.0) 0px,
      rgba(120, 62, 28, 0.22) 2px,
      rgba(78, 38, 16, 0.0) 6px,
      rgba(120, 62, 28, 0.12) 11px
    ),
    /* rich mahogany base */
    linear-gradient(180deg, #5a3318 0%, #4a2912 48%, #331a0c 100%);
  filter: saturate(1.05);
}

/* ============================================================
   BOOKCASE — a proper 3-shelf cabinet (2.5D depth)
   ============================================================ */
.bookcase {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  padding: 0;
  /* Back wall — deep mahogany, warmer than before */
  background:
    repeating-linear-gradient(
      90deg,
      rgba(120, 62, 28, 0.0) 0px,
      rgba(120, 62, 28, 0.20) 2px,
      rgba(70, 34, 14, 0.0) 6px,
      rgba(120, 62, 28, 0.10) 11px
    ),
    linear-gradient(180deg, #2e1a0d 0%, #23120a 100%);
  border-left:  0;
  border-right: 0;
  border-top:    0;
  border-bottom: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Bookshelf used to be a full-viewport flex; inside .bookcase it's just a row */
.bookshelf {
  position: static;
  inset: auto;
  padding: 0;
  gap: 0;
  flex-direction: row;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.shelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 0 6px;
}
.shelf-books   { height: auto; gap: 4px; }

/* Faint category label, sits above the books, only really visible in candlelight */
.shelf-label {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(220, 195, 160, 0.5);
  white-space: nowrap;
  pointer-events: none;
}

/* The wooden shelf board below each row */
.shelf::after {
  content: "";
  position: absolute;
  left: -3vw;
  right: -3vw;
  bottom: -16px;
  height: 16px;
  background:
    linear-gradient(180deg, #7a4a24 0%, #5a3015 45%, #3a1d0c 100%);
  box-shadow:
    0 3px 0 rgba(0,0,0,0.7),
    0 6px 14px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255, 180, 110, 0.08);
  z-index: 3;
}

/* faint top-of-shelf shadow */
.shelf::before {
  content: "";
  position: absolute;
  left: -3vw;
  right: -3vw;
  top: -10px;
  height: 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), transparent);
  pointer-events: none;
  z-index: 2;
}

/* ============================================================
   PROPS — keepsakes on the top & bottom shelves
   ============================================================ */
.prop {
  display: block;
  object-fit: contain;
  object-position: 50% 100%;
  /* Candlelight-responsive: dim by default, brightens when the candle is near.
     Shadow direction is set from candle.js based on candle position. */
  filter:
    brightness(calc(0.45 + var(--prop-light, 0) * 0.78))
    saturate(calc(0.7 + var(--prop-light, 0) * 0.35))
    drop-shadow(
      var(--shadow-x, 0px) var(--shadow-y, 6px)
      calc(8px + var(--prop-light, 0) * 8px)
      rgba(0, 0, 0, calc(0.42 + var(--prop-light, 0) * 0.28))
    );
  /* Soft elliptical mask so any remaining background bleeds into the dark */
  -webkit-mask-image: radial-gradient(ellipse 55% 58% at 50% 55%, black 65%, transparent 100%);
          mask-image: radial-gradient(ellipse 55% 58% at 50% 55%, black 65%, transparent 100%);
  flex-shrink: 0;
  transition: filter 90ms linear;
  cursor: none;
}
.prop:hover {
  transform: translateY(-3px);
  transition: transform 250ms ease, filter 90ms linear;
}
.prop-pigeon { width: 200px; height: 220px; }
.prop-lego   { width: 150px; height: 240px;
  -webkit-mask-image: radial-gradient(ellipse 42% 52% at 50% 52%, black 70%, transparent 100%);
          mask-image: radial-gradient(ellipse 42% 52% at 50% 52%, black 70%, transparent 100%);
}
.prop-car    { width: 400px; height: 220px;
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 50% 60%, black 70%, transparent 100%);
          mask-image: radial-gradient(ellipse 60% 55% at 50% 60%, black 70%, transparent 100%);
}

/* ============================================================
   BOOK SPINE
   ============================================================ */
.book {
  position: relative;
  height: 420px;
  width: 76px;
  border-radius: 1px 1px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: none;
  transform-origin: bottom center;
  transition: transform 250ms cubic-bezier(0.2, 0.7, 0.2, 1),
              filter 200ms ease;
  flex-shrink: 0;
  /* subtle base shadow between books */
  box-shadow:
    inset -1px 0 0 rgba(0,0,0,0.4),
    inset 1px 0 0 rgba(255,255,255,0.05),
    inset 0 -10px 14px rgba(0,0,0,0.35),
    inset 0 6px 10px rgba(255,255,255,0.08);
}

/* The spine's vertical title text */
.book .title-rail {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 90%;
  padding: 22px 0;
  color: var(--book-ink, rgba(245, 232, 210, 0.85));
  text-shadow: 0 1px 0 rgba(0,0,0,0.3);
}
/* Latin titles: rotate the whole word so head is at top (read by tilting head left) */
.book .title-rail.latin {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
/* CJK titles: characters stay upright, stack top-to-bottom (no rotation) */
.book .title-rail.cjk {
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 0.06em;
  font-size: 14px;
}

/* Two-tone label panel that floats on the spine */
.book.two-tone::before {
  content: "";
  position: absolute;
  left: 4px; right: 4px;
  top: 30%; height: 40%;
  background: var(--book-panel, rgba(0,0,0,0.25));
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(0,0,0,0.4);
}

/* Gilded line at top */
.book.gilded::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  top: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d9b16a, transparent);
}

/* Slight lean for some books */
.book.lean-left  { transform: rotate(-2.2deg); height: 400px; }
.book.lean-right { transform: rotate(2.0deg); height: 406px; }
.book.short      { height: 380px; }
.book.tall       { height: 448px; }

.book:hover {
  transform: translateY(-6px);
  filter: brightness(1.15);
}
.book.lean-left:hover  { transform: rotate(-2.2deg) translateY(-6px); }
.book.lean-right:hover { transform: rotate(2.0deg) translateY(-6px); }

/* ============================================================
   CANVAS LIGHTING LAYER
   ============================================================ */
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* ============================================================
   CURSOR CANDLESTICK
   The flame tip is at SVG (70, -4) within a 140x200 viewBox rendered 100x143.
   We position so the flame tip lands at the cursor:
     translate(x - flameOffsetX, y - flameOffsetY)
   where flameOffsetX = 100 * (70/140) = 50
         flameOffsetY = 143 * (-4/200) ≈ -2.86
   The candle body and saucer therefore hang BELOW the cursor.
*/
#cursor-candle {
  position: fixed;
  top: 0;
  left: 0;
  width: 100px;
  height: 143px;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transition: opacity 700ms ease;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
  will-change: transform;
}
#cursor-candle.lit {
  opacity: 1;
}

.cursor-flame {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: cursor-flame-flicker 240ms ease-in-out infinite;
}
@keyframes cursor-flame-flicker {
  0%, 100% { transform: scale(1, 1)        translate(0px, 0); }
  20%      { transform: scale(0.95, 1.05)  translate(-0.3px, -0.8px); }
  40%      { transform: scale(1.06, 0.96)  translate(0.4px, 0.6px); }
  60%      { transform: scale(0.97, 1.04)  translate(-0.4px, -0.4px); }
  80%      { transform: scale(1.03, 0.98)  translate(0.2px, 0.2px); }
}

/* Slow lateral sway separate from the fast flicker */
@keyframes cursor-flame-sway {
  0%, 100% { translate: 0 0; }
  33%      { translate: -1px -0.5px; }
  66%      { translate: 1px 0.5px; }
}
#cursor-candle .cursor-flame {
  animation: cursor-flame-flicker 240ms ease-in-out infinite,
             cursor-flame-sway 2400ms ease-in-out infinite;
}

/* ============================================================
   AMBIENT TEXT (faint corner mark, doesn't fight with the shelf)
   ============================================================ */
.ambient-text {
  position: absolute;
  top: 28px;
  left: 36px;
  z-index: 1;
  pointer-events: none;
  color: rgba(255, 220, 170, 0.42);
  text-align: left;
}
.ambient-text .name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.05;
  white-space: nowrap;
}
.ambient-text .tag {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: none;
  white-space: nowrap;
  margin-top: 6px;
  opacity: 0.65;
}

/* ============================================================
   OPENING ANIMATION (hand lights a candle)
   ============================================================ */
#intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #050308;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: none;
}

#intro.gone {
  opacity: 0;
  transition: opacity 900ms ease;
  pointer-events: none;
}

.intro-scene {
  position: relative;
  width: 320px;
  height: 460px;
}

.intro-title {
  position: absolute;
  top: 318px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  color: rgba(255, 220, 170, 0.0);
  transition: color 1200ms ease 600ms;
  font-family: var(--font-serif);
}
.intro-title.in { color: rgba(255, 220, 170, 0.85); }
.intro-title .name {
  font-family: var(--font-display);
  font-style: normal;
  font-size: 40px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(255, 226, 182, 0.92);
}
.intro-title .hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: rgba(255, 226, 182, 0.92);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  margin-top: 16px;
  opacity: 0.9;
}

/* ============================================================
   READING MODE
   ============================================================ */
#reader {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--paper);
  background-image:
    radial-gradient(ellipse at 50% 50%, rgba(255, 240, 210, 0.6), transparent 70%),
    radial-gradient(circle at 20% 10%, rgba(120, 80, 30, 0.08), transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(120, 80, 30, 0.06), transparent 60%);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8vh 6vw;
  cursor: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 700ms ease;
  overflow-y: auto;
}
#reader.open {
  opacity: 1;
  pointer-events: auto;
}
#reader::before {
  /* paper grain */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-radial-gradient(circle at 30% 20%, rgba(60,30,10,0.025) 0, rgba(60,30,10,0.025) 1px, transparent 1px, transparent 3px),
    repeating-radial-gradient(circle at 70% 80%, rgba(60,30,10,0.02) 0, rgba(60,30,10,0.02) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: multiply;
  opacity: 0.5;
  pointer-events: none;
}

.reader-inner {
  position: relative;
  max-width: 880px;
  width: 100%;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 64px;
  align-items: center;
}

/* ====================================================
   BOOK COVER (typographic mockup — no asset images)
   Rotated 3D-ish like a real paperback standing slightly tilted.
   ==================================================== */
.reader-cover {
  position: relative;
  width: 240px;
  height: 348px;
  border-radius: 2px 4px 4px 2px;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 22px;
  color: rgba(245, 232, 210, 0.95);
  font-family: var(--font-serif);
  transform: perspective(1200px) rotateY(-8deg) rotate(-1.5deg);
  transform-origin: left center;
  box-shadow:
    /* left-side "spine" shadow */
    inset 8px 0 12px rgba(0,0,0,0.32),
    inset 14px 0 0 rgba(0,0,0,0.18),
    /* paper edge sliver */
    inset -2px 0 0 rgba(255, 248, 230, 0.95),
    inset -3px 0 0 rgba(180, 160, 120, 0.6),
    /* shadow under the book */
    0 18px 30px rgba(60, 30, 10, 0.22),
    0 30px 60px rgba(60, 30, 10, 0.12);
}
/* Decorative inner frame */
.reader-cover::before {
  content: "";
  position: absolute;
  inset: 14px 14px 14px 26px;
  border: 1px solid rgba(255,255,255,0.18);
  pointer-events: none;
}
/* Gilded line under the title */
.reader-cover::after {
  content: "";
  position: absolute;
  left: 36px;
  right: 24px;
  bottom: 70px;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor 25%, currentColor 75%, transparent);
  opacity: 0.55;
}
.reader-cover .cv-eyebrow {
  font-family: var(--font-sans);
  font-size: 9.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: auto;
  padding-left: 12px;
}
.reader-cover .cv-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.01em;
  padding-left: 12px;
  padding-right: 4px;
  text-wrap: balance;
  margin-top: 24px;
  margin-bottom: 20px;
}
.reader-cover .cv-title.cjk {
  letter-spacing: 0.05em;
  line-height: 1.25;
  font-size: 26px;
}
.reader-cover .cv-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.35;
  opacity: 0.78;
  padding-left: 12px;
  padding-right: 6px;
  margin-bottom: 28px;
  max-height: 56px;
  overflow: hidden;
}
.reader-cover .cv-author {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.92;
  padding-left: 12px;
  margin-top: auto;
}
.reader-cover .cv-mark {
  position: absolute;
  bottom: 22px;
  right: 22px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.6;
  font-family: var(--font-serif);
  font-size: 10px;
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ====================================================
   REAL BOOK COVER — photo on a 3D-tilted frame
   ==================================================== */
.reader-cover-frame {
  position: relative;
  width: 240px;
  height: auto;                 /* hug the cover's real aspect ratio */
  border-radius: 2px 4px 4px 2px;
  transform: perspective(1400px) rotateY(-5deg) rotate(-1deg);
  transform-origin: center center;
  box-shadow:
    /* page edge sliver (right side) */
    3px 0 0 rgba(255, 248, 230, 0.95),
    4px 0 0 rgba(180, 160, 120, 0.55),
    /* under-book shadow */
    0 18px 30px rgba(60, 30, 10, 0.22),
    0 30px 60px rgba(60, 30, 10, 0.14);
}
.reader-cover-img {
  width: 100%;
  height: auto;
  display: block;
}
/* Subtle gloss on the cover */
.reader-cover-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgba(255,255,255,0.10) 0%,
    rgba(255,255,255,0.02) 28%,
    rgba(255,255,255,0) 50%,
    rgba(0,0,0,0.06) 100%
  );
  pointer-events: none;
}
/* Inner spine shadow on left edge */
.reader-cover-frame::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 18px;
  background: linear-gradient(90deg, rgba(0,0,0,0.32), rgba(0,0,0,0));
  pointer-events: none;
  z-index: 2;
}

.reader-content {
  padding-right: 24px;
}
.reader-content .eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.75;
}
.reader-content h1 {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-top: 14px;
  color: var(--ink);
}
.reader-content .subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: 10px;
  max-width: 38ch;
}
.reader-content .eyebrow .rating {
  color: var(--candle-deep);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.reader-content .tags {
  margin-top: 32px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.reader-content .tag {
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--ink-soft);
  background: rgba(196, 84, 10, 0.08);
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.reader-content .by {
  font-family: var(--font-sans);
  font-size: 14px;
  margin-top: 14px;
  color: var(--ink-soft);
}
.reader-content .meta {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-soft);
  opacity: 0.7;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.reader-content blockquote {
  margin: 32px 0 24px;
  padding-left: 22px;
  border-left: 2px solid var(--candle-deep);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink);
}
.reader-content blockquote cite {
  display: block;
  margin-top: 12px;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.75;
}
.reader-content .note {
  margin-top: 28px;
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink);
  max-width: 56ch;
}
.reader-content .note p {
  margin-bottom: 14px;
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink);
}
.reader-content .note p:last-child {
  margin-bottom: 0;
}
.reader-content .note-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.7;
  margin-bottom: 10px;
}

.reader-close {
  position: absolute;
  top: 28px;
  right: 32px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(243, 233, 214, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(60, 30, 10, 0.18);
  padding: 9px 14px;
  border-radius: 2px;
  cursor: pointer;
  opacity: 0.75;
  transition: all 200ms ease;
  z-index: 5;
}
.reader-close:hover {
  opacity: 1;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ============================================================
   MUSIC TOGGLE
   ============================================================ */
#music-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 210;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 210, 140, 0.22);
  background: rgba(28, 18, 10, 0.55);
  backdrop-filter: blur(4px);
  color: rgba(255, 214, 150, 0.78);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 220ms ease, color 220ms ease, border-color 220ms ease;
}
#music-toggle:hover {
  opacity: 1;
  color: var(--candle-flame, #ffb866);
  border-color: rgba(255, 210, 140, 0.5);
}
/* The diagonal slash shows only when muted */
#music-toggle .muteslash { opacity: 0; transition: opacity 200ms ease; }
#music-toggle.muted .note { opacity: 0.45; }
#music-toggle.muted .muteslash { opacity: 1; }

/* ============================================================
   TWEAK PANEL (later)
   ============================================================ */

/* ============================================================
   MOBILE / TOUCH ADAPTATIONS
   ============================================================ */
@media (max-width: 768px) {
  /* ---- Two rows of five on phones — bigger, readable books ----
     Flexbox wraps the 10 books into 2 rows that always fit the screen. */
  .stage { overflow: hidden; }
  .bookcase {
    width: 100vw !important;
    max-width: 100vw !important;
    height: auto !important;
    padding: 0 10px !important;
    transform: translate(-50%, -50%) !important;  /* JS scaling disabled in script */
  }
  .bookshelf {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    column-gap: 2px;
    row-gap: 30px;
  }
  .book {
    flex: 1 1 17% !important;
    min-width: 0 !important;
    max-width: 19% !important;
    width: auto !important;
    height: 42vw !important;        /* uniform height for a clean row */
  }
  /* neutralise the px height variations so each row stays even */
  .book.lean-left,
  .book.lean-right,
  .book.short,
  .book.tall { height: 42vw !important; }
  .book.lean-left  { transform: rotate(-1.5deg); }
  .book.lean-right { transform: rotate(1.5deg); }

  .book .title-rail {
    font-size: 3vw;
    padding: 10px 0;
  }

  /* Wooden shelf board between the two rows (so each row rests on a plank) */
  .bookshelf { position: relative; z-index: 1; }
  .bookcase::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 42vw;                 /* directly under the top row (row height = 42vw) */
    height: 15px;
    background: linear-gradient(180deg, #7a4a24 0%, #5a3015 45%, #3a1d0c 100%);
    box-shadow:
      0 3px 0 rgba(0,0,0,0.7),
      0 6px 14px rgba(0,0,0,0.45),
      inset 0 1px 0 rgba(255, 180, 110, 0.08);
    z-index: 0;
    pointer-events: none;
  }

  /* Ambient corner mark — tighter on small screens */
  .ambient-text {
    top: 14px;
    left: 16px;
  }
  .ambient-text .name { font-size: 18px; }
  .ambient-text .tag  { font-size: 11px; letter-spacing: 0.04em; }

  /* Smaller cursor candlestick — finger isn't precise anyway */
  #cursor-candle {
    width: 78px;
    height: 112px;
  }

  /* Intro animation: scale down so the whole match-+-candle scene fits */
  .intro-scene {
    transform: scale(0.7);
    transform-origin: center center;
  }
  .intro-title .name { font-size: 34px; }
  .intro-title .hint { font-size: 10px; letter-spacing: 0.2em; }

  /* Reader: stack cover above content, single column */
  #reader {
    padding: 28px 18px;
    align-items: flex-start;
  }
  .reader-inner {
    grid-template-columns: 1fr;
    gap: 22px;
    max-width: 100%;
    padding-top: 48px;        /* room above for the close button */
  }
  .reader-cover-frame {
    width: 180px;
    height: auto;
    margin: 0 auto;
    transform: rotate(-0.6deg);   /* flat 2D on mobile — iOS Safari can drop 3D layers */
    -webkit-transform: rotate(-0.6deg);
  }
  .reader-cover-img {
    width: 180px;
    height: auto;
    display: block;
  }
  .reader-content {
    padding-right: 0;
  }
  .reader-content h1 {
    font-size: 28px;
  }
  .reader-content .subtitle {
    font-size: 16px;
    max-width: 100%;
  }
  .reader-content .eyebrow {
    font-size: 10px;
    letter-spacing: 0.2em;
  }
  .reader-content .by {
    font-size: 13px;
  }
  .reader-content blockquote {
    font-size: 16px;
    padding-left: 16px;
    margin: 22px 0 14px;
  }
  .reader-content blockquote cite {
    font-size: 10px;
    letter-spacing: 0.14em;
  }
  .reader-content .note {
    margin-top: 22px;
    max-width: 100%;
  }
  .reader-content .note p {
    font-size: 15px;
    line-height: 1.65;
  }
  .reader-close {
    top: 12px;
    right: 12px;
    padding: 7px 11px;
    font-size: 9.5px;
    letter-spacing: 0.16em;
  }
}

/* On any touch-primary device, the SVG candlestick is decorative.
   The native cursor is already hidden via body { cursor: none }. */
@media (hover: none) and (pointer: coarse) {
  html, body { cursor: auto; }
}

/* Short viewports handled by JS fit-scaling (see index.html) */
