/* ===== 字体（本地文件，不依赖外网） ===== */
@font-face {
  font-family: "HisSerif";
  src: url("../fonts/serif-regular.woff") format("woff");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "HisSerif";
  src: url("../fonts/serif-bold.woff") format("woff");
  font-weight: 700; font-display: swap;
}

/* ===== 颜色：想换配色就改这里 ===== */
:root {
  --paper: #f1e6cd;
  --paper-2: #e8d9b8;
  --desk: #3a2c20;
  --ink: #2a1f16;
  --ink-2: #5b4532;
  --faded: #8c7559;
  --line: #b49a74;
  --red: #a5301c;
  --red-soft: rgba(165, 48, 28, .12);
  --lamp: #e7a33a;
  --serif: "HisSerif", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--desk);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
b { font-weight: 700; }

/* 纸张：底色 + 噪点 + 边缘发黄 */
#book {
  max-width: 520px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 40%, rgba(255,250,235,.55), transparent 70%);
  box-shadow: 0 0 60px rgba(0,0,0,.5);
  position: relative;
}
#book::before, #book::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 18px; pointer-events: none;
  background: linear-gradient(90deg, rgba(120,85,40,.18), transparent);
}
#book::before { left: 0; }
#book::after { right: 0; transform: scaleX(-1); }

/* ===== 顶部进度条 + 年份 ===== */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; }
.progress i { display: block; height: 100%; width: 0; background: var(--red); transition: width .15s linear; }
.year-chip {
  position: fixed; top: 12px; right: max(12px, calc(50% - 248px)); z-index: 50;
  font-size: 13px; letter-spacing: .1em; color: var(--paper);
  background: var(--ink); padding: 2px 10px; border-radius: 2px;
  opacity: 0; transform: translateY(-6px); transition: .4s;
}
.year-chip.show { opacity: .88; transform: none; }

/* ===== 每一段 ===== */
.sec {
  min-height: 100vh; min-height: 100svh;
  padding: 72px 28px 64px;
  position: relative;
  border-bottom: 1px dashed var(--line);
}
.sec > p { margin: 14px 0; }

.chap { text-align: center; margin-bottom: 26px; }
.chap-no { display: block; font-size: 13px; letter-spacing: .5em; color: var(--faded); }
.chap-year { display: block; font-size: 52px; line-height: 1.15; font-weight: 700; letter-spacing: .02em; }
.chap-year em { font-style: normal; color: var(--faded); margin: 0 4px; font-weight: 400; }
.chap-title {
  display: inline-block; margin-top: 8px; font-size: 24px; letter-spacing: .6em; padding-left: .6em;
  border-top: 1px solid var(--ink-2); border-bottom: 1px solid var(--ink-2); line-height: 1.8;
}
.red { color: var(--red); font-weight: 700; }
.note { font-size: 12px; color: var(--faded); text-align: center; margin-top: 6px; }

/* ===== 出场动画 ===== */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .9s ease, transform .9s ease; transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
.slow .reveal { transition-duration: 1.8s; }

/* ===== 封面 ===== */
.cover { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-top: 48px; }
.cover-top { position: absolute; top: 24px; left: 28px; right: 28px; display: flex; justify-content: space-between; font-size: 12px; color: var(--faded); letter-spacing: .2em; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.cover-title {
  writing-mode: vertical-rl; text-orientation: upright;
  font-size: 46px; line-height: 1.35; letter-spacing: .12em; font-weight: 700;
  display: flex; gap: 4px; margin: 10px 0 22px;
}
.cover-title span:last-child { color: var(--red); }
.seal {
  font-size: 13px; line-height: 1.3; letter-spacing: .15em; color: var(--red);
  border: 2px solid var(--red); padding: 6px 6px 6px 8px; border-radius: 4px;
  transform: rotate(-6deg); margin-bottom: 24px; opacity: .85;
}
.seal.in { transform: rotate(-6deg); }
.cover-lead { font-size: 16px; color: var(--ink-2); line-height: 2; }
.scroll-hint { position: absolute; bottom: 30px; left: 0; right: 0; font-size: 13px; color: var(--faded); letter-spacing: .2em; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.arrow { width: 12px; height: 12px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px) rotate(45deg); } }

/* ===== 大数字 ===== */
.big-num { text-align: center; margin: 24px 0 18px; }
.big-num .num { font-size: 88px; font-weight: 700; line-height: 1; color: var(--red); }
.big-num .unit { font-size: 22px; margin-left: 4px; }
.big-num small { display: block; font-size: 13px; letter-spacing: .3em; color: var(--faded); margin-top: 4px; }

/* ===== 照片占位 ===== */
.photo { margin: 30px auto 6px; width: 86%; background: #fbf5e6; padding: 10px 10px 4px; box-shadow: 0 3px 10px rgba(60,40,20,.22); position: relative; }
.photo::before { /* 胶带 */
  content: ""; position: absolute; top: -10px; left: 50%; width: 76px; height: 20px; margin-left: -38px;
  background: rgba(210,190,140,.65); transform: rotate(-3deg);
}
.photo.tilt-r { transform: rotate(1.6deg); }
.photo.tilt-l { transform: rotate(-1.6deg); }
.photo.reveal:not(.in) { transform: translateY(22px); }
.ph { aspect-ratio: 4 / 3; border: 1.5px dashed var(--line); display: flex; align-items: center; justify-content: center; text-align: center; color: var(--faded); font-size: 14px; line-height: 1.6; background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(150,120,80,.06) 10px 20px); }
.photo img { display: block; width: 100%; height: auto; }  /* 保持原比例，不裁切、不加滤镜 */
.photo figcaption { font-size: 12px; text-align: center; color: var(--ink-2); padding: 6px 0 4px; line-height: 1.6; }
.photo figcaption small, .badge-real small { display: block; font-size: 10.5px; color: var(--faded); }
.ph small { font-size: 11px; }
.badge-real { margin: 14px auto 2px; width: 140px; text-align: center; }
.badge-real img { display: block; width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; }
.badge-real figcaption { font-size: 12px; color: var(--ink-2); margin-top: 6px; line-height: 1.6; }

/* ===== 小时间线 ===== */
.mini-tl { list-style: none; margin: 20px 0; border-left: 1.5px solid var(--ink-2); padding-left: 18px; }
.mini-tl li { position: relative; margin: 12px 0; font-size: 16px; }
.mini-tl li::before { content: ""; position: absolute; left: -24px; top: .72em; width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink-2); }
.mini-tl time { display: block; font-size: 13px; color: var(--red); letter-spacing: .08em; line-height: 1.4; }
.mini-tl .home-li::before { background: var(--red); border-color: var(--red); }

/* ===== 印章：停办 / 复校 ===== */
.stamps { position: relative; height: 110px; margin: 10px 0; }
.stamp {
  position: absolute; top: 18px; font-size: 26px; font-weight: 700; letter-spacing: .2em;
  padding: 6px 14px 6px 18px; border: 3px solid; border-radius: 6px; opacity: 0;
}
.stamp-stop { left: 12%; color: var(--ink-2); border-color: var(--ink-2); transform: rotate(-8deg) scale(1.8); }
.stamp-go { right: 12%; color: var(--red); border-color: var(--red); transform: rotate(6deg) scale(1.8); }
.stamps.in .stamp-stop { animation: stampIn .5s .3s forwards, fadeStop 1s 1.8s forwards; }
.stamps.in .stamp-go { animation: stampIn2 .5s 1.6s forwards; }
@keyframes stampIn { to { opacity: .9; transform: rotate(-8deg) scale(1); } }
@keyframes stampIn2 { to { opacity: .95; transform: rotate(6deg) scale(1); } }
@keyframes fadeStop { to { opacity: .28; } }

/* ===== 校徽拼合 ===== */
.badge-game { margin: 28px -8px; padding: 18px 16px 14px; border: 1px solid var(--line); background: rgba(255,250,235,.45); position: relative; }
.badge-game::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(180,154,116,.5); pointer-events: none; }
.bg-head { text-align: center; font-size: 18px; font-weight: 700; letter-spacing: .3em; }
.bg-head time { color: var(--red); margin-right: 8px; letter-spacing: .05em; }
.bg-text { font-size: 14px; color: var(--ink-2); text-align: center; line-height: 1.8; margin: 6px 0 4px; }
.bg-stage { position: relative; height: 300px; touch-action: none; }
.bg-ring { position: absolute; left: 50%; top: 0; width: 180px; height: 180px; margin-left: -90px; }
.ring-o, .ring-i { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.ring-i { stroke-width: 1; }
.ring-slot { fill: none; stroke: var(--line); stroke-width: 1.2; stroke-dasharray: 4 5; }
.bg-stage.done .ring-o, .bg-stage.done .ring-i { stroke: var(--red); transition: stroke .6s; }
.bg-stage.done .ring-slot { opacity: 0; }
.piece {
  position: absolute; width: 96px; height: 112px; top: 186px;
  display: flex; flex-direction: column; align-items: center; touch-action: none; user-select: none;
  transition: left .6s cubic-bezier(.3,1.3,.5,1), top .6s cubic-bezier(.3,1.3,.5,1), transform .6s;
}
.piece svg { width: 84px; height: 84px; background: #fbf5e6; border: 1px solid var(--line); border-radius: 50%; padding: 6px; transition: .4s; }
.piece span { font-size: 13px; letter-spacing: .3em; margin-top: 2px; color: var(--ink-2); }
.piece .ink line, .piece .ink path { stroke: var(--ink); stroke-width: 6; stroke-linecap: round; fill: none; }
.piece .ink .head { fill: var(--ink); stroke-width: 3; stroke-linejoin: round; }
#pieceTrack { left: calc(50% - 128px); }
#pieceAxe { left: calc(50% + 32px); }
.piece.dragging { transition: none; z-index: 5; }
#pieceTrack.placed, #pieceAxe.placed { left: calc(50% - 48px); }
.piece.placed { top: 48px; pointer-events: none; transform: scale(1.55); transform-origin: 50% 42px; }
.piece.placed svg { background: transparent; border-color: transparent; }
.piece.placed span { opacity: 0; }
#pieceAxe.placed .ink line, #pieceAxe.placed .ink path { stroke: var(--red); }
#pieceAxe.placed .ink .head { fill: var(--red); }
.piece:not(.placed) svg { animation: wiggle 2.4s ease-in-out infinite; }
#pieceAxe:not(.placed) svg { animation-delay: 1.2s; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-6deg); } 90% { transform: rotate(6deg); } }
.bg-done { position: absolute; left: 50%; top: 200px; transform: translateX(-50%) scale(.6); color: var(--red); font-size: 20px; font-weight: 700; letter-spacing: .4em; padding: 2px 6px 2px 12px; border: 2px solid var(--red); opacity: 0; transition: .5s .3s; }
.bg-stage.done .bg-done { opacity: 1; transform: translateX(-50%) scale(1) rotate(-4deg); }
.bg-tip { text-align: center; font-size: 13px; color: var(--red); margin-top: -4px; }

/* ===== 地图 ===== */
.map-wrap { margin: 22px -12px; padding: 12px; border: 1px solid var(--ink-2); background: #f6edd8; position: relative; outline: 1px solid var(--line); outline-offset: 3px; }
.map-title { font-size: 15px; font-weight: 700; letter-spacing: .15em; margin-bottom: 4px; }
.map-title small { display: block; font-weight: 400; font-size: 12px; letter-spacing: .05em; color: var(--faded); }
.map { display: block; width: 100%; height: auto; overflow: visible; }
.map .grid { stroke: var(--line); stroke-width: .35; opacity: .55; stroke-dasharray: 1.2 2; }
.map .city circle.dot { fill: var(--paper); stroke: var(--ink); }
.map .city text { fill: var(--ink); font-family: var(--serif); }
.map .city .date { fill: var(--red); }
.map .city { opacity: .28; transition: opacity .6s; }
.map .city.on { opacity: 1; }
.map .city.on circle.dot { fill: var(--ink); }
.map .city.home circle.dot { fill: var(--red); stroke: var(--red); }
.map .route { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
.map .route.red { stroke: var(--red); }
.map .ghost { fill: none; stroke: var(--line); stroke-dasharray: 1.5 2.5; }
.map .walker { fill: var(--red); }
.map .hit { fill: transparent; cursor: pointer; }
.map .tap-ring { fill: none; stroke: var(--red); opacity: 0; }
.map.tappable .tap-ring { animation: tapRing 1.8s ease-out infinite; }
@keyframes tapRing { 0% { opacity: .8; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.8); } }
.map .tap-ring { transform-box: fill-box; transform-origin: center; }
.map .compass text { fill: var(--faded); font-family: var(--serif); }
.map .compass path { fill: var(--faded); }
.map .glow { fill: var(--lamp); opacity: 0; transform-box: fill-box; transform-origin: center; }
.map .glow.lit { animation: lamp 2.6s ease-in-out infinite; }
@keyframes lamp { 0%, 100% { opacity: .25; transform: scale(1); } 50% { opacity: .6; transform: scale(1.5); } }
.map .ripple { fill: none; stroke: var(--red); opacity: 0; transform-box: fill-box; transform-origin: center; }
.map .ripple.go { animation: ripple 1.6s ease-out 2; }
@keyframes ripple { 0% { opacity: .9; transform: scale(.5); } 100% { opacity: 0; transform: scale(3); } }

.replay { position: absolute; right: 10px; top: 10px; font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); padding: 1px 8px; border-radius: 2px; background: var(--paper); opacity: 0; pointer-events: none; transition: .4s; }
.map-wrap.finished .replay { opacity: 1; pointer-events: auto; }
.map-tip { font-size: 13px; color: var(--red); text-align: center; margin-top: 4px; opacity: 0; transition: .5s; }
.map-wrap.finished .map-tip { opacity: 1; }

.home-seal {
  position: absolute; left: 22px; bottom: 26px; color: var(--red); border: 3px solid var(--red);
  font-size: 22px; font-weight: 700; letter-spacing: .25em; padding: 4px 8px 4px 14px; border-radius: 6px;
  opacity: 0; transform: rotate(-10deg) scale(2.2); pointer-events: none;
}
.home-seal.show { animation: homeIn .55s forwards; }
@keyframes homeIn { to { opacity: .92; transform: rotate(-10deg) scale(1); } }

/* ===== 第五章：暗下来 ===== */
.sec.dark { background: linear-gradient(180deg, transparent, rgba(40,28,18,.10) 30%, rgba(40,28,18,.16) 70%, transparent); }
.sec.dark .map-wrap { background: #efe3c8; }
.quiet { color: var(--ink-2); text-align: center; }
.lamp-line { text-align: center; font-size: 22px; font-weight: 700; line-height: 1.7; margin-top: 26px !important; }
.lamp-line::before { content: ""; display: block; width: 10px; height: 10px; margin: 0 auto 12px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 14px 6px rgba(231,163,58,.5); animation: lampDot 2.6s ease-in-out infinite; }
@keyframes lampDot { 50% { box-shadow: 0 0 22px 10px rgba(231,163,58,.7); } }

/* ===== 第六章：校名 ===== */
.names { list-style: none; margin: 10px 0 0; }
.names li { display: grid; grid-template-columns: 64px 1fr auto; align-items: baseline; gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.names time { font-size: 20px; font-weight: 700; color: var(--faded); }
.names span { font-size: 19px; font-weight: 700; }
.names em { font-style: normal; font-size: 13px; color: var(--faded); }
.names .now time { color: var(--red); }
.names .now span { font-size: 22px; color: var(--red); }

/* ===== 结尾 ===== */
.end { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 22px; border-bottom: 0; }
.motto-label { font-size: 13px; letter-spacing: .6em; padding-left: .6em; color: var(--faded); margin-bottom: 6px; }
.motto-text { font-size: 44px; font-weight: 700; letter-spacing: .3em; padding: 6px 4px 6px 18px; border: 3px double var(--red); color: var(--red); }
.motto-text.small { font-size: 30px; color: var(--ink); border-color: var(--ink-2); }
.end-line { font-size: 18px; line-height: 2; color: var(--ink-2); margin-top: 10px !important; }
.again { font-size: 14px; border: 1px solid var(--ink-2); padding: 8px 22px; letter-spacing: .15em; background: rgba(255,250,235,.6); }
.foot { position: absolute; bottom: 18px; left: 0; right: 0; font-size: 11px; color: var(--faded); letter-spacing: .1em; }

/* ===== 城市卡片 ===== */
.sheet { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.sheet-mask { position: absolute; inset: 0; background: rgba(30,20,10,.45); opacity: 0; transition: .3s; }
.sheet-card {
  position: absolute; left: 50%; bottom: 0; width: 100%; max-width: 520px;
  transform: translate(-50%, 105%); transition: transform .4s cubic-bezier(.2,.9,.3,1);
  background: var(--paper); border-top: 3px solid var(--red); padding: 22px 26px calc(30px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.3); max-height: 80vh; overflow: auto;
}
.sheet.open { pointer-events: auto; }
.sheet.open .sheet-mask { opacity: 1; }
.sheet.open .sheet-card { transform: translate(-50%, 0); }
.sheet-x { position: absolute; right: 14px; top: 8px; font-size: 28px; color: var(--faded); width: 40px; height: 40px; }
.sheet-date { font-size: 13px; color: var(--red); letter-spacing: .1em; }
.sheet h3 { font-size: 24px; letter-spacing: .2em; margin-bottom: 8px; }
.sheet p { font-size: 16px; margin: 8px 0; }
.couplet { display: flex; justify-content: center; gap: 22px; margin: 16px 0 6px; }
.couplet div {
  writing-mode: vertical-rl; text-orientation: upright; background: var(--red); color: #f6e6c4;
  font-size: 18px; letter-spacing: .12em; padding: 14px 8px; font-weight: 700; box-shadow: 2px 3px 0 rgba(60,20,10,.25);
}

/* ===== 电脑屏幕 ===== */
@media (min-width: 600px) {
  body { padding: 0; }
  .sec { padding-left: 44px; padding-right: 44px; }
}

/* ===== 不想要动画的用户 ===== */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .arrow, .piece svg, .lamp-line::before { animation: none !important; }
}
