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

body {
  background: linear-gradient(180deg, #d8cdc0 0%, #c9bcaa 45%, #b8a898 100%);
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
}

.page-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 1rem 1.5rem;
  background: transparent;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header a {
  color: #000;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  transition: background 0.2s, border-color 0.2s;
}

.page-header a:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.5);
}

.book-counter {
  color: #000;
  font-size: 0.95rem;
  font-style: italic;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.08));
}

/* ----- Modal (from reading tool) ----- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 35, 30, 0.6);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: #faf9f7;
  border-radius: 12px;
  width: 90vw;
  max-width: 880px;
  height: 85vh;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #2c2a26;
  z-index: 2;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
}

.modal-body {
  display: flex;
  align-items: stretch;
  gap: 1.5rem;
  padding: 1.5rem;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.modal-cover {
  flex-shrink: 0;
  width: fit-content;
  margin: 0 1.5rem;
  align-self: center;
}

.modal-cover img {
  display: block;
  max-width: 280px;
  max-height: 75vh;
  width: auto;
  height: auto;
  border-radius: 3px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    inset 0 8px 14px -6px rgba(0, 0, 0, 0.2),
    inset 0 -8px 14px -6px rgba(0, 0, 0, 0.2),
    2px 0 8px rgba(0, 0, 0, 0.2),
    0 4px 12px rgba(40, 30, 20, 0.2),
    0 10px 28px rgba(0, 0, 0, 0.18);
}

.modal-cover .book-placeholder {
  width: 200px;
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  text-align: center;
  background: linear-gradient(145deg, #403830 0%, #2c2520 100%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.75rem;
  border-radius: 3px;
  box-shadow:
    0 4px 12px rgba(40, 30, 20, 0.2),
    0 10px 28px rgba(0, 0, 0, 0.18);
}

.modal-details {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 2rem;
  -webkit-overflow-scrolling: touch;
}

.modal-details .modal-title {
  font-size: 1.35rem;
  margin: 1.25rem 0 0.35rem;
  line-height: 1.3;
  color: #2c2a26;
}

.modal-author {
  font-size: 1rem;
  color: #5a554d;
  margin: 0 0 0.5rem;
}

.modal-meta {
  font-size: 0.85rem;
  color: #5a554d;
  margin: 0 0 0.75rem;
}

.modal-genres {
  font-size: 0.85rem;
  color: #5a554d;
  margin: 0 0 0.75rem;
}

.modal-rating-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.modal-rating {
  margin: 0;
}

.modal-rating-info {
  cursor: help;
  font-size: 0.7rem;
  color: #5a554d;
  opacity: 0.7;
}

.modal-rating-info:hover {
  opacity: 1;
}

.modal-rating-info-wrap {
  position: relative;
  display: inline-flex;
}

.modal-rating-info-wrap .modal-rating-info {
  cursor: pointer;
}

.modal-rating-popover {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.9rem;
  background: #2c2a26;
  color: #faf9f7;
  font-size: 0.8rem;
  line-height: 1.45;
  border-radius: 6px;
  width: max-content;
  max-width: 320px;
  min-width: 260px;
  white-space: normal;
  display: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-rating-info-wrap:hover .modal-rating-popover,
.modal-rating-info-wrap.is-open .modal-rating-popover {
  display: block;
}

.modal-rating-stars {
  display: inline-block;
  position: relative;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
}

.modal-rating-stars .stars-bg {
  color: #c9c4b8;
}

.modal-rating-stars .stars-fill {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  color: #b8860b;
  white-space: nowrap;
}

.modal-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a554d;
  margin: 1.25rem 0 0.5rem;
}

.modal-section-label:first-of-type {
  margin-top: 0;
}

.modal-review {
  font-size: 0.9rem;
  color: #2c2a26;
  font-style: italic;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.modal-description {
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
  color: #2c2a26;
  line-height: 1.5;
  white-space: pre-wrap;
}
