/* ============ Tokens ============ */
:root {
  --night: #140f0e;
  --night-2: #1d1614;
  --night-3: #2a201d;
  --line: rgba(239, 226, 204, 0.12);
  --line-strong: rgba(239, 226, 204, 0.24);
  --text: #f1e8d8;
  --muted: #ab9c8c;
  --gold: #d6af5c;
  --gold-soft: rgba(214, 175, 92, 0.16);
  --leather: #6e1f27;
  --leather-dark: #3a0d12;
  --paper: #fbf9f4;
  --paper-2: #f2eee5;
  --ink: #161412;
  --ink-soft: #5e5850;
  --rule: rgba(22, 20, 18, .55);
  --rose: #a8323e;
  --ok: #5f9a6b;
  --warn: #d6a24a;
  --bad: #d0605f;

  --f-display: 'Playfair Display', Georgia, serif;
  --f-book: 'EB Garamond', Georgia, serif;
  --f-ui: 'DM Sans', system-ui, -apple-system, sans-serif;
  --f-cond: 'Oswald', 'Arial Narrow', sans-serif;

  --radius: 10px;
  --ease: cubic-bezier(0.645, 0.045, 0.355, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(110, 31, 39, 0.28), transparent 70%),
    var(--night);
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}
a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ============ Header ============ */
.site-header {
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 50;
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--f-display); font-size: 22px; font-weight: 700;
  color: var(--text); text-decoration: none; letter-spacing: 0.01em;
}
.brand em { color: var(--gold); font-style: italic; font-weight: 500; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a, .nav button.linklike {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px;
  background: none; border: 0; cursor: pointer; font-size: 14px;
}
.nav a:hover, .nav button.linklike:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav a[aria-current="page"] { color: var(--text); }
.nav .who { border-radius: 0; color: var(--text); font-size: 14px; padding: 0 6px 0 14px; border-left: 1px solid var(--line); margin-left: 6px; }
.nav .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--rose); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line-strong); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }

@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--night-2); border-bottom: 1px solid var(--line); padding: 8px 16px 16px;
  }
  .nav.open { display: flex; }
  .nav a, .nav button.linklike { padding: 12px 8px; text-align: left; }
  .nav .who { border-left: 0; margin: 8px 0 0; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
}

main { flex: 1; width: 100%; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 16px; border-top: 1px solid var(--line); }
.site-footer p { margin: 0 0 10px; }
.footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 20px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* ============ Buttons & inputs ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); cursor: pointer; text-decoration: none;
  font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: rgba(255,255,255,0.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #1f160c; font-weight: 600; }
.btn-gold:hover { background: #e3bf6e; }
.btn-danger { color: var(--bad); border-color: rgba(208, 96, 95, .45); }
.btn-ok { color: #9fd3aa; border-color: rgba(95, 154, 107, .55); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label, .field .label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 13px; margin-top: -2px; }
.field .count { color: var(--muted); font-size: 12px; align-self: flex-end; margin-top: -2px; font-variant-numeric: tabular-nums; }
.field .count.over { color: var(--bad); }
.field .error { color: var(--bad); font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 8px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--line-strong); color: var(--text);
  font: inherit; font-size: 15px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select option { background: var(--night-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--gold); width: 16px; height: 16px; }

/* Rating picker */
.rating { display: flex; gap: 6px; flex-wrap: wrap; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating label {
  min-width: 44px; height: 40px; display: grid; place-items: center; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500;
}
.rating input:checked + label { background: var(--gold); color: #1f160c; border-color: var(--gold); }
.rating input:focus-visible + label { outline: 2px solid var(--gold); outline-offset: 2px; }
.rating-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; max-width: 270px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; border: 1px solid; }
.alert-error { background: rgba(208, 96, 95, .1); border-color: rgba(208, 96, 95, .4); color: #f2b5b4; }
.alert-ok { background: rgba(95, 154, 107, .12); border-color: rgba(95, 154, 107, .45); color: #b9e0c1; }
.alert-info { background: var(--gold-soft); border-color: rgba(214, 175, 92, .4); color: #ecd7a6; }

/* ============ Generic page layout ============ */
.wrap { width: min(1120px, 100%); margin: 0 auto; padding: 40px clamp(16px, 4vw, 40px) 64px; }
.wrap-narrow { width: min(460px, 100%); }
.page-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(30px, 4vw, 42px); line-height: 1.1; margin: 0 0 8px; }
.page-title em { color: var(--gold); font-weight: 500; }
.lede { color: var(--muted); margin: 0 0 32px; font-size: 16px; max-width: 60ch; }
.card { background: var(--night-2); border: 1px solid var(--line); border-radius: 14px; padding: clamp(20px, 3vw, 32px); }

/* Auth pages */
.auth-shell { display: grid; place-items: center; padding: 56px 16px; }
.auth-shell .card { width: min(440px, 100%); }
.auth-shell .alt { color: var(--muted); text-align: center; margin: 18px 0 0; font-size: 14px; }

/* ============ Reader / Book ============ */
.reader { display: flex; flex-direction: column; align-items: center; padding: 16px 16px 20px; gap: 12px; }
.reader-top { width: min(1100px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.search-row { display: flex; gap: 10px; align-items: center; justify-content: center; width: 100%; flex-wrap: wrap; }
.search-box { position: relative; flex: 0 1 440px; min-width: 0; }
.search-box input[type="search"] { padding: 10px 40px 10px 40px; border-radius: 999px; font-size: 15px; }
.search-box input[type="search"]::-webkit-search-cancel-button { display: none; }
.search-ico { position: absolute; left: 14px; top: 50%; width: 17px; height: 17px; margin-top: -8.5px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: var(--text); cursor: pointer; font-size: 18px; line-height: 1; }
.search-clear:hover { background: rgba(255,255,255,.16); }
.chapter-nav { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; max-width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted); cursor: pointer; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover:not(:disabled) { color: var(--text); border-color: var(--gold); }
.chip.active { background: var(--gold); border-color: var(--gold); color: #1f160c; font-weight: 600; }
.chip:disabled { opacity: .35; cursor: default; }
.chip-n { font-size: 11.5px; opacity: .75; font-variant-numeric: tabular-nums; }
.search-status { margin: 0; min-height: 0; color: var(--gold); font-size: 14px; }
.search-status:empty { display: none; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; width: min(640px, 100%); }
.pager-btn { min-width: 128px; padding: 11px 20px; font-size: 15px; }
.pager-btn:not(:disabled):hover { border-color: var(--gold); }
.page-indicator { flex: 1; display: flex; flex-direction: column; align-items: center; color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; text-align: center; line-height: 1.3; min-width: 120px; }
.page-indicator .pi-ch { color: var(--muted); font-size: 12.5px; }
.kbd-hint { display: none; }
kbd { font-family: var(--f-ui); font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--text); }

.stage { width: 100%; display: flex; justify-content: center; align-items: center; gap: 14px; }
.turn {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.03); color: var(--text); cursor: pointer; font-size: 20px; display: grid; place-items: center;
}
.turn:hover:not(:disabled) { background: rgba(255,255,255,0.08); border-color: var(--gold); }
.turn:disabled { opacity: .25; cursor: default; }

.book {
  /* Never smaller than a readable size: on short screens the page scrolls instead. */
  --w: min(1000px, calc(100vw - 150px), max(740px, calc((100vh - 262px) * 1.34)));
  width: var(--w); aspect-ratio: 1.34; position: relative;
  perspective: 2600px;
  transition: transform .9s var(--ease);
}
.book.closed-front { transform: translateX(-25%); }
.book.closed-back { transform: translateX(25%); }
.book .spine-shadow {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 60px; margin-left: -30px; z-index: 900; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.16) 45%, rgba(0,0,0,.22) 50%, rgba(0,0,0,.16) 55%, transparent);
  transition: opacity .4s;
}
.book.closed-front .spine-shadow, .book.closed-back .spine-shadow { opacity: 0; }

.leaf {
  position: absolute; top: 0; left: 50%; width: 50%; height: 100%;
  transform-origin: left center; transform-style: preserve-3d;
  transition: transform .9s var(--ease);
}
.leaf.flipped { transform: rotateY(-180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
  background: var(--paper); color: var(--ink);
}
.face.front { border-radius: 0 6px 6px 0; box-shadow: inset 14px 0 18px -14px rgba(0,0,0,.35), 6px 10px 30px rgba(0,0,0,.45); }
.face.back { transform: rotateY(180deg); border-radius: 6px 0 0 6px; box-shadow: inset -14px 0 18px -14px rgba(0,0,0,.35), -6px 10px 30px rgba(0,0,0,.45); }

/* Paper texture */
.paper {
  height: 100%; display: flex; flex-direction: column;
  padding: clamp(18px, 3.4%, 38px) clamp(20px, 6%, 48px) 14px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  font-family: var(--f-book);
}
.paper-body { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(42,32,26,.25) transparent; }
.paper-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding-top: 10px; margin-top: 6px; border-top: 1px solid rgba(42,32,26,.12);
  font-size: 12px; color: var(--ink-soft); font-family: var(--f-ui); letter-spacing: .04em;
}
.paper-foot .pf-by, .paper-foot .pf-vote { flex: 1; }
.paper-foot .pf-vote { display: flex; justify-content: flex-end; }
.paper-foot .pf-num { font-family: var(--f-book); font-size: 15px; color: var(--ink); letter-spacing: 0; }

/* Covers */
.cover {
  height: 100%; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 10%;
  background:
    radial-gradient(ellipse at 35% 25%, rgba(255,255,255,.10), transparent 55%),
    repeating-linear-gradient(35deg, rgba(0,0,0,.035) 0 2px, transparent 2px 5px),
    linear-gradient(160deg, var(--leather), var(--leather-dark));
  color: var(--gold);
}
.cover::before { content: ""; position: absolute; inset: 5%; border: 1.5px solid rgba(214,175,92,.6); border-radius: 4px; pointer-events: none; }
.cover::after { content: ""; position: absolute; inset: calc(5% + 6px); border: 1px solid rgba(214,175,92,.3); border-radius: 2px; pointer-events: none; }
.cover .eyebrow { font-family: var(--f-ui); font-size: clamp(9px, 1.1vw, 12px); letter-spacing: .38em; text-transform: uppercase; opacity: .85; }
.cover h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(30px, 5.4vw, 64px); line-height: .95; margin: .35em 0 .2em; letter-spacing: -.01em; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
.cover h1 em { display: block; font-weight: 500; font-size: .5em; letter-spacing: .02em; margin-bottom: .2em; }
.cover .rule { width: 40%; height: 1px; background: currentColor; opacity: .55; margin: 1em auto; }
.cover p { font-family: var(--f-book); font-style: italic; font-size: clamp(13px, 1.5vw, 18px); color: #e9cf95; margin: 0; max-width: 24ch; }
.cover-open {
  margin-top: 1.6em; padding: 10px 22px; border-radius: 999px; border: 1px solid rgba(214,175,92,.7);
  background: rgba(0,0,0,.18); color: var(--gold); font-family: var(--f-ui); font-size: 14px; font-weight: 600; letter-spacing: .04em; cursor: pointer;
  position: relative; z-index: 1;
}
.cover-open:hover { background: var(--gold); color: #2a0b0f; }
.cover .cover-hint { position: absolute; bottom: 9%; font-family: var(--f-ui); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; opacity: .6; }
.cover.back-cover h2 { font-family: var(--f-display); font-style: italic; font-weight: 500; font-size: clamp(18px, 2.4vw, 28px); margin: 0 0 .6em; }

/* Book typography */
.pg-eyebrow { font-family: var(--f-ui); font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--rose); margin: 0 0 6px; }
.pg-title { font-family: var(--f-display); font-weight: 700; font-size: clamp(20px, 2.5vw, 30px); line-height: 1.1; margin: 0 0 14px; color: var(--ink); }
.paper p { font-size: clamp(13.5px, 1.3vw, 16px); line-height: 1.45; margin: 0 0 10px; }
.intro-rules { list-style: none; padding: 0; margin: 12px 0 0; counter-reset: r; }
.intro-rules li { counter-increment: r; display: grid; grid-template-columns: 34px 1fr; gap: 4px; margin-bottom: 10px; font-size: clamp(13.5px, 1.3vw, 16px); line-height: 1.4; }
.intro-rules li::before { content: counter(r, upper-roman) "."; font-family: var(--f-display); font-weight: 700; color: var(--rose); }
.intro-rules strong { font-weight: 600; }

.toc-chapter { margin-bottom: 12px; }
.toc-chapter h3 { font-family: var(--f-display); font-style: italic; font-weight: 500; font-size: clamp(15px, 1.5vw, 18px); color: var(--rose); margin: 0 0 4px; }
.toc-item {
  display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 2px 0; border: 0; background: none; cursor: pointer;
  font-family: var(--f-book); font-size: clamp(13.5px, 1.3vw, 16px); color: var(--ink); text-align: left;
}
.toc-item .t { flex: none; max-width: 75%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-item .dots { flex: 1; border-bottom: 1.5px dotted rgba(42,32,26,.35); transform: translateY(-4px); min-width: 12px; }
.toc-item .n { flex: none; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.toc-item:hover .t { color: var(--rose); text-decoration: underline; text-underline-offset: 3px; }

.chapter-page { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 10%; }
.chapter-page .num { font-family: var(--f-ui); font-size: 12px; letter-spacing: .4em; text-transform: uppercase; color: var(--rose); }
.chapter-page h2 { font-family: var(--f-display); font-size: clamp(28px, 3.6vw, 46px); margin: .3em 0; line-height: 1.05; }
.chapter-page p { font-style: italic; color: var(--ink-soft); font-size: clamp(14px, 1.4vw, 18px); }
.chapter-page .orn { color: var(--rose); font-size: 22px; letter-spacing: .5em; margin-top: 10px; }

/* Play page (modelled on a printed playbook page) */
.running-head {
  display: flex; justify-content: space-between; gap: 10px; margin: -4px 0 6px;
  font-family: var(--f-cond); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
}
.pp-head { text-align: center; margin: 0 0 clamp(10px, 1.6vw, 18px); }
.pp-the {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--f-cond); font-weight: 500; text-transform: uppercase; letter-spacing: .12em;
  font-size: clamp(15px, 1.7vw, 22px); color: var(--ink); line-height: 1;
}
.pp-the-plain { gap: 0; }
.pp-flourish { width: clamp(56px, 7vw, 92px); height: auto; fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-linecap: round; opacity: .8; }
.pp-flourish.flip { transform: scaleX(-1); }
.pp-name {
  margin: 4px 0 0; font-family: var(--f-cond); font-weight: 500; text-transform: uppercase;
  font-size: clamp(24px, 3.1vw, 40px); line-height: 1; letter-spacing: .02em; color: var(--ink);
}
.pp-cap { font-size: 1.32em; line-height: .8; vertical-align: -0.04em; }
.pp-specs { width: 92%; margin: 0 auto clamp(12px, 1.8vw, 20px); border-collapse: collapse; font-family: var(--f-cond); font-size: clamp(13px, 1.3vw, 16px); line-height: 1.3; }
.pp-specs tr { border-top: 1.5px solid var(--rule); }
.pp-specs tr:last-child { border-bottom: 1.5px solid var(--rule); }
.pp-specs th { text-align: left; font-weight: 600; white-space: nowrap; padding: 7px 14px 7px 4px; vertical-align: top; width: 1%; }
.pp-specs td { font-weight: 400; padding: 7px 4px; width: 99%; }
.pp-play {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 8px;
  font-family: var(--f-cond); font-weight: 600; text-transform: uppercase; letter-spacing: .3em; font-size: clamp(14px, 1.5vw, 18px); color: var(--ink);
}
.pp-play .hand { font-family: 'Segoe UI Symbol', 'Apple Symbols', 'DejaVu Sans', serif; font-size: 1.4em; letter-spacing: 0; line-height: 1; color: var(--ink-soft); }
.pp-steps { margin: 0 0 12px; padding-left: 1.7em; font-size: clamp(14px, 1.4vw, 17px); line-height: 1.4; }
.pp-steps li { padding-left: .3em; margin-bottom: 3px; }
.pp-steps li::marker { font-family: var(--f-ui); font-weight: 500; font-size: .92em; }
.pp-why { margin: 0 0 2px; font-family: var(--f-ui); font-weight: 700; font-variant: small-caps; text-transform: lowercase; letter-spacing: .04em; font-size: clamp(14px, 1.35vw, 16.5px); color: var(--ink); }
.paper p.pp-why-text { font-size: clamp(14px, 1.4vw, 17px); line-height: 1.4; margin-bottom: 12px; }
.paper p.pp-note { font-size: clamp(11.5px, 1.05vw, 13px); line-height: 1.35; color: var(--ink); margin: 0 0 10px; padding-top: 8px; border-top: 1px solid rgba(22,20,18,.18); }
.pp-ph { color: #a39b90; font-style: italic; }
.play-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.play-tags span { font-family: var(--f-ui); font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(22,20,18,.18); color: var(--ink-soft); }
.vote {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-ui); font-size: 12px; letter-spacing: 0;
  border: 1px solid rgba(22,20,18,.25); background: transparent; color: var(--ink); border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.vote:hover { border-color: var(--rose); }
.vote.on { background: var(--rose); border-color: var(--rose); color: #fff; }
.vote:focus-visible { outline-color: var(--rose); }

.end-page { height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; padding: 12%; }
.end-page h2 { font-family: var(--f-display); font-size: clamp(22px, 2.8vw, 34px); margin: 0; }
.end-page p { color: var(--ink-soft); }
.end-page .btn { color: var(--ink); border-color: rgba(42,32,26,.3); }
.end-page .btn-gold { background: var(--rose); border-color: var(--rose); color: #fff; }
.blank-page { height: 100%; display: grid; place-items: center; color: rgba(42,32,26,.25); font-family: var(--f-display); font-style: italic; font-size: 20px; }

.empty-results { text-align: center; }

/* Single-page (mobile) mode */
.book.single { --w: min(520px, calc(100vw - 32px)); aspect-ratio: auto; height: min(calc(100dvh - 270px), 780px); min-height: 460px; perspective: none; transform: none !important; }
.book.single .spine-shadow { display: none; }
.single-page { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; box-shadow: 0 14px 40px rgba(0,0,0,.5); background: var(--paper); color: var(--ink); }
.single-page.anim-next { animation: slideNext .38s var(--ease); }
.single-page.anim-prev { animation: slidePrev .38s var(--ease); }
@keyframes slideNext { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slidePrev { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) {
  .stage .turn { display: none; }
  .reader { padding-bottom: 96px; }
  .search-row { flex-wrap: nowrap; }
  .search-box { flex: 1 1 auto; }
  .search-row .btn { padding: 8px 12px; }
  #random-play { display: none; }
  .chapter-nav { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; width: 100%; padding-bottom: 4px; scrollbar-width: none; }
  .chapter-nav::-webkit-scrollbar { display: none; }
  .pager {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; width: 100%; gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(20, 15, 14, .94);
    border-top: 1px solid var(--line); backdrop-filter: blur(8px);
  }
  .pager-btn { min-width: 0; padding: 10px 14px; }
  .kbd-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .leaf, .book, .single-page { transition: none !important; animation: none !important; }
}

/* ============ Contribute ============ */
.contribute-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 32px; align-items: start; }
.preview-col { position: sticky; top: 20px; }
.preview-col > h2 { font-family: var(--f-ui); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.preview-page { color: var(--ink); aspect-ratio: 0.66; border-radius: 6px; overflow: hidden; box-shadow: 0 14px 40px rgba(0,0,0,.5); }

.form-section { border: 0; padding: 0; margin: 0 0 8px; }
.form-section legend { font-family: var(--f-display); font-size: 20px; font-weight: 600; margin-bottom: 14px; padding: 0; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 22px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.house-rules { font-size: 14px; color: var(--muted); margin: 0 0 26px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 10px; }
.house-rules strong { color: var(--text); }
.house-rules ul { margin: 6px 0 0; padding-left: 18px; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
@media (max-width: 920px) {
  .contribute-grid { grid-template-columns: 1fr; }
  .preview-col { position: static; max-width: 440px; }
}
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }

/* ============ Lists (my plays / admin) ============ */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--text); color: var(--night); border-color: var(--text); }
.tab .n { opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat { background: var(--night-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.stat .v { font-family: var(--f-display); font-size: 30px; font-weight: 700; line-height: 1; }
.stat .k { color: var(--muted); font-size: 13px; margin-top: 6px; }


.list { display: flex; flex-direction: column; gap: 12px; }
.row { background: var(--night-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.row-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.row-title { font-family: var(--f-display); font-size: 20px; font-weight: 600; margin: 0; }
.row-sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.row-line { font-family: var(--f-display); font-style: italic; color: #e9dcc4; margin: 10px 0 0; font-size: 15px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.row-note { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: rgba(208, 96, 95, .08); border: 1px solid rgba(208, 96, 95, .3); font-size: 14px; }
.row-note b { color: #f2b5b4; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid; font-weight: 600; letter-spacing: .02em; }
.pill-pending { color: var(--warn); border-color: rgba(214, 162, 74, .5); }
.pill-approved { color: #9fd3aa; border-color: rgba(95, 154, 107, .55); }
.pill-rejected { color: var(--bad); border-color: rgba(208, 96, 95, .5); }
.pill-admin { color: var(--gold); border-color: rgba(214, 175, 92, .5); }
.row-expand { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 420px) 1fr; gap: 18px; align-items: start; }
.row-expand .preview-page { max-width: 420px; }
@media (max-width: 760px) { .row-expand { grid-template-columns: 1fr; } }
.reject-form { display: flex; flex-direction: column; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.empty h3 { font-family: var(--f-display); color: var(--text); font-size: 22px; margin: 0 0 6px; }

table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.users th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.table-wrap { overflow-x: auto; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--night); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  transition: opacity .2s, transform .2s; z-index: 2000; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.loading { color: var(--muted); text-align: center; padding: 60px 0; }
.notfound { text-align: center; padding: 80px 16px; }
.pg-title-spaced { margin-top: 14px; }
.btn-block { width: 100%; }
.lede-center { margin-inline: auto; }
.row-head .btn { margin-left: auto; }

/* Contribute form v2 */
.form-section legend { display: flex; align-items: center; gap: 10px; }
.step-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #1f160c; font-family: var(--f-ui); font-size: 14px; font-weight: 700; }
.step-list { list-style: none; margin: 4px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: s; }
.step-row { display: grid; grid-template-columns: 30px 1fr 38px; gap: 8px; align-items: start; counter-increment: s; }
.step-row::before { content: counter(s) "."; font-weight: 600; color: var(--muted); padding-top: 11px; text-align: right; }
.step-row textarea { min-height: 46px; resize: vertical; }
.step-remove { width: 38px; height: 44px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.step-remove:hover { color: var(--bad); border-color: rgba(208,96,95,.5); }
.add-step { align-self: flex-start; }
.form-extras { border-top: 1px solid var(--line); padding: 18px 0 6px; margin-bottom: 8px; }
.form-extras summary { cursor: pointer; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.form-extras summary:hover { color: var(--text); }
.jump-preview { display: none; }
@media (max-width: 920px) { .jump-preview { display: inline-flex; } }
.side-forms { display: flex; flex-direction: column; gap: 16px; }
.approve-form { display: flex; flex-direction: column; gap: 10px; }

/* Play pages scale with the page itself, like a printed page (container query units). */
.face, .single-page, .preview-page { container-type: inline-size; }
.paper-play { padding: 4.6cqw 7cqw 2.4cqw; }
.running-head { font-size: clamp(9.5px, 2.2cqw, 11.5px); margin: 0 0 1cqw; }
.pp-head { margin-bottom: 3cqw; }
.pp-the { font-size: clamp(13px, 3.8cqw, 22px); }
.pp-flourish { width: clamp(44px, 15cqw, 92px); }
.pp-name { font-size: clamp(22px, 7.4cqw, 44px); margin-top: .6cqw; }
.pp-specs { font-size: clamp(12.5px, 3.25cqw, 17px); margin-bottom: 3.4cqw; }
.pp-specs th, .pp-specs td { padding-top: .42em; padding-bottom: .42em; }
.pp-play { font-size: clamp(12px, 3.3cqw, 18px); margin-bottom: 1.6cqw; }
.pp-steps, .paper p.pp-why-text { font-size: clamp(13px, 3.45cqw, 17.5px); line-height: 1.36; }
.pp-steps { margin-bottom: 2.6cqw; }
.pp-why { font-size: clamp(12.5px, 3.3cqw, 16.5px); }
.paper p.pp-note { font-size: clamp(11px, 2.65cqw, 13.5px); }
.paper-play .paper-foot { padding-top: 1.6cqw; }

/* ============ Policy pages ============ */
.prose { max-width: 760px; }
.prose h2 { font-family: var(--f-display); font-size: 22px; font-weight: 600; margin: 34px 0 10px; }
.prose p, .prose li { font-size: 16px; line-height: 1.65; max-width: 68ch; }
.prose p { margin: 0 0 14px; }
.prose ul { padding-left: 20px; margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); font-weight: 600; }
.rules-list { padding-left: 24px; margin: 0 0 8px; }
.rules-list li { margin-bottom: 12px; padding-left: 4px; }
.rules-list li::marker { font-family: var(--f-display); font-weight: 700; color: var(--gold); }
.prose-table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 6px 0 16px; display: block; overflow-x: auto; }
.prose-table th, .prose-table td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.prose-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.prose-table td:first-child { color: var(--text); min-width: 160px; }

/* ============ Account & forms ============ */
.auth-shell { gap: 20px; }
.card-title { font-family: var(--f-display); font-size: 22px; font-weight: 600; margin: 0 0 8px; }
.card-text { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }
.card-danger { border-color: rgba(208, 96, 95, .3); }
.field-link { align-self: flex-end; font-size: 13px; margin-top: 2px; }
.check a { color: var(--gold); }

/* ============ Reporting ============ */
.pf-vote { gap: 10px; align-items: center; }
.pf-report { border: 0; background: none; padding: 4px 2px; font-family: var(--f-ui); font-size: 11.5px; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; opacity: .75; }
.pf-report:hover { opacity: 1; color: var(--rose); }
.report-dialog { width: min(480px, calc(100vw - 32px)); padding: clamp(20px, 3vw, 28px); border-radius: 14px; border: 1px solid var(--line-strong); background: var(--night-2); color: var(--text); }
.report-dialog::backdrop { background: rgba(10, 7, 6, .7); }
.report-reasons { border: 0; padding: 0; margin: 0 0 18px; gap: 10px; }
.report-reasons legend { padding: 0; margin-bottom: 8px; }
.report-reasons .check { font-size: 14.5px; }
.report-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.report-list li { padding: 10px 14px; border-radius: 8px; background: rgba(214, 162, 74, .07); border: 1px solid rgba(214, 162, 74, .25); font-size: 14px; }
.report-details { margin-top: 4px; color: #e9dcc4; white-space: pre-wrap; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ============ Advertising ============ */
.ad-slot { width: min(970px, calc(100% - 32px)); margin: 8px auto 28px; text-align: center; }
.ad-label { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ad-unit { display: block; min-height: 90px; }
/* Collapse the space when Google has no ad to show, or an ad blocker removed it. */
.ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; }
