/* Hunter Notebook — styled after the Monster of the Week books: paper, black ink, worn headings, hand-drawn boxes. */

:root {
  --paper: #ffffff;
  --paper-2: #f4f4f2;
  --ink: #000000;
  --ink-2: #2b2b2b;
  --muted: #5c5c5c;
  --faint: #c9c9c9;
  --wash: #ececea;
  --display: "Anton", "Impact", "Haettenschweiler", "Arial Narrow Bold", sans-serif;
  --body: "Crimson Pro", "Minion Pro", "Iowan Old Style", Georgia, serif;
  --hand: "Permanent Marker", "Marker Felt", "Comic Sans MS", cursive;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 19px/1.42 var(--body);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; }
.boot { padding: 2rem; max-width: 40rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Worn display type, like the book's headings and page numbers */
h1, h2, .display {
  font-family: var(--display); font-weight: 400; text-transform: uppercase;
  line-height: 0.95; letter-spacing: 0.005em; margin: 0 0 0.5rem;
  filter: url(#worn);
}
h1 { font-size: clamp(2.6rem, 7vw, 4rem); }
h2 { font-size: 2rem; }
/* Book-style small-caps labels: "RATINGS, PICK ONE LINE:" */
h3, .label {
  font-family: var(--body); font-weight: 800; font-size: 1rem; text-transform: uppercase;
  letter-spacing: 0.06em; margin: 0 0 0.4rem; line-height: 1.25;
}
h4 { font-weight: 700; margin: 0.6rem 0 0.2rem; }
p { margin: 0 0 0.7rem; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.page-ref { color: var(--muted); font-size: 0.82rem; white-space: nowrap; font-style: italic; text-transform: none; letter-spacing: 0; font-weight: 400; }

/* Hand-drawn box: a wobbly ink border drawn behind the content */
.panel, .btn, .rating, .choice, .pb-card, .hunter-row, .modal, .notice, .levelup-callout, .empty, .sketch { position: relative; }
.panel::before, .btn::before, .rating::before, .pb-card::before, .hunter-row::before, .modal::before,
.notice::before, .levelup-callout::before, .empty::before, .choice.boxed::before, .sketch::before {
  content: ""; position: absolute; inset: 0; border: 2px solid var(--ink); pointer-events: none;
  filter: url(#sketch); border-radius: 2px;
}

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem max(1rem, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 3px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand img { width: 30px; height: 30px; }
.brand span { font-family: var(--display); font-size: 1.65rem; text-transform: uppercase; filter: url(#worn); line-height: 1; }
.nav { display: flex; gap: 0.2rem; }
.nav a {
  text-decoration: none; color: var(--ink); padding: 0.3rem 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.95rem;
}
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.nav a:hover:not([aria-current="page"]) { text-decoration: underline; }
main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 5rem; position: relative; }

@media (max-width: 720px) {
  .nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    justify-content: space-around; padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
    background: var(--paper); border-top: 3px solid var(--ink);
  }
  .nav a { flex: 1; text-align: center; font-size: 0.85rem; padding: 0.45rem 0.2rem; }
  main { padding-bottom: 6rem; }
}

/* Running head down the page edge, like the book: "THE CHOSEN • THE PLAYBOOKS" */
.running-head {
  position: absolute; left: -2.4rem; top: 1.5rem;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.95rem; white-space: nowrap;
}
@media (max-width: 1180px) { .running-head { display: none; } }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.45rem 1.05rem;
  border: 0; background: var(--paper); color: var(--ink);
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.92rem;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); }
.btn.ghost::before { border-style: dashed; border-width: 1.5px; }
.btn.danger { text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 4px; }
.btn.small { min-height: 34px; padding: 0.2rem 0.65rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }

label.field { display: block; margin-bottom: 0.9rem; }
label.field > span, .field > .label { display: block; margin-bottom: 0.15rem; }
label.field > span { font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.9rem; }
/* Write-in lines, like the blanks on a printed playbook */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input:not([type]), select {
  width: 100%; padding: 0.35rem 0.15rem; min-height: 42px;
  border: 0; border-bottom: 2px solid var(--ink); border-radius: 0; background: transparent;
  font-size: 1.1rem;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus, select:focus { outline: none; border-bottom-width: 3px; background: var(--paper-2); }
select {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #000 50%), linear-gradient(135deg, #000 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 8px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 1.6rem;
}
textarea {
  width: 100%; min-height: 6rem; resize: vertical; padding: 0 0.5rem; border: 2px solid var(--ink); border-radius: 0;
  /* ruled notebook lines */
  background: var(--paper) repeating-linear-gradient(transparent, transparent calc(1.6em - 1px), #d0d0d0 calc(1.6em - 1px), #d0d0d0 1.6em);
  background-attachment: local; line-height: 1.6em;
}
input::placeholder, textarea::placeholder { color: #8a8a8a; font-style: italic; }

.error { font-weight: 700; }
.error::before { content: "✗ "; }
.notice { padding: 0.8rem 1rem; margin-bottom: 1rem; background: var(--paper); }
.notice::before { border-style: dashed; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; background: var(--paper); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h1 { font-size: clamp(3.6rem, 17vw, 5.8rem); line-height: 0.86; margin-bottom: 0.9rem; }
.auth-card .lede { font-style: italic; font-size: 1.15rem; margin-bottom: 1.4rem; }
.auth-tabs { display: flex; margin-bottom: 1rem; border-bottom: 3px solid var(--ink); }
.auth-tabs button { flex: 1; background: none; border: 0; padding: 0.55rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; color: var(--muted); }
.auth-tabs button[aria-selected="true"] { color: var(--paper); background: var(--ink); }

/* ---------- roster ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head .lede { font-style: italic; margin: 0.3rem 0 0; }
.roster { display: grid; gap: 0.9rem; }
.hunter-row {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 1rem; align-items: center;
  padding: 0.85rem 1rem; background: var(--paper); text-decoration: none; color: var(--ink);
}
.hunter-row:hover { background: var(--paper-2); }
.avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--paper);
  display: grid; place-items: center; font-family: var(--display); font-size: 2rem; color: var(--ink);
  border: 2.5px solid var(--ink);
}
img.avatar { filter: grayscale(1) contrast(1.3); }
.avatar.big { width: 120px; height: 120px; font-size: 3.2rem; }
.hunter-row h2 { margin: 0; font-size: 2rem; }
.hunter-row .meta { font-size: 1.02rem; }
.hunter-row .meta.small { color: var(--muted); font-size: 0.88rem; font-style: italic; }
.mini-tracks { display: grid; gap: 4px; justify-items: end; }
.mini { display: flex; gap: 2px; align-items: center; }
.mini i { width: 12px; height: 12px; border: 1.5px solid var(--ink); display: block; }
.mini i.on { background: var(--ink); }
.mini b { font-size: 0.75rem; margin-right: 6px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; width: 3.2em; text-align: right; }
@media (max-width: 560px) {
  .hunter-row { grid-template-columns: 56px 1fr; }
  .hunter-row .avatar { width: 56px; height: 56px; }
  .mini-tracks { grid-column: 1 / -1; justify-items: start; grid-auto-flow: column; justify-content: start; gap: 1rem; }
}
.empty { padding: 2.5rem 1.25rem; text-align: center; }
.empty::before { border-style: dashed; }
.empty h2 { font-size: 2.6rem; }
.section-title { margin: 2.2rem 0 0.8rem; }

/* ---------- panels ---------- */
.panel { background: var(--paper); padding: 1rem 1.15rem; margin-bottom: 1.1rem; }
.panel > h2, .panel > h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- character sheet ---------- */
.sheet-head { display: grid; grid-template-columns: auto 1fr; gap: 1.2rem; align-items: center; margin-bottom: 1.1rem; }
.sheet-head h1 { margin: 0 0 0.2rem; }
.sheet-head .sub { font-size: 1.15rem; font-style: italic; }
.save-state { font-size: 0.88rem; font-style: italic; color: var(--muted); }
.save-state.error { color: var(--ink); font-weight: 700; font-style: normal; }

.ratings { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6rem; margin-bottom: 1.2rem; }
.rating { text-align: center; padding: 0.55rem 0.2rem 0.45rem; background: var(--paper); border: 0; cursor: pointer; }
.rating:hover { background: var(--paper-2); }
.rating .num { font-family: var(--display); font-size: clamp(2.8rem, 9vw, 4.2rem); line-height: 1; display: block; filter: url(#worn); }
.rating .name { font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.rating.advanced .name::after { content: " ★"; }

.sheet-grid { display: grid; grid-template-columns: 330px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .sheet-grid { grid-template-columns: 1fr; } }

/* Tracks, printed like the book: Okay ☐☐☐|☐☐☐☐ Dying */
.track-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.4rem; }
.track-head strong { font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.track-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: nowrap; }
.track-row .end { font-size: 1rem; }
.boxes { display: flex; gap: 2px; flex-wrap: nowrap; align-items: center; }
.box { width: 26px; height: 26px; border: 2.5px solid var(--ink); background: var(--paper); cursor: pointer; padding: 0; border-radius: 1px; }
.box:hover:not(:disabled) { background: var(--paper-2); }
/* Inked mark: a hand-drawn X */
.box.on, .toggle input:checked, .choice input[type="checkbox"]:checked, .steps button.done::before {
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M5 6 C11 12 19 19 27 27 M26 5 C19 12 13 19 6 27' stroke='%23000' stroke-width='4.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / 100% no-repeat;
}
/* Harm gets inked in solid */
.box.on.harm { background: var(--ink); }
.box-divider { width: 3px; height: 28px; background: var(--ink); margin: 0 3px; }
.toggle { display: inline-flex; gap: 0.5rem; align-items: center; cursor: pointer; margin-top: 0.55rem; }
.toggle input, .choice input {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 0; border: 2.5px solid var(--ink);
  background: var(--paper); flex: none; cursor: pointer; border-radius: 1px;
}
.choice input[type="radio"] { border-radius: 50%; }
.choice input[type="radio"]:checked { background: radial-gradient(circle, #000 0 40%, transparent 45%); }
.toggle input:disabled, .choice input:disabled { opacity: 0.4; cursor: not-allowed; }

.levelup-callout {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.8rem 1rem; margin-bottom: 1.1rem; background: var(--ink); color: var(--paper);
}
.levelup-callout strong { font-family: var(--display); font-size: 1.9rem; text-transform: uppercase; filter: url(#worn); font-weight: 400; }
.levelup-callout .btn { background: var(--paper); color: var(--ink); }

.tabs { display: flex; overflow-x: auto; border-bottom: 3px solid var(--ink); margin-bottom: 1rem; scrollbar-width: none; }
.tabs button {
  background: none; border: 0; padding: 0.5rem 0.85rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 0.88rem; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tabs button:hover:not([aria-selected="true"]) { text-decoration: underline; }

/* Moves read like the playbook: bold name, then the text */
.move { padding: 0.7rem 0; border-top: 1px solid var(--faint); }
.move:first-child { border-top: 0; padding-top: 0.1rem; }
.move-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.move-name { margin: 0; font-weight: 800; font-size: 1.12rem; }
.roll-chip { font-size: 0.75rem; font-weight: 800; padding: 0 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; border: 1.5px solid var(--ink); }
.adv-chip { background: var(--ink); color: var(--paper); }
.move .prose p:last-child { margin-bottom: 0; }
.move .adv-text { margin-top: 0.4rem; padding-left: 0.75rem; border-left: 4px solid var(--ink); }
.move ul { margin: 0.3rem 0 0; padding-left: 1.3rem; }

.gear-item { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.75rem; padding: 0.55rem 0; border-top: 1px solid var(--faint); }
.gear-item:first-child { border-top: 0; }
.tag { display: inline-block; font-size: 0.9rem; font-style: italic; padding: 0 0.15rem; margin-right: 0.25rem; border-bottom: 1.5px dotted var(--ink); cursor: help; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; align-items: baseline; }
.kv dt { font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.88rem; }
.kv dd { margin: 0; }

/* ---------- choices: printed checkbox lists ---------- */
.choices { display: grid; gap: 0.1rem 1.2rem; }
.choices.cols { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.choice { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.3rem 0.3rem; cursor: pointer; }
.choice:hover { background: var(--paper-2); }
.choice input { margin-top: 0.15rem; }
.choice .ctext { flex: 1; min-width: 0; }
.choice .ctext strong { display: block; font-weight: 600; }
.choice.selected .ctext > strong { font-weight: 800; }
.choice .ctext small { display: block; font-size: 0.92rem; color: var(--ink-2); line-height: 1.35; margin-top: 0.1rem; }
.choice.boxed { padding: 0.6rem 0.75rem; margin-bottom: 0.55rem; }
.choice.boxed.selected::before { border-width: 3.5px; }
.counter { font-size: 0.92rem; font-style: italic; }
.counter.done { font-weight: 700; font-style: normal; }
.counter.done::after { content: " ✓"; }
.counter.over { font-weight: 700; font-style: normal; text-decoration: underline wavy; }

.ratings-pick { display: grid; gap: 0.05rem; }
.ratings-line { display: flex; flex-wrap: wrap; gap: 0.1rem 0.9rem; font-size: 1.12rem; }
.ratings-line span { white-space: nowrap; }

/* ---------- wizard ---------- */
.wizard { display: grid; grid-template-columns: 210px 1fr; gap: 1.6rem; align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; position: sticky; top: 4.5rem; }
.steps button {
  width: 100%; text-align: left; background: none; border: 0; padding: 0.4rem; cursor: pointer;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.88rem; color: var(--muted);
  display: flex; gap: 0.5rem; align-items: center;
}
.steps button::before { content: ""; width: 18px; height: 18px; border: 2px solid currentColor; flex: none; background: var(--paper); }
.steps button.done { color: var(--ink); }
.steps button[aria-current="step"] { color: var(--paper); background: var(--ink); }
.steps button[aria-current="step"]::before { border-color: var(--paper); }
.steps button:disabled { cursor: not-allowed; opacity: 0.5; }
.wizard-foot { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 1.4rem; padding-top: 1rem; border-top: 3px solid var(--ink); }
@media (max-width: 820px) {
  .wizard { grid-template-columns: 1fr; gap: 1rem; }
  .steps { position: static; display: flex; overflow-x: auto; gap: 0.1rem; border-bottom: 3px solid var(--ink); scrollbar-width: none; }
  .steps button { white-space: nowrap; padding: 0.4rem 0.5rem; }
}

.playbook-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.9rem; }
.pb-card { text-align: left; padding: 0.85rem 1rem; background: var(--paper); border: 0; cursor: pointer; color: var(--ink); }
.pb-card:hover { background: var(--paper-2); }
.pb-card.selected { background: var(--ink); color: var(--paper); }
.pb-card h2 { margin: 0 0 0.35rem; font-size: 2rem; display: inline-block; }
.pb-card p { margin: 0; font-style: italic; font-size: 1rem; line-height: 1.35; }
.source-badge { font-family: var(--body); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; border: 1.5px solid currentColor; padding: 0 0.3rem; margin-left: 0.45rem; display: inline-block; vertical-align: middle; transform: translateY(-0.6em); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(255, 255, 255, 0.85); display: grid; place-items: center; padding: 1rem; }
.modal { width: 100%; max-width: 660px; max-height: 88vh; overflow: auto; background: var(--paper); padding: 1.25rem 1.4rem; box-shadow: 6px 6px 0 var(--ink); }
.modal::before { border-width: 3px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 0.75rem; }
.modal-head h2 { margin: 0; }
.big-roll { font-family: var(--display); font-size: 6rem; line-height: 1; filter: url(#worn); }
.roll-band { font-family: var(--hand); font-size: 1.6rem; transform: rotate(-2deg); display: inline-block; margin: 0.3rem 0 0.8rem; }

/* ---------- reference ---------- */
.ref-layout { display: grid; grid-template-columns: 230px 1fr; gap: 1.5rem; align-items: start; }
.ref-nav { position: sticky; top: 4.5rem; display: grid; max-height: calc(100vh - 6rem); overflow: auto; }
.ref-nav a { text-decoration: none; padding: 0.12rem 0.5rem; font-size: 1rem; }
.ref-nav a:hover { text-decoration: underline; }
.ref-nav a.active { background: var(--ink); color: var(--paper); }
.ref-nav .grp { font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.85rem; margin: 0.9rem 0 0.2rem 0.5rem; border-bottom: 2px solid var(--ink); }
.ref-select { display: none; margin-bottom: 1rem; }
@media (max-width: 820px) { .ref-layout { grid-template-columns: 1fr; } .ref-nav { display: none; } .ref-select { display: block; } }
.prose { max-width: 68ch; }
.prose ul { padding-left: 1.3rem; margin: 0.3rem 0 0.7rem; }
.prose li { margin-bottom: 0.2rem; }
.search { position: relative; margin-bottom: 1.2rem; max-width: 34rem; }
.search input { padding-left: 2rem; }
.search svg { position: absolute; left: 0.2rem; top: 50%; transform: translateY(-50%); }
mark { background: var(--ink); color: var(--paper); padding: 0 0.1em; }

/* ---------- log ---------- */
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 0.45rem 0; border-top: 1px solid var(--faint); display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.75rem; }
.log li:first-child { border-top: 0; }
.log time { font-style: italic; font-size: 0.92rem; }

table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--faint); vertical-align: middle; }
table.users th { font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.85rem; border-bottom: 2px solid var(--ink); }
table.users select { min-height: 34px; width: auto; }
@media (max-width: 640px) { table.users .hide-sm { display: none; } }

details > summary { cursor: pointer; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; background: var(--paper-2); padding: 0.05rem 0.3rem; }

.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%) rotate(-1deg); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 0.55rem 1.1rem; font-family: var(--hand); font-size: 1.1rem;
}
.toast[hidden] { display: none; }

/* Keeper-only wording editor */
.edit-wording {
  background: none; border: 0; padding: 0 0.2rem; cursor: pointer; font-size: 0.8rem; text-decoration: underline;
  font-style: italic; color: var(--muted); font-family: var(--body);
}
.edit-wording:hover { color: var(--ink); }
.custom-mark { font-size: 0.78rem; font-style: italic; color: var(--muted); }

/* Grid children must be allowed to shrink, or wide content causes sideways scrolling. */
.sheet-grid > *, .wizard > *, .ref-layout > * { min-width: 0; }
@media (max-width: 560px) {
  body { font-size: 18px; }
  .sheet-head { grid-template-columns: 76px 1fr; gap: 0.8rem; }
  .sheet-head .avatar.big { width: 76px; height: 76px; font-size: 2.1rem; }
  .rating .name { font-size: 0.72rem; letter-spacing: 0.03em; }
  .panel { padding: 0.85rem 0.9rem; }
}

@media print {
  .topbar, .nav, .btn, .tabs, .levelup-callout, .notice, .save-state, .edit-wording { display: none !important; }
  .panel { break-inside: avoid; }
}

/* ======================================================================
   Notebook: every screen is an open journal lying on a desk.
   ====================================================================== */
:root {
  --desk: #d2d1cc;
  --dot: #bdbdb8;
  --page-pad-x: 2.6rem;
  --page-pad-top: 2.2rem;
}
body { background: var(--desk); }
.desk { max-width: 1260px; margin: 0 auto; padding: 1.4rem 1.25rem 3rem; }
.desk-foot { text-align: center; font-size: 0.95rem; margin-top: 1.6rem; }

/* Divider tabs poking up from the top edge of the book */
.book-tabs { display: flex; justify-content: flex-end; gap: 0.35rem; padding: 0 2.2rem; position: relative; z-index: 2; margin-bottom: -2px; }
.book-tabs a {
  text-decoration: none; color: var(--ink); background: var(--paper);
  border: 2px solid var(--ink); border-bottom: 0; border-radius: 10px 10px 0 0;
  padding: 0.35rem 1rem 0.3rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.85rem;
  transform: translateY(5px); transition: transform 0.12s;
}
.book-tabs a:hover { transform: translateY(1px); }
.book-tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); transform: translateY(0); }
.book-tabs .tab-brand { margin-right: auto; border: 0; background: none; transform: none; padding-left: 0; font-family: var(--display); font-weight: 400; font-size: 1.5rem; letter-spacing: 0.01em; filter: url(#worn); }

.notebook {
  position: relative; display: grid; grid-template-columns: 1fr 14px 1fr; align-items: stretch;
  filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.22)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15));
}
/* stacked page edges underneath */
.notebook::before, .notebook::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -6px; height: 30px; z-index: -1;
  background: var(--paper); border: 1.5px solid #9d9d98; border-top: 0; border-radius: 0 0 22px 22px;
}
.notebook::after { left: 16px; right: 16px; bottom: -11px; }

.page {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: calc(100vh - 7rem);
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.4px);
  background-size: 24px 24px; background-position: 12px 12px;
  padding: var(--page-pad-top) var(--page-pad-x) 1.2rem;
  border: 2px solid var(--ink);
}
.page.left { border-radius: 26px 0 0 26px; border-right: 0; }
.page.right { border-radius: 0 26px 26px 0; border-left: 0; }
/* gutter shading toward the spine */
.page.left::after, .page.right::after { content: ""; position: absolute; top: 0; bottom: 0; width: 46px; pointer-events: none; }
.page.left::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, 0.13), transparent); }
.page.right::after { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, 0.11), transparent); }
.spine {
  background: var(--paper); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  background-image: linear-gradient(to right, rgba(0,0,0,0.22), rgba(0,0,0,0.04) 50%, rgba(0,0,0,0.18));
  position: relative;
}
/* stitching */
.spine::before {
  content: ""; position: absolute; left: 50%; top: 8%; bottom: 8%; width: 0; transform: translateX(-1px);
  border-left: 3px dashed #4a4a4a;
}
.page-body { flex: 1; min-width: 0; }
.page-foot {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding-top: 0.6rem;
  border-top: 2px solid var(--ink); font-size: 0.95rem; font-style: italic;
}

/* Black band across the top of the left page */
.head-band {
  background: var(--ink); color: var(--paper);
  margin: calc(var(--page-pad-top) * -1) calc(var(--page-pad-x) * -1) 1.6rem;
  padding: 1.2rem var(--page-pad-x) 1.3rem; border-radius: 24px 0 0 0;
}
.head-band .kicker { font-size: 0.92rem; font-weight: 700; letter-spacing: 0.04em; opacity: 0.85; margin-bottom: 0.5rem; }
.head-band-row { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; border-bottom: 3px solid var(--paper); padding-bottom: 0.8rem; }
.head-band-title h1 { margin: 0; color: var(--paper); }
.head-band-aside { text-align: right; font-style: italic; }
.head-band .btn { background: transparent; color: var(--paper); }
.head-band .btn::before { border-color: var(--paper); }
.head-band .btn:hover { background: rgba(255, 255, 255, 0.12); }
.head-band .btn.primary { background: var(--paper); color: var(--ink); }
.head-band .save-state { color: #cfcfcf; }
.head-band .avatar { border-color: var(--paper); background: var(--ink); color: var(--paper); }
.head-band a { color: var(--paper); }

/* Section labels: "02 · FIELD NOTES" */
.j-label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.88rem; margin: 1.6rem 0 0.6rem;
}
.j-label:first-child { margin-top: 0.2rem; }
.j-label b { font-weight: 800; }
.j-label-aside { text-transform: none; letter-spacing: 0; font-weight: 400; font-style: italic; font-size: 0.95rem; }

/* Dotted leaders */
.leaders { margin: 0; display: grid; gap: 0.35rem; }
.leader { display: flex; align-items: baseline; gap: 0.5rem; }
.leader dt { white-space: nowrap; }
.leader dt::after { content: ""; }
.leader::after { content: none; }
.leader dd { margin: 0; font-weight: 700; text-align: right; order: 3; }
.leader dt { order: 1; }
.leader .dots, .leader:before { content: ""; order: 2; flex: 1; border-bottom: 2px dotted #8f8f8f; transform: translateY(-0.3em); min-width: 1.5rem; }
.field-notes { padding: 0.9rem 1.1rem; }

/* Rubber stamps */
.stamp {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0.35rem 0.9rem 0.3rem; border: 3px solid var(--ink); outline: 1.5px solid var(--ink); outline-offset: 2px;
  transform: rotate(var(--angle, -6deg)); background: transparent; color: var(--ink); cursor: default;
  filter: url(#worn); opacity: 0.9; font: inherit; line-height: 1;
}
button.stamp { cursor: pointer; }
button.stamp:hover { opacity: 1; transform: rotate(var(--angle, -6deg)) scale(1.04); }
.stamp-main { font-family: var(--display); font-size: 1.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stamp-sub { font-weight: 800; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; margin-top: 0.15rem; }
.stamps { display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; align-items: center; margin: 0.4rem 0 1rem; min-height: 0; }

/* Panels inside pages sit on the dot grid */
.page .panel { background: var(--paper); }

/* Closed notebook cover for logging in */
.cover-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.cover {
  position: relative; width: min(100%, 470px); min-height: 620px; padding: 3rem 2.4rem 2.4rem 3.2rem;
  background: #111 radial-gradient(ellipse at 30% 20%, #2a2a2a, #0d0d0d 70%); color: var(--paper);
  border-radius: 10px 26px 26px 10px; box-shadow: 0 26px 40px rgba(0,0,0,0.3), inset 10px 0 0 #000, inset 12px 0 0 #333;
  display: flex; flex-direction: column;
}
/* elastic band */
.cover::after { content: ""; position: absolute; top: 0; bottom: 0; right: 46px; width: 14px; background: #000; box-shadow: inset 2px 0 0 #2b2b2b; }
.cover h1 { color: var(--paper); font-size: clamp(3.6rem, 15vw, 5.4rem); line-height: 0.86; margin: 0 0 0.6rem; }
.cover .lede { font-style: italic; color: #d9d9d9; margin-bottom: 1.8rem; max-width: 18rem; }
.cover-label {
  position: relative; z-index: 1; background: var(--paper); color: var(--ink); padding: 1.2rem 1.3rem 1.1rem; margin-right: 1.4rem;
  background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.4px); background-size: 22px 22px;
  border: 2px solid var(--ink); transform: rotate(-1.2deg); box-shadow: 3px 4px 0 rgba(0,0,0,0.6);
}
.cover-label .auth-tabs { margin-top: -0.2rem; }
.cover .cover-foot { margin-top: auto; padding-top: 1.4rem; font-size: 0.95rem; color: #cfcfcf; }
.cover .cover-foot a { color: var(--paper); }

/* ---------- phones and small tablets: one page at a time ---------- */
@media (max-width: 860px) {
  :root { --page-pad-x: 1.15rem; --page-pad-top: 1.3rem; }
  .desk { padding: 0.6rem 0.5rem 6rem; }
  .notebook { grid-template-columns: 1fr; filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.18)); }
  .spine { height: 14px; border: 0; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink);
    background-image: linear-gradient(to bottom, rgba(0,0,0,0.16), rgba(0,0,0,0.03) 50%, rgba(0,0,0,0.14)); }
  .spine::before { left: 6%; right: 6%; top: 50%; bottom: auto; width: auto; height: 0; border-left: 0; border-top: 3px dashed #4a4a4a; transform: translateY(-1px); }
  .page { min-height: 0; }
  .page.left { border-radius: 18px 18px 0 0; border-right: 2px solid var(--ink); border-bottom: 0; }
  .page.right { border-radius: 0 0 18px 18px; border-left: 2px solid var(--ink); border-top: 0; }
  .page.left::after, .page.right::after { display: none; }
  .head-band { border-radius: 16px 16px 0 0; }
  .book-tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; margin: 0; padding: 0.35rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
    background: var(--paper); border-top: 3px solid var(--ink); justify-content: space-around; gap: 0.2rem;
  }
  .book-tabs a { border: 0; border-radius: 0; transform: none; flex: 1; text-align: center; padding: 0.5rem 0.2rem; font-size: 0.8rem; }
  .book-tabs a:hover { transform: none; }
  .book-tabs .tab-brand { display: none; }
  .page-foot { font-size: 0.85rem; }
  .cover { padding: 2.2rem 1.4rem 1.8rem 2rem; min-height: 0; }
  .cover::after { right: 22px; width: 10px; }
  .cover-label { margin-right: 0.8rem; }
}
.sheet-title { display: flex; align-items: center; gap: 1rem; }
.sheet-title .avatar { width: 64px; height: 64px; font-size: 1.8rem; flex: none; }
.page .ratings { gap: 0.45rem; }
.page .rating .num { font-size: clamp(2.4rem, 5vw, 3.4rem); }
.page .tabs button { padding: 0.45rem 0.6rem; font-size: 0.8rem; }
.page .panel + .panel { margin-top: 0; }
/* Builder steps inside the notebook */
.page .steps { position: static; display: grid; gap: 0.1rem; }
.page .steps button { font-size: 0.95rem; padding: 0.35rem 0.5rem; }
.step-n { font-weight: 800; min-width: 1.6em; }
.page .playbook-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.leader .ratings-line { font-size: 0.95rem; gap: 0 0.4rem; justify-content: flex-end; }
@media (max-width: 860px) {
  .hide-phone { display: none; }
  .page .steps { display: flex; overflow-x: auto; border-bottom: 3px solid var(--ink); scrollbar-width: none; }
  .page .steps button { white-space: nowrap; }
}
/* Rules table of contents with dotted leaders */
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { display: flex; align-items: baseline; gap: 0.4rem; text-decoration: none; padding: 0.12rem 0.3rem; }
.toc a:hover .toc-title { text-decoration: underline; }
.toc a.active { background: var(--ink); color: var(--paper); }
.toc a.active .toc-dots { border-color: var(--paper); }
.toc-dots { flex: 1; border-bottom: 2px dotted #8f8f8f; transform: translateY(-0.3em); min-width: 1rem; }
.toc-page { font-style: italic; font-size: 0.92rem; white-space: nowrap; }
.page .ref-select { display: none; }
@media (max-width: 860px) {
  .toc { display: none; }
  .page .ref-select { display: block; margin-bottom: 1rem; }
}
.player-card { padding: 0.8rem 1rem; }
.player-top { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.player-top select { width: auto; min-height: 34px; }
.head-band-aside .btn { font-style: normal; }
@media (max-width: 860px) { .stamp-main { font-size: 1.3rem; } .stamp { padding: 0.25rem 0.7rem; } .stamps { gap: 0.6rem 1rem; } }
.cover .cover-foot { padding-right: 3.2rem; }

/* ======================================================================
   Fixed A5 spread (= A4 landscape, 297 x 210, ratio 1.414) that fits the
   window; each page scrolls inside the book. Phones keep a single page.
   ====================================================================== */
@media (min-width: 861px) {
  html:has(.desk), body:has(.desk) { height: 100%; overflow: hidden; }
  .desk {
    height: 100dvh; display: flex; flex-direction: column; align-items: center;
    padding: 0.9rem 1.5rem 1.6rem; max-width: none;
  }
  .book-tabs { width: min(100%, calc((100dvh - 5.2rem) * 1.414)); flex: none; }
  .notebook {
    width: min(100%, calc((100dvh - 5.2rem) * 1.414));
    aspect-ratio: 297 / 210;
    min-height: 0; flex: none;
  }
  .page { min-height: 0; padding: 0; overflow: hidden; }
  .page-body {
    overflow-y: auto; overscroll-behavior: contain; min-height: 0;
    padding: var(--page-pad-top) var(--page-pad-x) 1rem;
    scrollbar-width: thin; scrollbar-color: #000 transparent;
  }
  .page-body::-webkit-scrollbar { width: 8px; }
  .page-body::-webkit-scrollbar-thumb { background: #000; border-radius: 4px; border: 2px solid var(--paper); }
  .page-body::-webkit-scrollbar-track { background: transparent; }
  .page-foot { margin: 0 var(--page-pad-x); padding: 0.55rem 0 0.9rem; flex: none; background: transparent; }
  .page.left .page-body { border-top-left-radius: 24px; }
  /* the sheet tabs stay pinned while the right page scrolls */
  .head-band { position: relative; }
  .page .tabs { position: sticky; top: calc(var(--page-pad-top) * -1); z-index: 3; background: var(--paper); margin-top: calc(var(--page-pad-top) * -1); padding-top: var(--page-pad-top); }
  :root { --page-pad-x: clamp(1.4rem, 2.6vw, 2.4rem); --page-pad-top: 1.6rem; }
  h1 { font-size: clamp(2.2rem, 4vw, 3.4rem); }
}
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; font: inherit; color: inherit; }

/* ---------- dice: bonuses, roll window, live roll log ---------- */
.bonus-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem; margin: -0.3rem 0 1.1rem; }
.bonus { display: inline-flex; align-items: center; gap: 0.3rem; }
.bonus-label { font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.82rem; margin-right: 0.2rem; }
.bonus-btn { width: 28px; height: 28px; border: 2px solid var(--ink); background: var(--paper); font-weight: 800; cursor: pointer; line-height: 1; padding: 0; }
.bonus-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.bonus-val { min-width: 2.2em; text-align: center; font-family: var(--display); font-size: 1.35rem; color: var(--muted); }
.bonus-val.set { color: var(--ink); filter: url(#worn); }
.bonus-note { flex: 1 1 12rem; min-height: 34px; font-size: 0.95rem; }
.roll-btn { cursor: pointer; background: var(--ink); color: var(--paper); border-color: var(--ink); font-family: var(--body); }
.roll-btn:hover { background: var(--ink-2); }
.roll-setup { display: grid; gap: 0.2rem; }
.die-pick { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.45rem; flex-wrap: wrap; }
.die-pick > span { width: 3.4em; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.die { width: 40px; height: 40px; border: 2.5px solid var(--ink); background: var(--paper); font-family: var(--display); font-size: 1.3rem; cursor: pointer; border-radius: 6px; }
.die.on { background: var(--ink); color: var(--paper); }
.modal .stamp { margin: 0.4rem 0 0.2rem; }
.live-dot { display: inline-flex; align-items: center; gap: 0.4rem; font-style: normal; font-weight: 700; font-size: 0.9rem; }
.live-dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--paper); }
.live-dot.on::before { background: var(--paper); animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: 0.25; } }
.roll-log { list-style: none; margin: 0; padding: 0; }
.roll-entry { display: grid; grid-template-columns: 3.2rem 1fr auto; gap: 0.8rem; align-items: center; padding: 0.6rem 0; border-top: 1px solid var(--faint); }
.roll-entry:first-child { border-top: 0; }
.roll-total { font-family: var(--display); font-size: 2.2rem; line-height: 1; text-align: center; filter: url(#worn); }
.roll-entry.miss .roll-total { color: var(--muted); }
.roll-meta { display: grid; justify-items: end; gap: 0.1rem; }
.roll-result { font-family: var(--hand); font-size: 1rem; transform: rotate(-2deg); white-space: nowrap; }
.roll-entry.hit .roll-result, .roll-entry.advanced .roll-result { text-decoration: underline; text-decoration-thickness: 2px; }
@media (max-width: 560px) { .roll-entry { grid-template-columns: 2.6rem 1fr; } .roll-meta { grid-column: 2; justify-items: start; grid-auto-flow: column; gap: 0.6rem; } }

/* ---------- 3D dice ---------- */
.dice3d { display: flex; justify-content: center; gap: 1.8rem; perspective: 700px; padding: 0.7rem 0 0.5rem; }
.dice3d[title="Tap to skip"] { cursor: pointer; }
.die3d { --s: 64px; width: var(--s); height: var(--s); }
.die3d.rolling { animation: die-hop 1.05s cubic-bezier(0.3, 0.7, 0.4, 1) var(--delay) both; }
@keyframes die-hop {
  0% { transform: translate(-70px, -46px); }
  45% { transform: translate(0, -26px); }
  70% { transform: translate(0, 0); }
  83% { transform: translate(0, -7px); }
  100% { transform: none; }
}
.die3d-cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.95s cubic-bezier(0.15, 0.65, 0.25, 1); }
.die3d:not(.rolling) .die3d-cube { transition: none; }
.die3d-face {
  position: absolute; inset: 0; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 9px;
  background: #fff; border: 3px solid #000; border-radius: 12px; backface-visibility: hidden;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 12px rgba(0, 0, 0, 0.16);
}
.die3d-face span { place-self: center; width: 11px; height: 11px; border-radius: 50%; }
.die3d-face .pip { background: #000; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.die3d-face.f1 { transform: translateZ(calc(var(--s) / 2)); }
.die3d-face.f6 { transform: rotateY(180deg) translateZ(calc(var(--s) / 2)); }
.die3d-face.f3 { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); }
.die3d-face.f4 { transform: rotateY(-90deg) translateZ(calc(var(--s) / 2)); }
.die3d-face.f2 { transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); }
.die3d-face.f5 { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); }
.die3d-face.f1 span:nth-child(5).pip { width: 15px; height: 15px; }
.rolling-caption { text-align: center; font-family: var(--hand); font-size: 1.15rem; margin: 0.2rem 0 0; transform: rotate(-1.5deg); }
