/* ============================================================
 * 史·地 · 设计系统（暖色宣纸风）
 * ============================================================ */

:root {
  --paper: #f6f1e7;          /* 宣纸底色 */
  --surface: #fffdf7;        /* 卡片表面 */
  --surface-2: #fbf6ec;      /* 次级表面 */
  --ink: #2f2a24;            /* 墨色 */
  --ink-2: #5c544a;          /* 次级文字 */
  --ink-3: #8a7f70;          /* 弱化文字 */
  --line: #e6dcc8;           /* 边框 */
  --line-strong: #d8cbaf;
  --red: #b03a2e;            /* 朱砂红（中国史） */
  --teal: #2f6f6a;           /* 青绿（世界史 / 地理） */
  --gold: #c9a227;
  --blue: #3a6ea5;
  --purple: #7a5c9e;
  --green: #5b8c5a;
  --brown: #8c5a3b;
  --shadow: 0 1px 2px rgba(70, 55, 30, .06), 0 6px 20px rgba(70, 55, 30, .06);
  --shadow-lg: 0 10px 40px rgba(70, 55, 30, .14);
  --radius: 14px;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -100px, rgba(201, 162, 39, .07), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 28px;
  background: rgba(255, 253, 247, .86);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-family: var(--serif);
  font-size: 20px; font-weight: 700;
  color: var(--surface);
  background: linear-gradient(135deg, var(--red), var(--teal));
  padding: 4px 10px; border-radius: 8px;
  box-shadow: var(--shadow);
  letter-spacing: 1px;
}
.brand-name { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: 1px; }

.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  padding: 7px 13px; border-radius: 999px;
  font-size: 14px; color: var(--ink-2);
  transition: all .18s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--ink); color: var(--surface); }

.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 18px; padding: 4px 10px; cursor: pointer; color: var(--ink); }

/* ---------- 布局 ---------- */
.app { max-width: 1120px; margin: 0 auto; padding: 40px 28px 80px; min-height: 70vh; }
.page { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.35; }
h1 { font-size: 34px; margin: 0 0 10px; letter-spacing: 1px; }
.lead { color: var(--ink-2); font-size: 16px; max-width: 720px; margin: 0 0 28px; }

.section-title { font-size: 24px; margin: 44px 0 6px; display: flex; align-items: center; gap: 10px; }
.section-title::before { content: ""; width: 6px; height: 22px; background: linear-gradient(var(--red), var(--teal)); border-radius: 4px; }
.section-sub { color: var(--ink-3); margin: 0 0 20px; font-size: 14px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}

/* ---------- 首页 ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 52px 44px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(176, 58, 46, .06), rgba(47, 111, 106, .08)),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero h1 { font-size: 42px; margin-bottom: 16px; }
.hero .lead { font-size: 17px; }
.hero-cta { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all .18s ease;
}
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 28px; }
.feature {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 20px;
  box-shadow: var(--shadow); cursor: pointer; transition: all .2s ease;
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.feature .ico { font-size: 30px; margin-bottom: 10px; }
.feature h3 { font-size: 17px; margin: 0 0 6px; }
.feature p { font-size: 13px; color: var(--ink-2); margin: 0; }

.period-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 8px; }
.period-preview .card { padding: 20px 22px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  font-size: 13px; border: 1px solid var(--line-strong); color: var(--ink-2);
  background: var(--surface);
}
.chip b { color: var(--ink); }

/* ---------- 时间轴 ---------- */
.timeline-wrap { position: relative; padding-left: 8px; }
.timeline-legend { display: flex; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; }

.tl-row {
  display: grid; grid-template-columns: 1fr 74px 1fr; gap: 14px;
  align-items: start; margin-bottom: 8px; position: relative;
}
.tl-row::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; transform: translateX(-50%);
  background: linear-gradient(var(--line-strong), var(--line-strong));
}
.tl-card { padding: 16px 18px; }
.tl-card.cn { border-left: 4px solid var(--red); text-align: right; }
.tl-card.world { border-right: 4px solid var(--teal); text-align: left; }
.tl-card h3 { font-size: 16px; margin: 0 0 4px; }
.tl-card .era-tag { font-size: 11px; letter-spacing: 1px; color: var(--ink-3); text-transform: uppercase; }
.tl-card p { font-size: 14px; color: var(--ink-2); margin: 0; }
.tl-year {
  position: relative; z-index: 2;
  align-self: center; justify-self: center;
  background: var(--ink); color: var(--surface);
  font-family: var(--serif); font-weight: 700; font-size: 13px;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}

/* ---------- 地图 ---------- */
.map-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.map-tabs button {
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--ink-2); transition: all .18s;
}
.map-tabs button.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.map-stage { position: relative; }
.map-card { padding: 18px; }
.map-card svg { width: 100%; height: auto; display: block; }
.map-note { font-size: 12px; color: var(--ink-3); margin-top: 12px; text-align: center; }

.dynasty-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.dynasty-bar button {
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-family: var(--serif); font-weight: 700; font-size: 15px; transition: all .18s;
}
.dynasty-bar button.active { color: var(--surface); border-color: transparent; box-shadow: var(--shadow); }

.map-info { margin-top: 6px; }
.map-info h3 { font-size: 19px; margin: 0 0 4px; }
.map-info .range { color: var(--ink-3); font-size: 13px; }
.map-info p { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }

.zone-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.zone-legend span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.zone-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.zone-legend i.off { background: #e9e2d2; border: 1px dashed var(--line-strong); }

.route-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.route-tabs button {
  padding: 8px 15px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--ink-2); transition: all .18s;
}
.route-tabs button.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- 事件卡片 ---------- */
.event-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.event-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; cursor: pointer;
  transition: all .2s ease; position: relative; overflow: hidden;
}
.event-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.event-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ec); }
.event-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.era-badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; color: #fff; background: var(--ec); }
.tag-badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.event-card h3 { font-size: 18px; margin: 0 0 4px; }
.event-meta { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.event-card .story { font-size: 14px; color: var(--ink-2); margin: 0; }
.event-card .geo-hint { margin-top: 10px; font-size: 13px; color: var(--teal); }

/* ---------- 事件弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(40, 32, 20, .42);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 18px; max-width: 640px; width: 100%;
  max-height: 86vh; overflow: auto; padding: 30px 32px; box-shadow: var(--shadow-lg);
  animation: pop .22s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .close { float: right; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: var(--ink-2); }
.modal h2 { margin: 6px 0 6px; font-size: 24px; }
.geo-block { margin-top: 18px; }
.geo-block h4 { font-family: var(--serif); margin: 0 0 8px; color: var(--teal); font-size: 15px; }
.geo-block li { margin: 0 0 8px; font-size: 14px; }
.key-line { margin-top: 16px; padding: 12px 16px; background: var(--surface-2); border-radius: 10px; font-size: 13px; color: var(--ink-2); border-left: 3px solid var(--gold); }

/* ---------- 测验 ---------- */
.quiz-shell { max-width: 720px; margin: 0 auto; }
.quiz-progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.quiz-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--teal)); transition: width .3s; border-radius: 999px; }
.quiz-q { font-family: var(--serif); font-size: 21px; margin: 0 0 20px; line-height: 1.5; }
.opt {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px; margin-bottom: 10px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 15px; transition: all .15s;
}
.opt:hover { border-color: var(--ink); }
.opt.correct { background: #e7f2e4; border-color: var(--green); }
.opt.wrong { background: #f7e3e0; border-color: var(--red); }
.opt.disabled { pointer-events: none; opacity: .85; }
.feedback { padding: 14px 16px; border-radius: 12px; margin-top: 16px; font-size: 14px; }
.feedback.ok { background: #e7f2e4; color: #2f5c2a; }
.feedback.no { background: #f7e3e0; color: #8a3024; }
.quiz-nav { display: flex; gap: 12px; margin-top: 22px; align-items: center; }

.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-item {
  padding: 12px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 15px; transition: all .15s; display: flex; align-items: center; gap: 10px;
}
.order-item:hover { border-color: var(--ink); }
.order-item.picked { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.order-item .num { font-family: var(--serif); font-weight: 700; width: 22px; text-align: center; }
.order-reset { margin-top: 12px; }

.score-card { text-align: center; padding: 40px 20px; }
.score-num { font-family: var(--serif); font-size: 64px; font-weight: 700; background: linear-gradient(135deg, var(--red), var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-sub { color: var(--ink-2); margin: 8px 0 20px; }

/* ---------- 页脚 ---------- */
.footer { max-width: 1120px; margin: 0 auto; padding: 26px 28px 40px; border-top: 1px solid var(--line); text-align: center; color: var(--ink-3); font-size: 12px; }
.footer p { margin: 4px 0; }

/* ---------- 朝代详解 ---------- */
.dynasty-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.dynasty-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: all .18s ease;
}
.dynasty-item:hover { transform: translateX(4px); border-color: var(--ink); box-shadow: var(--shadow); }
.dynasty-name { color: #fff; font-family: var(--serif); font-weight: 700; padding: 4px 12px; border-radius: 8px; white-space: nowrap; font-size: 15px; }
.dynasty-range { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.dynasty-sum { color: var(--ink-2); font-size: 13px; }

.back-link { display: inline-block; margin-bottom: 14px; color: var(--ink-2); font-size: 14px; }
.back-link:hover { color: var(--ink); }
.range-badge { color: #fff; font-family: var(--serif); font-size: 14px; padding: 3px 12px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-top: 18px; }
.clean-list { margin: 8px 0 0; padding-left: 20px; }
.clean-list li { margin-bottom: 8px; font-size: 14px; color: var(--ink-2); }
.res-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.res-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  transition: all .18s ease;
}
.res-item:hover { transform: translateX(4px); border-color: var(--ink); box-shadow: var(--shadow); }
.res-type { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.res-body { display: flex; flex-direction: column; gap: 2px; }
.res-body b { font-size: 15px; }
.res-note { font-size: 12.5px; color: var(--ink-3); }
.res-arrow { margin-left: auto; color: var(--ink-3); font-size: 16px; }

/* ---------- 学习进度 & 打卡 ---------- */
.progress-card { display: flex; flex-direction: column; gap: 10px; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; }
.progress-label { font-family: var(--serif); font-weight: 700; font-size: 16px; }
.progress-num { color: var(--ink-2); font-size: 14px; }
.progress-bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--teal)); border-radius: 999px; transition: width .4s ease; }
.progress-pct { color: var(--ink-3); font-size: 12px; text-align: right; }

.checkin-btn { border: 1px solid var(--line-strong); background: var(--surface); }
.checkin-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.checkin-btn.checked { background: #e7f2e4; color: #2f5c2a; border-color: var(--green); }
.checkmark { margin-left: auto; color: var(--green); font-weight: 700; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
.checkin-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- 趣味小游戏 ---------- */
.game-top { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.clue-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.clue { padding: 10px 14px; background: var(--surface-2); border-radius: 10px; font-size: 14px; color: var(--ink-2); border-left: 3px solid var(--gold); }
.clue-num { display: inline-block; font-size: 12px; color: var(--ink-3); margin-right: 8px; background: var(--surface); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }

.match-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.match-card { perspective: 800px; height: 100px; cursor: pointer; }
.match-inner { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.match-card.flip .match-inner { transform: rotateY(180deg); }
.match-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 13px; padding: 8px; text-align: center; line-height: 1.35; }
.match-front { background: var(--ink); color: var(--surface); font-size: 24px; font-family: var(--serif); }
.match-back { transform: rotateY(180deg); }
.match-back.side-a { background: #f7e3e0; border: 1px solid var(--red); color: #8a3024; font-weight: 600; }
.match-back.side-b { background: #e7f2e4; border: 1px solid var(--green); color: #2f5c2a; font-weight: 600; }
.match-card.matched .match-inner { transform: rotateY(180deg); }
.match-card.matched .match-back { background: #efe9da; color: var(--ink-3); border-color: var(--line-strong); }
.match-card.matched { cursor: default; }

.qf-status { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.qf-timer { font-family: var(--serif); font-size: 34px; font-weight: 700; color: var(--teal); line-height: 1; }
.qf-timer.danger { color: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.qf-score { font-size: 16px; color: var(--ink-2); }
.qf-btn { flex: 1; padding: 16px; font-size: 17px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; transition: all .15s; }
.qf-btn[data-a="true"]:hover { background: #e7f2e4; border-color: var(--green); }
.qf-btn[data-a="false"]:hover { background: #f7e3e0; border-color: var(--red); }

.tl-event { text-align: center; padding: 28px 20px; }
.tl-event-label { color: var(--ink-3); font-size: 13px; margin-bottom: 10px; }
.tl-event-name { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.era-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.era-btn { padding: 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600; transition: all .15s; }
.era-btn:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.era-btn.wrong { background: #f7e3e0; border-color: var(--red); color: #8a3024; }
.era-btn.disabled { pointer-events: none; opacity: .7; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .period-preview, .event-grid { grid-template-columns: 1fr; }
  .tl-row { grid-template-columns: 1fr; }
  .tl-row::before { left: 12px; }
  .tl-card.cn { text-align: left; border-left: 4px solid var(--red); }
  .tl-card.world { border-right: none; border-left: 4px solid var(--teal); }
  .tl-year { justify-self: start; margin-left: 12px; }
}
@media (max-width: 640px) {
  .nav { display: none; position: absolute; top: 58px; left: 0; right: 0; background: var(--surface); flex-direction: column; padding: 12px 18px; border-bottom: 1px solid var(--line); }
  .nav.open { display: flex; }
  .nav-toggle { display: block; }
  .hero { padding: 32px 22px; }
  .hero h1 { font-size: 30px; }
  .feature-grid { grid-template-columns: 1fr; }
  .app { padding: 28px 16px 60px; }
  .detail-grid { grid-template-columns: 1fr; }
  .dynasty-item { flex-wrap: wrap; }
  .era-grid { grid-template-columns: repeat(2, 1fr); }
  .match-card { height: 78px; }
  .match-face { font-size: 11px; }
}
