:root {
  --night: #080b10;
  --ink: #0e141d;
  --parchment: #f5ead1;
  --gold: #d8b56a;
  --gold-bright: #ffe8a6;
  --blue: #8bc8ff;
  --mist: rgba(173, 214, 255, 0.11);
  --panel: rgba(10, 15, 23, 0.84);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--parchment);
  background:
    radial-gradient(circle at 50% 42%, rgba(67, 103, 139, 0.17), transparent 30%),
    linear-gradient(180deg, #05070b 0%, var(--night) 58%, #040608 100%);
  font-family: Georgia, "Times New Roman", serif;
}

button {
  font: inherit;
}

.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: 0;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: white;
  opacity: 0.2;
  animation: twinkle var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
}

.moon-glow {
  position: absolute;
  left: 50%;
  top: 15%;
  width: min(54vw, 720px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(116, 174, 232, 0.13), transparent 67%);
  filter: blur(12px);
  animation: breathe 7s ease-in-out infinite;
}

.library {
  position: absolute;
  bottom: 0;
  width: 34vw;
  min-width: 360px;
  height: 92vh;
  opacity: 0.9;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.02), transparent 7%),
    repeating-linear-gradient(
      90deg,
      #111821 0 12px,
      #0b1017 12px 17px,
      #182130 17px 27px,
      #0b1017 27px 33px
    );
  box-shadow: inset 0 0 70px rgba(0,0,0,0.75);
}

.library::before,
.library::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 12px;
  background: #17120d;
  box-shadow: 0 4px 12px black;
}

.library::before {
  top: 28%;
}

.library::after {
  top: 59%;
}

.library-left {
  left: -6vw;
  transform: perspective(900px) rotateY(11deg);
  transform-origin: left center;
  clip-path: polygon(0 0, 100% 10%, 100% 100%, 0 100%);
}

.library-right {
  right: -6vw;
  transform: perspective(900px) rotateY(-11deg);
  transform-origin: right center;
  clip-path: polygon(0 10%, 100% 0, 100% 100%, 0 100%);
}

.library span {
  position: absolute;
  bottom: 6%;
  width: 18px;
  height: 58%;
  background: linear-gradient(90deg, #2d1e15, #111);
  opacity: 0.7;
}

.library span:nth-child(1) { left: 16%; }
.library span:nth-child(2) { left: 37%; }
.library span:nth-child(3) { left: 61%; }
.library span:nth-child(4) { left: 82%; }

.arch {
  position: absolute;
  left: 50%;
  bottom: 4vh;
  width: min(35vw, 430px);
  height: min(70vh, 670px);
  transform: translateX(-50%);
  border: 16px solid #19150f;
  border-bottom: 0;
  border-radius: 48% 48% 0 0 / 28% 28% 0 0;
  box-shadow:
    0 0 0 4px #302718,
    0 0 60px rgba(0,0,0,0.95),
    inset 0 0 38px rgba(0,0,0,0.8);
}

.arch::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 2px solid rgba(216,181,106,0.24);
  border-bottom: 0;
  border-radius: inherit;
}

.door-light {
  position: absolute;
  inset: 30px 24px 0;
  border-radius: 48% 48% 0 0 / 28% 28% 0 0;
  background:
    linear-gradient(180deg, rgba(139,200,255,0.08), rgba(216,181,106,0.23)),
    radial-gradient(circle at 50% 70%, rgba(255,232,166,0.44), transparent 35%),
    #070b11;
  box-shadow:
    inset 0 0 90px rgba(139,200,255,0.16),
    0 0 35px rgba(216,181,106,0.2);
  animation: doorPulse 5s ease-in-out infinite;
}

.sigil {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  color: var(--gold-bright);
  font-size: clamp(2rem, 4vw, 4rem);
  text-shadow: 0 0 14px var(--gold);
  animation: sigilFloat 4s ease-in-out infinite;
}

.floor-glow {
  position: absolute;
  left: 50%;
  bottom: -7vh;
  width: min(70vw, 900px);
  height: 25vh;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(216,181,106,0.2), transparent 67%);
  filter: blur(10px);
}

.mist {
  position: absolute;
  bottom: 0;
  width: 70vw;
  height: 20vh;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--mist), transparent 70%);
  filter: blur(18px);
  opacity: 0.55;
}

.mist-one {
  left: -15vw;
  animation: driftOne 14s ease-in-out infinite alternate;
}

.mist-two {
  right: -15vw;
  animation: driftTwo 17s ease-in-out infinite alternate;
}

.hero {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  width: min(860px, 92vw);
  margin: 0 auto;
  padding: 12vh 20px 8vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.eyebrow {
  margin: 0 0 16px;
  color: rgba(245,234,209,0.68);
  font-size: clamp(0.76rem, 1.4vw, 0.98rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0;
  animation: riseIn 1s 0.25s forwards;
}

.title {
  position: relative;
  margin: 0;
  font-size: clamp(4.3rem, 13vw, 9.7rem);
  line-height: 0.9;
  letter-spacing: 0.05em;
  text-shadow:
    0 2px 0 #8f7441,
    0 8px 30px rgba(0,0,0,0.95);
}

.title-text {
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, #fff9e8 0%, #e8ce8d 56%, #896d37 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.title-glow {
  position: absolute;
  inset: 6% -5%;
  background: radial-gradient(ellipse, rgba(216,181,106,0.22), transparent 65%);
  filter: blur(20px);
  animation: breathe 6s ease-in-out infinite;
}

.subtitle {
  margin: 24px 0 0;
  color: var(--gold-bright);
  font-size: clamp(1.05rem, 2.6vw, 1.7rem);
  letter-spacing: 0.05em;
  text-shadow: 0 0 16px rgba(216,181,106,0.32);
  opacity: 0;
  animation: riseIn 1s 0.7s forwards;
}

.welcome {
  max-width: 680px;
  margin: 16px 0 0;
  color: rgba(245,234,209,0.87);
  font-size: clamp(1rem, 2vw, 1.28rem);
  line-height: 1.65;
  opacity: 0;
  animation: riseIn 1s 1s forwards;
}

.actions {
  margin-top: 38px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  opacity: 0;
  animation: riseIn 1s 1.25s forwards;
}

.primary-button,
.secondary-button {
  position: relative;
  min-width: 210px;
  padding: 15px 26px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-button {
  border: 1px solid rgba(255,232,166,0.8);
  color: #16110a;
  background: linear-gradient(180deg, #ffeab1, #c99f4f);
  box-shadow:
    0 8px 30px rgba(216,181,106,0.2),
    inset 0 1px 0 rgba(255,255,255,0.75);
}

.secondary-button {
  border: 1px solid rgba(245,234,209,0.34);
  color: var(--parchment);
  background: rgba(8,11,16,0.5);
  backdrop-filter: blur(8px);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-3px);
}

.primary-button:hover {
  box-shadow:
    0 12px 38px rgba(216,181,106,0.35),
    0 0 25px rgba(255,232,166,0.18);
}

.secondary-button:hover {
  background: rgba(245,234,209,0.1);
}

.button-spark {
  margin-left: 8px;
  display: inline-block;
  animation: sparkle 2.4s ease-in-out infinite;
}

.whisper {
  min-height: 1.5em;
  margin: 28px 0 0;
  color: rgba(139,200,255,0.62);
  font-style: italic;
  font-size: 0.95rem;
  opacity: 0;
  animation: riseIn 1s 1.55s forwards;
}

.intro-panel {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 4, 8, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease, visibility 250ms ease;
}

.intro-panel.open {
  opacity: 1;
  visibility: visible;
}

.panel-card {
  position: relative;
  width: min(610px, 94vw);
  padding: 42px;
  border: 1px solid rgba(216,181,106,0.38);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(30,38,49,0.97), var(--panel)),
    var(--panel);
  box-shadow: 0 24px 80px rgba(0,0,0,0.75);
  text-align: left;
}

.panel-card h2 {
  margin: 8px 0 16px;
  color: var(--gold-bright);
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.panel-card p {
  margin: 0;
  line-height: 1.7;
  color: rgba(245,234,209,0.82);
}

.panel-kicker {
  color: var(--blue) !important;
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 18px;
  border: 0;
  color: var(--parchment);
  background: transparent;
  font-size: 2rem;
  cursor: pointer;
}

.noscript-message {
  position: fixed;
  z-index: 20;
  inset: auto 20px 20px;
  padding: 12px 16px;
  background: #420d0d;
  color: white;
}

@keyframes riseIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.12; transform: scale(0.8); }
  50% { opacity: 0.95; transform: scale(1.8); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.68; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); }
}

@keyframes doorPulse {
  0%, 100% { filter: brightness(0.9); }
  50% { filter: brightness(1.17); }
}

@keyframes sigilFloat {
  0%, 100% { transform: translate(-50%, 0) rotate(0deg); }
  50% { transform: translate(-50%, -10px) rotate(12deg); }
}

@keyframes sparkle {
  0%, 100% { transform: scale(0.85) rotate(0deg); opacity: 0.5; }
  50% { transform: scale(1.25) rotate(45deg); opacity: 1; }
}

@keyframes driftOne {
  from { transform: translateX(-4vw); }
  to { transform: translateX(20vw); }
}

@keyframes driftTwo {
  from { transform: translateX(5vw); }
  to { transform: translateX(-18vw); }
}

@media (max-width: 700px) {
  .library {
    width: 45vw;
    min-width: 240px;
    opacity: 0.55;
  }

  .arch {
    width: 70vw;
    height: 60vh;
  }

  .hero {
    padding-top: 8vh;
  }

  .actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    width: min(330px, 100%);
  }

  .panel-card {
    padding: 34px 26px;
  }
}

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