:root {
  --sx-ink: #10161a;
  --sx-ink-soft: #1a2428;
  --sx-jade: #245b55;
  --sx-jade-light: #4f8779;
  --sx-skin: #d5c9b3;
  --sx-skin-shadow: #857967;
  --sx-vermilion: #a9352a;
  --sx-ember: #ff6a32;
  --sx-gold: #d8b56d;
  --sx-paper: #f1e8d3;
}

.sx-overlay,
.sx-overlay * {
  box-sizing: border-box;
}

body.sx-overlay-body > *:not(.sx-overlay) {
  opacity: 0.1;
}

body.sx-overlay-body {
  overflow: hidden;
}

.sx-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  color: var(--sx-paper);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  isolation: isolate;
}

.sx-overlay.is-visible {
  opacity: 1;
}

.sx-overlay.is-closing {
  opacity: 0;
  transition: opacity 220ms ease;
}

.sx-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 9, 11, 0.84) 0%, rgba(7, 11, 13, 0.64) 22%, rgba(7, 11, 13, 0.58) 50%, rgba(7, 11, 13, 0.66) 78%, rgba(5, 8, 10, 0.84) 100%),
    radial-gradient(circle at 50% 54%, rgba(19, 30, 31, 0.2) 0%, rgba(8, 12, 14, 0.52) 52%, rgba(2, 4, 5, 0.9) 100%);
  opacity: 1;
}

.sx-grain {
  position: absolute;
  inset: -20%;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.018) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
  opacity: 0.5;
  transform: rotate(0.01deg);
  pointer-events: none;
}

.sx-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.sx-lines {
  opacity: 0.34;
}

.sx-threads {
  opacity: 0.18;
  filter: url(#sxBlur);
}

.sx-thread {
  fill: none;
  stroke: rgba(151, 37, 31, 0.62);
  stroke-width: 2;
  stroke-dasharray: 5 17;
  vector-effect: non-scaling-stroke;
  animation: sx-thread-run 1.9s linear infinite;
}

.sx-thread.is-dim {
  stroke: rgba(216, 181, 109, 0.28);
  stroke-dasharray: 2 24;
  animation-duration: 3.2s;
}

.sx-throw-trace {
  fill: none;
  stroke: #65ffc2;
  stroke-width: 2;
  stroke-dasharray: 4 15;
  stroke-linecap: square;
  vector-effect: non-scaling-stroke;
  filter: url(#sxSoftGlow);
  animation: sx-trace-run 680ms linear infinite;
}

.sx-throw-trace circle {
  fill: var(--sx-ember);
  stroke: none;
}

@keyframes sx-trace-run {
  to { stroke-dashoffset: -38; }
}

.sx-target-lock {
  fill: none;
  stroke: rgba(101, 255, 194, 0.72);
  stroke-width: 1.5;
  stroke-dasharray: 9 8;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(101, 255, 194, 0.34));
  animation: sx-lock-spin 2.4s linear infinite;
}

@keyframes sx-lock-spin {
  to { stroke-dashoffset: -68; }
}

@keyframes sx-thread-run {
  to { stroke-dashoffset: -44; }
}

.sx-glyph {
  fill: rgba(229, 222, 204, 0.18);
  font-family: "Songti SC", SimSun, serif;
  font-size: 21px;
  letter-spacing: 0.42em;
  animation: sx-glyph-flicker 2.8s steps(2,end) infinite;
}

@keyframes sx-glyph-flicker {
  0%, 74%, 100% { opacity: 0.18; }
  76% { opacity: 0.75; }
  79% { opacity: 0.08; }
  82% { opacity: 0.56; }
}

.sx-line {
  fill: none;
  stroke: rgba(216, 181, 109, 0.36);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.sx-line.is-dim {
  stroke: rgba(216, 181, 109, 0.18);
}

.sx-dust {
  color: rgba(216, 181, 109, 0.55);
}

.sx-dust circle {
  animation: sx-float 5.8s ease-in-out infinite;
}

.sx-dust circle:nth-child(2n) {
  animation-delay: -1.7s;
  animation-duration: 7.2s;
}

.sx-dust circle:nth-child(3n) {
  animation-delay: -3.1s;
  animation-duration: 6.4s;
}

@keyframes sx-float {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: 0.18; }
  50% { transform: translate3d(5px, -14px, 0); opacity: 0.72; }
}

.sx-scene-shadow {
  fill: rgba(0, 0, 0, 0.38);
  filter: blur(7px);
}

.sx-pot-shadow {
  fill: rgba(0, 0, 0, 0.34);
}

.sx-pot-body {
  fill: url(#sxPotBody);
  stroke: rgba(216, 181, 109, 0.3);
  stroke-width: 1.2;
}

.sx-pot-band {
  fill: url(#sxPotBand);
}

.sx-pot-rim {
  fill: url(#sxPotRim);
  stroke: rgba(238, 205, 135, 0.48);
  stroke-width: 1.2;
}

.sx-pot-inner {
  fill: #111719;
  stroke: rgba(216, 181, 109, 0.32);
  stroke-width: 1;
}

.sx-pot-ash {
  fill: #2f3938;
  opacity: 0.88;
}

.sx-pot-leg {
  fill: #1a2325;
  stroke: rgba(216, 181, 109, 0.2);
  stroke-width: 1;
}

.sx-pot-glow {
  fill: url(#sxPotGlow);
  opacity: 0;
}

.sx-pot-tooth {
  fill: #d8ceb9;
  opacity: 0.78;
}

.sx-pot-teeth path {
  fill: #d8ceb9;
  opacity: 0.74;
}

.sx-pot-eye-void {
  fill: #050809;
  stroke: rgba(216, 181, 109, 0.42);
  stroke-width: 1.5;
}

.sx-pot-eye-iris {
  fill: rgba(229, 222, 204, 0.18);
}

.sx-pot-eye-pupil {
  fill: var(--sx-ember);
  filter: url(#sxSoftGlow);
  animation: sx-pupil-shift 1.1s steps(3,end) infinite;
}

@keyframes sx-pupil-shift {
  0%, 100% { transform: translateX(-4px); }
  45% { transform: translateX(5px); }
  70% { transform: translateX(0); }
}

.sx-character {
  filter: drop-shadow(0 7px 9px rgba(0, 0, 0, 0.3));
}

.sx-pixel {
  shape-rendering: crispEdges;
}

.sx-face-void {
  fill: #060809;
  stroke: rgba(229, 222, 204, 0.16);
  stroke-width: 1;
}

.sx-face-pupil {
  fill: var(--sx-ember);
  filter: url(#sxSoftGlow);
  animation: sx-eye-pulse 760ms steps(2,end) infinite;
}

@keyframes sx-eye-pulse {
  0%, 62%, 100% { opacity: 0.9; }
  64% { opacity: 0.12; }
  67% { opacity: 1; }
}

.sx-face-crack {
  fill: none;
  stroke: rgba(122, 31, 27, 0.88);
  stroke-width: 2.2;
  stroke-linecap: square;
}

.sx-face-eye {
  fill: #202224;
}

.sx-face-mouth {
  fill: none;
  stroke: #761f1a;
  stroke-width: 4;
  stroke-linecap: square;
}

.sx-hair {
  fill: #050708;
}

.sx-hood-rim {
  fill: #12191a;
}

.sx-shirt {
  fill: #0a0f11;
  stroke: rgba(101, 255, 194, 0.28);
  stroke-width: 1;
}

.sx-shirt-light {
  fill: #20312f;
}

.sx-shirt-dark {
  fill: #050809;
}

.sx-torso-hole {
  fill: #070a0b;
  stroke: rgba(216, 181, 109, 0.24);
  stroke-width: 1;
}

.sx-torso-flame {
  fill: #65ffc2;
  filter: url(#sxSoftGlow);
}

.sx-visor-void {
  fill: #050708;
  stroke: rgba(101, 255, 194, 0.4);
  stroke-width: 1;
}

.sx-visor-line {
  fill: #65ffc2;
  filter: url(#sxSoftGlow);
}

.sx-visor-line.is-dim {
  opacity: 0.46;
}

.sx-visor-cursor {
  fill: var(--sx-ember);
  filter: url(#sxSoftGlow);
  animation: sx-cursor-blink 420ms steps(2,end) infinite;
}

@keyframes sx-cursor-blink {
  0%, 58%, 100% { opacity: 1; }
  60%, 78% { opacity: 0.08; }
}

.sx-mask {
  fill: #090c0d;
  stroke: rgba(101, 255, 194, 0.34);
  stroke-width: 1;
}

.sx-mask-line {
  fill: none;
  stroke: #65ffc2;
  stroke-width: 2;
  opacity: 0.78;
}

.sx-hack-panel {
  filter: drop-shadow(0 0 6px rgba(101, 255, 194, 0.2));
}

.sx-hack-panel-bg {
  fill: rgba(4, 8, 9, 0.84);
  stroke: rgba(101, 255, 194, 0.48);
  stroke-width: 1;
}

.sx-hack-panel-line {
  fill: rgba(101, 255, 194, 0.62);
}

.sx-hack-panel-line.is-long {
  fill: rgba(229, 222, 204, 0.48);
}

.sx-hack-cursor {
  fill: var(--sx-ember);
  animation: sx-cursor-blink 360ms steps(2,end) infinite;
}

.sx-pants {
  fill: #303b3e;
}

.sx-shoe {
  fill: #171d1f;
}

.sx-skin {
  fill: var(--sx-skin);
}

.sx-skin-shadow {
  fill: var(--sx-skin-shadow);
}

.sx-sleeve {
  fill: #111a1c;
}

.sx-hand {
  fill: var(--sx-skin);
}

.sx-back-incense .sx-stick-body,
.sx-held-incense .sx-stick-body,
.sx-planted-incense .sx-stick-body {
  fill: url(#sxIncenseBody);
}

.sx-stick-edge {
  fill: rgba(255, 205, 140, 0.28);
}

.sx-stick-base {
  fill: #5b2c25;
}

.sx-stick-gold {
  fill: url(#sxGoldBand);
}

.sx-stick-cap {
  fill: #59251f;
  stroke: rgba(232, 186, 108, 0.52);
  stroke-width: 1;
}

.sx-stick-ember {
  fill: #ff8a45;
  filter: url(#sxSoftGlow);
}

.sx-stick-core {
  fill: #ffd39a;
}

.sx-stick-eye-void {
  fill: #060809;
  stroke: rgba(229, 222, 204, 0.2);
  stroke-width: 1;
}

.sx-stick-eye-pupil {
  fill: var(--sx-ember);
  filter: url(#sxSoftGlow);
}

.sx-echoes {
  mix-blend-mode: screen;
  pointer-events: none;
}

.sx-echo {
  opacity: 0.16;
  filter: url(#sxBlur);
}

.sx-echo.is-right {
  opacity: 0.1;
}

.sx-float-pixel {
  fill: var(--sx-gold);
  opacity: 0.8;
  animation: sx-block-orbit 1.7s steps(3,end) infinite;
}

.sx-float-pixel.is-late {
  animation-delay: -700ms;
}

@keyframes sx-block-orbit {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: 0.18; }
  35% { transform: translate3d(8px, -10px, 0); opacity: 0.88; }
  68% { transform: translate3d(-5px, -18px, 0); opacity: 0.36; }
}

.sx-tie {
  fill: none;
  stroke: #8c6f4d;
  stroke-width: 5;
  stroke-linecap: square;
}

.sx-smoke {
  fill: none;
  stroke: rgba(221, 229, 220, 0.52);
  stroke-width: 6;
  stroke-linecap: round;
  opacity: 0;
  filter: blur(2px);
}

.sx-smoke-face {
  filter: url(#sxCrack);
}

.sx-smoke-face-void {
  fill: rgba(5, 8, 9, 0.76);
  stroke: rgba(229, 222, 204, 0.34);
  stroke-width: 2;
}

.sx-smoke-face-pupil {
  fill: var(--sx-ember);
  filter: url(#sxSoftGlow);
}

.sx-smoke-face-mouth {
  fill: none;
  stroke: rgba(118, 31, 26, 0.84);
  stroke-width: 4;
  stroke-linecap: round;
}

.sx-overlay.is-smoking .sx-smoke {
  animation: sx-smoke-rise 4.8s ease-out infinite;
}

.sx-overlay.is-smoking .sx-smoke:nth-child(2) {
  animation-delay: -1.6s;
}

.sx-overlay.is-smoking .sx-smoke:nth-child(3) {
  animation-delay: -3.2s;
}

@keyframes sx-smoke-rise {
  0% { opacity: 0; stroke-dashoffset: 30; transform: translateY(12px) scale(0.9); }
  18% { opacity: 0.45; }
  72% { opacity: 0.22; }
  100% { opacity: 0; stroke-dashoffset: -70; transform: translateY(-48px) scale(1.16); }
}

.sx-spark {
  fill: var(--sx-ember);
  opacity: 0;
}

.sx-overlay.is-sparking .sx-spark {
  animation: sx-spark-out 700ms ease-out both;
}

.sx-overlay.is-sparking .sx-spark:nth-child(2) { animation-delay: 50ms; }
.sx-overlay.is-sparking .sx-spark:nth-child(3) { animation-delay: 100ms; }
.sx-overlay.is-sparking .sx-spark:nth-child(4) { animation-delay: 150ms; }
.sx-overlay.is-sparking .sx-spark:nth-child(5) { animation-delay: 210ms; }

@keyframes sx-spark-out {
  0% { opacity: 1; transform: translate3d(0, 0, 0) scale(0.7); }
  100% { opacity: 0; transform: translate3d(var(--dx), var(--dy), 0) scale(0.1); }
}

.sx-captions {
  position: absolute;
  top: clamp(52px, 9vh, 110px);
  left: 50%;
  width: min(620px, calc(100vw - 48px));
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
}

.sx-captions.is-showing {
  opacity: 1;
  transition: opacity 900ms ease;
}

.sx-kicker {
  margin: 0 0 12px;
  color: rgba(216, 181, 109, 0.78);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.36em;
  text-indent: 0.36em;
  text-transform: uppercase;
}

.sx-title {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 46px);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-shadow: -2px 0 0 rgba(134, 33, 28, 0.45), 2px 0 0 rgba(64, 119, 102, 0.32), 0 2px 22px rgba(0, 0, 0, 0.62);
  animation: sx-title-drift 2.4s steps(2,end) infinite;
}

@keyframes sx-title-drift {
  0%, 88%, 100% { transform: translate3d(0, 0, 0); opacity: 1; }
  90% { transform: translate3d(-5px, 1px, 0); opacity: 0.72; }
  93% { transform: translate3d(4px, -1px, 0); opacity: 0.94; }
}

.sx-subtitle {
  margin: 12px 0 0;
  color: rgba(241, 232, 211, 0.66);
  font-size: clamp(12px, 1.3vw, 15px);
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}

.sx-actions {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  opacity: 0;
  pointer-events: auto;
}

.sx-overlay.is-visible .sx-actions {
  opacity: 0.72;
  transition: opacity 500ms ease 900ms;
}

.sx-overlay.is-visible .sx-actions:hover,
.sx-overlay.is-visible .sx-actions:focus-within {
  opacity: 1;
}

.sx-icon-button {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(241, 232, 211, 0.22);
  border-radius: 50%;
  background: rgba(8, 13, 15, 0.46);
  color: rgba(241, 232, 211, 0.86);
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.sx-icon-button:hover {
  border-color: rgba(216, 181, 109, 0.64);
  background: rgba(15, 23, 24, 0.72);
  color: #fff7e6;
}

.sx-icon-button:focus-visible {
  outline: 2px solid var(--sx-gold);
  outline-offset: 3px;
}

.sx-icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sx-icon-button::after {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  padding: 5px 8px;
  border: 1px solid rgba(241, 232, 211, 0.16);
  border-radius: 4px;
  background: rgba(7, 11, 12, 0.88);
  color: rgba(241, 232, 211, 0.9);
  content: attr(data-tip);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateY(-3px);
  transition: 160ms ease;
  pointer-events: none;
}

.sx-icon-button:hover::after,
.sx-icon-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.sx-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  overflow: hidden;
  opacity: 0.72;
}

.sx-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(169, 53, 42, 0.72), rgba(216, 181, 109, 0.92));
}

.sx-overlay.is-running .sx-progress span {
  animation: sx-progress var(--sx-ritual-duration, 3.04s) linear both;
}

@keyframes sx-progress {
  to { width: 100%; }
}

@media (max-width: 720px) {
  .sx-captions {
    top: max(72px, 9vh);
  }

  .sx-kicker {
    margin-bottom: 9px;
    font-size: 9px;
  }

  .sx-title {
    font-size: clamp(22px, 8vw, 34px);
  }

  .sx-subtitle {
    margin-top: 9px;
    font-size: 11px;
  }

  .sx-icon-button {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sx-overlay *,
  .sx-overlay *::before,
  .sx-overlay *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
