/* Tithe & Tattle */
:root {
  --parch: #efe2c4; --parch2: #e6d5b0; --page: #f7eed8; --cell: #fbf4e2;
  --ink: #3b2a1a; --ink2: #6b5238; --faint: #9a8264;
  --verm: #b23a26; --verm-d: #8e2a19; --gold: #b8892a; --gold-l: #e2c06a; --woad: #34568c;
  --rule: rgba(110, 76, 40, 0.35);
  --serif: "EB Garamond", Garamond, Georgia, serif;
  --display: "IM Fell English SC", "EB Garamond", Georgia, serif;
  --grain: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--parch); color: var(--ink); font-family: var(--serif); font-size: 18px; line-height: 1.4;
  background-image: var(--grain), radial-gradient(ellipse at 50% 30%, #f4e9d0 0%, var(--parch) 55%, var(--parch2) 100%);
  overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
h1, h2, h3 { font-family: var(--display); font-weight: normal; margin: 0; }

.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: flex; }
.screen.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; justify-content: center; }

/* buttons */
.btn {
  border: 1px solid #8a6a45; background: #f8efd9; border-radius: 6px; padding: 9px 16px; cursor: pointer;
  font-size: 17px; line-height: 1.15; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 1px 2px rgba(60,40,20,.15);
}
.btn:active { transform: translateY(1px); }
.btn.verm { background: var(--verm); border-color: var(--verm-d); color: #fff6e6; }
.btn.big { font-size: 20px; padding: 12px 26px; font-family: var(--display); }
.btn.small { font-size: 15px; padding: 5px 11px; }
.btn:disabled { opacity: .45; }
.iconbtn {
  border: 0; background: transparent; width: 44px; height: 44px; border-radius: 22px; font-size: 24px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--ink);
}
.iconbtn:active { background: rgba(120,80,40,.12); }
.iconbtn:disabled { opacity: .3; }
.btnrow { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btnrow.left { justify-content: flex-start; }

/* ---------------------------------------------------------------- leaves (Chronicle, Day Book) */
.leaf { width: 100%; max-width: 680px; padding: 8px 18px 60px; }
.topnav { display: flex; gap: 6px; justify-content: center; margin: 4px 0 10px; }
.topnav button {
  border: 0; background: none; font-family: var(--display); font-size: 18px; padding: 8px 12px; cursor: pointer; color: var(--ink2);
  border-bottom: 2px solid transparent;
}
.topnav button.on { color: var(--verm); border-bottom-color: var(--verm); }
.leafhead { text-align: center; margin-top: 10px; }
.leafhead h1 { font-size: 40px; color: var(--verm); letter-spacing: .5px; }
.leafhead .subtitle { font-style: italic; color: var(--ink2); margin-top: 2px; }
canvas.fl { display: block; margin: 10px auto 6px; }
.chapter { margin-top: 22px; }
.chapter h2 { font-size: 26px; color: var(--ink); border-bottom: 1px solid var(--rule); padding-bottom: 2px; }
.chapter h2 .rn { color: var(--verm); }
.chsub { font-style: italic; color: var(--ink2); font-size: 16px; margin: 3px 0 6px; }
.chapter.locked h2, .chapter.locked .chsub { opacity: .55; }
.lockline { font-size: 15px; color: var(--faint); font-style: italic; margin-top: 4px; }
.plist { list-style: none; margin: 0; padding: 0; }
.prow {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 9px 4px;
  border-bottom: 1px dotted var(--rule); cursor: pointer; min-height: 52px;
}
.prow:active:not(:disabled) { background: rgba(178,58,38,.06); }
.prow:disabled { cursor: default; opacity: .5; }
.pn { font-family: var(--display); color: var(--verm); width: 24px; text-align: right; font-size: 20px; flex: none; }
.pt { flex: 1; display: flex; flex-direction: column; }
.ptitle { font-size: 19px; }
.pmeta { font-size: 14.5px; color: var(--ink2); }
.pmark { width: 26px; text-align: center; color: var(--gold); font-size: 22px; flex: none; }
li.done .ptitle { color: var(--ink2); }
.empty { text-align: center; font-style: italic; color: var(--ink2); }

.leaf h3 { font-size: 19px; color: var(--verm); margin: 20px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid #a88a62; background: #f8efd9; border-radius: 20px; padding: 8px 16px; font-size: 18px; cursor: pointer; min-width: 64px;
}
.chip.on { background: var(--ink); color: #f8efd9; border-color: var(--ink); }
.chipnote { font-size: 15.5px; font-style: italic; color: var(--ink2); margin-top: 6px; min-height: 1.2em; }
.continue { background: rgba(184,137,42,.12); border: 1px solid rgba(184,137,42,.45); border-radius: 8px; padding: 10px 14px; margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seedline { font-size: 13px; color: var(--faint); margin-top: 10px; letter-spacing: .3px; }
table.stats { border-collapse: collapse; font-size: 16px; }
table.stats th, table.stats td { padding: 4px 12px; text-align: center; border-bottom: 1px solid var(--rule); }
table.stats thead th { font-family: var(--display); font-weight: normal; color: var(--ink2); }
table.stats tbody th { text-align: left; font-weight: normal; }
table.stats td.zero { color: var(--faint); }

/* ---------------------------------------------------------------- the puzzle screen */
#scr-puzzle { flex-direction: column; }
.pz-head {
  flex: none; display: flex; align-items: center; gap: 4px; padding: 4px 4px 2px; height: 54px; position: relative;
  border-bottom: 1px solid var(--rule); background: rgba(247,238,216,.55);
}
.pz-titles { flex: 1; min-width: 0; line-height: 1.1; }
.pz-titles h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pz-sub { font-size: 13px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hintbtn { padding: 7px 12px; font-size: 16px; white-space: nowrap; border-color: var(--gold); background: #fbf1d6; }
.hintbtn.showme { background: var(--gold-l); }
#scr-puzzle.solved .hintbtn { visibility: hidden; }
.menusheet {
  position: absolute; right: 6px; top: 50px; z-index: 30; background: var(--page); border: 1px solid #a88a62; border-radius: 8px;
  box-shadow: 0 6px 22px rgba(50,30,10,.25); padding: 6px 0; min-width: 250px; display: none;
}
.menusheet.on { display: block; }
.menusheet button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 18px; font-size: 17px; cursor: pointer; }
.menusheet button:active { background: rgba(120,80,40,.1); }
.menusheet button:disabled { opacity: .4; }
.menusheet .sep { height: 1px; background: var(--rule); margin: 4px 0; }
.menusheet button[hidden] { display: none; }
.menusheet .tog { padding-left: 46px; position: relative; }
.menusheet .tog::before {
  content: ''; position: absolute; left: 16px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border: 1.5px solid var(--ink2); border-radius: 3px;
}
.menusheet .tog.on::after { content: '✓'; position: absolute; left: 19px; top: 50%; margin-top: -13px; color: var(--verm); font-size: 18px; }

.pz-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pz-gridwrap { flex: none; position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 6px 4px; }
.pz-gridbox { position: relative; flex: none; }
canvas.grid { display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.zoombar { position: absolute; left: 0; top: 0; display: none; align-items: flex-start; justify-content: flex-start; gap: 4px; padding: 2px; pointer-events: none; }
.zoombar.on { display: flex; }
.zoombar button {
  pointer-events: auto; width: 32px; height: 32px; border-radius: 16px; border: 1px solid #a88a62; background: rgba(248,239,217,.95);
  font-size: 20px; line-height: 1; padding: 0; cursor: pointer;
}
.zoombar button:disabled { opacity: .35; }
.gridtip {
  position: absolute; left: 0; top: 0; z-index: 20; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: rgba(43,29,16,.92); color: #f8efd9; border-radius: 6px; padding: 5px 10px; font-size: 16px; white-space: nowrap; max-width: 96vw;
  overflow: hidden; text-overflow: ellipsis;
}
.gridtip.on { opacity: 1; }
.gridtip span { margin: 0 6px; color: var(--gold-l); }
.gridtip i { color: #d9c7a4; }
.tally-under { display: none; }

.pz-side { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.tabs { flex: none; display: flex; align-items: center; height: 46px; padding: 0 4px 0 8px; gap: 2px; }
.tabs [data-tab] {
  border: 0; background: none; font-family: var(--display); font-size: 18px; padding: 8px 10px; cursor: pointer; color: var(--ink2);
  border-bottom: 2px solid transparent;
}
.tabs [data-tab].on { color: var(--verm); border-bottom-color: var(--verm); }
.tabs .sp { flex: 1; }
.note { display: none; flex: none; margin: 0 8px 4px; padding: 8px 10px; border-radius: 6px; font-size: 17px; line-height: 1.35; }
.note.on { display: block; }
.note.hintnote { background: rgba(226,192,106,.28); border: 1px solid rgba(184,137,42,.6); }
.note.wrongnote { background: rgba(178,58,38,.09); border: 1px solid rgba(178,58,38,.45); }
.note.checknote { background: rgba(50,112,80,.10); border: 1px solid rgba(50,112,80,.4); }
.note .who { font-family: var(--display); color: var(--verm); }
.note .acts { display: inline-flex; gap: 8px; margin-left: 8px; vertical-align: middle; float: right; }
.note .close { border: 0; background: none; box-shadow: none; font-size: 20px; padding: 0 6px; }
.panel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 2px 14px 30px; }
.pane { display: none; }
.pane.on { display: block; }
.clues { margin: 0; padding: 0; list-style: none; }
.clues li { display: flex; gap: 8px; padding: 7px 4px; border-bottom: 1px dotted var(--rule); font-size: 18px; cursor: pointer; border-radius: 4px; }
.clues .num { color: var(--verm); font-family: var(--display); min-width: 24px; text-align: right; flex: none; }
.clues li.struck .ct { text-decoration: line-through; text-decoration-color: rgba(59,42,26,.7); color: var(--faint); }
.clues li.lit { background: rgba(226,192,106,.35); box-shadow: inset 3px 0 0 var(--gold); }
.howto { font-size: 14.5px; color: var(--ink2); font-style: italic; margin-top: 12px; }
table.tally { border-collapse: collapse; width: 100%; font-size: 16px; margin-top: 6px; }
table.tally th, table.tally td { border-bottom: 1px solid var(--rule); padding: 5px 6px; text-align: left; vertical-align: top; }
table.tally thead th { font-family: var(--display); font-weight: normal; color: var(--verm); font-size: 15px; }
table.tally tbody th { font-weight: 600; }
table.tally .unk { color: var(--faint); }
table.tally tr.conflict td, table.tally tr.conflict th { background: rgba(178,58,38,.1); color: var(--verm-d); }
.story { font-size: 18px; }
.story .place { font-style: italic; color: var(--ink2); margin: 8px 0 4px; }
.story canvas.art[class*="flourish"], .story canvas.art { }
.task .rubric, .rubric { color: var(--verm); font-family: var(--display); }

/* wide: grid on the left, panels on the right */
#scr-puzzle.wide .pz-body { flex-direction: row; justify-content: center; }
#scr-puzzle.wide .pz-gridwrap { flex: 0 1 auto; min-width: 0; align-items: center; justify-content: flex-start; padding: 8px 8px; overflow: hidden; }
#scr-puzzle.wide .pz-side { flex: none; width: var(--side, 360px); border-top: 0; border-left: 1px solid var(--rule); }
#scr-puzzle.tally-under .tally-under { display: block; width: 100%; max-width: 640px; margin-top: 10px; }
#scr-puzzle.tally-under .tallytab { display: none; }

/* ---------------------------------------------------------------- sheets */
.sheet-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(40,26,12,0); display: flex; align-items: center; justify-content: center;
  padding: 14px; transition: background .25s;
}
.sheet-back.on { background: rgba(40,26,12,.38); }
.sheet {
  background: var(--page); background-image: var(--grain); border-radius: 4px; max-width: 620px; width: 100%; max-height: 100%; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(40,20,5,.4); opacity: 0; transform: translateY(14px); transition: opacity .25s, transform .25s;
  border: 1px solid #c8ad7f;
}
.sheet-back.on .sheet { opacity: 1; transform: none; }
.sheet-back.small .sheet { max-width: 400px; }
.confirm { padding: 20px 22px 18px; font-size: 18px; }
.confirm p { margin: 0; }
.writing { padding: 26px; text-align: center; font-size: 20px; font-style: italic; }
.writing .quill { font-size: 34px; color: var(--verm); animation: write 1s ease-in-out infinite alternate; display: inline-block; }
.writing p { margin: 6px 0 0; }
@keyframes write { from { transform: translate(-10px, 2px) rotate(-8deg); } to { transform: translate(10px, -2px) rotate(6deg); } }
.page { position: relative; padding: 30px 26px 24px; font-size: 18.5px; }
.page .corner { position: absolute; top: 6px; }
.page .corner.tl { left: 6px; } .page .corner.tr { right: 6px; }
.page .kicker { text-align: center; font-size: 14px; color: var(--ink2); letter-spacing: .5px; font-style: italic; }
.page h2 { text-align: center; color: var(--verm); font-size: 28px; margin: 4px 30px 6px; line-height: 1.15; }
.page .place { text-align: center; font-style: italic; color: var(--ink2); margin-bottom: 8px; }
.page .task { margin-top: 10px; }
p.dropcap { margin: 10px 0; }
p.dropcap::after { content: ''; display: block; clear: both; }
canvas.initial { float: left; margin: 4px 10px 0 0; }
.page .fl { display: block; margin: 12px auto 4px; }
.sealrow { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; }
.hintsline { font-style: italic; color: var(--ink2); font-size: 16px; }
.inkw { opacity: 0; animation: inkin .6s ease-out forwards; }
@keyframes inkin { from { opacity: 0; color: #a08868; filter: blur(.6px); } to { opacity: 1; color: var(--ink); filter: none; } }

@media (max-width: 380px) {
  .hintbtn { font-size: 15px; padding: 6px 9px; }
  .pz-titles h1 { font-size: 18px; }
}
@media (min-width: 700px) {
  .clues li { font-size: 19px; }
}

/* ---------------------------------------------------------------- part 2: nav, chapter leaves */
.topnav { flex-wrap: wrap; gap: 2px; }
.topnav button { font-size: 16px; padding: 8px 8px; }
.topnav button.home { color: var(--faint); }
.chapter.card {
  background: rgba(251,244,226,.55); border: 1px solid rgba(184,137,42,.45); border-radius: 3px;
  box-shadow: 0 0 0 3px rgba(251,244,226,.4), 0 0 0 4px rgba(184,137,42,.22); padding: 12px 16px 10px; margin-top: 26px;
}
.chapter h2 { font-size: 23px; line-height: 1.2; }
.chapter h2 .rn { color: var(--verm); }
.chapter h2 .dot { color: var(--faint); }
.chapter h2 .feast { color: var(--ink2); font-size: .85em; }
.chapter.locked { background: transparent; box-shadow: none; border-style: dashed; border-color: var(--rule); }
.chapter.locked h2 { opacity: .55; border-bottom: 0; }
.chapter p.chopen { font-size: 17.5px; line-height: 1.45; margin: 10px 0; }
.chapter p.chopen + p.chopen { text-indent: 1.4em; margin-top: -4px; }
.grade { white-space: nowrap; }
.gglyph { color: var(--verm); font-size: .8em; letter-spacing: 1px; }
.pmark canvas { display: block; margin: 0 auto; }
li.locked .ptitle { font-style: italic; color: var(--faint); }
.center { text-align: center; }

/* ---------------------------------------------------------------- title page */
#scr-title { align-items: center; }
#scr-title.on .titlepage { animation: ttfade 1.2s ease both; }
@keyframes ttfade { from { opacity: 0; } to { opacity: 1; } }
.titlepage { width: 100%; max-width: 560px; padding: 70px 26px 60px; margin: auto; text-align: center; }
.tcorner { position: fixed; pointer-events: none; opacity: .9; }
.tcorner.tl { top: 8px; left: 8px; } .tcorner.tr { top: 8px; right: 8px; }
.tcorner.bl { bottom: 8px; left: 8px; } .tcorner.br { bottom: 8px; right: 8px; }
.tline { display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.tline .tcap { flex: none; }
.tline h1 { font-size: 46px; line-height: 1; color: var(--verm); padding-bottom: 6px; letter-spacing: .5px; text-align: left; }
.tsub { font-style: italic; color: var(--ink2); margin: 16px auto 0; max-width: 26em; }
.tmenu { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; }
.tmenu .btn { width: 240px; }
.tmenu .btn.verm { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tcont { font-family: var(--serif); font-style: italic; font-size: 15px; opacity: .9; }
@media (min-width: 700px) { .titlepage { max-width: 660px; } .tline h1 { font-size: 62px; white-space: nowrap; } }
@media (max-width: 380px) { .tline h1 { font-size: 38px; } }
/* index.html's static title (.shell), painted from HTML and CSS alone while the scripts load; pages.js replaces it
   in place (.nofade) with the real one, laid out to match */
#scr-title.on .titlepage.shell, #scr-title.on .titlepage.nofade { animation: none; }
.shell .tcap-ph { flex: none; box-sizing: border-box; width: 92px; height: 92px; display: flex; align-items: center; justify-content: center;
  background: #8e2a18; border: 3px solid #d4a83c; border-radius: 3px; color: #fbf1d6; font-family: var(--display); font-size: 64px; line-height: 1; }
.shell .fl-ph { height: 26px; margin: 10px auto 6px; }
.shell .tmenu .btn { cursor: default; }
@media (min-width: 700px) { .shell .tcap-ph { width: 128px; height: 128px; font-size: 90px; } }
.tt-resume #scr-title .shell { visibility: hidden; }   /* a reload returning to another screen: no title flash */

/* ---------------------------------------------------------------- Who's Who */
.castgroup { margin-top: 22px; }
.castgroup h2 { font-size: 23px; color: var(--verm); border-bottom: 1px solid var(--rule); padding-bottom: 2px; }
.castlist { list-style: none; margin: 0; padding: 0; }
.person { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px dotted var(--rule); }
.person canvas { flex: none; margin-top: 2px; }
.pinfo { flex: 1; min-width: 0; }
.pinfo h3 { font-size: 19px; color: var(--ink); }
.pdesc { margin: 2px 0 0; font-size: 16.5px; line-height: 1.38; }
.firstmet { margin: 3px 0 0; font-size: 14.5px; color: var(--ink2); }
.person.unmet .pinfo h3 { color: var(--faint); padding-top: 14px; }

/* ---------------------------------------------------------------- map */
.leaf.wide { max-width: 860px; }
.maptools { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 4px 0 6px; }
.zlabel { font-style: italic; color: var(--ink2); font-size: 15px; min-width: 80px; text-align: center; }
.mapwrap { overflow: auto; -webkit-overflow-scrolling: touch; margin: 0 auto; border: 1px solid rgba(110,76,40,.35); box-shadow: 0 2px 8px rgba(60,40,20,.18); max-width: 100%; width: max-content; background: #ead9b2; }
.mapinner { position: relative; }
.mapinner canvas { display: block; }
.marks { position: absolute; inset: 0; }
.mark {
  position: absolute; transform: translate(-50%, -50%); width: 26px; height: 26px; border-radius: 13px; padding: 0;
  background: var(--verm); color: #fff6e6; border: 2px solid var(--gold-l); box-shadow: 0 0 0 1px rgba(60,30,10,.6), 0 1px 3px rgba(40,20,5,.4);
  font-family: var(--display); font-size: 15px; line-height: 22px; text-align: center; cursor: pointer;
}
.mark.shut { background: #c9a98a; color: #f7eed8; border-color: #e6d5b0; }
.mark:active { transform: translate(-50%, -50%) scale(1.12); }
.mark.inline { position: static; transform: none; display: inline-block; flex: none; }
.mapkey { list-style: none; margin: 0; padding: 0; columns: 2 260px; column-gap: 24px; }
.mapkey li { break-inside: avoid; }
.keyrow { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 2px; border-bottom: 1px dotted var(--rule); cursor: pointer; }
.placesheet h3 { color: var(--verm); font-size: 22px; margin-bottom: 4px; }

/* ---- lightbox: portraits and the whole map, full screen */
.portbtn { flex: none; margin: 2px 0 0; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; line-height: 0; }
.portbtn canvas { margin: 0; border-radius: 50%; }
.portbtn:hover canvas, .portbtn:focus-visible canvas { box-shadow: 0 0 0 2px var(--gold); }
.lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(22, 14, 6, .9); opacity: 0; transition: opacity .18s;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; overflow: hidden;
}
.lightbox.on { opacity: 1; }
.lbfig { margin: 0; padding: 16px; display: flex; flex-direction: column; align-items: center; max-width: 100%; max-height: 100%; box-sizing: border-box; }
.lbfig .lbmedia { max-width: min(92vw, 900px); max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); object-fit: contain; border-radius: 4px; box-shadow: 0 6px 30px rgba(0,0,0,.6); }
.lbcap { text-align: center; color: var(--page); margin-top: 12px; max-width: 520px; }
.lbname { font-family: var(--display); font-size: 22px; color: var(--gold-l); }
.lbdesc { font-size: 17px; line-height: 1.35; margin-top: 3px; }
.lbclose {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 44px; height: 44px; border-radius: 22px; cursor: pointer;
  border: 1px solid var(--gold-l); background: rgba(22, 14, 6, .8); color: var(--page); font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0 0 3px;
}
.lbclose:hover, .lbclose:focus-visible { background: var(--verm); outline: 2px solid var(--gold-l); outline-offset: 2px; }
.lightbox.zoomable { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.lightbox.zoomable .lbmedia { position: absolute; transform-origin: 0 0; max-width: none; max-height: none; will-change: transform; -webkit-user-drag: none; }
