/* Turkey Tracks v57: storybook Boss Books (The Fib Gremlin Files, later The Night Before Test-mas). Fills the whole game area. */
main.incab .bk { --ink: #2a1408; --paper: #fff8e6; --paper2: #f6e7c4; --leather: #6b3410; }
.bk .bkstage { position: relative; flex: 1 1 auto; min-height: max(360px, calc(100svh - var(--hudh, 72px) - 130px)); border-radius: 20px; overflow: hidden; background: #2b1a0e; }
.bk .bkbg { position: absolute; inset: 0; }
.bk .bkbg img { width: 100%; height: 100%; object-fit: cover; opacity: .55; display: block; }
.bk .bkbg img.stand { object-fit: contain; opacity: .18; }
.bk .bkbody { position: absolute; inset: clamp(6px, 1vw, 14px); display: flex; flex-direction: column; gap: clamp(6px, .8vw, 10px); min-height: 0; }

/* cover */
.bk .bkcover { flex: 1 1 0; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 3vw, 48px); padding: clamp(10px, 2vw, 30px);
  background: linear-gradient(90deg, var(--leather), #8a4a1c 48%, #5a2a0c 50%, #8a4a1c 52%, var(--leather)); border-radius: 18px; box-shadow: inset 0 0 0 6px #c98a3a, 0 12px 40px #0008; color: var(--paper); }
.bk .bkcoverart { flex: 0 1 38%; display: flex; justify-content: center; }
.bk .bkcoverimg { width: 100%; max-width: 420px; max-height: 58vh; object-fit: contain; filter: drop-shadow(0 10px 20px #0009); }
.bk .bkcovertext { flex: 1 1 50%; max-width: 640px; }
.bk .bkcovertext h3 { font-size: clamp(26px, 3.4vw, 64px); margin: 4px 0 8px; line-height: 1.05; color: #ffd23f; text-shadow: 0 3px 0 #3a1a06; }
.bk .bkcovertext p { font-size: clamp(16px, 1.35vw, 26px); line-height: 1.35; margin: 0 0 10px; }
.bk .bkboss { display: inline-block; font-weight: 900; letter-spacing: .08em; font-size: clamp(13px, 1.1vw, 20px); background: #e0324b; color: #fff; padding: 4px 12px; border-radius: 999px; margin: 0; }
.bk .bkrules { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; font-size: clamp(15px, 1.2vw, 23px); line-height: 1.3; }
.bk .bkopen { font-size: clamp(18px, 1.6vw, 30px); }
@media (max-width: 700px) { .bk .bkcover { flex-direction: column; justify-content: flex-start; } .bk .bkcoverimg { max-height: 26vh; } }

/* top strip on every page */
.bk .bkbar { flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #000a; color: #fff; border-radius: 14px; padding: 6px 10px; font-weight: 800; font-size: clamp(14px, 1.1vw, 21px); }
.bk .bkprog { flex: 1 1 80px; min-width: 60px; height: 12px; background: #fff3; border-radius: 99px; overflow: hidden; }
.bk .bkprog i { display: block; height: 100%; background: linear-gradient(90deg, #ffd23f, #ff8a1f); border-radius: 99px; }
.bk .bkx2 { background: #ffd23f; color: var(--ink); border-radius: 10px; padding: 2px 10px; font-weight: 900; }
.bk .bkdeep { background: #b06cff; color: #fff; border-radius: 10px; padding: 2px 10px; }
.bk .bkread { margin-left: auto; }

/* the open book: two pages side by side on wide screens, one long page on narrow ones */
.bk .bkpages { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 1fr; gap: 0; overflow: auto; border-radius: 16px;
  background: var(--paper); box-shadow: 0 0 0 5px var(--leather), 0 12px 34px #0009; color: var(--ink); -webkit-overflow-scrolling: touch; }
.bk .bkpg { padding: clamp(10px, 1.6vw, 28px); min-width: 0; }
.bk .bkstory { background: linear-gradient(180deg, var(--paper), var(--paper2)); }
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .bk .bkpages { grid-template-columns: 1fr 1.15fr; overflow: hidden; background: linear-gradient(90deg, var(--paper) 0 calc(46.5% - 10px), #d9c391 46.5%, var(--paper) calc(46.5% + 10px)); }
  .bk .bkpg { overflow: auto; min-height: 0; }
  .bk .bkstory { box-shadow: inset -18px 0 22px -18px #7a5a2a; }
  .bk .bkquest { box-shadow: inset 18px 0 22px -18px #7a5a2a; }
}
.bk .bkpages.turnin { animation: bkturn .55s ease-out; transform-origin: left center; }
@keyframes bkturn { from { transform: perspective(1400px) rotateY(-14deg); opacity: .35; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .bk .bkpages.turnin { animation: bkfade .3s ease-out; } }
@keyframes bkfade { from { opacity: .3; } to { opacity: 1; } }

/* story side */
.bk .bkscene { display: flex; gap: 10px; align-items: flex-start; }
.bk .bkscene p { margin: 0; font-size: clamp(16px, 1.35vw, 26px); line-height: 1.4; }
.bk .bkhero img { width: clamp(52px, 5vw, 96px); height: auto; flex: none; }
.bk .bkfib { display: flex; gap: 10px; align-items: flex-end; margin-top: clamp(10px, 1.4vw, 22px); }
.bk .bkvil img { width: clamp(60px, 6.5vw, 130px); height: auto; flex: none; }
.bk .bkbubble { position: relative; flex: 1; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 14px; font-size: clamp(16px, 1.3vw, 25px); line-height: 1.35; }
.bk .bkbubble::before { content: ''; position: absolute; left: -14px; bottom: 16px; border: 10px solid transparent; border-right-color: var(--ink); border-left: 0; }
.bk .bkbubble b { color: #b0182e; }

/* data tables: text wraps inside every cell */
.bk .bktbl { margin: 12px 0 0; }
.bk .bktbl figcaption { font-weight: 900; font-size: clamp(15px, 1.15vw, 22px); margin-bottom: 4px; }
.bk .bktblwrap { overflow-x: auto; }
.bk .bktbl table { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; font-size: clamp(14px, 1.1vw, 21px); line-height: 1.25; }
.bk .bktbl th, .bk .bktbl td { border: 2px solid var(--ink); padding: 6px 8px; text-align: left; vertical-align: top; overflow-wrap: break-word; word-break: normal; hyphens: none; white-space: normal; }
.bk .bktbl thead th { background: #f0d9a8; }

/* particle model boxes */
.bk .bkpics { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.bk .bkpic { margin: 0; text-align: center; font-weight: 900; font-size: clamp(14px, 1.1vw, 20px); }
.bk .bkbox { position: relative; width: clamp(110px, 10vw, 170px); aspect-ratio: 1; background: #fff; border: 3px solid var(--ink); border-radius: 10px; }
.bk .bkdot { position: absolute; width: 9%; aspect-ratio: 1; margin: -4.5% 0 0 -4.5%; border-radius: 50%; background: #1f6fd1; box-shadow: inset -2px -2px 0 #0004; animation: bkjig 1s var(--d, 0s) infinite alternate ease-in-out; }
.bk .bkdot.gas { animation-duration: .5s; }
.bk .bkdot.gasc { animation-duration: .9s; }
@keyframes bkjig { from { transform: translate(-1px, 1px); } to { transform: translate(1px, -1px); } }
.bk .bkdot.gas { animation-name: bkzoom; }
@keyframes bkzoom { from { transform: translate(-4px, 3px); } to { transform: translate(4px, -3px); } }
@media (prefers-reduced-motion: reduce) { .bk .bkdot { animation: none !important; } }

/* question side */
.bk .bkq { font-weight: 900; font-size: clamp(17px, 1.45vw, 28px); line-height: 1.3; margin: 0 0 8px; }
.bk .bkq2 { margin-top: 14px; padding-top: 10px; border-top: 3px dashed #c9a96a; }
.bk .bkpick { margin: 0 0 6px; font-size: clamp(14px, 1.05vw, 20px); font-weight: 700; color: #6b4a20; }
.bk .bkchoices { display: grid; gap: 8px; }
.bk .bkch { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; text-align: left; border: 3px solid var(--ink); background: #fff; color: var(--ink); border-radius: 14px;
  padding: 8px 12px; font: inherit; font-size: clamp(15px, 1.25vw, 24px); line-height: 1.3; cursor: pointer; white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: none; }
.bk .bkch > b { flex: none; width: 1.8em; height: 1.8em; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: .85em; }
.bk .bkch > span { flex: 1; min-width: 0; }
.bk .bkch:hover:not(:disabled), .bk .bkch:focus-visible { background: #fff1c9; outline: 3px solid #ff8a1f; outline-offset: 1px; }
.bk .bkch.sel { background: #ffd23f; box-shadow: 0 0 0 3px #ff8a1f inset; }
.bk .bkch.crossed { opacity: .4; text-decoration: line-through; cursor: not-allowed; }
.bk .bkch:disabled { cursor: default; }
.bk .bkch.key { background: #d8f7c0; border-color: #2c8a1a; }
.bk .bkch.key > b { background: #2c8a1a; }
.bk .bkch.no { background: #ffd0d6; border-color: #b0182e; }
.bk .bkch.no > b { background: #b0182e; }
.bk .bkch.ok::after, .bk .bkch.key::after { content: '✓'; font-weight: 900; color: #2c8a1a; font-size: 1.3em; }
.bk .bkch.no::after { content: '✗'; font-weight: 900; color: #b0182e; font-size: 1.3em; }
/* put in order */
.bk .bkslots { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.bk .bkslot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; min-height: 48px; border: 3px dashed #8a6a3a; background: #fffdf5; border-radius: 14px; padding: 6px 12px; font: inherit; font-size: clamp(15px, 1.2vw, 23px); text-align: left; color: var(--ink); cursor: pointer; }
.bk .bkslot b { flex: none; width: 1.8em; height: 1.8em; border-radius: 50%; display: grid; place-items: center; background: #8a6a3a; color: #fff; }
.bk .bkslot span { flex: 1; min-width: 0; }
.bk .bkslot.full { border-style: solid; border-color: var(--ink); background: #ffd23f; }
.bk .bkslot.lock { background: #e6f3ff; }
.bk .bkslot.ok { background: #d8f7c0; border-color: #2c8a1a; }
.bk .bkslot.no { background: #ffd0d6; border-color: #b0182e; }
.bk .bkfix { flex-basis: 100%; font-style: normal; font-weight: 800; color: #2c6a12; padding-left: 2.6em; }
.bk .bktile.used { opacity: .35; }
.bk .bkacts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
.bk .bkacts .bkcheck { flex: 1 1 220px; }
.bk .bkquill { width: 1.4em; height: 1.4em; vertical-align: middle; }
/* result */
.bk .bkres:empty { display: none; }
.bk .bkres { margin-top: 12px; }
.bk .bkstamp { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border: 4px solid; border-radius: 16px; padding: 8px 12px; font-size: clamp(18px, 1.6vw, 32px); }
.bk .bkstamp.good { border-color: #2c8a1a; background: #eaffde; color: #1d5e10; }
.bk .bkstamp.oops { border-color: #b0182e; background: #fff0f2; color: #8a1023; }
.bk .bkstamp b { font-weight: 900; letter-spacing: .03em; }
.bk .bkstampimg { width: clamp(60px, 6vw, 110px); height: auto; }
.bk .bkstamp.slam { animation: bkslam .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bkslam { from { transform: scale(1.7) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.bk .bkpts { margin-left: auto; font-size: .7em; font-weight: 900; color: #7a4a00; }
.bk .bkex, .bk .bktip { font-size: clamp(16px, 1.3vw, 25px); line-height: 1.38; margin: 10px 0 0; }
.bk .bktip { background: #fff4c7; border-left: 6px solid #ffb000; padding: 8px 12px; border-radius: 8px; }
.bk .bknext { margin-top: 12px; width: 100%; }

/* Bonus Chest and the prize wheel */
.bk .bkchest { flex: 1 1 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: #fff;
  background: radial-gradient(circle at 50% 40%, #6b3410cc, #1b0d05ee); border-radius: 18px; padding: 12px; }
.bk .bkchest h3 { font-size: clamp(24px, 3vw, 56px); margin: 0; color: #ffd23f; }
.bk .bkchestbtn { background: none; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; color: #fff; font: inherit; font-weight: 900; font-size: clamp(18px, 1.6vw, 30px); }
.bk .bkchestimg { width: clamp(150px, 22vw, 360px); max-height: 42vh; object-fit: contain; animation: bkwob 1.2s infinite ease-in-out; }
.bk .bkchestimg.small { width: clamp(90px, 12vw, 200px); animation: none; }
@keyframes bkwob { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .bk .bkchestimg { animation: none; } }
.bk .bkchestrow { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 3vw, 40px); flex-wrap: wrap; }
.bk .bkwheelbox { position: relative; width: min(84vw, 50vh, 520px); aspect-ratio: 1; }
.bk .bkwheel { position: absolute; inset: 0; }
.bk .bkwheel canvas { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 0 0 8px #ffd23f, 0 10px 40px #000a; }
/* the gold rim art stays still around the spinning wheel */
.bk .bkwheelbox.hasrim .bkwheel { inset: 12.5%; }
.bk .bkwheelbox.hasrim .bkwheel canvas { box-shadow: none; }
.bk .bkrim { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; z-index: 1; display: none; }
.bk .bkwheelbox.hasrim .bkrim { display: block; }
.bk .bkpointer { position: absolute; left: 50%; top: -4%; transform: translateX(-50%); width: 13%; z-index: 2; }
.bk .bkpointer img { width: 100%; height: auto; filter: drop-shadow(0 3px 4px #000a); }
.bk .bkwheelmsg { font-size: clamp(18px, 1.6vw, 32px); margin: 4px 0; }
.bk .bkwin { color: #ffd23f; font-size: 1.4em; }
.bk .bkspin { font-size: clamp(20px, 2vw, 36px); min-width: 200px; }
.bk .bkfinale { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 5; }
.bk .bkfinale b { font-size: clamp(40px, 8vw, 150px); font-weight: 900; color: #ffd23f; text-shadow: 0 6px 0 #7a3b10, 0 0 40px #ff8a1f; animation: bkboom 1s cubic-bezier(.2, 1.5, .4, 1); text-align: center; }
.bk .bkfinale.calm b { animation: bkfade .6s ease-out; }
@keyframes bkboom { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }

/* small or short screens: tighter spacing so the page stays big */
@media (max-width: 520px) { .bk .bkbar { font-size: 14px; padding: 4px 8px; } .bk .bkread { padding: 4px 10px; } .bk .bkfib { flex-direction: row; } }
@media (max-height: 520px) { .bk .bkhero img { width: 44px; } .bk .bkvil img { width: 56px; } }

/* phones held upright: the book takes the whole screen under the top bar */
@media (max-width: 700px) and (orientation: portrait) {
  body.cmp[data-screen="fib-files"] main.incab, body.cmp[data-screen="testmas"] main.incab { height: calc(100svh - var(--hudh, 60px)) !important; min-height: 420px !important; overflow: hidden !important; padding-top: 6px !important; }
  body.cmp[data-screen="fib-files"] main.incab > .wrap, body.cmp[data-screen="testmas"] main.incab > .wrap { flex: 1 1 auto !important; min-height: 0 !important; overflow: hidden !important; padding: 8px !important; }
  body.cmp[data-screen="fib-files"] main.incab .lockhead, body.cmp[data-screen="testmas"] main.incab .lockhead { padding-top: 46px !important; }
  body.cmp[data-screen="fib-files"] .bk .bkstage, body.cmp[data-screen="testmas"] .bk .bkstage { min-height: 0; flex: 1 1 0; }
  .bk .lockhead .eyebrow { font-size: 11px; }
}
@media (max-width: 700px) and (orientation: portrait) { .bk .bkchestrow { flex-direction: column; gap: 6px; } .bk .bkchestimg.small { width: 90px; } }
@media (orientation: landscape) and (max-height: 500px) { .bk .bkwheelbox { width: min(40vh, 300px); } .bk .bkchestimg.small { width: 80px; } .bk .bkspin { min-height: 44px; padding: 4px 18px; } .bk .bkwheelmsg { margin: 0; } }

/* v58: The Night Before Test-mas winter look (icy pages, midnight blue leather, frosty gold title) */
main.incab .bk.bktm { --ink: #10243f; --paper: #f4f9ff; --paper2: #dcebfb; --leather: #173a6b; }
.bk.bktm .bkstage { background: #0b1830; }
.bk.bktm .bkcover { background: linear-gradient(90deg, var(--leather), #24538f 48%, #102b52 50%, #24538f 52%, var(--leather)); box-shadow: inset 0 0 0 6px #9fd3ff, 0 12px 40px #0008; }
.bk.bktm .bkcovertext h3 { color: #ffe27a; text-shadow: 0 3px 0 #0b1830; }
.bk.bktm .bkboss { background: #2f7de1; }
.bk.bktm .bkprog i { background: linear-gradient(90deg, #9fd3ff, #ffe27a); }
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .bk.bktm .bkpages { background: linear-gradient(90deg, var(--paper) 0 calc(46.5% - 10px), #b9d3ee 46.5%, var(--paper) calc(46.5% + 10px)); }
  .bk.bktm .bkstory { box-shadow: inset -18px 0 22px -18px #3d6a9a; }
  .bk.bktm .bkquest { box-shadow: inset 18px 0 22px -18px #3d6a9a; }
}
.bk.bktm .bkbubble b { color: #1c5aa8; }
