.fortune-book-of-fortune {
  --book-ink: #163b33;
  --book-border: #c7ded2;
  --book-gold: #fff0b5;
  padding: clamp(12px, 2vw, 24px);
  border: 1px solid var(--book-border);
  border-radius: 16px;
  background: #fbfffd;
  color: var(--book-ink);
  font-size: 16px;
}
.fortune-book-of-fortune [hidden] { display: none !important; }
.fortune-book-of-fortune :focus-visible,
.book-reading :focus-visible { outline: 3px solid #266c95; outline-offset: 3px; }
.fortune-book-of-fortune :is(button, select, summary) {
  min-height: 44px;
  box-sizing: border-box;
  font: inherit;
}
.fortune-book-of-fortune :is(button, summary) { cursor: pointer; }
.fortune-book-of-fortune button:disabled { cursor: default; }
#book-question {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 12px;
  margin-bottom: 12px;
}
#book-question select { width: 100%; min-width: 0; }
#book-guide { grid-column: 2; margin: 0; line-height: 1.5; }
#book-form #stage { min-height: 0; }
.book-board {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 180px;
  padding: 16px 12px;
  overflow: hidden;
  border: 1px solid #345f56;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 0%, #24574d, #143932 70%);
  color: #f4fbf7;
  isolation: isolate;
}
.book-table {
  display: flex;
  gap: clamp(12px, 3vw, 24px);
  align-items: center;
  justify-content: center;
}
#book-cover { width: clamp(58px, 14vw, 78px); height: auto; object-fit: contain; }
.book-dice {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 3vw, 22px);
  perspective: 500px;
}
.book-die {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  box-sizing: border-box;
  width: clamp(43px, 12vw, 61px);
  aspect-ratio: 1;
  padding: clamp(6px, 1.8vw, 11px);
  border: 1px solid #dfcc9d;
  border-radius: 15%;
  background: #fffbeb;
  box-shadow: inset 0 -4px #ddc89c, 0 3px 8px #071f1a;
}
.book-die i {
  place-self: center;
  width: clamp(5px, 1.4vw, 8px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #24483f;
}
.book-dice.is-rolling .book-die { animation: book-toss .72s both ease-in-out; }
.book-dice.is-rolling .book-die:nth-child(2) { animation-direction: reverse; }
.book-dice.is-rolling .book-die:nth-child(3) { animation-timing-function: ease-out; }
@keyframes book-toss {
  0% { transform: translateY(0) rotateX(0) rotateZ(0); }
  22% { transform: translateY(-16px) rotateX(150deg) rotateZ(-15deg); }
  47% { transform: translateY(2px) rotateX(275deg) rotateZ(16deg); }
  69% { transform: translateY(-9px) rotateX(323deg) rotateZ(-7deg); }
  100% { transform: translateY(0) rotateX(360deg) rotateZ(0); }
}
#book-progress { margin: 10px 0 0; text-align: center; }
.book-rivers { width: min(100%, 40rem); }
.book-rivers svg { display: block; width: 100%; height: clamp(32px, 8vw, 66px); }
.book-current { fill: none; stroke: #75aaa9; stroke-width: 4px; opacity: .65; pointer-events: none; }
.book-current-active { stroke: #ffdd8a; opacity: 1; stroke-width: 6px; pointer-events: stroke; cursor: pointer; }
.book-river-trigger {
  display: block;
  min-width: min(100%, 9rem);
  max-width: 100%;
  margin: 0 auto;
  padding: .46rem 1rem;
  border: 1px solid #ecd68a;
  border-radius: 8px;
  background: var(--book-gold);
  color: #372a10;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.book-river-trigger:hover { background: #fff8d7; }
.book-river-trigger:focus-visible { outline-color: white; }
.book-opening .book-board::after {
  position: absolute;
  inset: 10% 5% 10% 50%;
  content: '';
  border: 1px solid #d5c99e;
  border-radius: 3px 10px 10px 3px;
  background: linear-gradient(90deg, #cab989, #fff9de 18%, #fffaf0);
  transform-origin: left center;
  animation: book-open .43s ease-in-out both;
  pointer-events: none;
}
@keyframes book-open {
  0% { opacity: 0; transform: perspective(550px) rotateY(-6deg); }
  35% { opacity: .95; }
  100% { opacity: .9; transform: perspective(550px) rotateY(-178deg); }
}
.book-controls {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.book-sound summary, .book-reading-details summary { align-content: center; }
.book-sound > div {
  display: grid;
  grid-template-columns: auto minmax(5rem, 8rem);
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}
.book-sound input[type=range] { width: 100%; min-height: 44px; }
.book-sound label:nth-of-type(2) { min-height: 44px; align-content: center; }
.book-sound label:nth-of-type(2), .book-sound p { grid-column: 1 / -1; }
.fortune-book-of-fortune :is(#book-error, #book-progress, #journal-note, #fortune-audio-notice):empty { display: none; }
#book-error { color: #932e28; }
.book-reading {
  padding: clamp(12px, 2vw, 22px);
  border: 1px solid #d5c99e;
  border-radius: 12px;
  background: #fffaf0;
  color: #352816;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.book-reading-question { margin: 0 0 3px; }
.book-reading .book-poem-heading { margin: 0; font-size: 1.25rem; }
.book-cast-result {
  margin: 4px 0 0;
  color: #5b431c;
  font-variant-numeric: tabular-nums;
}
.book-poem-kind { margin: 4px 0 0; color: #5b431c; font-size: .95rem; }
.book-poem {
  margin: 8px 0 0;
  padding: 8px 0 8px 14px;
  border: 0;
  border-inline-start: 3px solid #a88942;
  font-size: 1.125rem;
}
.book-poem p { margin: 0 0 4px; }
.book-poem p:last-child { margin-bottom: 0; }
.book-reading-details { margin-top: 8px; }
.book-reading-details summary { min-height: 44px; cursor: pointer; }
.book-reading-details dl { margin: 4px 0 0; }
.book-reading-details dl > div {
  display: grid;
  grid-template-columns: minmax(5rem, 8rem) minmax(0, 1fr);
  gap: 8px;
  padding-block: 5px;
  border-top: 1px solid #e0d5b6;
}
.book-reading-details dt { font-weight: 650; }
.book-reading-details dd { margin: 0; }
@media (max-height: 500px) and (orientation: landscape) {
  .book-board { min-height: 120px; padding-block: 10px; }
  .book-die { width: 44px; }
  .book-rivers svg { height: 26px; }
  #book-progress { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .book-dice.is-rolling .book-die { animation: none; }
  .book-opening .book-board::after { content: none; }
}

.fortune-frame[data-book-of-fortune-reading] {
  height: auto !important;
  min-height: 0;
  overflow: visible;
}
.fortune-frame[data-book-of-fortune-reading] > :is(#fortune-canvas, #canvas-access, #fortune-state) {
  display: none;
}
.book-of-fortune-journal-detail {
  min-width: 0;
}
.book-of-fortune-journal-detail > button {
  min-height: 44px;
}
.book-of-fortune-journal-detail > :is(h2, .date) {
  margin-block: 6px;
}
