:root {
  color-scheme: light;
  --bg: #eeeeee;
  --bg-deep: #d7d7d7;
  --paper: #fafafa;
  --paper-strong: #ffffff;
  --panel: rgba(252, 252, 252, 0.86);
  --panel-soft: rgba(0, 0, 0, 0.035);
  --line: rgba(18, 18, 18, 0.15);
  --line-strong: rgba(18, 18, 18, 0.28);
  --ink: #111111;
  --ink-soft: #3f3f3f;
  --paper-ink: #111111;
  --paper-soft: #3f3f3f;
  --accent: #111111;
  --accent-deep: #000000;
  --success: #222222;
  --danger: #333333;
  --shadow: 0 20px 44px rgba(0, 0, 0, 0.17);
  --brush-font: "STXingkai", "华文行楷", "STKaiti", "KaiTi", "Kaiti SC", "Noto Serif SC", serif;
  --reading-font: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --ui-font: var(--reading-font);
  --display-font: var(--reading-font);
  --mono-font: var(--reading-font);
  --hint-font: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --type-small: 1rem;
  --type-main: 1.35rem;
  --type-title: 2rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body {
  position: relative;
  margin: 0;
  color: var(--ink);
  font-family: var(--ui-font);
  font-weight: 400;
  line-height: 1.5;
  background:
    url("./assets/ink-wash.svg") center bottom / cover no-repeat fixed,
    linear-gradient(180deg, #ffffff 0%, var(--bg) 58%, var(--bg-deep) 100%);
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background: none;
  pointer-events: none;
}

button {
  font: inherit;
}

button[hidden] {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: 326px minmax(0, 1fr);
  gap: 14px;
}

.panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: none;
  overflow: hidden;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.status-panel,
.info-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
}

.status-panel {
  gap: 8px;
}

.info-head,
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.label,
.section-head span,
.status-label,
.experience-row span {
  color: var(--ink-soft);
  font-size: var(--type-small);
  font-weight: 600;
  letter-spacing: 0;
}

.status-section {
  display: grid;
  gap: 6px;
}

.identity-line {
  min-height: 30px;
  display: grid;
  grid-template-columns: auto 1px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.stage-name,
.realm-name {
  min-width: 0;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
}

.stage-name {
  font-size: var(--type-small);
  font-weight: 600;
}

.identity-separator {
  width: 1px;
  height: 14px;
  background: rgba(17, 17, 17, 0.24);
}

.realm-name {
  overflow: hidden;
  font-family: var(--brush-font);
  font-size: var(--type-main);
  font-weight: 700;
  text-overflow: clip;
}

.section-head h2,
.text-card h3 {
  font-family: var(--ui-font);
}

.identity-section {
  gap: 7px;
}

.experience-row {
  min-height: 25px;
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 8px;
}

.experience-row strong {
  justify-self: end;
  color: var(--ink);
  font-size: var(--type-small);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.meter {
  position: relative;
  overflow: visible;
  height: 8px;
  background: transparent;
  box-shadow: none;
}

.meter-fill {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 5px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(8, 8, 8, 0.38) 18%,
    rgba(8, 8, 8, 0.92) 39%,
    rgba(8, 8, 8, 0.88) 68%,
    rgba(8, 8, 8, 0.24) 86%,
    transparent 100%
  );
  clip-path: polygon(0 43%, 5% 28%, 28% 25%, 54% 29%, 78% 24%, 96% 31%, 100% 47%, 98% 68%, 74% 72%, 49% 68%, 25% 74%, 5% 69%, 0 57%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 5%, #000 92%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 5%, #000 92%, transparent 100%);
  transform: translateY(-50%);
  transition: width 180ms ease;
  opacity: 0.68;
}

.meter::before,
.mini-meter::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 7px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(8, 8, 8, 0.04) 16%,
    rgba(8, 8, 8, 0.13) 37%,
    rgba(8, 8, 8, 0.12) 66%,
    rgba(8, 8, 8, 0.035) 84%,
    transparent 100%
  );
  clip-path: polygon(0 46%, 5% 32%, 29% 29%, 52% 33%, 76% 28%, 96% 34%, 100% 49%, 98% 66%, 74% 70%, 51% 67%, 27% 72%, 5% 68%, 0 57%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 3%, #000 97%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 3%, #000 97%, transparent 100%);
  transform: translateY(-50%);
  pointer-events: none;
}

.meter::before {
  height: 4px;
  opacity: 0.68;
}

.section-head {
  position: relative;
  padding-bottom: 8px;
  border-bottom: 0;
}

.section-head h2 {
  color: var(--ink);
  font-size: var(--type-main);
}

.stage-attribute-section,
.item-section {
  position: relative;
  margin-top: 1px;
  padding-top: 11px;
}

.stage-attribute-section::before,
.item-section::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: rgba(17, 17, 17, 0.14);
}

.item-section[hidden] {
  display: none;
}

.attribute-list {
  display: grid;
  gap: 2px;
}

.attr-row--meter {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 8px;
  min-height: 25px;
}

.attribute-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 24px;
  padding: 3px 0 1px;
}

.attr-stat {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4ch;
  align-items: baseline;
  gap: 4px;
}

.attr-name {
  color: var(--ink);
  font-size: var(--type-small);
  font-weight: 600;
  white-space: nowrap;
}

.attr-value {
  justify-self: end;
  color: var(--ink);
  font-family: var(--mono-font);
  font-size: var(--type-small);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.mini-meter {
  position: relative;
  overflow: visible;
  height: 13px;
  background: transparent;
}

.mini-fill {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 11px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(8, 8, 8, 0.34) 17%,
    rgba(8, 8, 8, 0.9) 39%,
    rgba(8, 8, 8, 0.86) 68%,
    rgba(8, 8, 8, 0.22) 86%,
    transparent 100%
  );
  clip-path: polygon(0 43%, 6% 27%, 29% 24%, 53% 29%, 77% 23%, 96% 31%, 100% 48%, 98% 68%, 75% 72%, 50% 67%, 26% 74%, 6% 69%, 0 57%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 6%, #000 91%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 6%, #000 91%, transparent 100%);
  transform: translateY(-50%);
  transition: width 180ms ease;
}

.mini-meter::before {
  height: 9px;
}

.meter-fill::after,
.mini-fill::after {
  content: "";
  position: absolute;
  top: 31%;
  right: 2%;
  width: 5px;
  height: 4px;
  border-radius: 58% 42% 64% 36% / 47% 61% 39% 53%;
  background: rgba(0, 0, 0, 0.52);
}

.item-list {
  min-height: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-chip {
  min-height: 26px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(18, 18, 18, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(232, 232, 232, 0.72));
  color: var(--ink);
  font-size: var(--type-small);
  font-weight: 700;
}

.info-panel {
  height: calc(100vh - 32px);
  min-height: 640px;
  display: block;
  padding: 0;
  overflow: hidden;
}

.timeline {
  position: relative;
  height: 100%;
  min-height: 0;
  padding: 0 30px;
  overflow-x: hidden;
  overflow-y: auto;
  cursor: grab;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
}

.timeline::after {
  content: "";
  display: block;
  height: var(--timeline-tail-space, 0px);
  pointer-events: none;
}

.timeline::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.timeline.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
  scroll-snap-type: none;
  user-select: none;
}

.timeline.is-positioning {
  scroll-behavior: auto;
  scroll-snap-type: none;
}

.timeline-entry {
  position: relative;
  display: flex;
  padding: 28px 4px 0 44px;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
}

.timeline-entry::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 10px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(8, 8, 8, 0.11) 15%,
    rgba(8, 8, 8, 0.43) 31%,
    rgba(8, 8, 8, 0.49) 68%,
    rgba(8, 8, 8, 0.15) 85%,
    transparent 100%
  );
  clip-path: polygon(
    35% 0, 66% 0, 70% 14%, 61% 28%, 72% 43%, 64% 58%, 69% 73%, 59% 87%, 65% 100%,
    31% 100%, 28% 87%, 36% 73%, 27% 58%, 38% 43%, 29% 28%, 37% 14%
  );
  opacity: 0.82;
}

.timeline-entry:first-child::before {
  top: 34px;
}

.timeline-entry:last-child::before {
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 94%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 94%, transparent 100%);
}

.timeline-entry:first-child:last-child::before {
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 7%, #000 94%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 7%, #000 94%, transparent 100%);
}

.timeline-marker {
  position: absolute;
  top: 28px;
  left: -5px;
  width: 18px;
  height: 17px;
  border: 0;
  border-radius: 58% 42% 52% 48% / 46% 57% 43% 54%;
  background: rgba(6, 6, 6, 0.94);
  box-shadow:
    1px 0 1px rgba(0, 0, 0, 0.34),
    -1px 1px 1px rgba(0, 0, 0, 0.22);
  transform: rotate(-5deg);
}

.timeline-marker::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: 1px;
  width: 5px;
  height: 4px;
  border-radius: 61% 39% 68% 32%;
  background: inherit;
  opacity: 0.72;
}

.timeline-entry:nth-child(3n + 2) .timeline-marker {
  top: 29px;
  left: -3px;
  width: 15px;
  height: 16px;
  border-radius: 47% 53% 61% 39% / 58% 43% 57% 42%;
  opacity: 0.86;
  transform: rotate(8deg);
}

.timeline-entry:nth-child(3n + 2) .timeline-marker::after {
  top: 1px;
  right: auto;
  bottom: auto;
  left: -1px;
  width: 4px;
  height: 5px;
}

.timeline-entry:nth-child(3n) .timeline-marker {
  top: 27px;
  left: -6px;
  width: 20px;
  height: 18px;
  border-radius: 65% 35% 48% 52% / 41% 62% 38% 59%;
  opacity: 0.92;
  transform: rotate(-7deg);
}

.timeline-entry:nth-child(3n) .timeline-marker::after {
  top: -1px;
  right: 2px;
  bottom: auto;
  width: 6px;
  height: 4px;
}

.timeline-content {
  position: relative;
  min-width: 0;
  flex: 1;
  padding: 0 0 28px;
  border-bottom: 0;
}

.timeline-entry--revealed:not(:last-child) .timeline-content::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 10px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(8, 8, 8, 0.16) 18%,
    rgba(8, 8, 8, 0.72) 39%,
    rgba(8, 8, 8, 0.64) 66%,
    rgba(8, 8, 8, 0.12) 86%,
    transparent 100%
  );
  clip-path: polygon(
    0 43%, 7% 31%, 23% 36%, 41% 27%, 59% 34%, 77% 25%, 95% 34%, 100% 48%,
    98% 63%, 79% 59%, 61% 69%, 43% 60%, 24% 70%, 6% 61%, 0 56%
  );
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 4%, #000 96%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 4%, #000 96%, transparent 100%);
  opacity: 0.56;
  pointer-events: none;
}

.timeline-entry--empty {
  min-height: 190px;
}

.timeline-entry--empty .timeline-content {
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-entry--active .timeline-marker {
  background: #050505;
  opacity: 0.92;
}

.timeline-entry--active {
  cursor: pointer;
  outline: none;
}

.timeline-entry--active .timeline-content {
  transition: background-color 160ms ease;
}

.timeline-entry--active:hover .timeline-content,
.timeline-entry--active:focus-visible .timeline-content {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.025), rgba(0, 0, 0, 0.055) 52%, rgba(0, 0, 0, 0.018));
}

.timeline-entry--active:focus-visible .timeline-content {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.timeline.is-dragging .timeline-entry--active {
  cursor: grabbing;
}

.timeline-advance {
  color: rgba(17, 17, 17, 0.42);
  font-family: var(--hint-font);
  font-size: var(--type-small);
  font-weight: 400;
  text-align: center;
  pointer-events: none;
}

.timeline-moment {
  display: block;
  color: var(--ink-soft);
  font-size: var(--type-small);
  font-weight: 700;
}

.timeline-content h2 {
  margin: 5px 0 12px;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: var(--type-main);
  line-height: 1.35;
}

.timeline-content p {
  color: var(--ink-soft);
  font-size: var(--type-small);
  line-height: 1.85;
}

.timeline-content p + p {
  margin-top: 10px;
}

.info-head {
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line-strong);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.78);
}

.info-head h1 {
  position: relative;
  display: inline-block;
  margin-top: 2px;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: var(--type-title);
  font-weight: 700;
  line-height: 1.08;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

#primaryAction,
.choice-btn {
  min-height: 38px;
  border: 1px solid rgba(18, 18, 18, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(232, 232, 232, 0.88));
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 1px 0 rgba(0, 0, 0, 0.06);
  cursor: pointer;
  font-weight: 700;
}

#primaryAction {
  min-width: 96px;
  padding: 0 16px;
  position: relative;
}

#primaryAction:hover,
.choice-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    2px 2px 0 rgba(0, 0, 0, 0.24);
}

#primaryAction::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.42), transparent);
}

.info-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  padding: 2px 0;
}

.text-card {
  position: relative;
  padding: 14px 2px 16px;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
}

.text-card.is-highlight {
  border-color: rgba(0, 0, 0, 0.24);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.44), transparent 72%);
}

.text-card h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: var(--type-main);
}

.text-card p {
  color: var(--ink-soft);
  font-size: var(--type-small);
  line-height: 1.75;
}

.battle-line {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  min-height: 42px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
}

.battle-line span {
  color: var(--ink-soft);
  font-size: var(--type-small);
  font-weight: 700;
}

.battle-line strong {
  color: var(--ink);
  font-size: var(--type-main);
}

.battle-line em {
  color: var(--accent-deep);
  font-family: var(--mono-font);
  font-size: var(--type-small);
  font-style: normal;
  font-weight: 700;
}

.result-line,
.trial-summary {
  color: var(--ink-soft);
  font-size: var(--type-small);
  font-weight: 700;
}

.result-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.result-line strong,
.trial-summary strong {
  color: var(--ink);
  font-size: var(--type-main);
}

.trial-summary {
  display: grid;
  gap: 8px;
}

.trial-summary > div {
  min-height: 36px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
}

.choice-area {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.choice-btn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  text-align: left;
}

.choice-btn strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--type-main);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-btn span {
  color: var(--ink-soft);
  font-size: var(--type-small);
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .info-panel {
    height: clamp(520px, 72vh, 680px);
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .game-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    gap: 0;
  }

  .panel {
    border-right: 0;
    border-left: 0;
    box-shadow: none;
  }

  .status-panel,
  .info-panel {
    padding: 14px;
  }

  .info-head {
    align-items: stretch;
  }

  .info-head {
    display: grid;
    justify-content: stretch;
  }

  .info-panel {
    order: -1;
    padding: 0;
  }

  .timeline {
    padding: 0 18px;
  }

  .timeline-entry {
    padding-left: 34px;
  }

  #primaryAction {
    width: 100%;
  }

  .battle-line {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .choice-btn {
    display: grid;
    grid-template-columns: 1fr;
  }

  .choice-btn strong {
    white-space: normal;
  }
}
