:root {
  --black: #020201;
  --warm-black: #070504;
  --paper-glow: rgba(255, 235, 199, 0.24);
  --signal-white: rgba(255, 249, 232, 0.94);
  --stage-width: min(88vw, 760px);
  --stage-gap: clamp(0.15rem, 1.2vh, 0.9rem);
  --safe-block: min(96svh, 96vh);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(59, 42, 28, 0.13), transparent 46%),
    radial-gradient(circle at 50% 50%, var(--warm-black) 0%, var(--black) 72%);
  color: #e7dcc4;
  font-family: Georgia, "Times New Roman", serif;
}

.welcome-page {
  min-height: 100svh;
  overflow: hidden;
}

.welcome-shell {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(0.5rem, 2.5vmin, 1.4rem);
  isolation: isolate;
}

.signal-stage {
  display: grid;
  grid-template-rows: auto minmax(0, auto) auto;
  justify-items: center;
  align-items: center;
  gap: var(--stage-gap);
  width: var(--stage-width);
  max-height: var(--safe-block);
  transform: translateY(clamp(-0.4rem, -1vh, 0rem));
}

.title-sprite,
.centre-image,
.enter-button img {
  display: block;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.title-sprite {
  width: min(100%, 68vh, 879px);
  object-fit: contain;
  opacity: 0.94;
  filter:
    brightness(0.92)
    contrast(1.08)
    drop-shadow(0 0 0.5rem rgba(255, 223, 178, 0.08));
}

.centre-image {
  width: auto;
  max-width: min(100%, 1177px);
  max-height: min(58vh, calc(var(--safe-block) - clamp(10.5rem, 30vh, 19rem)));
  object-fit: contain;
  opacity: 0.9;
  filter:
    brightness(0.74)
    contrast(1.08)
    saturate(0.84)
    drop-shadow(0 1.1rem 2.5rem rgba(0, 0, 0, 0.75));
}

.enter-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(31vw, 142px);
  min-width: 92px;
  max-width: 214px;
  min-height: 52px;
  padding: 0.75rem 1.1rem;
  color: inherit;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.12);
}

.enter-button::before {
  position: absolute;
  inset: -0.6rem -1rem;
  content: "";
}

.enter-button img {
  position: relative;
  width: 100%;
  max-width: 214px;
  opacity: 0.86;
  filter:
    brightness(0.86)
    contrast(1.12)
    drop-shadow(0 0 0.55rem rgba(255, 226, 181, 0.08));
  transition: opacity 120ms ease, filter 120ms ease, transform 120ms ease;
}

.enter-button:hover img,
.enter-button:focus-visible img,
.enter-button.is-active img {
  opacity: 1;
  filter:
    brightness(1.06)
    contrast(1.1)
    drop-shadow(0 0 0.65rem rgba(255, 235, 198, 0.16));
}

.enter-button:focus-visible {
  outline: 1px solid rgba(238, 218, 178, 0.36);
  outline-offset: 0.3rem;
}

.enter-button:active img,
.enter-button.is-active img {
  transform: scale(0.985);
}

.noise-canvas,
.screen-veil,
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.noise-canvas {
  z-index: 5;
  width: 100%;
  height: 100%;
  opacity: 0.68;
}

.screen-veil {
  z-index: 4;
  background:
    linear-gradient(rgba(255, 238, 206, 0.018) 50%, rgba(0, 0, 0, 0.08) 50%),
    radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.2) 73%, rgba(0, 0, 0, 0.74) 100%);
  background-size: 100% 4px, 100% 100%;
  opacity: 0.56;
}

.crt-overlay {
  z-index: 10;
  overflow: hidden;
  opacity: 0;
}

.crt-overlay::before,
.crt-overlay::after {
  position: absolute;
  left: 50%;
  top: 50%;
  content: "";
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.crt-overlay::before {
  width: 100vw;
  height: 100vh;
  background: var(--signal-white);
  opacity: 0;
}

.crt-overlay::after {
  width: 100vw;
  height: 2px;
  border-radius: 999px;
  background: #fff8e8;
  box-shadow:
    0 0 0.65rem rgba(255, 248, 232, 0.95),
    0 0 2rem rgba(255, 248, 232, 0.78);
  opacity: 0;
}

.crt-shutdown-active {
  pointer-events: none;
}

.crt-shutdown-active .crt-overlay {
  opacity: 1;
}

.crt-shutdown-active .crt-overlay::before {
  animation: crt-flash 880ms cubic-bezier(0.2, 0, 0.15, 1) forwards;
}

.crt-shutdown-active .crt-overlay::after {
  animation: crt-line 880ms cubic-bezier(0.18, 0.82, 0.18, 1) forwards;
}

.crt-shutdown-active .welcome-shell,
.crt-shutdown-active .noise-canvas,
.crt-shutdown-active .screen-veil {
  animation: picture-collapse 880ms cubic-bezier(0.2, 0, 0.15, 1) forwards;
}

.rabbit-hole-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
}

.rabbit-hole-shell {
  width: min(88vw, 42rem);
  text-align: center;
}

.rabbit-hole-shell p {
  margin: 0;
  color: rgba(232, 218, 190, 0.7);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  letter-spacing: 0.055em;
  text-shadow: 0 0 1.4rem rgba(255, 230, 180, 0.08);
}

@keyframes crt-flash {
  0% {
    opacity: 0;
  }

  8% {
    opacity: 0.98;
  }

  19% {
    opacity: 0.74;
  }

  34% {
    opacity: 0;
  }

  100% {
    opacity: 0;
  }
}

@keyframes crt-line {
  0%,
  20% {
    opacity: 0;
    width: 100vw;
    height: 100vh;
    filter: blur(0);
  }

  36% {
    opacity: 1;
    width: 100vw;
    height: 5px;
    filter: blur(1px);
  }

  62% {
    opacity: 1;
    width: 22vw;
    height: 3px;
    filter: blur(1.5px);
  }

  78% {
    opacity: 0.9;
    width: 10px;
    height: 10px;
    filter: blur(3px);
  }

  100% {
    opacity: 0;
    width: 2px;
    height: 2px;
    filter: blur(8px);
  }
}

@keyframes picture-collapse {
  0% {
    opacity: 1;
    filter: brightness(1);
    transform: scaleY(1);
  }

  28% {
    opacity: 1;
    filter: brightness(2.8);
    transform: scaleY(1);
  }

  44% {
    opacity: 0.28;
    filter: brightness(3.2);
    transform: scaleY(0.012);
  }

  70% {
    opacity: 0.08;
    transform: scale(0.06, 0.006);
  }

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

@media (max-aspect-ratio: 4 / 5) {
  :root {
    --stage-width: min(92vw, 520px);
    --stage-gap: clamp(0.05rem, 1vh, 0.45rem);
  }

  .welcome-shell {
    padding: clamp(0.35rem, 2.5vw, 0.9rem);
  }

  .title-sprite {
    width: min(92vw, 430px);
  }

  .centre-image {
    width: auto;
    max-width: min(94vw, 520px);
    max-height: min(54vh, calc(var(--safe-block) - 12rem));
  }

  .enter-button {
    width: clamp(104px, 34vw, 154px);
    min-height: 58px;
    padding: 0.7rem 1.1rem;
  }
}

@media (max-height: 620px) {
  :root {
    --stage-gap: 0;
  }

  .signal-stage {
    width: min(86vw, 620px);
    transform: none;
  }

  .title-sprite {
    width: min(72vw, 54vh, 620px);
  }

  .centre-image {
    max-height: 49vh;
  }

  .enter-button {
    min-height: 44px;
    padding-block: 0.35rem;
  }
}

@media (max-height: 460px) {
  .welcome-page {
    overflow: auto;
  }

  .welcome-shell {
    min-height: 460px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .noise-canvas {
    opacity: 0.16;
  }

  .screen-veil {
    background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.66) 100%);
    opacity: 0.72;
  }

  .title-sprite,
  .centre-image,
  .enter-button img {
    transition: none;
  }

  .crt-shutdown-active .crt-overlay {
    background: #000;
    animation: reduced-fade 420ms ease forwards;
  }

  .crt-shutdown-active .crt-overlay::before,
  .crt-shutdown-active .crt-overlay::after,
  .crt-shutdown-active .welcome-shell,
  .crt-shutdown-active .noise-canvas,
  .crt-shutdown-active .screen-veil {
    animation: none;
  }
}

@keyframes reduced-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}
