.booksort-game {
  --bs-paper: #f4e7c6;
  --bs-ink: #293f43;
  --bs-teal: #3c645f;
  --bs-gold: #efc77d;
  --bs-wood: #ba9360;
  color: var(--bs-ink);
  font-family: Georgia, "Times New Roman", serif;
}
.bs-shell { position: relative; width: min(100%, 1120px); margin: 0 auto; padding: 12px 16px 10px; border: 3px solid var(--bs-wood); background: var(--bs-paper); box-shadow: inset 0 0 0 2px #fff5dc, 0 4px 0 #806244; }
.bs-heading, .bs-toolbar, .bs-readouts, .bs-actions { display: flex; align-items: center; gap: 10px; }
.bs-heading, .bs-toolbar { justify-content: space-between; }
.bs-heading h2 { margin: 2px 0 0; color: var(--bs-ink); font: 700 clamp(1.35rem, 2.5vw, 1.8rem)/1.1 Georgia, serif; }
.bs-kicker { margin: 0; color: var(--bs-teal); font: 700 .7rem/1.2 system-ui, sans-serif; letter-spacing: .12em; }
.bs-memory { margin: 4px auto 0; color: #6e5c3d; font: .76rem/1.3 system-ui, sans-serif; text-align: center; }
.bs-instructions { max-width: 900px; margin: 8px auto; color: #425b58; font: .9rem/1.4 system-ui, sans-serif; text-align: center; }
.bs-toolbar { flex-wrap: wrap; margin-top: 8px; padding: 7px 8px; border-block: 2px dashed #c6ad7d; color: #395854; font: .85rem/1.3 system-ui, sans-serif; }
.bs-readouts { flex-wrap: wrap; }
.bs-readouts span { white-space: nowrap; }
.bs-actions { justify-content: flex-end; }
.bs-actions button, .bs-dialog button, .bs-dialog select { min-height: 40px; padding: 6px 10px; border: 2px solid var(--bs-teal); border-radius: 3px; background: #fff3d5; color: var(--bs-ink); font: 700 .84rem/1.2 system-ui, sans-serif; cursor: pointer; }
.bs-actions button:hover:not(:disabled), .bs-actions button:focus-visible, .bs-dialog button:hover, .bs-dialog button:focus-visible, .bs-dialog select:focus-visible { outline: 3px solid #bf7a38; outline-offset: 2px; background: #f7dda5; }
.bs-actions button:disabled { cursor: default; opacity: .62; }
.bs-rewards { min-height: 1.3em; margin: 6px 0 0; color: #68522f; text-align: center; font: 700 .8rem/1.3 system-ui, sans-serif; text-transform: capitalize; }
.bs-board { --bs-columns: 7; display: grid; grid-template-columns: repeat(var(--bs-columns), minmax(0, 1fr)); align-items: end; gap: clamp(5px, 1vw, 12px); width: min(100%, 1020px); margin: 12px auto 4px; padding: 14px 10px 10px; border: 4px solid #806244; border-radius: 5px; background: linear-gradient(#d7bd8d, #b99462); box-shadow: inset 0 0 0 2px #f8e6bd, 0 4px 0 #806244; }
.bs-board:has(> .bs-stack:nth-child(5):last-child) { --bs-columns: 5; }
.bs-stack { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; min-height: 210px; padding: 0 2px 5px; border: 0; border-bottom: 8px solid #765738; border-radius: 0; background: transparent; color: var(--bs-ink); box-shadow: none; cursor: pointer; }
.bs-stack-label, .bs-stack-foot { max-width: 100%; overflow: hidden; color: #405551; font: 700 clamp(.62rem, .9vw, .78rem)/1.2 system-ui, sans-serif; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.bs-books { display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start; width: 100%; min-height: 168px; margin: 4px 0 3px; }
.bs-book { display: flex; align-items: center; justify-content: space-between; width: min(100%, 100px); height: clamp(34px, 4.8vh, 46px); flex: 0 0 auto; margin-top: -1px; padding: 1px 6px; border: 2px solid #634d34; border-radius: 4px 7px 4px 3px; color: #213c3f; box-shadow: inset 5px 0 0 #fff6de88, 0 2px 0 #765738; font: 700 clamp(.9rem, 1.55vw, 1.25rem)/1 Georgia, serif; }
.bs-book span { text-shadow: 0 1px #fff8df; }
.bs-book i { font: 700 .55rem/1 system-ui, sans-serif; opacity: .7; }
.bs-family-a { background: repeating-linear-gradient(0deg, #e8c26b 0 8px, #f4d990 8px 11px); }
.bs-family-b { background: repeating-linear-gradient(135deg, #a5c39a 0 8px, #c8d9b8 8px 11px); }
.bs-family-c { background: repeating-linear-gradient(90deg, #9ebec0 0 8px, #c1d8d8 8px 11px); }
.bs-family-d { background: repeating-linear-gradient(45deg, #d69b91 0 8px, #edbdb0 8px 11px); }
.bs-family-e { background: repeating-linear-gradient(0deg, #b8a5c7 0 8px, #d7c7e0 8px 11px); }
.bs-pattern-moon { border-left-width: 7px; }
.bs-pattern-leaf { border-left-style: double; }
.bs-pattern-star { border-left-width: 5px; border-right-width: 5px; }
.bs-pattern-heart { border-radius: 9px 3px 9px 3px; }
.bs-pattern-flower { border-style: dashed; }
.bs-empty-mark { display: grid; place-items: center; width: clamp(34px, 4.8vh, 46px); aspect-ratio: 1; margin: auto 0; border: 2px dashed #806244; border-radius: 4px; color: #806244; font: 700 1.2rem/1 system-ui, sans-serif; }
.bs-stack.is-destination { border-bottom-color: #9c5f1e; background: #ffdf9766; }
.bs-stack.is-destination .bs-stack-label { color: #75420d; }
.bs-stack.is-selected { outline: 4px solid #b66e20; outline-offset: 2px; background-color: #f9df9c88; }
.bs-stack:hover:not(:disabled) { filter: none; background-color: #f4e7c6; color: var(--bs-ink); }
.bs-stack:focus-visible { outline: 4px solid #263e43; outline-offset: 4px; z-index: 1; }
.bs-stack:disabled { cursor: default; opacity: 1; }
.bs-status { min-height: 1.5em; margin: 4px 0 0; color: #395854; text-align: center; font: 700 .95rem/1.4 system-ui, sans-serif; }
.bs-status.is-success { color: #2e6a4c; }
.bs-help { margin: 5px auto 0; color: #526660; font: .78rem/1.35 system-ui, sans-serif; text-align: center; }
.bs-dialog { width: min(calc(100% - 28px), 430px); padding: 18px; border: 3px solid var(--bs-wood); border-radius: 5px; background: var(--bs-paper); color: var(--bs-ink); box-shadow: 0 8px 24px #18262666; }
.bs-dialog::backdrop { background: #293f4377; }
.bs-dialog h3 { margin: 0 0 8px; font: 700 1.2rem/1.2 Georgia, serif; }
.bs-dialog p { color: var(--bs-ink); font: .9rem/1.4 system-ui, sans-serif; }
.bs-dialog label { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 8px; margin: 10px 0; font: 700 .88rem/1.3 system-ui, sans-serif; }
.bs-dialog-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
@media (max-width: 900px) {
  .bs-shell { padding-inline: 12px; }
  .bs-board { gap: 5px; padding: 10px 5px 7px; }
  .bs-stack { min-height: 190px; }
  .bs-books { min-height: 150px; }
  .bs-book { width: min(100%, 84px); padding-inline: 3px; }
}
@media (max-width: 760px) {
  .bs-board { --bs-columns: 4; }
  .bs-stack { min-height: 180px; }
  .bs-books { min-height: 144px; }
  .bs-book { width: min(100%, 98px); height: clamp(31px, 6vh, 42px); }
}
@media (max-width: 560px) {
  .bs-shell { padding: 9px 10px; }
  .bs-heading, .bs-toolbar { align-items: flex-start; flex-direction: column; }
  .bs-memory { text-align: left; }
  .bs-actions { flex-wrap: wrap; justify-content: flex-start; }
  .bs-board { --bs-columns: 3; gap: 5px; padding-inline: 4px; }
  .bs-stack { min-height: 172px; }
  .bs-books { min-height: 136px; }
  .bs-book { width: min(100%, 96px); height: 31px; }
}
@media (max-height: 760px) {
  .bs-shell { padding-block: 5px 4px; }
  .bs-instructions { margin: 4px auto; font-size: .82rem; }
  .bs-toolbar { margin-top: 3px; padding-block: 4px; }
  .bs-board { margin-block: 6px 2px; padding-block: 6px 4px; }
  .bs-stack { min-height: 160px; }
  .bs-books { min-height: 124px; margin-block: 2px; }
  .bs-book { height: clamp(27px, 4.5vh, 34px); }
  .bs-empty-mark { width: 30px; }
  .bs-status { margin-top: 2px; }
  .bs-help { margin-top: 2px; }
}
@media (prefers-reduced-motion: reduce) { .booksort-game *, .booksort-game *::before, .booksort-game *::after { scroll-behavior: auto; transition: none; animation: none; } }
