/* 地支藏干 · 十二间房 —— 绘画本样式（只作用于本页） */
:root {
  --ink: #2d2a26;
  --paper: #f7f0df;
  --card: #fffaf0;
  --margin-red: rgba(196, 83, 74, 0.55);
  --wood: #7fa36b;
  --fire: #c96b4b;
  --earth: #b58b5a;
  --metal: #b9a45e;
  --water: #6f93a8;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", "Songti SC", "Noto Serif SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--kai);
  font-size: 17px;
  line-height: 1.6;
  background: #e7dcc4;
  overflow-x: hidden;
}

.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;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 3px dashed var(--fire); outline-offset: 3px; }

/* ---------- 画纸 ---------- */
.book {
  position: relative;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 22px 28px 56px 62px;
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(45, 42, 38, 0.13) 1px, transparent 1.4px),
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.5), transparent 40%);
  background-size: 20px 20px, 100% 100%;
  box-shadow: 0 0 0 1px rgba(45, 42, 38, 0.08), 0 10px 30px rgba(60, 40, 20, 0.12);
  min-height: 100vh;
}
.book::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 40px;
  width: 2px;
  background: var(--margin-red);
}

.book-head { position: relative; max-width: 900px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 15px; }
.crumbs a { color: var(--ink); text-decoration: underline; text-decoration-style: wavy; text-decoration-color: rgba(201, 107, 75, 0.6); text-underline-offset: 4px; min-height: 32px; display: inline-flex; align-items: center; }
h1 {
  margin: 8px 0 4px;
  font-size: clamp(2.1rem, 5.4vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
}
h1::after {
  content: "";
  display: block;
  width: min(360px, 70%);
  height: 6px;
  margin-top: 4px;
  background: radial-gradient(ellipse at center, rgba(45, 42, 38, 0.55) 0 40%, transparent 70%) 0 0 / 14px 6px repeat-x;
  opacity: 0.6;
}
.lead { margin: 6px 0 14px; font-size: 1.08rem; max-width: 46em; }

/* ---------- 页签 ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 6px 0 18px; }
.tab {
  min-height: 44px;
  padding: 6px 14px 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px 12px 4px 4px;
  background: #f1e6cd;
  cursor: pointer;
  font-size: 1.02rem;
  transition: transform 0.15s, background 0.15s;
}
.tab:hover { background: #fbf2dc; }
.tab.on { background: #fff3cf; transform: translateY(-3px); box-shadow: 0 3px 0 var(--ink); }
.tab-no {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.8rem;
  font-family: var(--sans);
}

/* ---------- 版面 ---------- */
.spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 28px;
  align-items: start;
}
.stage-col { min-width: 0; }

.window {
  position: relative;
  height: clamp(400px, 66vh, 700px);
  border: 3px solid var(--ink);
  border-radius: 8px 14px 10px 16px;
  background: #f3ead6;
  box-shadow: 5px 6px 0 rgba(45, 42, 38, 0.13);
}
.stage { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.stage canvas { display: block; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.tape {
  position: absolute;
  z-index: 2;
  width: 104px; height: 28px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0 6px, transparent 6px 12px), rgba(127, 163, 107, 0.62);
  pointer-events: none;
}
.tape-l { top: -13px; left: 22px; transform: rotate(-5deg); }
.tape-r { top: -11px; right: 26px; transform: rotate(4deg); background-color: rgba(185, 164, 94, 0.66); }
.drag-hint {
  position: absolute;
  left: 50%; bottom: 10px;
  transform: translateX(-50%);
  margin: 0;
  padding: 2px 12px;
  max-width: calc(100% - 24px);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.86);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.caption {
  position: absolute;
  left: 12px; right: 12px; bottom: 10px;
  z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  width: fit-content; max-width: calc(100% - 24px);
  margin: 0 auto;
  padding: 4px 14px;
  border: 2px solid var(--ink);
  border-radius: 12px 8px 14px 10px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 2px 3px 0 rgba(45, 42, 38, 0.15);
}
.caption b { font-size: 1.6rem; line-height: 1.2; }
.caption .cap-kind { font-size: 0.95rem; }
.caption .cap-eq { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.04em; }
.caption .cap-more { display: none; }
.no-webgl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 12px; }
.btn {
  min-height: 44px;
  padding: 6px 16px;
  border: 2px solid var(--ink);
  border-radius: 10px 6px 12px 8px;
  background: var(--card);
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(45, 42, 38, 0.18);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 3px 4px 0 rgba(45, 42, 38, 0.2); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(45, 42, 38, 0.2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.on { background: #fff3cf; }
.btn.good { background: #e3efd8; }

/* ---------- 房间按钮 ---------- */
.room-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.season-col { min-width: 0; padding: 8px; border: 2px dashed rgba(45, 42, 38, 0.35); border-radius: 12px; background: rgba(255, 250, 240, 0.55); }
.season-col h3 { margin: 0 0 6px; font-size: 1.1rem; display: flex; align-items: center; gap: 6px; }
.season-col .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); }
.season-春 .dot { background: var(--wood); }
.season-夏 .dot { background: var(--fire); }
.season-秋 .dot { background: var(--metal); }
.season-冬 .dot { background: var(--water); }
.room-btn {
  display: flex;
  width: 100%;
  align-items: baseline;
  gap: 8px;
  min-height: 46px;
  margin-top: 6px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  text-align: left;
}
.room-btn b { font-size: 1.5rem; line-height: 1.1; }
.room-btn small { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.room-btn[aria-pressed="true"] { background: #fff3cf; }
.room-btn.selected { box-shadow: inset 0 0 0 2px var(--ink), 2px 3px 0 rgba(45, 42, 38, 0.25); }
.room-btn.found { background: #e3efd8; }
.room-btn.stamped b::after { content: "印"; margin-left: 4px; padding: 0 3px; font-size: 0.7rem; color: #fff; background: #c0473a; border-radius: 3px; vertical-align: super; }

/* ---------- 纸条 ---------- */
.notes { display: grid; gap: 18px; min-width: 0; }
.note {
  position: relative;
  min-width: 0;
  padding: 16px 16px 14px;
  border: 2px solid var(--ink);
  border-radius: 4px 14px 6px 12px;
  background: var(--card);
  box-shadow: 4px 5px 0 rgba(45, 42, 38, 0.1);
  overflow-wrap: anywhere;
}
.page-note { transform: rotate(-0.5deg); }
.page-note::before {
  content: "";
  position: absolute;
  top: -12px; left: 50%;
  width: 86px; height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(201, 107, 75, 0.45);
}
.note h2 { margin: 0 0 8px; font-size: 1.32rem; line-height: 1.35; }
.points { margin: 0; padding-left: 1.2em; }
.points li { margin: 4px 0; }
.hint { margin: 10px 0 0; padding: 6px 10px; border-left: 4px solid var(--metal); background: rgba(185, 164, 94, 0.14); }
.muted { color: #6b6257; }
.small { font-size: 0.85rem; }

.room-kicker { margin: 0; font-size: 0.95rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.season-chip { display: inline-block; padding: 0 8px; border: 2px solid var(--ink); border-radius: 999px; font-weight: 700; }
.season-chip.season-春 { background: rgba(127, 163, 107, 0.4); }
.season-chip.season-夏 { background: rgba(201, 107, 75, 0.35); }
.season-chip.season-秋 { background: rgba(185, 164, 94, 0.45); }
.season-chip.season-冬 { background: rgba(111, 147, 168, 0.4); }
.room-note h2 { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 400; margin-top: 4px; }
.big-branch {
  display: inline-grid; place-items: center;
  width: 58px; height: 58px;
  border: 3px solid var(--ink); border-radius: 10px;
  font-size: 2.3rem; font-weight: 700; line-height: 1;
  background: #fff3cf;
}
.line { margin: 6px 0 10px; font-size: 1.08rem; }
.tenants { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tenant { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px; border-radius: 10px; }
.tenant.main { background: rgba(255, 243, 207, 0.8); }
.tenant img { width: 56px; height: 56px; }
.tenant p { margin: 0; }
.t-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.t-stem { font-size: 1.6rem; line-height: 1; }
.t-name { font-size: 0.95rem; }
.chip { font-family: var(--sans); font-size: 0.75rem; padding: 0 7px; border-radius: 999px; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
.role { font-size: 0.85rem; padding: 0 7px; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; }
.role-main { background: #fff3cf; }
.role-birth { background: #fde7d9; }
.role-tail { background: #e6efd9; }
.role-tomb { background: #e0e7ee; }
.t-why { font-size: 0.95rem; color: #4d463d; }
.hidden-tenant b { font-size: 1.6rem; margin-right: 8px; }
.formula { margin-top: 12px; padding: 10px 12px; border: 2px dashed var(--ink); border-radius: 10px; background: #fff3cf; }
.formula p { margin: 0; }
.formula .rule { font-size: 0.95rem; }
.formula .concrete { font-size: 1.45rem; font-weight: 700; letter-spacing: 0.06em; }

.cast-note h2 { font-size: 1.15rem; }
.cast-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.cast-btn {
  display: grid; justify-items: center; gap: 0;
  min-width: 0; min-height: 44px;
  padding: 4px 2px;
  border: 2px solid transparent; border-radius: 10px;
  background: none; cursor: pointer;
}
.cast-btn:hover { border-color: rgba(45, 42, 38, 0.35); }
.cast-btn.on { border-color: var(--ink); background: #fff3cf; }
.cast-btn img { width: 48px; height: 48px; max-width: 100%; }
.cast-btn span { font-size: 1.1rem; line-height: 1.1; text-align: center; }
.cast-btn small { display: block; font-size: 0.72rem; }
.cast-result { margin: 8px 0 0; font-size: 0.95rem; }
.link-btn { border: 0; background: none; padding: 0 2px; text-decoration: underline; cursor: pointer; min-height: 32px; }

.quiz-modes { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.quiz-card { padding: 12px; border: 2px solid var(--ink); border-radius: 12px; background: #fff3cf; }
.quiz-q { margin: 0; font-size: 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.quiz-q b { font-size: 1.6rem; }
.quiz-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stamps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.stamp {
  display: grid; place-items: center;
  aspect-ratio: 1;
  border: 2px dashed rgba(45, 42, 38, 0.4); border-radius: 50%;
  font-size: 1.1rem; color: rgba(45, 42, 38, 0.45);
}
.stamp.got { border: 3px solid #c0473a; color: #fff; background: #c0473a; transform: rotate(-8deg); }

.caveat { margin: 0; font-size: 0.86rem; color: #6b6257; padding: 0 4px; }

.page-no {
  position: absolute;
  right: 28px; bottom: 16px;
  font-size: 1.15rem;
  transform: rotate(-2deg);
  border-bottom: 2px solid var(--ink);
}

/* ---------- 适配 ---------- */
@media (max-width: 1100px) {
  .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .spread { grid-template-columns: minmax(0, 1fr); }
  .notes { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .notes .caveat { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .book { padding: 14px 12px 56px 28px; }
  .book::before { left: 16px; }
  .window { height: min(108vw, 62vh); min-height: 320px; }
  .caption { padding: 2px 10px; }
  .caption b { font-size: 1.35rem; }
  .caption .cap-eq { font-size: 1.1rem; }
  .caption .cap-more { display: inline-flex; align-items: center; }
  .notes { grid-template-columns: minmax(0, 1fr); }
  .tab { padding: 4px 10px 4px 8px; font-size: 0.95rem; }
  .tape { width: 76px; }
}
@media (max-width: 380px) {
  .room-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .season-col { padding: 6px; }
  .cast-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .cast-btn small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .tab.on { transform: none; }
}
