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

  body {
    min-height: 100vh;
    background: linear-gradient(180deg, #c4b49a 0%, #b0a080 55%, #8a7050 100%);
    font-family: Georgia, serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px 60px;
  }
  body::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
      repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.018) 3px, rgba(0,0,0,0.018) 4px),
      repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0,0,0,0.018) 3px, rgba(0,0,0,0.018) 4px);
    pointer-events: none;
  }

  .back {
    position: fixed; top: 20px; left: 24px;
    font-size: 12px; letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(60,40,20,0.65);
    text-decoration: none;
    transition: color 0.2s; z-index: 100;
  }
  .back:hover { color: rgba(60,40,20,1); }

  /* ── SHELF ── */
  .shelf-container {
    position: relative;
    width: 1220px;
    height: 662px;
    box-shadow: 4px 8px 40px rgba(0,0,0,0.5);
    border-radius: 3px;
    flex-shrink: 0;
  }

  .shelf-img {
    width: 100%; height: 100%;
    display: block; border-radius: 3px;
  }

  /* ── BOOK SLOT — each cell in the grid ── */
  .book-slot {
    position: absolute;
    z-index: 2;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 2px;
    padding: 0;
  }

  /* ── BOOK SPINE (horizontal — tumbado) ── */
  .book {
    flex: 1;
    border-radius: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    box-shadow:
      0 2px 5px rgba(0,0,0,0.5),
      inset 0 -2px 4px rgba(0,0,0,0.2),
      inset 0 1px 2px rgba(255,255,255,0.06);
  }
  .book:hover {
    filter: brightness(1.18);
    transform: translateY(-5px);
    z-index: 5;
  }
  /* gilt top edge */
  .book::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, #a87820, #e8c050, #a87820);
    opacity: 0.5;
  }

  /* horizontal books */
  .book-h {
    writing-mode: horizontal-tb !important;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 6px;
  }
  .book-h .h-text {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 12px;
    font-style: italic;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    font-family: Georgia, serif;
    padding: 0 4px;
  }
  .book span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 12px;
    font-style: italic;
    color: rgba(255,255,255,0.82);
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    max-height: 90%;
    padding: 2px 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    font-family: Georgia, serif;
  }

  /* ── OVERLAY ── */
  #book-overlay {
    display: none;
    position: fixed; inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: rgba(15,8,2,0);
    transition: background 0.5s ease;
  }
  #book-overlay.open {
    display: flex;
    background: rgba(15,8,2,0.82);
  }
  #book-open {
    position: relative;
    width: min(900px, 95vw);
    height: min(580px, 88vh);
    display: flex;
    opacity: 0;
    transform: scale(0.85) rotateY(-12deg);
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22,1,0.36,1);
    filter: drop-shadow(0 30px 70px rgba(0,0,0,0.75));
  }
  #book-overlay.open #book-open {
    opacity: 1;
    transform: scale(1) rotateY(0deg);
  }
  /* left page */
  .book-left {
    flex: 1;
    background: linear-gradient(90deg, #e8e0ce, #f0ead8);
    border-radius: 6px 0 0 6px;
    padding: 44px 40px 44px 50px;
    position: relative;
    overflow: hidden;
  }
  .book-left::after {
    content: '';
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(
      180deg, transparent, transparent 31px,
      rgba(170,158,136,0.45) 31px, rgba(170,158,136,0.45) 32px
    );
    pointer-events: none;
  }
  .book-left::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 68px;
    width: 1px;
    background: rgba(210,90,80,0.35);
    pointer-events: none;
  }
  .book-left-content {
    position: relative; z-index: 1;
    height: 100%; display: flex; flex-direction: column;
  }
  .book-cover-thumb {
    width: 100%; height: 160px;
    border-radius: 3px; margin-bottom: 22px;
    display: flex; align-items: center; justify-content: center;
    position: relative; flex-shrink: 0;
    box-shadow: 3px 4px 14px rgba(0,0,0,0.4), inset -3px 0 8px rgba(0,0,0,0.2);
  }
  .book-cover-thumb span {
    font-size: 13px; font-style: italic;
    color: rgba(255,255,255,0.85);
    text-align: center; padding: 0 14px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
    font-family: Georgia, serif; line-height: 1.4;
  }
  .book-cover-thumb::after {
    content: '';
    position: absolute;
    top: 5px; bottom: 5px; left: 5px;
    width: 2px;
    background: linear-gradient(180deg, transparent, rgba(240,208,80,0.6), transparent);
  }
  .left-genre { font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: #a09080; margin-bottom: 8px; }
  .left-title { font-size: 20px; color: #2a1e14; font-style: italic; line-height: 1.25; margin-bottom: 6px; }
  .left-author { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: #8a7860; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(170,158,136,0.5); }
  .left-rating { font-size: 17px; letter-spacing: 3px; color: #c8a030; margin-bottom: 12px; }
  .left-date { font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; color: #b0a090; font-style: italic; margin-top: auto; }
  /* spine */
  .book-spine {
    width: 22px; flex-shrink: 0;
    background: linear-gradient(90deg, #0c0604, #1e0e06, #0c0604);
    position: relative; z-index: 3;
    box-shadow: -3px 0 10px rgba(0,0,0,0.5), 3px 0 10px rgba(0,0,0,0.5);
  }
  .book-spine::before {
    content: '';
    position: absolute;
    top: 14px; bottom: 14px; left: 50%;
    width: 1px; border-left: 1px dashed #4a2a10; opacity: 0.6;
  }
  /* right page */
  .book-right {
    flex: 1;
    background: linear-gradient(90deg, #f4efe4, #ede5d2);
    border-radius: 0 6px 6px 0;
    padding: 44px 50px 44px 40px;
    position: relative; overflow: hidden;
  }
  .book-right::after {
    content: '';
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(
      180deg, transparent, transparent 31px,
      rgba(170,158,136,0.45) 31px, rgba(170,158,136,0.45) 32px
    );
    pointer-events: none;
  }
  .book-right-edge {
    position: absolute; top: 5px; right: -10px; bottom: 5px;
    width: 10px;
    background: linear-gradient(90deg, #ddd4be, #c4bcaa);
    border-radius: 0 3px 3px 0;
  }
  .book-right-edge::before {
    content: '';
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(
      180deg, transparent, transparent 5px,
      rgba(0,0,0,0.055) 5px, rgba(0,0,0,0.055) 6px
    );
  }
  .book-right-content {
    position: relative; z-index: 1;
    height: 100%; overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(180,160,120,0.3) transparent;
  }
  .right-label { font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase; color: #a09080; margin-bottom: 16px; }
  .right-review { font-size: 14.5px; line-height: 2.13; color: #3a2e20; font-family: Georgia, serif; }
  /* close */
  #close-btn {
    position: absolute; top: 10px; right: 16px;
    background: none; border: none;
    font-size: 19px; color: rgba(50,35,15,0.38);
    cursor: pointer; z-index: 10;
    transition: color 0.2s, transform 0.2s; line-height: 1;
  }
  #close-btn:hover { color: rgba(50,35,15,0.85); transform: scale(1.2); }