:root {
  --wine: #962d47;
  --dark: #392a25;
  --soft: #725d52;
  --line: #d7b8a2;
  --ivory: #fffaf1;
  --serif:
    "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif CJK SC", "Songti SC", "SimSun",
    serif;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--dark);
  background: #f1e6d8;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: clamp(9px, 2.1vw, 32px);
  min-height: 100svh;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.62;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #b16a35;
  outline-offset: 4px;
}
.paper {
  max-width: 1550px;
  margin: auto;
  min-height: calc(100svh - 4vw);
  border: 1px solid #b98978;
  border-radius: 22px;
  background: #fbf6ed url(art/stationery.webp) center center/100% 100% no-repeat;
  box-shadow: 0 4px 24px #7d4f3018;
  display: flex;
  flex-direction: column;
  position: relative;
}
header,
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
header {
  padding: 24px clamp(20px, 4vw, 66px) 14px;
}
.wordmark {
  font: clamp(31px, 3.5vw, 53px) / 1.1 var(--serif);
  color: var(--wine);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.wordmark span {
  font: 13px/1.5 var(--serif);
  color: var(--soft);
  margin-left: 15px;
  letter-spacing: 0.15em;
  border-left: 1px solid var(--line);
  padding-left: 15px;
}
.textbtn,
.link {
  background: #fffbf1db;
  border: 0;
  color: var(--wine);
  padding: 8px 12px;
  border-radius: 8px;
}
.textbtn:hover,
.link:hover {
  text-decoration: underline;
}
main {
  width: 100%;
  max-width: 1280px;
  padding: 24px clamp(20px, 5vw, 78px) 38px;
  margin: auto;
  flex: 1;
}
footer {
  font-size: 12px;
  color: var(--soft);
  padding: 10px clamp(18px, 4vw, 55px);
  background: #fbf4e8d9;
  border-radius: 0 0 22px 22px;
}
footer .textbtn {
  font-size: 12px;
  background: none;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3,
.prompt,
.reply {
  font-family: var(--serif);
}
h1 {
  font-size: clamp(32px, 4.1vw, 61px);
  font-weight: 500;
  letter-spacing: 0.025em;
  line-height: 1.24;
}
h2 {
  font-size: clamp(23px, 2.4vw, 34px);
  line-height: 1.35;
  font-weight: 500;
}
h3 {
  font-size: 21px;
}
.small {
  font-size: 14px;
  color: var(--soft);
  line-height: 1.6;
}
.quiet {
  font-size: 14px;
  line-height: 1.7;
  color: var(--soft);
  margin-top: 13px;
}
.home {
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  align-items: center;
  gap: clamp(12px, 4vw, 58px);
  min-height: min(64vh, 650px);
}
.entry {
  padding: 14px 0;
}
.entry h1 {
  max-width: 9em;
}
.entry form {
  margin-top: 26px;
}
.entry textarea {
  height: 112px;
}
textarea,
input:not([type="checkbox"]),
select {
  border: 1px solid #bd9f87;
  border-radius: 9px;
  background: #fffaf3ee;
  padding: 12px 14px;
  outline: 0;
  width: 100%;
  min-width: 0;
}
textarea {
  resize: vertical;
  min-height: 70px;
  line-height: 1.65;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--wine);
  box-shadow: 0 0 0 2px #af52652b;
}
.primary,
.secondary {
  border: 1px solid var(--wine);
  border-radius: 9px;
  padding: 12px 23px;
  min-height: 45px;
}
.primary {
  background: var(--wine);
  color: #fff9ee;
}
.primary:hover {
  background: #81253b;
}
.secondary {
  background: #fff9f1e8;
  color: var(--wine);
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.fan {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: clamp(245px, 30vw, 390px);
  display: grid;
  place-items: center;
}
.fan img {
  position: absolute;
  width: 38%;
  max-height: 90%;
  object-fit: cover;
  aspect-ratio: 0.58;
  border: 8px double #d1b297;
  border-radius: 9px;
  box-shadow: 0 12px 24px #563c2636;
  background: #f9eddb;
}
.fan img:first-child {
  transform: translate(-60%, 8%) rotate(-15deg);
}
.fan img:nth-child(2) {
  transform: translate(59%, 6%) rotate(15deg);
}
.fan img:last-child {
  transform: rotate(-3deg);
}
.board .fan { overflow: clip; }
.board .fan img {
  height: 66%;
  width: auto;
  max-height: none;
  max-width: 27%;
  border-width: 5px;
}
.header-tools { display:flex; align-items:center; justify-content:flex-end; gap:4px; flex-wrap:wrap }
.sound-toggle { font-size:14px; white-space:nowrap }
.centering { max-width:34em; margin:16px 0 0; padding-left:14px; border-left:2px solid var(--line); font-family:var(--serif); font-size:18px; line-height:1.65; background:#fff9efdb }
@media(max-width:700px){
  header .header-tools {gap:1px}
  header .header-tools button {font-size:13px;padding:8px 5px}
  header .wordmark {white-space:nowrap}
  header .wordmark span {display:none}
  .centering {font-size:17px}
}
.pagehead {
  margin: 4px 0 22px;
}
.pagehead h1 {
  font-size: clamp(30px, 3.5vw, 46px);
  margin: 5px 0;
}
.board,
.accountbox {
  background: #fffaf2ed;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(15px, 2.4vw, 30px);
}
.board {
  max-width: 960px;
  margin: auto;
}
.board .prompt {
  max-width: 900px;
  overflow-wrap: anywhere;
  font-size: 21px;
  line-height: 1.5;
}
.slots {
  display: flex;
  justify-content: center;
  gap: clamp(7px, 2vw, 24px);
  margin: 20px auto;
}
.slot,
.face {
  min-width: 0;
  flex: 1;
  max-width: 160px;
  text-align: center;
  background: #fff8ec;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px;
  color: var(--dark);
}
.slot {
  min-height: 112px;
  border-style: dashed;
  display: grid;
  place-content: center;
  gap: 5px;
}
.slot strong,
.role {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--wine);
}
.slot small,
.face small {
  display: block;
  font-size: 13px;
}
.face img {
  width: 100%;
  aspect-ratio: 0.59;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: block;
  margin: 5px 0;
}
.face span {
  display: block;
}
.face .name {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.3;
}
.face .rev {
  transform: rotate(180deg);
}
.deck {
  display: flex;
  overflow-x: auto;
  scrollbar-color: #b98575 #f7eadb;
  padding: 12px 7px 16px;
  align-items: center;
}
.back {
  border: 4px double #e6c9ac;
  border-radius: 8px;
  color: #fce8be;
  background:
    repeating-linear-gradient(45deg, transparent 0 9px, #c5887940 10px 11px),
    #92394b;
  box-shadow: 0 4px 9px #55301b25;
  flex: none;
  width: 76px;
  height: 115px;
  margin-right: -42px;
  transition: transform 0.18s;
}
.back:last-child {
  margin-right: 0;
}
.back:hover,
.back:focus-visible {
  transform: translateY(-7px);
}
.back:disabled {
  opacity: 0.25;
}
.back span {
  font-size: 24px;
}
.flip {
  width: 100%;
  height: auto;
  aspect-ratio: 0.59;
  margin: 4px 0;
}
.fold {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.shuffle .back {
  animation: shuffle 0.48s ease;
}
@keyframes shuffle {
  50% {
    transform: translateX(9px) rotate(4deg);
  }
}
.reading {
  display: grid;
  grid-template-columns: minmax(155px, 24%) 1fr;
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
}
.margin {
  border-right: 1px solid var(--line);
  padding: 12px 22px 22px 0;
  min-height: 180px;
}
.margin .prompt {
  margin-top: 14px;
  font-size: 23px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  background: #fff6eac9;
  border-radius: 5px;
}
.role {
  display: inline-block;
  padding: 3px 12px;
  background: #f5e4d8;
  border-radius: 16px;
  font-size: 16px;
}
.reply {
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: clamp(20px, 2.1vw, 28px);
  line-height: 1.67;
}
.letter {
  padding: clamp(16px, 2.1vw, 30px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2eb;
}
.letter .slots {
  justify-content: flex-start;
}
.thread {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 17px;
}
.thread .reply {
  font-size: 20px;
}
.follow {
  display: flex;
  gap: 9px;
}
.follow input {
  flex: 1;
}
.follow .primary {
  white-space: nowrap;
}
.memo {
  color: var(--wine);
  margin-bottom: 9px;
  font-weight: 600;
}
.error {
  color: #8b2839;
  margin: 10px 0;
  line-height: 1.6;
}
.accountbox {
  max-width: 520px;
  margin: 15px auto;
}
.accountbox h1 {
  font-size: 31px;
}
.accountbox label,
dialog label {
  display: block;
  margin: 16px 0 5px;
}
.check {
  display: flex !important;
  align-items: center;
  gap: 6px;
}
.row {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 8px;
}
.row input {
  margin: 0;
}
.full {
  width: 100%;
  margin-top: 15px;
}
.subactions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}
.subactions .link {
  padding: 7px 0;
}
.topgap {
  margin-top: 16px;
}
.status {
  padding: 10px 0;
  color: var(--soft);
  line-height: 1.6;
}
.pending {
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.57;
  }
}
dialog {
  width: min(460px, 92vw);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 32px 24px 23px;
  box-shadow: 0 12px 70px #311c2740;
  background: #fff9ef;
  color: var(--dark);
}
dialog::backdrop {
  background: #2d1e1b62;
}
dialog p {
  line-height: 1.7;
  margin-top: 12px;
}
.close {
  position: absolute;
  right: 8px;
  top: 4px;
  font-size: 26px;
  border: 0;
  background: none;
  color: var(--wine);
}
#notice:not(:empty) {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 9px;
  background: #4c3330;
  color: white;
  max-width: 90vw;
  z-index: 9;
}
@media (max-width: 700px) {
  body {
    padding: 6px;
  }
  .paper {
    min-height: calc(100svh - 12px);
    border-radius: 17px;
    background-size: auto 100%;
    background-position: 53% center;
  }
  header {
    padding: 18px 15px 12px;
  }
  .wordmark span {
    margin-left: 8px;
    padding-left: 8px;
    font-size: 12px;
  }
  .textbtn {
    font-size: 14px;
  }
  main {
    padding: 12px 12px 27px;
  }
  .home {
    display: flex;
    flex-direction: column-reverse;
    gap: 0;
    min-height: 0;
  }
  .fan {
    height: clamp(147px, 38vw, 220px);
    max-width: 360px;
  }
  .fan img {
    width: 25%;
    border-width: 5px;
  }
  .entry {
    width: 100%;
    padding: 13px 3px;
  }
  .entry h1 {
    font-size: 34px;
    max-width: none;
  }
  .entry form {
    margin-top: 15px;
  }
  .entry textarea {
    height: 93px;
  }
  .entry .primary {
    width: 100%;
  }
  .reading {
    display: block;
  }
  .margin {
    border: 1px solid var(--line);
    min-height: 0;
    padding: 10px 13px;
    margin-bottom: 12px;
    border-radius: 11px;
    background: #fff8ece6;
  }
  .margin .prompt {
    margin-top: 3px;
    font-size: 20px;
    background: none;
  }
  .slots {
    gap: 5px;
  }
  .face {
    padding: 4px;
  }
  .face .name {
    font-size: 14px;
  }
  .role {
    font-size: 14px;
    padding: 2px 7px;
  }
  .letter {
    padding: 14px 10px;
  }
  .follow {
    flex-direction: column;
  }
  .reply {
    font-size: 21px;
  }
  .fold {
    align-items: flex-start;
  }
  .slot {
    min-height: 75px;
  }
  .board {
    padding: 13px 9px;
  }
  .board .prompt {
    font-size: 18px;
  }
  .reading + .actions {
    justify-content: center;
  }
  .back {
    margin-right: -33px;
  }
  .face .flip {
    margin-right: 0;
  }
  .row {
    grid-template-columns: 98px 1fr;
  }
  footer {
    font-size: 11px;
  }
  .quiet {
    font-size: 13px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.deck .back {
  margin-right: -26px;
}
.deck .back:last-child {
  margin-right: 0;
}
.more {
  margin-top: 14px;
  color: var(--wine);
}
.more summary {
  cursor: pointer;
  font-size: 15px;
  padding: 6px 0;
}
.more .reply {
  font-size: clamp(18px, 1.5vw, 22px);
  color: var(--dark);
  margin: 12px 0;
}

.question-preview {
  display: block;
  border: 0;
  background: transparent;
  text-align: left;
  font: 20px/1.45 var(--serif);
  padding: 3px 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.question-preview:hover {
  text-decoration: underline;
  text-decoration-color: var(--line);
}
.mini-back,
.travelling {
  display: grid;
  place-items: center;
  background-color: #92394b;
  color: #fce8be;
  border: 3px double #e4bda2;
  border-radius: 5px;
}
.mini-back {
  width: 24px;
  height: 33px;
  margin: 2px auto;
}
.travelling {
  position: fixed;
  top: 0;
  left: 0;
  width: 66px;
  height: 94px;
  pointer-events: none;
  z-index: 6;
  font-size: 24px;
}
.chapters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}
.chapter {
  border: 1px solid var(--line);
  background: #fffaf3;
  padding: 8px 16px;
  border-radius: 22px;
}
.chapter[aria-pressed="true"] {
  background: var(--wine);
  color: white;
  border-color: var(--wine);
}
.annotation {
  display: grid;
  grid-template-columns: minmax(110px, 20%) 1fr;
  align-items: center;
  gap: clamp(14px, 2vw, 36px);
}
.illustration .face {
  display: block;
  margin: auto;
  width: 100%;
  max-width: 125px;
}
.annotation .reply {
  font-size: clamp(18px, 1.6vw, 23px);
  line-height: 1.65;
  margin-top: 8px;
}
.summary-cards {
  display: flex;
  gap: 3px;
}
.summary-cards .face {
  padding: 2px;
}
.summary-cards .face .name,
.summary-cards .face small {
  font-size: 12px;
}
.summary-cards .face .role {
  font-size: 12px;
  padding: 2px;
}
@media (min-width: 701px) {
  body {
    --edge: clamp(6px, 1.35vh, 15px);
    padding: var(--edge);
  }
  .paper {
    min-height: calc(100dvh - 2 * var(--edge));
  }
  body:is(
      [data-screen="shuffle"],
      [data-screen="table"],
      [data-screen="reading"]
    )
    header {
    padding-block: clamp(5px, 1.4vh, 14px);
  }
  body:is(
      [data-screen="shuffle"],
      [data-screen="table"],
      [data-screen="reading"]
    )
    main {
    padding-block: clamp(6px, 1.7vh, 18px);
    min-width: 0;
  }
  body:is(
      [data-screen="shuffle"],
      [data-screen="table"],
      [data-screen="reading"]
    )
    footer {
    padding-block: 2px;
  }
  .board {
    padding: clamp(12px, 2.2vh, 24px);
  }
  .board .fan {
    height: clamp(100px, 33dvh, 315px);
    margin: auto;
  }
  .board .pagehead {
    margin: 0 0 8px;
  }
  .board .slots {
    margin: clamp(6px, 1.7vh, 17px) auto;
  }
  .board .slots .face {
    max-width: clamp(80px, 15vh, 146px);
  }
  .board .slot {
    min-height: clamp(55px, 12vh, 105px);
  }
  .board .deck {
    padding-block: 8px;
  }
  .board .deck .back {
    height: clamp(70px, 14vh, 115px);
  }
  .board .error:empty {
    display: none;
  }
  .board .quiet {
    margin-top: 5px;
  }
}
@media (max-width: 700px) {
  .annotation {
    grid-template-columns: 1fr;
  }
  .illustration .face {
    max-width: 93px;
  }
  .summary-cards {
    max-width: 220px;
    margin: auto;
  }
  .chapters {
    gap: 4px;
  }
  .chapter {
    flex: 1;
    padding: 7px 4px;
  }
  .annotation .reply {
    font-size: 19px;
  }
}
@media(min-width:701px) and (max-height:760px){
  .annotated .illustration>.face{max-width:clamp(76px,13vh,102px);padding:4px}
  .annotated .annotation{gap:18px;grid-template-columns:minmax(106px,16%) 1fr}
  .annotated .annotation h2{font-size:24px}
  .annotated .annotation .reply{font-size:18px;line-height:1.55;max-height:36dvh;overflow:auto}
  .annotated .chapters{margin:5px 0 10px}
  .annotated .actions,.annotated .thread{margin-top:8px}
  .annotated .illustration .role{padding:1px 8px}
  .annotated .summary-cards{flex-direction:column}
  .annotated .summary-cards .face{display:grid;grid-template-columns:28px 1fr;align-items:center;max-width:125px;width:100%;min-height:40px}
  .annotated .summary-cards .face img{grid-row:1/4;grid-column:1;width:24px;margin:0}
  .annotated .summary-cards .face span,.annotated .summary-cards .face small{grid-column:2}
}
@media(min-width:701px) and (max-height:760px){
  .annotated .pagehead{display:flex;align-items:center;gap:12px}
  .annotated .pagehead .small{flex:none}
  .annotated .question-preview{min-width:0}
  .annotated:has(.summary-cards) .annotation .reply{max-height:29dvh}
}
@media(min-width:701px) and (max-height:760px){
  body[data-screen=reading]:has(.annotated) .paper{height:calc(100dvh - 2 * var(--edge))}
  body[data-screen=reading]:has(.annotated) main{min-height:0;display:flex;flex-direction:column}
  .annotated{display:flex;flex-direction:column;width:100%;max-height:100%;min-height:0}
  .annotated .annotation{flex:0 1 auto;min-height:0;overflow-y:auto;align-items:start}
  .annotated .annotation .reply{overflow:visible;max-height:none}
  .annotated>.link{align-self:start}
  .annotated .thread:has(.memo){max-height:26dvh;overflow:auto}
  .annotated .error:empty{display:none}
}
#language{width:auto;max-width:7em;padding:5px 7px;border-radius:8px;font-size:14px;flex:none}
html[lang=en] .home h1{max-width:14em}
html[lang=en] .chapters{row-gap:5px}
html[lang=en] .face .name{overflow-wrap:anywhere}
@media(max-width:700px){html[lang=en] header{flex-wrap:wrap;gap:6px}html[lang=en] .header-tools{margin-left:auto}html[lang=en] .chapter{font-size:13px}}
