@font-face {
  font-family: "Christmas Wish";
  src: url("./assets/houtuan-wish.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #fbf8ff;
  --lavender: #cbb8ff;
  --violet: #9472ff;
  --magenta: #ff86da;
  --ice: #bfe9ff;
  --night: #060211;
  --wish-font: "Christmas Wish", "Yuanti SC", YouYuan, "PingFang SC", sans-serif;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
}

button {
  font: inherit;
}

.experience {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 54% 42%, rgba(66, 35, 117, 0.2), transparent 35rem),
    linear-gradient(155deg, #090218 0%, #04010d 52%, #070216 100%);
}

#scene {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
}

.film-grain,
.vignette {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}

.film-grain {
  opacity: 0.11;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
}

.vignette {
  z-index: 4;
  background:
    linear-gradient(90deg, rgba(2, 0, 8, 0.44), transparent 28%, transparent 73%, rgba(2, 0, 8, 0.46)),
    radial-gradient(circle at 50% 45%, transparent 45%, rgba(2, 0, 8, 0.48) 100%);
}

.code-stream {
  position: absolute;
  z-index: 1;
  top: 19%;
  left: max(1rem, calc(50% - 34rem));
  width: min(27vw, 20rem);
  padding-left: 1rem;
  border-left: 1px solid rgba(186, 155, 255, 0.13);
  color: rgba(196, 177, 235, 0.19);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: clamp(0.52rem, 1.1vw, 0.68rem);
  line-height: 1.8;
  letter-spacing: 0.01em;
  opacity: 0.58;
  transition: opacity 1.2s ease;
  user-select: none;
}

.code-stream::before {
  content: "RUNNING / PARTICLE_TREE.JS";
  display: block;
  margin-bottom: 1rem;
  color: rgba(191, 233, 255, 0.35);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
}

.code-stream p {
  margin: 0;
  white-space: nowrap;
}

.code-stream b {
  margin-right: 0.65rem;
  color: rgba(255, 134, 218, 0.25);
  font-weight: 400;
}

.has-started .code-stream {
  opacity: 1;
  animation: code-breathe 4s ease-in-out infinite;
}

.gate {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
  text-align: center;
  background:
    radial-gradient(circle at 50% 44%, rgba(94, 59, 156, 0.19), transparent 19rem),
    rgba(5, 1, 14, 0.92);
  transition: opacity 1.15s ease, visibility 1.15s ease;
}

.gate.is-open {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-orbit {
  position: relative;
  display: grid;
  width: 7.2rem;
  aspect-ratio: 1;
  margin-bottom: 2rem;
  place-items: center;
}

.gate-orbit::before,
.gate-orbit::after,
.gate-orbit i {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(203, 184, 255, 0.2);
  border-radius: 50%;
}

.gate-orbit::after {
  inset: 0.85rem;
  border-color: rgba(191, 233, 255, 0.13);
}

.gate-orbit i:nth-child(1) {
  transform: rotateX(64deg);
  border-color: rgba(255, 134, 218, 0.3);
  animation: orbit-spin 5s linear infinite;
}

.gate-orbit i:nth-child(2) {
  transform: rotateY(64deg);
  border-color: rgba(148, 114, 255, 0.28);
  animation: orbit-spin-reverse 6s linear infinite;
}

.gate-orbit i:nth-child(3) {
  inset: 1.55rem;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 25px rgba(148, 114, 255, 0.18);
}

.gate-orbit span {
  color: #fff;
  font-size: 2rem;
  text-shadow: 0 0 10px #fff, 0 0 28px var(--magenta), 0 0 56px var(--violet);
  animation: star-pulse 1.9s ease-in-out infinite;
}

.micro-label {
  margin: 0 0 0.9rem;
  color: rgba(205, 187, 255, 0.66);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.18em;
}

.gate h1 {
  margin: 0;
  color: #fff2ff;
  font: 400 clamp(1.5rem, 9vw, 3.75rem)/1.25 var(--wish-font);
  letter-spacing: 0.035em;
  text-shadow: 0 2px 0 #65426f, 0 0 24px rgba(213, 156, 249, 0.27);
}

.start-button {
  position: relative;
  min-width: 11rem;
  margin-top: 2.7rem;
  padding: 0.9rem 1.8rem;
  overflow: hidden;
  border: 1px solid rgba(217, 201, 255, 0.46);
  border-radius: 999px;
  background: linear-gradient(115deg, rgba(110, 76, 176, 0.18), rgba(255, 255, 255, 0.05));
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.13em;
  box-shadow: 0 0 32px rgba(148, 114, 255, 0.18), inset 0 0 18px rgba(255, 255, 255, 0.05);
}

.start-button:active {
  transform: scale(0.97);
}

.button-scan {
  position: absolute;
  top: -80%;
  bottom: -80%;
  left: -30%;
  width: 24%;
  background: rgba(255, 255, 255, 0.45);
  filter: blur(15px);
  transform: rotate(18deg);
  animation: button-scan 3s ease-in-out infinite;
}

.start-button span:last-child {
  position: relative;
}

.sound-hint {
  margin: 1rem 0 0;
  color: rgba(215, 200, 244, 0.42);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.ending {
  position: absolute;
  z-index: 8;
  top: 50%;
  right: max(1rem, calc(50% - 29rem));
  display: grid;
  width: min(47vw, 26rem);
  grid-template-columns: minmax(8rem, 0.9fr) minmax(8rem, 1.15fr);
  align-items: center;
  gap: clamp(0.8rem, 2.4vw, 1.7rem);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(2.2rem, -45%, 0) scale(0.96);
  visibility: hidden;
  transition: visibility 0s, opacity 1.25s ease, transform 1.6s cubic-bezier(0.19, 0.8, 0.28, 1);
}

.is-revealed .ending {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, -45%, 0) scale(1);
}

.portrait-shell {
  position: relative;
  isolation: isolate;
}

.portrait-halo {
  position: absolute;
  z-index: -2;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 128, 255, 0.2), rgba(255, 134, 218, 0.07) 45%, transparent 70%);
  animation: halo-breathe 3.8s ease-in-out infinite;
}

.portrait-frame {
  position: relative;
  aspect-ratio: 260 / 300;
}

.portrait-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mask-image: linear-gradient(to bottom, #000 0 82%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0 82%, transparent 100%);
}

.portrait-star {
  position: absolute;
  color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 25px var(--magenta);
  animation: star-pulse 2.2s ease-in-out infinite;
}

.star-one {
  top: 5%;
  left: -8%;
  font-size: 1rem;
}

.star-two {
  right: -4%;
  bottom: 17%;
  font-size: 0.7rem;
  animation-delay: -0.8s;
}

.ending-copy {
  min-width: 0;
}

.ending-copy .micro-label {
  margin-bottom: 0.45rem;
  color: rgba(191, 233, 255, 0.48);
  font-size: clamp(0.54rem, 1vw, 0.66rem);
}

.ending-copy h2 {
  margin: 0;
  color: #fff2ff;
  font: 400 clamp(1.42rem, 3.75vw, 2.25rem)/1.28 var(--wish-font);
  letter-spacing: 0.025em;
  text-shadow: 0 2px 0 #65426f, 0 0 18px rgba(232, 162, 247, 0.26);
}

.ending-copy .recipient {
  display: block;
  margin-bottom: 0.18em;
  color: #ddc7f2;
  font-size: 0.8em;
  letter-spacing: 0.08em;
}

.ending-wish {
  margin: 0.5rem 0 0;
  color: var(--lavender);
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(1rem, 2.4vw, 1.55rem);
  letter-spacing: 0.17em;
}

.hairline {
  width: 3.2rem;
  height: 1px;
  margin: 1rem 0;
  background: linear-gradient(90deg, rgba(255, 134, 218, 0.8), transparent);
}

.ending-note {
  max-width: 13rem;
  margin: 0;
  color: rgba(235, 225, 255, 0.58);
  font-family: "Songti SC", "SimSun", serif;
  font-size: clamp(0.75rem, 1.5vw, 0.95rem);
  line-height: 1.75;
  letter-spacing: 0.06em;
}

.status-rail {
  position: absolute;
  z-index: 9;
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  left: max(1rem, calc(50% - 34rem));
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: rgba(202, 184, 239, 0.4);
  font-family: Consolas, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.11em;
}

.status-dot {
  width: 0.38rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 10px var(--magenta);
}

.has-started .status-dot {
  animation: status-pulse 1.1s ease-in-out infinite;
}

.controls {
  position: absolute;
  z-index: 12;
  top: max(1rem, env(safe-area-inset-top));
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.icon-button,
.replay-button {
  border: 1px solid rgba(220, 205, 255, 0.24);
  background: rgba(12, 4, 28, 0.56);
  color: rgba(255, 255, 255, 0.82);
}

[hidden] { display: none !important; }

.gate .micro-label {
  font: italic clamp(1.15rem, 3vw, 1.55rem)/1.2 Georgia, serif;
  color: #cdb5e4;
  letter-spacing: .055em;
}

.gate.is-open *, .experience:not(.is-revealed) .portrait-shell * {
  animation-play-state: paused;
}

.icon-button {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border-radius: 50%;
}

.replay-button {
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.sound-off {
  display: none;
}

.icon-button.is-muted .sound-on {
  display: none;
}

.icon-button.is-muted .sound-off {
  display: inline;
}

@keyframes orbit-spin {
  to { transform: rotateX(64deg) rotateZ(360deg); }
}

@keyframes orbit-spin-reverse {
  to { transform: rotateY(64deg) rotateZ(-360deg); }
}

@keyframes star-pulse {
  50% { transform: scale(1.18) rotate(7deg); opacity: 0.72; }
}

@keyframes button-scan {
  0%, 38% { transform: translateX(-220%) rotate(18deg); }
  72%, 100% { transform: translateX(650%) rotate(18deg); }
}

@keyframes code-breathe {
  50% { opacity: 0.62; }
}

@keyframes halo-breathe {
  50% { transform: scale(1.08); opacity: 0.68; }
}

@keyframes status-pulse {
  50% { opacity: 0.28; transform: scale(0.65); }
}

@media (max-width: 700px) {

  .code-stream {
    top: 18%;
    left: 0.8rem;
    width: 44vw;
    padding-left: 0.55rem;
    font-size: 0.43rem;
    opacity: 0.32;
  }

  .code-stream p:nth-child(n + 6) {
    display: none;
  }

  .ending {
    top: 47%;
    right: 0.65rem;
    width: 48vw;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    transform: translate3d(1.5rem, -42%, 0) scale(0.94);
  }

  .is-revealed .ending {
    transform: translate3d(0, -42%, 0) scale(1);
  }

  .portrait-frame {
    width: min(100%, 10rem);
    margin-left: auto;
  }

  .portrait-shell {
    width: min(100%, 9rem);
    margin-left: auto;
  }

  .ending-copy {
    justify-self: end;
    width: min(100%, 9.5rem);
    text-align: center;
  }

  .ending-copy h2 {
    font-size: clamp(1.42rem, 6.2vw, 1.72rem);
  }

  .ending-copy .micro-label {
    white-space: nowrap;
  }

  .hairline {
    margin-left: auto;
    background: linear-gradient(90deg, transparent, rgba(255, 134, 218, 0.8));
  }

  .ending-note {
    margin-left: auto;
    font-size: 0.72rem;
  }

  .status-rail {
    left: 0.9rem;
  }
}

@media (max-height: 650px) {
  .gate-orbit {
    width: 5rem;
    margin-bottom: 1.2rem;
  }

  .gate h1 {
    font-size: clamp(1.5rem, 9vw, 2rem);
  }

  .start-button {
    margin-top: 1.7rem;
  }

  .portrait-frame {
    max-height: 13rem;
  }
}

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