:root {
  --bg-color: #12100e;
  --gold: #d4af37;
  --dark-gold: #9e8022;
  --red: #8b0000;
  --text-main: #e8dcc4;
  --text-muted: #8a7f6c;
  --border-color: #4a3e2d;
  --paper: rgba(255, 248, 233, 0.03);
  --font-body: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-display: "Ma Shan Zheng", "STKaiti", "KaiTi", "FangSong", serif;
  --font-ui: "Noto Serif SC", "PingFang SC", "Microsoft YaHei", serif;
}

@font-face {
  font-family: "Classic";
  src: local("Ma Shan Zheng"),
    local("STKaiti"),
    local("KaiTi"),
    local("FangSong"),
    local("SimSun");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top, rgba(139, 0, 0, 0.18), transparent 34%),
    linear-gradient(rgba(18, 16, 14, 0.92), rgba(18, 16, 14, 0.97)),
    linear-gradient(135deg, #1a1714 0%, #0f0d0b 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 620px;
  min-height: 88vh;
  margin: 20px;
  padding: 40px 30px;
  background:
    linear-gradient(135deg, rgba(26, 23, 20, 0.98) 0%, rgba(15, 13, 11, 0.98) 100%);
  border: 2px solid var(--border-color);
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(212, 175, 55, 0.05);
  overflow: hidden;
}

.container::before,
.container::after {
  content: "";
  position: absolute;
  width: 40px;
  height: 40px;
  border: 2px solid var(--gold);
}

.container::before {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
}

.container::after {
  right: 10px;
  bottom: 10px;
  border-left: none;
  border-top: none;
}

h1,
h2,
h3 {
  text-align: center;
  font-weight: normal;
  letter-spacing: 2px;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

.page {
  display: none;
  position: relative;
  z-index: 2;
}

.page.active {
  display: block;
}

.fade-in {
  animation: fadeIn 0.8s forwards;
}

#scroll-overlay {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 20;
  justify-content: center;
  align-items: center;
}

.scroll-half {
  position: absolute;
  height: 80%;
  width: 50%;
  background: linear-gradient(to right, #d4af37, #f3e5ab, #d4af37);
  border: 5px solid #8b0000;
  transition: transform 1.5s cubic-bezier(0.65, 0, 0.35, 1);
}

.scroll-left {
  left: 0;
  transform-origin: left;
  border-right: 2px dashed #8b0000;
}

.scroll-right {
  right: 0;
  transform-origin: right;
  border-left: 2px dashed #8b0000;
}

.scroll-open .scroll-left {
  transform: translateX(-100%);
}

.scroll-open .scroll-right {
  transform: translateX(100%);
}

.scroll-center-text {
  position: absolute;
  z-index: 21;
  color: #8b0000;
  font-size: 2.5rem;
  font-weight: 700;
  opacity: 1;
  transition: opacity 0.5s;
  text-shadow: 0 0 5px #f3e5ab;
  writing-mode: vertical-rl;
  letter-spacing: 10px;
  font-family: var(--font-display);
}

#page-start {
  text-align: center;
  margin-top: 15%;
}

.title-seal {
  color: var(--red);
  font-size: 1.2rem;
  border: 2px solid var(--red);
  display: inline-block;
  padding: 5px 10px;
  margin-bottom: 20px;
  border-radius: 4px;
  font-family: var(--font-display);
}

#page-start h1 {
  font-size: 2.55rem;
  color: var(--gold);
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
  font-family: var(--font-display);
  letter-spacing: 5px;
}

.intro,
.subcopy {
  color: var(--text-muted);
  line-height: 1.85;
}

.intro {
  margin-bottom: 40px;
  font-size: 1.08rem;
}

.name-entry {
  width: min(360px, 100%);
  margin: 0 auto 26px auto;
  text-align: left;
}

.name-entry label {
  display: block;
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 2px;
  font-family: var(--font-display);
}

.name-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font: inherit;
  font-size: 1.05rem;
  outline: none;
}

.name-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.2);
}

.name-tip {
  color: var(--text-muted);
  margin-top: 10px;
  font-size: 0.93rem;
  line-height: 1.7;
}

.btn {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 12px 30px;
  font-size: 1.18rem;
  font-family: var(--font-display);
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover {
  background: var(--gold);
  color: var(--bg-color);
  box-shadow: 0 0 15px var(--dark-gold);
}

#page-role {
  text-align: center;
  margin-top: 10%;
}

#page-role h2 {
  color: var(--gold);
  margin-bottom: 14px;
  font-size: 1.8rem;
  font-family: var(--font-display);
}

.subcopy {
  margin-bottom: 24px;
}

.role-cards {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  margin-top: 20px;
}

.role-card {
  flex: 1;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  padding: 30px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: inherit;
  font: inherit;
}

.role-card:hover {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.role-icon {
  font-size: 3rem;
  color: var(--red);
  margin-bottom: 15px;
  font-weight: bold;
  border: 2px solid var(--red);
  width: 80px;
  height: 80px;
  line-height: 75px;
  border-radius: 50%;
  margin: 0 auto 15px auto;
}

.role-card h3 {
  color: var(--text-main);
  margin-bottom: 10px;
  font-size: 1.5rem;
  font-family: var(--font-display);
  letter-spacing: 3px;
}

.role-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.role-tag {
  display: block;
  margin-top: 10px;
  color: var(--gold);
  font-size: 0.9rem;
  font-family: var(--font-ui);
}

.progress {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  font-family: var(--font-ui);
}

.role-progress {
  color: var(--gold);
}

.question-text {
  font-size: 1.3rem;
  line-height: 1.75;
  margin-bottom: 30px;
  color: var(--text-main);
  text-indent: 2em;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.quote-box {
  margin-top: 26px;
  padding: 16px 18px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

.quote-mark {
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 2px;
  font-family: var(--font-display);
}

.quote-text {
  color: var(--text-muted);
  line-height: 1.85;
  font-size: 1rem;
  font-family: var(--font-body);
}

.quote-person {
  margin-top: 10px;
  color: var(--gold);
  text-align: right;
  font-size: 0.96rem;
  font-family: var(--font-display);
}

.option {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 15px 20px;
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 1.08rem;
  text-align: left;
  transition: all 0.2s;
  line-height: 1.6;
}

.option:hover {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
}

.result-header {
  text-align: center;
  margin-bottom: 20px;
}

.rank-stamp {
  width: 90px;
  height: 90px;
  margin: 0 auto 15px auto;
  border: 4px solid var(--red);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  transform: rotate(-5deg);
  border-radius: 8px;
  box-shadow: inset 0 0 5px rgba(139, 0, 0, 0.5);
  font-family: var(--font-display);
}

.official-title {
  font-size: 1.85rem;
  color: var(--gold);
  margin-bottom: 5px;
  font-family: var(--font-display);
  line-height: 1.5;
  letter-spacing: 3px;
}

.role-badge {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--bg-color);
  background: var(--gold);
  padding: 2px 8px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 10px;
  font-family: var(--font-ui);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  gap: 8px;
  flex-wrap: nowrap;
}

.tab-btn {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 11px 8px;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 1px;
  transition: all 0.3s;
}

.tab-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
  box-shadow: inset 0 -2px 0 rgba(212, 175, 55, 0.45);
}

.tab-content {
  display: none;
  animation: fadeIn 0.5s forwards;
}

.tab-content.active {
  display: block;
}

.chart-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 20px auto;
  padding: 8px;
}

.personality-chart {
  margin-top: 4px;
}

#fateChart {
  width: 100%;
  height: auto;
  display: block;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.subtab-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 14px;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all 0.25s ease;
}

.subtab-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
}

.subtab-content {
  display: none;
}

.subtab-content.active {
  display: block;
}

.analysis-box {
  background: var(--paper);
  border: 1px solid var(--border-color);
  padding: 20px;
  margin-bottom: 20px;
}

.analysis-box h3 {
  color: var(--gold);
  margin-bottom: 10px;
  text-align: left;
  border-left: 3px solid var(--red);
  padding-left: 10px;
  font-size: 1.2rem;
  font-family: var(--font-display);
  letter-spacing: 2px;
}

.analysis-box p {
  font-size: 1.03rem;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.analysis-box strong {
  color: var(--text-main);
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 14px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

.stat-label {
  color: var(--gold);
  margin-bottom: 8px;
  font-family: var(--font-display);
}

.bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b0000, #d4af37);
}

.stat-value {
  margin-top: 8px;
  color: var(--text-muted);
}

.timeline {
  position: relative;
  padding-left: 20px;
  margin-top: 15px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding-left: 15px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 5px;
  width: 12px;
  height: 12px;
  background: var(--bg-color);
  border: 2px solid var(--gold);
  border-radius: 50%;
}

.timeline-year {
  color: var(--gold);
  font-size: 0.95rem;
  margin-bottom: 5px;
  font-family: var(--font-display);
  letter-spacing: 1px;
}

.timeline-text {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.timeline-item.major {
  background: rgba(212, 175, 55, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.18);
  padding: 14px 14px 14px 18px;
  margin-left: -6px;
}

.timeline-item.major::before {
  width: 14px;
  height: 14px;
  left: -28px;
  border-width: 3px;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.22);
}

.timeline-title {
  color: var(--text-main);
  font-size: 1.05rem;
  margin-bottom: 8px;
  letter-spacing: 1px;
  font-family: var(--font-display);
}

.memorial-epitaph {
  margin-top: 18px;
  color: var(--text-main);
  line-height: 1.95;
  font-size: 1.04rem;
  border-left: 3px solid rgba(139, 0, 0, 0.6);
  padding-left: 12px;
  font-family: var(--font-display);
}

.memorial-cta {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed rgba(212, 175, 55, 0.22);
  color: var(--gold);
  line-height: 1.9;
  font-size: 0.98rem;
  font-family: var(--font-body);
}

.access-gate {
  position: fixed;
  inset: 0;
  background: rgba(9, 7, 6, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.gate-card {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  text-align: center;
  border: 1px solid var(--border-color);
  background: rgba(15, 13, 11, 0.98);
}

.gate-title {
  color: var(--gold);
  font-size: 1.5rem;
  margin-bottom: 12px;
  font-family: var(--font-display);
}

.gate-text {
  color: var(--text-muted);
  line-height: 1.7;
}

.secondary {
  margin-top: 18px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  body {
    align-items: flex-start;
  }

  .container {
    max-width: 100%;
    min-height: calc(100vh - 16px);
    margin: 8px;
    padding: 28px 18px;
  }

  #page-start {
    margin-top: 10%;
  }

  #page-start h1 {
    font-size: 2.1rem;
    letter-spacing: 3px;
  }

  .intro {
    font-size: 1rem;
  }

  .role-cards {
    flex-direction: column;
  }

  .question-text {
    font-size: 1.12rem;
    text-indent: 0;
  }

  .option {
    font-size: 1rem;
    padding: 14px 16px;
  }

  .tabs {
    gap: 6px;
  }

  .tab-btn {
    min-width: 0;
    font-size: 0.9rem;
    padding: 10px 4px;
  }

  .subtabs {
    flex-direction: column;
  }

  .subtab-btn {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .official-title {
    font-size: 1.45rem;
    line-height: 1.6;
    letter-spacing: 2px;
  }

  .scroll-center-text {
    font-size: 1.9rem;
  }
}
