:root {
  --bg: #060503;
  --panel: rgba(10, 9, 6, 0.78);
  --panel-strong: rgba(255, 236, 181, 0.1);
  --paper: #fff0bd;
  --paper-strong: #fff8dc;
  --muted: rgba(255, 240, 189, 0.68);
  --line: rgba(255, 240, 189, 0.18);
  --red: #ff3d22;
  --gold: #ffc447;
  --lime: #c7ff44;
  --cyan: #54d8ff;
  --ink: #080704;
  --shadow: 0 34px 110px rgba(0, 0, 0, 0.62);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  font-family: "Hiragino Sans GB", "Microsoft YaHei", "PingFang SC", sans-serif;
  overflow-x: hidden;
  background:
    repeating-linear-gradient(102deg, rgba(255, 196, 71, 0.06) 0 1px, transparent 1px 96px),
    linear-gradient(126deg, #050403 0%, #171006 42%, #090a08 66%, #030303 100%);
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  z-index: 0;
  background:
    linear-gradient(rgba(255, 240, 189, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 240, 189, 0.035) 1px, transparent 1px),
    repeating-linear-gradient(158deg, transparent 0 24px, rgba(84, 216, 255, 0.035) 24px 25px, transparent 25px 80px);
  background-size: 48px 48px, 48px 48px, auto;
  transform: perspective(900px) rotateX(58deg) translateY(-30vh) scale(1.55);
  transform-origin: center top;
}

body::after {
  z-index: 3;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.64), transparent 28%, transparent 68%, rgba(0, 0, 0, 0.72)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.82));
}

body[data-phase="loading"] .rift-stage,
body[data-phase="story"] .rift-stage {
  opacity: 0.92;
  filter: saturate(1.28) contrast(1.08);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button[disabled] {
  cursor: wait;
}

#riftCanvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.88;
}

.rift-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.95;
  transition: opacity 240ms ease, filter 240ms ease;
}

.gate-rings {
  position: absolute;
  left: -70px;
  top: 50%;
  width: 740px;
  height: 740px;
  transform: translateY(-50%) rotate(-8deg);
}

.gate-rings::before,
.gate-rings::after,
.gate-rings span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 196, 71, 0.34);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 70px rgba(255, 61, 34, 0.28), inset 0 0 70px rgba(84, 216, 255, 0.13);
}

.gate-rings::before {
  border-width: 2px;
  border-style: dashed;
  animation: turn 14s linear infinite;
}

.gate-rings::after {
  inset: 116px;
  border-color: rgba(84, 216, 255, 0.42);
  animation: turn 9s linear infinite reverse;
}

.gate-rings span:nth-child(1) {
  inset: 58px;
  border-color: rgba(199, 255, 68, 0.28);
  animation: pulse-ring 3.1s ease-in-out infinite;
}

.gate-rings span:nth-child(2) {
  inset: 174px;
  border-color: rgba(255, 61, 34, 0.5);
  border-style: dashed;
  animation: turn 7s linear infinite;
}

.gate-rings span:nth-child(3) {
  inset: 248px;
  border-color: rgba(255, 248, 220, 0.58);
  animation: pulse-ring 2.4s ease-in-out infinite reverse;
}

.gate-rings span:nth-child(4) {
  inset: 300px;
  border-color: rgba(255, 196, 71, 0.86);
  background: conic-gradient(from 90deg, rgba(255, 61, 34, 0.32), rgba(84, 216, 255, 0.2), rgba(199, 255, 68, 0.18), rgba(255, 61, 34, 0.32));
  box-shadow: 0 0 80px rgba(255, 196, 71, 0.32);
  animation: turn 5.5s linear infinite reverse;
}

.gate-rings span:nth-child(4)::after {
  position: absolute;
  inset: -110px;
  border: 1px solid rgba(255, 248, 220, 0.13);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 140px rgba(255, 196, 71, 0.24);
}

.era-shard {
  position: absolute;
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 240, 189, 0.22);
  background: rgba(0, 0, 0, 0.38);
  color: rgba(255, 240, 189, 0.52);
  font-family: "Songti SC", "STSong", serif;
  font-size: 15px;
  font-weight: 900;
  transform: rotate(var(--tilt));
  animation: drift-shard 5.6s ease-in-out infinite;
}

.shard-a {
  --tilt: -13deg;
  left: 42vw;
  top: 12vh;
}

.shard-b {
  --tilt: 8deg;
  left: 70vw;
  top: 18vh;
  animation-delay: -1.4s;
}

.shard-c {
  --tilt: -5deg;
  left: 58vw;
  top: 72vh;
  animation-delay: -2.1s;
}

.shard-d {
  --tilt: 11deg;
  left: 14vw;
  top: 78vh;
  animation-delay: -3s;
}

.shard-e {
  --tilt: -9deg;
  left: 82vw;
  top: 56vh;
  animation-delay: -4s;
}

.sound-button {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 7;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 240, 189, 0.28);
  background: rgba(0, 0, 0, 0.52);
  color: var(--paper);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 1000;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.sound-button:hover {
  border-color: var(--lime);
  transform: translateY(-1px);
}

.sound-button[aria-pressed="true"] {
  border-color: rgba(199, 255, 68, 0.62);
  background: rgba(199, 255, 68, 0.16);
  color: var(--lime);
}

.app-shell {
  position: relative;
  z-index: 4;
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0 30px;
}

.intro-screen {
  min-height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 30px;
  align-items: center;
}

.brand-area {
  min-width: 0;
  padding-top: 36px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid var(--red);
  color: var(--red);
  background: rgba(0, 0, 0, 0.34);
  font-family: "Songti SC", "STSong", serif;
  font-size: 34px;
  font-weight: 900;
  transform: rotate(-5deg);
  box-shadow: 0 0 34px rgba(255, 61, 34, 0.3);
}

.kicker,
.tiny-label,
.mode-badge {
  margin: 0;
  color: var(--lime);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 810px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 104px;
  line-height: 0.94;
  color: var(--paper-strong);
  text-shadow: 6px 0 0 rgba(255, 61, 34, 0.28), 0 0 42px rgba(255, 196, 71, 0.12);
}

.subtitle {
  max-width: 650px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1.68;
}

.player-card,
.loading-state,
.story-view,
.share-panel,
.archive-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 240, 189, 0.09), transparent 32%),
    linear-gradient(135deg, rgba(255, 61, 34, 0.08), transparent 44%),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.player-card {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 22px;
  overflow: hidden;
}

.player-card::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 196, 71, 0.055) 18px 19px),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.28));
}

.player-card > * {
  position: relative;
}

.player-card h2 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 38px;
  line-height: 1;
}

.field span,
legend {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(255, 240, 189, 0.25);
  border-radius: 0;
  outline: none;
  background: rgba(0, 0, 0, 0.46);
  color: var(--paper-strong);
  padding: 12px;
}

input:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(199, 255, 68, 0.14);
}

input::placeholder {
  color: rgba(255, 240, 189, 0.34);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid rgba(255, 240, 189, 0.25);
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  min-height: 50px;
  margin: 0;
  display: grid;
  place-items: center;
  border-right: 1px solid rgba(255, 240, 189, 0.18);
  background: rgba(0, 0, 0, 0.42);
  color: var(--paper);
  font-weight: 900;
}

.segmented label:last-child span {
  border-right: 0;
}

.segmented input:checked + span {
  background: var(--lime);
  color: var(--ink);
  box-shadow: 0 0 30px rgba(199, 255, 68, 0.26);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.jump-button {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  background:
    linear-gradient(90deg, #ff351f, #ff9f28 52%, #ffe163),
    var(--gold);
  color: var(--ink);
  font-size: 20px;
  font-weight: 1000;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.86), 0 0 42px rgba(255, 61, 34, 0.38);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.jump-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.88), 0 0 54px rgba(255, 196, 71, 0.36);
}

.jump-button:active {
  transform: translate(3px, 3px);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.9);
}

.jump-button[disabled] {
  filter: saturate(0.8) brightness(0.86);
}

.hidden {
  display: none !important;
}

.loading-state {
  position: relative;
  min-height: calc(100vh - 68px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
  padding: 40px;
  overflow: hidden;
}

.loading-state::before,
.loading-state::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.loading-state::before {
  width: 900px;
  height: 900px;
  border: 1px solid rgba(255, 196, 71, 0.14);
  border-radius: 50%;
  animation: tunnel-zoom 900ms ease-in-out infinite;
}

.loading-state::after {
  width: 70%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 248, 220, 0.54), transparent);
  transform: rotate(-9deg);
  animation: scanline 680ms linear infinite;
}

.portal {
  width: 260px;
  height: 260px;
  position: relative;
  display: grid;
  place-items: center;
}

.portal i,
.portal span {
  position: absolute;
  border-radius: 50%;
}

.portal i {
  width: 54px;
  height: 54px;
  background: var(--paper-strong);
  box-shadow: 0 0 34px rgba(255, 248, 220, 0.75), 0 0 96px rgba(255, 61, 34, 0.42);
  animation: core-beat 620ms ease-in-out infinite;
}

.portal span {
  inset: calc(var(--i, 0) * 31px);
  border: 2px solid var(--red);
  box-shadow: 0 0 34px rgba(255, 61, 34, 0.34);
  animation: turn 1.4s linear infinite;
}

.portal span:nth-child(2) {
  --i: 0;
  border-style: dashed;
}

.portal span:nth-child(3) {
  --i: 1;
  border-color: var(--cyan);
  animation-duration: 1s;
  animation-direction: reverse;
}

.portal span:nth-child(4) {
  --i: 2;
  border-color: var(--paper-strong);
  animation-duration: 1.8s;
}

.loading-state h2 {
  max-width: 760px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 66px;
  line-height: 1.04;
  color: var(--paper-strong);
  text-shadow: 5px 0 0 rgba(255, 61, 34, 0.26);
}

.loading-state p:not(.kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.loading-line {
  width: min(340px, 72vw);
  height: 2px;
  margin-top: 8px;
  overflow: hidden;
  background: rgba(255, 240, 189, 0.14);
}

.loading-line span {
  width: 42%;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, transparent, rgba(255, 248, 220, 0.88), transparent);
  animation: loading-pass 1.45s ease-in-out infinite;
}

.story-view {
  padding: 28px;
}

.story-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.mode-badge {
  width: max-content;
  padding: 5px 8px;
  border: 1px solid rgba(199, 255, 68, 0.35);
  background: rgba(0, 0, 0, 0.42);
}

.story-header h2 {
  max-width: 900px;
  margin-top: 12px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 56px;
  line-height: 1.08;
  color: var(--paper-strong);
  text-shadow: 4px 0 0 rgba(255, 61, 34, 0.22);
}

.story-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-meta span {
  border: 1px solid rgba(255, 240, 189, 0.2);
  background: rgba(0, 0, 0, 0.32);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 900;
}

.chapter-list {
  display: grid;
  gap: 0;
  margin-top: 22px;
  padding: 2px 0 0;
}

.chapter {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.chapter + .chapter {
  margin-top: 15px;
}

.chapter-index {
  display: none;
}

.chapter p {
  margin: 0;
  color: rgba(255, 248, 220, 0.94);
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  line-height: 1.95;
  text-indent: 2em;
}

.live-story {
  white-space: pre-wrap;
  text-indent: 0;
}

.typing::after {
  width: 0.58em;
  height: 1em;
  margin-left: 3px;
  display: inline-block;
  vertical-align: -0.12em;
  background: var(--lime);
  content: "";
  animation: blink 540ms steps(2, end) infinite;
}

.result-card {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 0.8fr 1.5fr 0.75fr 1.2fr;
  border: 1px solid rgba(255, 240, 189, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 61, 34, 0.12), transparent 46%),
    rgba(0, 0, 0, 0.28);
}

.result-card div {
  min-width: 0;
  padding: 15px;
  border-right: 1px solid rgba(255, 240, 189, 0.13);
}

.result-card div:last-child {
  border-right: 0;
}

.result-card strong,
.quick-panel strong {
  display: block;
  margin-top: 6px;
  line-height: 1.18;
  word-break: break-word;
}

.comment {
  margin: 16px 0 0;
  padding: 15px;
  border-left: 3px solid rgba(199, 255, 68, 0.74);
  background: rgba(199, 255, 68, 0.06);
  color: rgba(255, 240, 189, 0.78);
  line-height: 1.6;
}

.action-row {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr);
  gap: 10px;
}

.secondary-button,
.archive-heading button {
  min-height: 46px;
  border: 1px solid rgba(255, 240, 189, 0.28);
  background: rgba(0, 0, 0, 0.46);
  color: var(--paper);
  font-size: 14px;
  font-weight: 1000;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
}

.secondary-button:hover,
.archive-heading button:hover {
  border-color: var(--lime);
  background: var(--lime);
  color: var(--ink);
  transform: translateY(-1px);
}

.primary-retry {
  border-color: var(--red);
  background: rgba(255, 61, 34, 0.16);
}

.share-panel {
  margin-top: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.share-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 240, 189, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 61, 34, 0.2), transparent 40%),
    linear-gradient(315deg, rgba(84, 216, 255, 0.15), transparent 36%),
    #100d07;
}

.share-card-kicker {
  color: var(--lime);
  font-size: 12px;
  font-weight: 1000;
}

.share-card h3 {
  font-family: "Songti SC", "STSong", serif;
  font-size: 34px;
  line-height: 1.1;
}

.share-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.share-card-grid span {
  min-height: 36px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 240, 189, 0.18);
  background: rgba(0, 0, 0, 0.34);
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 900;
}

.share-card p {
  margin: 0;
  color: rgba(255, 240, 189, 0.82);
  line-height: 1.6;
}

.archive-panel {
  margin-top: 18px;
  padding: 18px;
}

.archive-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.archive-heading button {
  padding: 0 10px;
}

.archive-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.archive-item {
  padding: 12px;
  border-left: 4px solid var(--red);
  background: rgba(0, 0, 0, 0.34);
}

.archive-item strong {
  display: block;
  line-height: 1.25;
}

.archive-item span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.quick-panel {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-panel div {
  padding: 12px;
  border: 1px solid rgba(255, 240, 189, 0.14);
  background: rgba(0, 0, 0, 0.32);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 6;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(199, 255, 68, 0.36);
  background: rgba(0, 0, 0, 0.88);
  color: var(--paper);
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-ring {
  50% {
    transform: scale(1.04);
    opacity: 0.56;
  }
}

@keyframes drift-shard {
  50% {
    translate: 0 -14px;
  }
}

@keyframes tunnel-zoom {
  0% {
    transform: scale(0.78);
    opacity: 0;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    transform: scale(1.08);
    opacity: 0;
  }
}

@keyframes scanline {
  to {
    transform: translateY(220px) rotate(-9deg);
  }
}

@keyframes core-beat {
  50% {
    transform: scale(0.72);
    opacity: 0.72;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes loading-pass {
  from {
    transform: translateX(-110%);
  }

  to {
    transform: translateX(250%);
  }
}

@media (max-width: 1060px) {
  .intro-screen {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  h1 {
    font-size: 82px;
  }

  .gate-rings {
    left: -120px;
  }
}

@media (max-width: 900px) {
  .sound-button {
    top: 10px;
    right: 10px;
    min-height: 38px;
    padding: 0 10px;
  }

  .app-shell {
    width: min(100vw - 18px, 620px);
    padding: 9px 0 18px;
  }

  .intro-screen {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .brand-area {
    padding-top: 28px;
  }

  h1 {
    font-size: 58px;
  }

  .subtitle {
    font-size: 18px;
  }

  .gate-rings {
    left: -190px;
    top: 34vh;
    width: 520px;
    height: 520px;
  }

  .era-shard {
    display: none;
  }

  .metric-grid,
  .result-card,
  .action-row,
  .share-card-grid,
  .archive-list,
  .quick-panel {
    grid-template-columns: 1fr;
  }

  .story-view,
  .player-card,
  .loading-state,
  .archive-panel {
    padding: 16px;
  }

  .loading-state {
    min-height: 72vh;
  }

  .loading-state h2 {
    font-size: 42px;
  }

  .portal {
    width: 210px;
    height: 210px;
  }

  .story-header h2 {
    font-size: 38px;
  }

  .chapter {
    display: block;
  }

  .chapter p {
    font-size: 17px;
    line-height: 1.86;
  }

  .result-card div {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 240, 189, 0.13);
  }

  .result-card div:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 46px;
  }

  .subtitle {
    margin-top: 18px;
    font-size: 16px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 29px;
  }

  .player-card h2 {
    font-size: 32px;
  }

  .segmented span {
    min-height: 46px;
  }

  .jump-button {
    min-height: 64px;
  }
}
