/* Roomful Mystery's pages (/mystery/, one page per mystery, the how-to-host page) and the printable party kit
   (/mystery/print, js/mystery-print.js). Loaded after site.css and gamenight.css on those pages only
   (tools/mystery_pages.py). The live game's screens use mystery-game.css instead.

   The kit is print only: #kit never shows on screen, so the host doesn't see the answer by accident. In print it is a
   stack of US Letter pages (@page in gamenight.css: letter, 0.4in margins). Fixed pages (.kp) are 7.5 x 9.9 in, a little
   inside the printable area, so Chrome, Edge and Safari all keep one .kp to a sheet; the host guide (.kflow) flows. */

.mystery-page ul:not([class]), .mystery-page ol.steps { padding-left: 1.3em; }
.mystery-page ul:not([class]) li, .mystery-page ol.steps li { margin: 6px 0; }
.mystery-page .crumbs { font-size: 1rem; }
/* The shared "Play on your TV" block's small print: at least 16 px on these pages. */
.mystery-page .video-note, .mystery-page .tv-help-small { font-size: 1rem; }

/* ---------- Mystery cards (hub and how-to-host) ---------- */
.mystery-cards { list-style: none; padding: 0; margin: 18px 0 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.mystery-card { display: flex; flex-direction: column; background: var(--night); border: 2px solid rgba(255, 246, 229, 0.14); border-radius: 18px; padding: 16px 18px 8px; }
.mystery-card h3 { margin: 0 0 6px; font-size: 1.4rem; line-height: 1.2; }
.mystery-card h3 a { color: var(--paper); text-decoration: none; }
.mystery-card h3 a:hover, .mystery-card h3 a:focus-visible { color: var(--accent); text-decoration: underline; }
.mystery-card p { margin: 0 0 10px; color: var(--paper-dim); }
.mystery-card .mystery-facts { color: var(--paper); font-weight: 650; font-size: 1rem; }
.mystery-card-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto !important; padding-top: 4px; }
.mystery-card-cta .btn { white-space: normal; text-align: center; }

/* ---------- A mystery's page ---------- */
.ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; margin: 22px 0 8px; }
.way { background: var(--night); border: 2px solid rgba(255, 246, 229, 0.14); border-radius: 18px; padding: 4px 18px 16px; display: flex; flex-direction: column; }
.way h2 { margin-top: 14px; font-size: 1.45rem; }
.way p { color: var(--paper-dim); margin: 0 0 12px; }
.way .way-cta { margin: auto 0 0; }
.way .btn { white-space: normal; text-align: center; }
.premise { font-size: 1.15rem; max-width: 42em; }
.cast-list { list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cast-list li { background: var(--night); border: 2px solid rgba(255, 246, 229, 0.12); border-radius: 14px; padding: 12px 14px; }
.cast-list h3 { margin: 0 0 4px; font-size: 1.25rem; }
.cast-role { display: block; font-size: 1rem; font-weight: 650; color: var(--accent); }
.cast-list p { margin: 4px 0; color: var(--paper-dim); }
.cast-list .cast-costume { color: var(--paper); }
.facts-list { padding-left: 1.3em; }
.facts-list li { margin: 6px 0; }

/* ---------- How-to-host: the timings table ---------- */
.table-wrap { max-width: 100%; overflow-x: auto; }
.timings { width: 100%; border-collapse: collapse; margin: 10px 0; }
.timings th, .timings td { text-align: left; vertical-align: top; padding: 8px 10px; border-top: 1px solid rgba(255, 246, 229, 0.16); }
.timings thead th { border-top: 0; color: var(--muted); font-size: 1rem; }
.timings tbody th { white-space: nowrap; }
.timings td:nth-child(2) { white-space: nowrap; font-weight: 650; }
@media (max-width: 560px) {
  .timings, .timings tbody, .timings tr, .timings th, .timings td { display: block; }
  .timings thead { display: none; }
  .timings tr { padding: 8px 0; border-top: 1px solid rgba(255, 246, 229, 0.16); }
  .timings th, .timings td { border: 0; padding: 2px 0; }
  .timings tbody th, .timings td:nth-child(2) { white-space: normal; }
}

/* ---------- The print page's controls ---------- */
.kit-form { display: grid; gap: 8px; max-width: 30em; margin: 18px 0 6px; }
.kit-form input[type="number"] { width: 6em; }
.kit-one[hidden] { display: none; }
.kit-one { display: grid; gap: 8px; }
.kit-code-line { margin: 10px 0 0; font-size: 1.1rem; }
.kit-code { display: inline-block; padding: 2px 10px; border-radius: 8px; background: var(--paper); color: var(--ink); letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.kit-form .print-buttons .btn { white-space: normal; }
.kit-reprint { display: grid; gap: 8px; max-width: 30em; margin: 18px 0; padding: 12px 14px; border: 2px solid rgba(255, 246, 229, 0.16); border-radius: 14px; background: rgba(11, 20, 80, 0.3); }
.kit-reprint-row { display: flex; gap: 8px; align-items: center; }
.kit-reprint-row input { text-transform: uppercase; letter-spacing: 0.08em; }
.kit-reprint-row .btn { flex: none; }
.kit-reprint .note, .kit-reprint .error { margin: 0; }
.kit-reprint .error:empty { display: none; }
.planning { max-width: 40em; margin: 22px 0; padding: 4px 18px 8px; border-radius: 16px; background: var(--paper); color: var(--ink); }
.planning h2 { color: var(--ink); margin-top: 14px; font-size: 1.4rem; }
.kit-contents { padding-left: 1.3em; }
.kit-contents li { margin: 6px 0; }
@media (max-width: 400px) {
  .kit-reprint-row { flex-wrap: wrap; }
  .kit-reprint-row .btn { width: 100%; }
}

/* ---------- The kit: never on screen ---------- */
.kit { display: none; }

@media print {
  .kit-page main > *:not(.kit) { display: none !important; }
  .kit-page main { padding: 0; margin: 0; max-width: none; }
  .kit { display: block; color: #111; font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 10.5pt; line-height: 1.3; }
  .kit h2, .kit h3 { color: #111; font-family: inherit; }
  .kit p { margin: 0; }

  /* A fixed page: one sheet. */
  .kp {
    width: 7.5in; height: 9.9in; margin: 0 auto; box-sizing: border-box; overflow: hidden; position: relative;
    display: flex; flex-direction: column; break-after: page; page-break-after: always; break-inside: avoid;
  }
  .kit > :last-child { break-after: auto; page-break-after: auto; }
  .kp-foot { display: flex; justify-content: space-between; gap: 0.2in; margin-top: auto !important; padding-top: 0.08in; font-size: 7.5pt; color: #555; }
  .kit-brand { font-size: 8pt; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: #555; }
  .kit-tag { font-size: 7.5pt; color: #555; letter-spacing: 0.04em; }
  .box { display: inline-block; flex: none; width: 0.16in; height: 0.16in; border: 1.5px solid #111; border-radius: 2px; }
  .blank-line { flex: 1; border-bottom: 1px solid #111; min-width: 1in; }

  /* A flap row: label | words | flap. Cut along the solid lines across the flap; fold it over the words along the dashed line. */
  .flap { display: grid; grid-template-columns: 1.35in 3.075in 3.075in; flex: none; break-inside: avoid; }
  .flap-label { display: flex; flex-direction: column; gap: 0.04in; padding: 0.08in 0.1in 0.08in 0; border-right: 1px dotted #999; border-bottom: 1px solid #111; font-size: 8.5pt; line-height: 1.2; }
  .flap-label strong { font-size: 11.5pt; line-height: 1.1; }
  .flap-when { font-weight: 650; }
  .flap-who { color: #555; }
  .flap-text { padding: 0.08in 0.12in; border-right: 1.5px dashed #111; border-bottom: 1px solid #111; font-size: 9.5pt; line-height: 1.25; }
  .flap-text h3 { font-size: 9pt; margin: 0 0 0.02in; text-transform: uppercase; letter-spacing: 0.06em; }
  .flap-text h3 + p { margin-bottom: 0.06in; }
  .flap-text .clue + .clue { margin-top: 0.06in; }
  .flap-text .clue::before { content: "• "; }
  .flap-cover {
    position: relative; display: flex; align-items: center; justify-content: center;
    background: repeating-linear-gradient(45deg, #bdbdbd 0 1.6px, #fff 1.6px 6px);
    border-bottom: 2px solid #111; /* the cut line */
  }
  .flap-cover-note { background: #fff; padding: 0.03in 0.1in; font-size: 8pt; font-weight: 650; color: #444; border-radius: 3px; }
  .flap-cover::before { content: "✂"; position: absolute; right: 0.02in; top: -0.11in; font-size: 10pt; line-height: 1; color: #111; background: #fff; }

  /* Character cards */
  .card-front { flex: 1 1 auto; display: flex; flex-direction: column; gap: 0.05in; padding: 0.1in 0.18in; border: 2px solid #111; border-radius: 0.12in; margin-bottom: 0.06in; min-height: 0; box-sizing: border-box; }
  .card-name { font-size: 26pt; line-height: 1; margin: 0.04in 0 0; font-weight: 850; }
  .card-role { font-size: 14pt; font-weight: 700; }
  .card-about { font-size: 11pt; }
  .card-costume { font-size: 10pt; }
  .card-warn { margin-top: auto !important; font-size: 8.5pt; font-weight: 650; }
  .fold-help { font-size: 8pt; color: #333; padding: 0 0 0.06in; border-bottom: 1.5px solid #111; }
  /* Every card's flaps are the same size (the culprit's "You did it" too), so no card stands out. A longer text than
     these heights allow grows its flap and shrinks the front; tests check that nothing overflows. */
  .kp-card .flap-secret .flap-text { min-height: 2.15in; }
  .kp-card .flap-intro .flap-text { min-height: 0.9in; }
  .kp-card .flap-round .flap-text { min-height: 1.4in; }
  .kp-card .flap > * { box-sizing: border-box; }
  .card-front { flex-shrink: 1; }
  .intro-line { font-style: italic; }

  /* Detective cards: two to a page */
  .kp-detectives { gap: 0.25in; }
  .dcard { flex: 1 1 0; display: flex; flex-direction: column; border-top: 1.5px solid #111; min-height: 0; }
  .dcard + .dcard { border-top-style: dashed; padding-top: 0.15in; }
  .dcard-head { display: grid; gap: 0.04in; padding: 0.1in 0 0.1in; border-bottom: 1.5px solid #111; }
  .dcard-head h2 { font-size: 20pt; margin: 0; }
  .dcard .flap { flex: 1 1 auto; }

  /* Evidence cards */
  .evidence-head { display: grid; gap: 0.05in; padding-bottom: 0.12in; border-bottom: 1.5px solid #111; }
  .evidence-head h2 { font-size: 22pt; margin: 0; }
  .kp-evidence .flap { flex: 1 1 auto; max-height: 2.8in; }
  .evidence-text { font-size: 13pt; line-height: 1.35; }

  /* Invitations: two to a page */
  .kp-invites { gap: 0.3in; }
  .invite {
    flex: 1 1 0; display: flex; flex-direction: column; gap: 0.08in; justify-content: center; text-align: center;
    padding: 0.3in 0.45in; border: 3px double #111; border-radius: 0.15in; min-height: 0;
  }
  .invite-top { font-size: 12pt; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
  .invite h2 { font-size: 24pt; line-height: 1.1; margin: 0; }
  .invite-text { font-size: 12.5pt; }
  .invite-lines { display: grid; grid-template-columns: auto 1fr; gap: 0.12in 0.12in; margin: 0.1in 0 0; text-align: left; font-size: 12pt; }
  .invite-lines dt { font-weight: 700; }
  .invite-lines dd { margin: 0; border-bottom: 1px solid #111; }
  .invite-who { display: flex; gap: 0.12in; align-items: flex-end; text-align: left; font-size: 12pt; font-weight: 700; }
  .invite-note { font-size: 10.5pt; }
  .invite-from { font-size: 8pt; color: #555; }

  /* Detective notebooks: two to a page */
  .kp-notebooks { gap: 0.3in; }
  .notebook { flex: 1 1 0; display: flex; flex-direction: column; gap: 0.06in; min-height: 0; }
  .notebook + .notebook { border-top: 1.5px dashed #111; padding-top: 0.2in; }
  .nb-head, .slip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.2in; }
  .nb-head h2, .slip-head h2 { font-size: 16pt; margin: 0; }
  .nb-name, .slip-name { display: flex; gap: 0.1in; align-items: flex-end; font-weight: 700; }
  .nb-help { font-size: 9pt; color: #333; }
  .nb-cast { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .nb-cast th { text-align: left; font-size: 8.5pt; padding: 0 0.05in 0.03in; }
  .nb-cast td { border-top: 1px solid #999; padding: 0.04in 0.05in; height: 0.22in; }
  .nb-box { width: 0.6in; text-align: center; }
  .nb-who { width: 2.6in; font-weight: 650; }
  .nb-note { border-left: 1px solid #ccc; }
  .nb-lines { flex: 1 1 auto; min-height: 1.2in; display: flex; flex-direction: column; }
  .nb-line { flex: none; height: 0.3in; border-bottom: 1px solid #999; box-sizing: border-box; }

  /* Voting slips: three to a page */
  .kp-slips { gap: 0.2in; }
  .slip { flex: 1 1 0; display: flex; flex-direction: column; gap: 0.06in; min-height: 0; }
  .slip + .slip { border-top: 1.5px dashed #111; padding-top: 0.15in; }
  .slip-q { font-weight: 700; font-size: 10pt; }
  .slip-who, .slip-why { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.05in 0.2in; font-size: 10pt; }
  .slip-why { grid-template-columns: repeat(3, 1fr); }
  .slip-who li, .slip-why li { display: flex; gap: 0.08in; align-items: center; }
  .slip-name { margin-top: auto !important; }

  /* The host guide: flows over a few pages */
  .kflow { width: 7.5in; margin: 0 auto; break-after: page; page-break-after: always; }
  .guide-head { padding-bottom: 0.1in; border-bottom: 2px solid #111; margin-bottom: 0.1in; }
  .guide-head h2 { font-size: 22pt; margin: 0.02in 0 0.04in; }
  .guide-code { font-size: 9.5pt; }
  .gblock { break-inside: avoid; page-break-inside: avoid; margin: 0 0 0.14in; }
  .gblock h3 { font-size: 13pt; margin: 0 0 0.05in; }
  .gblock p + p, .gblock p + ul, .gblock p + ol, .gblock ul + p { margin-top: 0.05in; }
  .gblock ul, .gblock ol { margin: 0.03in 0 0; padding-left: 0.25in; }
  .gblock li { margin: 0.02in 0; }
  .read-aloud { border-left: 4px solid #111; padding: 0.04in 0.12in; margin: 0.04in 0 0.06in; background: #f1f1f1; font-size: 11pt; }
  .read-label { display: block; font-size: 7.5pt; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: #555; }
  .prompt { font-weight: 650; }
  .guide-cast, .guide-times { border-collapse: collapse; margin-top: 0.06in; font-size: 10pt; }
  .guide-cast { width: 100%; }
  .guide-cast th, .guide-cast td, .guide-times th, .guide-times td { border: 1px solid #999; padding: 0.04in 0.08in; text-align: left; }
  .guide-cast .first { font-weight: 750; white-space: nowrap; }
  .guide-cast .blank { width: 2.4in; }

  /* The answer: the guide's last page */
  .kp-answer { gap: 0.1in; }
  .answer-head { padding: 0.12in 0.15in; border: 3px solid #111; text-align: center; }
  .answer-stop { font-size: 24pt; font-weight: 850; line-height: 1.1; }
  .answer-sub { font-size: 9pt; margin-top: 0.04in !important; }
  .answer-who { font-size: 18pt; font-weight: 800; }
  .kp-answer .gblock { margin: 0; }
  .recap { margin: 0; padding-left: 0.25in; }
}
