:root {
  color-scheme: light;
  --paper: #f1ece3;
  --ink: #171717;
  --muted: #6d6a63;
  --line: rgba(20, 20, 20, 0.18);
  --jade: #2f8f7d;
  --seal: #b44637;
  --panel: rgba(248, 247, 243, 0.84);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
}

button {
  font: inherit;
}

.prototype-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 720px;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 46%, rgba(255, 255, 255, 0.92), rgba(244, 242, 237, 0.5) 34%, transparent 58%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.045) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: auto, 96px 100%, auto;
}

.video-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--paper);
}

.scene-video,
.scene-poster {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
  transform: translate(-50%, -50%);
}

.scene-video {
  z-index: 1;
  opacity: 0;
  filter: saturate(1.02) contrast(1.02);
  background: var(--paper);
  box-shadow: 0 0 90px 90px rgba(241, 236, 227, 0.72);
  transition: opacity 820ms cubic-bezier(0.22, 1, 0.36, 1);
}

.scene-video.is-active {
  z-index: 2;
  opacity: 1;
}

.scene-poster {
  z-index: 3;
  opacity: 0;
  transition: opacity 240ms ease;
}

body.poster-active .scene-poster {
  opacity: 1;
}

.video-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(90deg,
      var(--paper) 0%,
      rgba(241, 236, 227, 0.96) 5%,
      rgba(241, 236, 227, 0.68) 11%,
      transparent 20%,
      transparent 80%,
      rgba(241, 236, 227, 0.68) 89%,
      rgba(241, 236, 227, 0.96) 95%,
      var(--paper) 100%),
    linear-gradient(180deg,
      var(--paper) 0%,
      rgba(241, 236, 227, 0.96) 7%,
      rgba(241, 236, 227, 0.62) 14%,
      transparent 24%,
      transparent 76%,
      rgba(241, 236, 227, 0.62) 86%,
      rgba(241, 236, 227, 0.96) 93%,
      var(--paper) 100%);
}

.video-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  background:
    radial-gradient(circle at 54% 46%, transparent 0 42%, rgba(241, 236, 227, 0.18) 72%, rgba(241, 236, 227, 0.46) 100%),
    linear-gradient(90deg, rgba(241, 236, 227, 0.16), transparent 24%, transparent 76%, rgba(241, 236, 227, 0.2));
  pointer-events: none;
}

@media (min-width: 901px) {
  .scene-video,
  .scene-poster {
    width: min(1280px, 82vw);
    height: auto;
    aspect-ratio: 16 / 9;
  }
}

.topbar {
  position: absolute;
  top: 34px;
  left: 44px;
  right: 44px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity 650ms ease, transform 650ms ease;
}

.brand,
.profile-chip {
  pointer-events: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
  font-weight: 700;
}

.brand strong,
.profile-chip strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.brand small,
.profile-chip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 214px;
  padding: 8px 0 8px 10px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle at 45% 36%, #ecdfcf 0 18%, transparent 19%),
    linear-gradient(135deg, #101010, #414141);
}

.landing-copy {
  position: absolute;
  z-index: 8;
  left: clamp(36px, 6vw, 96px);
  top: 26vh;
  width: 300px;
  transition: opacity 700ms ease, transform 900ms cubic-bezier(0.2, 0.8, 0.16, 1), filter 900ms ease;
}

.landing-copy p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 16px;
}

.landing-copy h1 {
  margin: 0 0 28px;
  font-size: clamp(48px, 6vw, 84px);
  font-weight: 600;
  line-height: 0.95;
}

.ink-button,
.confirm-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 236px;
  min-height: 62px;
  padding: 12px 24px;
  border: 0;
  color: #f8f7f1;
  background: #111;
  cursor: pointer;
  clip-path: polygon(0 11%, 95% 0, 100% 84%, 7% 100%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.ink-button span,
.confirm-button span {
  font-size: 22px;
}

.ink-button small {
  display: block;
  color: rgba(255, 255, 255, 0.62);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.ghost-link {
  display: block;
  margin-top: 22px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.test-panel,
.attribute-panel {
  position: absolute;
  z-index: 8;
  width: min(30vw, 360px);
  max-height: calc(100vh - 150px);
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 800ms ease, transform 1000ms cubic-bezier(0.2, 0.8, 0.16, 1), filter 1000ms ease;
}

.test-panel {
  left: 48px;
  top: 15vh;
  padding: 24px;
  transform: translate3d(-52px, 18px, 0) scale(0.97);
}

.attribute-panel {
  right: 56px;
  top: 18vh;
  padding: 24px;
  transform: translate3d(70px, 24px, 0) scale(0.97);
}

.panel-heading,
.attribute-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading span,
.attribute-title span {
  font-size: 22px;
}

.panel-heading strong,
.attribute-title strong {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.step-list {
  display: grid;
  gap: 8px;
}

.step-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0 14px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.step-row.active {
  color: #fff;
  background: var(--ink);
}

.step-row span {
  grid-row: span 2;
  color: var(--jade);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.step-row strong {
  font-size: 17px;
  font-weight: 600;
}

.step-row small {
  margin-top: 2px;
  color: currentColor;
  opacity: 0.62;
  font-size: 12px;
}

.test-form {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-section {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.form-section.active {
  display: grid;
  gap: 12px;
}

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

.form-section label span {
  color: var(--muted);
  font-size: 13px;
}

.form-section input,
.form-section select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(20, 20, 20, 0.2);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  font: 15px/1.2 "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
}

.form-section input:focus,
.form-section select:focus {
  outline: 2px solid rgba(47, 143, 125, 0.32);
  outline-offset: 1px;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.text-button {
  flex: 1;
  min-height: 36px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.46);
  color: var(--ink);
  cursor: pointer;
}

.text-button:disabled {
  color: rgba(23, 23, 23, 0.3);
  cursor: default;
}

.confirm-button {
  width: 100%;
  margin-top: 18px;
  justify-content: center;
  font-size: 22px;
}

.realm-result {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.realm-result small {
  display: block;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.realm-result strong {
  display: block;
  margin-top: 6px;
  font-size: 36px;
  font-weight: 600;
  line-height: 1;
}

.realm-result span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.meter {
  display: grid;
  grid-template-columns: 84px 1fr 34px;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
  font-size: 15px;
}

.meter i {
  position: relative;
  height: 10px;
  overflow: hidden;
  background: rgba(20, 20, 20, 0.11);
}

.meter i::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--value);
  background: linear-gradient(90deg, var(--ink), var(--jade));
}

.meter b {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 600;
}

.result-details {
  display: grid;
  gap: 11px;
  margin: 22px 0 0;
}

.result-details div {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid rgba(20, 20, 20, 0.1);
}

.result-details dt {
  color: var(--muted);
  font-size: 13px;
}

.result-details dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.fate-card-overlay {
  --fate-glow: #48ead7;
  --fate-accent: #35d6c8;
  position: absolute;
  inset: 0;
  z-index: 14;
  opacity: 0;
  pointer-events: none;
  transition: opacity 620ms ease;
}

.fate-card-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.fate-card-overlay.is-final {
  pointer-events: none;
}

.fate-card-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.1), rgba(241, 236, 227, 0.56) 52%, rgba(241, 236, 227, 0.82) 100%),
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--fate-glow) 34%, transparent), transparent 34%);
  backdrop-filter: blur(8px) saturate(0.92);
  transition: opacity 700ms ease, backdrop-filter 700ms ease;
}

.fate-card-overlay.is-final .fate-card-scrim {
  opacity: 0.16;
  backdrop-filter: blur(1px);
}

.fate-card-stack,
.fate-card-trigger,
.fate-card-canvas {
  position: absolute;
  inset: 0;
}

.fate-card-trigger {
  z-index: 2;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}

.fate-card-overlay.is-ready .fate-card-trigger {
  cursor: pointer;
}

.fate-card-canvas {
  filter:
    drop-shadow(0 28px 55px rgba(0, 0, 0, 0.24))
    drop-shadow(0 0 34px color-mix(in srgb, var(--fate-glow) 58%, transparent));
}

.fate-card-canvas canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.fate-card-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(44vw, 560px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--fate-glow) 42%, transparent);
  border-radius: 50%;
  box-shadow:
    inset 0 0 34px color-mix(in srgb, var(--fate-glow) 20%, transparent),
    0 0 54px color-mix(in srgb, var(--fate-glow) 22%, transparent);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.84);
  transition: opacity 900ms ease, transform 1200ms cubic-bezier(0.2, 0.8, 0.16, 1);
}

.fate-card-overlay.is-open .fate-card-ring {
  opacity: 0.64;
  transform: translate(-50%, -50%) scale(1);
}

.fate-card-overlay.is-final .fate-card-ring {
  opacity: 0;
  transform: translate(-72%, -50%) scale(0.72);
}

.fate-card-share {
  position: absolute;
  left: clamp(72px, 21vw, 304px);
  top: calc(50% + 286px);
  z-index: 4;
  min-width: 172px;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--fate-glow) 42%, rgba(20, 20, 20, 0.18));
  color: #f8f7f1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 44%),
    #111;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.18),
    0 0 24px color-mix(in srgb, var(--fate-glow) 28%, transparent);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transform: translate(-50%, 12px);
  transition: opacity 520ms ease, transform 680ms cubic-bezier(0.2, 0.8, 0.16, 1);
}

.fate-card-overlay.is-final .fate-card-share {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

body.fate-card-open:not(.fate-card-final) .video-stage,
body.fate-card-open:not(.fate-card-final) .topbar,
body.fate-card-open:not(.fate-card-final) .test-panel {
  filter: blur(8px) saturate(0.86);
}

body.fate-card-open:not(.fate-card-final) .test-panel {
  opacity: 0.22;
  pointer-events: none;
}

body.fate-card-open:not(.fate-card-final) .attribute-panel {
  opacity: 0;
  pointer-events: none;
}

body.fate-card-final .test-panel {
  opacity: 0;
  transform: translate3d(-52px, 18px, 0) scale(0.97);
  pointer-events: none;
}

body.fate-card-final .attribute-panel {
  z-index: 18;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.focus-vignette,
.motion-wash,
.cinema-bars {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.focus-vignette {
  background: radial-gradient(circle at 56% 48%, transparent 0 38%, rgba(244, 242, 237, 0.14) 58%, rgba(244, 242, 237, 0.7) 100%);
  opacity: 0.45;
  transition: opacity 900ms ease;
}

.motion-wash {
  background: linear-gradient(100deg, transparent 0 28%, rgba(255, 255, 255, 0.42) 48%, transparent 72%);
  opacity: 0;
  transform: translateX(-70%);
}

.cinema-bars::before,
.cinema-bars::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  background: #0f0f0f;
  transition: height 850ms cubic-bezier(0.2, 0.8, 0.16, 1);
}

.cinema-bars::before {
  top: 0;
}

.cinema-bars::after {
  bottom: 0;
}

body.testing .landing-copy {
  opacity: 0;
  transform: translate3d(-48px, 18px, 0) scale(0.94);
  filter: blur(4px);
  pointer-events: none;
}

body.testing .test-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

body.testing .focus-vignette {
  opacity: 0.72;
}

body.artifact-active .focus-vignette {
  opacity: 0.34;
}

body.artifact-active:not(.result-ready) .attribute-panel {
  opacity: 0;
  transform: translate3d(70px, 24px, 0) scale(0.97);
  pointer-events: none;
}

body.result-active .test-panel {
  opacity: 0;
  transform: translate3d(-52px, 18px, 0) scale(0.97);
  pointer-events: none;
}

body.result-active .attribute-panel {
  opacity: 1;
  transform: none;
}

body.testing .motion-wash {
  animation: wash 900ms cubic-bezier(0.16, 1, 0.3, 1);
}

body.testing .cinema-bars::before,
body.testing .cinema-bars::after {
  height: 28px;
}

@keyframes wash {
  0% {
    opacity: 0;
    transform: translateX(-72%);
  }
  34% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(70%);
  }
}

@media (max-width: 900px) {
  .prototype-shell {
    min-height: 740px;
  }

  .topbar {
    left: 22px;
    right: 22px;
  }

  .scene-video,
  .scene-poster {
    object-position: 58% center;
  }

  .profile-chip {
    display: none;
  }

  .landing-copy {
    left: 24px;
    top: auto;
    bottom: 96px;
    width: min(250px, calc(100vw - 48px));
  }

  .landing-copy p {
    max-width: 230px;
  }

  .landing-copy h1 {
    width: 190px;
    margin-bottom: 22px;
    font-size: 56px;
    line-height: 0.98;
  }

  .test-panel,
  .attribute-panel {
    width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
  }

  .test-panel {
    top: auto;
    bottom: 24px;
    padding: 18px;
    max-height: min(70vh, 560px);
  }

  .attribute-panel {
    display: none;
  }

  .fate-card-ring {
    width: min(86vw, 430px);
  }

  .fate-card-share {
    left: 50%;
    top: 344px;
  }

  body.fate-card-final .attribute-panel {
    display: block;
    top: auto;
    bottom: 16px;
    max-height: min(52vh, 430px);
  }

  body.testing .topbar {
    opacity: 0;
    transform: translateY(-18px);
    pointer-events: none;
  }

  body.result-active .test-panel {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
