:root {
  color-scheme: light;
  --paper: #f6f0e3;
  --ink: #23382e;
  --muted: #526359;
  --pine: #20382e;
  --marigold: #f3b95b;
  --line: #d7cebb;
  font-family: system-ui, sans-serif;
  font-size: 16px;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .wordmark { font-family: Georgia, serif; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button:not(:disabled), summary { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #a4561b; outline-offset: 4px; }
.top { background: var(--pine); color: var(--paper); border-bottom: 4px solid #d59a47; }
.wrap { width: min(1180px, 100% - 56px); margin-inline: auto; }
.header-inner { min-height: 66px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.wordmark, .shelf-link { text-decoration: none; color: inherit; }
.wordmark { font-weight: 700; font-size: clamp(1.15rem, 3vw, 1.52rem); display: inline-flex; align-items: center; gap: 10px; }
.brand-icon { background: var(--marigold); color: var(--pine); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.shelf-link { font-size: .9rem; padding: 8px 0; border-bottom: 1px solid #94a694; }
main { padding-block: 36px 48px; }
.shelf-hero { display: grid; grid-template-columns: 1fr 1.02fr; min-height: 450px; background: var(--pine); color: var(--paper); overflow: hidden; border-radius: 22px; box-shadow: 0 12px 32px #332c1b26; }
.hero-content { padding: clamp(32px, 5vw, 68px); align-self: center; }
.hero-content h1 { font-size: clamp(3.2rem, 7.2vw, 6.7rem); line-height: .88; letter-spacing: -.065em; }
.hero-content h1 span { color: var(--marigold); }
.hero-content p { max-width: 32ch; line-height: 1.55; margin-top: 26px; color: #eee7d3; font-size: 1.08rem; }
.hero-art { min-height: 260px; background: #866144 url("library.webp") center center / cover no-repeat; }
.hero-actions, .match-tools, .dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.hero-actions { margin-top: 28px; }
.primary, .secondary, .ghost { border-radius: 8px; min-height: 45px; padding: 10px 15px; font-weight: 700; border: 1px solid transparent; }
.primary { background: var(--marigold); color: #292516; border-color: #e1a447; }
.primary:hover { background: #ffce78; }
.secondary { background: #faf6eb; border-color: #aca994; }
.secondary:hover { background: #eee7d6; }
.ghost { color: inherit; background: transparent; border-color: #a3a58c; }
.ghost:hover { background: #ffffff12; }
.up-next { margin-top: 37px; }
.up-next h2, .board h2 { font-size: 1.8rem; letter-spacing: -.03em; }
.game-shelf { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 15px; }
.game-shelf article { padding: 14px; display: flex; align-items: center; gap: 14px; background: #fffaf0; border: 1px solid var(--line); border-radius: 12px; }
.game-shelf h3 { font-size: 1.2rem; }
.game-shelf p, .planned, .match-top p { font-size: .9rem; color: var(--muted); margin-top: 5px; }
.planned { margin-top: 13px; }
.box-mark { flex: 0 0 65px; height: 64px; display: flex; gap: 2px; align-items: center; justify-content: center; border-radius: 7px; font: bold 1.85rem Georgia, serif; color: #fff3dc; box-shadow: inset 0 0 0 4px #ffffff20; }
.workshop { background: #894936; }
.bingo { background: #46685b; }
.bingo span { border-radius: 50%; background: #f3d39b; color: #253b30; padding: .24rem; font-size: .85rem; }
.rack { background: #4b4f71; }
.rack span { background: #fff0cc; border-radius: 2px; color: #42324a; padding: .3rem .1rem; font-size: .85rem; }
.match-top { display: flex; gap: 12px; align-items: end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.match-top h1 { font-size: clamp(2rem, 5vw, 3.65rem); line-height: .98; letter-spacing: -.04em; }
.scoreboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.score { background: #fffaf1; border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 5px; font-weight: 700; }
.score strong { font: bold 1.5rem Georgia, serif; }
.score.active { background: #e2eadc; border-color: #719477; box-shadow: inset 3px 0 #4c7156; }
.backpack { display: grid; align-content: start; gap: 5px; text-align: left; }
.backpack:hover { border-color: #719477; background: #e8ebdd; }
.backpack-header, .bag-preview { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bag-preview { justify-content: start; min-height: 30px; }
.bag-icon { width: 35px; height: 25px; flex: 0 0 35px; background: #9d503c; border: 1px solid #66392a; border-radius: 10px 10px 5px 5px; position: relative; margin-top: 4px; }
.backpack + .backpack .bag-icon { background: #3d6172; border-color: #344b61; }
.bag-icon::before { content: ""; position: absolute; inset: -5px 11px auto; height: 5px; border: 1px solid #673e2c; border-radius: 3px 3px 0 0; }
.bag-icon::after { content: ""; position: absolute; inset: auto 4px 3px; height: 7px; border: 1px solid #ffe2a8b0; border-radius: 2px; }
.spines { position: absolute; inset: 2px 3px auto; display: flex; gap: 1px; justify-content: center; }
.spines i { width: 3px; min-width: 0; height: 8px; border-radius: 1px; background: var(--book); box-shadow: inset 0 1px #ffebbc; }
.pin-preview { font-size: .9rem; color: var(--muted); }
.bag-contents { padding: 0; list-style: none; margin: 14px 0 0; display: grid; gap: 6px; }
.bag-contents li { display: grid; align-items: center; grid-template-columns: 31px 1fr auto; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.book-token { background: var(--book); color: #ffdc9e; display: grid; place-items: center; height: 35px; border-radius: 2px 5px 5px 2px; }
.pin-token { padding: 5px 7px; background: #efe7d2; border-radius: 14px; font-size: .87rem; }
.turn { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 90px; background: var(--pine); color: var(--paper); padding: 15px 18px; border-radius: 11px; margin-block: 13px 18px; }
.turn-controls { flex: 1; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.wheel { position: relative; width: clamp(76px, 13vw, 105px); aspect-ratio: 1; flex: none; }
.wheel-disc { position: absolute; inset: 0; border-radius: 50%; border: 3px solid #f8dfad; background: conic-gradient(from -60deg, #f5c168 0deg 120deg, #9ac5ad 120deg 240deg, #e69983 240deg); transform: rotate(var(--wheel-angle)); }
.wheel-disc::after { content: ""; position: absolute; inset: 42%; border-radius: 50%; background: var(--pine); border: 2px solid #fff2ce; }
.wheel-disc span { position: absolute; transform: translate(-50%, -50%); color: #25352a; font-weight: 850; }
.wheel-disc span:nth-child(1) { left: 50%; top: 21%; }
.wheel-disc span:nth-child(2) { left: 75%; top: 65%; }
.wheel-disc span:nth-child(3) { left: 25%; top: 65%; }
.wheel-pointer { position: absolute; z-index: 1; top: -5px; left: calc(50% - 7px); width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 13px solid #fff5d8; filter: drop-shadow(0 1px 1px #202e24); }
.turn.match { box-shadow: inset 0 0 0 2px var(--marigold); }
.turn h2 { font-size: 1.45rem; }
.turn h2:focus { outline: none; }
.turn p { margin-top: 4px; line-height: 1.45; }
.board { display: grid; grid-template-columns: 1fr 1.1fr; align-items: start; gap: 22px; }
.board h2 { margin-bottom: 10px; }
.cabinet { background: #573c2c; padding: 10px; border-radius: 11px; box-shadow: inset 0 0 0 2px #453125, 0 5px 10px #3d271f20; }
.wing { padding: 6px 8px 8px; border: 2px solid transparent; border-radius: 7px; --drawer: #bd8960; }
.wing-1 { --drawer: #c19358; }
.wing-2 { --drawer: #ad786a; }
.wing.current { background: #392a22; border-color: var(--marigold); }
.wing h3 { color: #fff0d6; font: 700 .88rem system-ui, sans-serif; margin-bottom: 6px; }
.cubby-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cubby { min-height: 64px; display: grid; align-content: center; justify-items: center; gap: 6px; padding: 6px 2px; background: var(--drawer); color: #281d13; border: 2px solid #422e24; border-radius: 5px; box-shadow: inset 0 -3px #422e2455; }
.cubby:not(:disabled) { border-color: #f5cc82; }
.cubby:not(:disabled):hover, .cubby.selected { background: #f1bf76; color: #241a10; }
.cubby.empty { background: #49372d; color: #e6cfb1; }
.cubby-id { font-weight: 800; font-size: .88rem; }
.cubby-icon { font-size: 1.35rem; line-height: 1; }
.revealed { font-size: .78rem; font-weight: 800; line-height: 1.16; }
.books { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.book { min-height: 103px; border: 1px solid #19181140; border-radius: 5px 8px 8px 5px; padding: 8px 5px 9px 9px; box-shadow: inset 4px 0 #0003, inset 0 -3px #f2d5a28f; background: var(--book); color: #fff6dd; display: flex; flex-direction: column; justify-content: center; align-items: center; font-family: Georgia, serif; font-size: .92rem; line-height: 1.1; font-weight: bold; gap: 5px; overflow-wrap: anywhere; }
.book-icon { font: 1.45rem/1 system-ui, sans-serif; color: #ffdc9e; }
.book { position: relative; }
.book.different-genre { filter: saturate(.2); }
.clue-mark { position: absolute; top: 3px; right: 4px; color: #ffdc9e; font: bold .8rem system-ui, sans-serif; }
.book:not(:disabled):hover { filter: brightness(1.14); transform: translateY(-2px); }
.book:disabled, .cubby:disabled { opacity: 1; }
dialog { width: min(500px, 100% - 28px); max-height: 90vh; overflow: auto; background: #fffaf0; color: var(--ink); border: 1px solid #a89979; border-radius: 16px; padding: 24px; box-shadow: 0 16px 60px #0005; }
dialog::backdrop { background: #101f18b3; }
dialog h2 { font-size: 2rem; margin-bottom: 10px; }
dialog p { line-height: 1.5; }
.dialog-actions { margin-top: 18px; }
.rules { padding-left: 24px; margin-bottom: 0; line-height: 1.48; }
.rules li + li { margin-top: 9px; }
.difficulty { display: grid; gap: 8px; margin: 15px 0; }
.difficulty button { display: grid; gap: 4px; text-align: left; padding: 12px; background: #eae9d8; border: 1px solid #b5b29c; border-radius: 8px; }
.difficulty button:hover { background: #e1ead8; border-color: #6b836d; }
.small { color: var(--muted); font-size: .9rem; }
@media (max-width: 820px) {
  .wrap { width: min(1180px, 100% - 32px); }
  main { padding-block: 22px 36px; }
  .shelf-hero { min-height: 360px; }
  .game-shelf article { align-items: flex-start; flex-direction: column; }
  .box-mark { flex-basis: auto; width: 60px; height: 57px; }
  .board { gap: 14px; }
}
@media (max-width: 600px) {
  .shelf-hero, .board { grid-template-columns: 1fr; }
  .hero-content { padding: 30px 22px; }
  .hero-art { min-height: 215px; background-position: center 55%; }
  .game-shelf { grid-template-columns: 1fr; gap: 7px; }
  .game-shelf article { flex-direction: row; align-items: center; padding: 10px; }
  .match-top { align-items: start; }
  .scoreboard { grid-template-columns: 1.25fr 1.25fr .65fr; }
  .score { padding: 8px; font-size: .83rem; }
  .backpack-header { align-items: start; }
  .score strong { font-size: 1.2rem; }
  .book { min-height: 85px; }
  .cubby { min-height: 52px; }
  .turn { min-height: 85px; }
}
@media (prefers-reduced-motion: no-preference) {
  .cubby.selected { animation: lift .24s ease-out; }
  @keyframes lift { from { transform: scale(.94); } to { transform: scale(1); } }
  .wheel-disc.spinning { animation: spin-wheel 1.45s cubic-bezier(.2, .65, .12, 1) both; }
  @keyframes spin-wheel {
    from { transform: rotate(var(--spin-from)); }
    to { transform: rotate(var(--spin-to)); }
  }
}
