:root {
  color-scheme: dark;
  --black: #080808;
  --paper: #eeeae2;
  --faded: #aaa49a;
  --pink: #ff4f9a;
  --red: #e63756;
  --line: rgba(238, 234, 226, 0.34);
  --mouse-x: 50%;
  --mouse-y: 50%;
  --move-x: 0;
  --move-y: 0;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--black);
  color: var(--paper);
}

body {
  overflow-x: hidden;
  font-family: Arial, Helvetica, sans-serif;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}

#site {
  min-height: 100svh;
}

.front-door {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: #090909;
}

.front-door.leaving {
  animation: enter-house 0.58s cubic-bezier(.7,0,.9,.4) both;
}

@keyframes enter-house {
  0% { opacity: 1; transform: scale(1); filter: blur(0); }
  65% { opacity: 1; transform: scale(1.12); filter: blur(2px); }
  100% { opacity: 0; transform: scale(1.25); filter: blur(15px); }
}

.front-photo,
.room-photo {
  position: absolute;
  inset: -2%;
  background: #171312 url("assets/real-room.webp") center / cover no-repeat;
}

.front-photo {
  z-index: -3;
  filter: grayscale(0.5) sepia(0.1) brightness(0.4) contrast(1.18);
  animation: front-drift 14s ease-in-out infinite alternate;
}

@keyframes front-drift {
  from { transform: scale(1.025) translate3d(-0.25%, 0, 0); }
  to { transform: scale(1.09) translate3d(0.55%, -0.6%, 0); }
}

.front-door::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: rgba(0, 0, 0, 0.34);
  box-shadow: inset 0 0 180px 20px #000;
}

.noise,
.ending-noise {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  animation: noise-jump 0.23s steps(2) infinite;
}

@keyframes noise-jump {
  0% { transform: translate(0); }
  25% { transform: translate(1.2%, -0.8%); }
  50% { transform: translate(-0.8%, 0.5%); }
  75% { transform: translate(0.5%, 1%); }
}

.corner-file,
.front-tip,
.doomicy-credit {
  position: absolute;
  z-index: 2;
  margin: 0;
  font: 13px/1.45 "Courier New", monospace;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.corner-file {
  top: 24px;
  left: 26px;
  color: rgba(238, 234, 226, 0.56);
}

.front-tip {
  right: 28px;
  bottom: 27px;
  transform: rotate(3deg);
  color: var(--pink);
}

.doomicy-credit {
  left: 27px;
  bottom: 27px;
  color: rgba(238, 234, 226, 0.72);
}

.front-copy {
  position: absolute;
  top: 50%;
  left: clamp(1.5rem, 10vw, 10rem);
  width: min(88vw, 620px);
  transform: translateY(-48%);
}

.scribble {
  width: max-content;
  margin: 0 0 0.55rem 0.5rem;
  color: var(--pink);
  font: 18px/1.2 "Comic Sans MS", "Comic Sans", cursive;
  transform: rotate(-3deg);
  animation: scribble-in 0.75s 0.15s both;
}

@keyframes scribble-in {
  from { opacity: 0; transform: translateX(-22px) rotate(-7deg); }
}

.front-copy h1 {
  margin: 0 0 clamp(4.5rem, 7vw, 6.5rem);
  font: 400 clamp(4.8rem, 13vw, 10rem) / 0.95 "Times New Roman", Times, serif;
  letter-spacing: -0.075em;
  text-transform: lowercase;
  text-shadow: 5px 4px 0 rgba(0, 0, 0, 0.55);
  animation: title-in 0.9s cubic-bezier(.18,.82,.18,1) both;
}

.front-copy h1 i {
  display: block;
  margin-left: clamp(2rem, 8vw, 7rem);
  margin-top: 0.08em;
  line-height: 0.78;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--paper);
  transform: rotate(-5deg);
}

@keyframes title-in {
  from { opacity: 0; transform: translateY(35px) skewY(3deg); }
}

.front-intro {
  max-width: 33rem;
  margin: 0 0 0.7rem 0.4rem;
  font: 17px/1.55 "Courier New", monospace;
  color: rgba(238, 234, 226, 0.78);
  animation: fade-up 0.65s 0.45s both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
}

.knock-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 3.6rem;
  min-width: 225px;
  margin: 1.2rem 0 0 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--paper);
  border-radius: 0;
  background: var(--paper);
  color: var(--black);
  font: 700 15px/1 "Courier New", monospace;
  cursor: pointer;
  box-shadow: 6px 6px 0 rgba(255, 79, 154, 0.82);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  animation: fade-up 0.65s 0.62s both;
}

.knock-button:hover {
  transform: translate(3px, 3px) rotate(-1deg);
  box-shadow: 3px 3px 0 var(--pink);
  background: #fff;
}

.door-arrow {
  font-size: 1.25rem;
  transition: transform 0.18s;
}

.knock-button:hover .door-arrow {
  transform: translateX(5px);
}

.room-page {
  min-height: 100svh;
  overflow: hidden;
  background: #0a0909;
  animation: room-enter 1.05s cubic-bezier(.2,.85,.18,1) both;
}

@keyframes room-enter {
  0% { opacity: 0; filter: blur(14px); transform: scale(1.08); }
  45% { opacity: 1; filter: blur(2px); }
  100% { filter: blur(0); transform: scale(1); }
}

.room-bar,
.room-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, 1600px);
  min-height: 64px;
  margin: 0 auto;
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  font-family: "Courier New", monospace;
}

.room-title,
.room-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.room-title strong {
  font-size: 16px;
  font-weight: 400;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(230, 55, 86, 0.7);
  animation: live-pulse 1.7s infinite;
}

@keyframes live-pulse {
  55% { box-shadow: 0 0 0 8px rgba(230, 55, 86, 0); }
}

.room-time,
.found-count {
  color: var(--faded);
  font-size: 13px;
}

.room-controls button {
  padding: 0.42rem 0.6rem;
  border: 1px solid rgba(238, 234, 226, 0.22);
  border-radius: 0;
  background: transparent;
  color: var(--paper);
  font: 13px/1 "Courier New", monospace;
  cursor: pointer;
}

.room-controls button:hover {
  border-color: var(--pink);
  color: var(--pink);
}

.room-scroll {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--pink) #111;
}

.room-frame {
  --photo-shift-x: calc(var(--move-x) * -7px);
  --photo-shift-y: calc(var(--move-y) * -5px);
  position: relative;
  width: min(calc(100% - clamp(1.5rem, 5vw, 5rem)), 1500px);
  aspect-ratio: 16 / 9;
  min-height: 440px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(238, 234, 226, 0.35);
  background: #161313;
  cursor: crosshair;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
}

.room-photo {
  filter: saturate(0.68) contrast(1.1) brightness(0.74);
  transform: translate3d(var(--photo-shift-x), var(--photo-shift-y), 0) scale(1.035);
  transition: transform 0.08s linear;
}

.room-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(37, 9, 21, 0.12);
  mix-blend-mode: color;
  animation: bad-light 9s infinite;
}

@keyframes bad-light {
  0%, 42%, 44%, 67%, 69%, 100% { opacity: 0.8; }
  43%, 68% { opacity: 0.12; }
}

.flashlight {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle 190px at var(--mouse-x) var(--mouse-y), transparent 0%, rgba(0, 0, 0, 0.08) 45%, rgba(0, 0, 0, 0.58) 100%);
  transition: opacity 0.25s;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0.12;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, 0.46) 4px);
  animation: scan-drift 7s linear infinite;
}

@keyframes scan-drift {
  to { background-position-y: 80px; }
}

.tape-note {
  position: absolute;
  z-index: 4;
  padding: 0.7rem 0.8rem;
  color: #171112;
  background: #ddd4bd;
  font: 15px/1.15 "Comic Sans MS", "Comic Sans", cursive;
  text-align: center;
  box-shadow: 4px 6px 13px rgba(0, 0, 0, 0.3);
}

.tape-note::before {
  content: "";
  position: absolute;
  left: 28%;
  right: 28%;
  top: -9px;
  height: 17px;
  background: rgba(220, 207, 169, 0.72);
  transform: rotate(-3deg);
}

.note-one {
  left: 2.2%;
  top: 5%;
  transform: rotate(-5deg);
}

.note-two {
  right: 2.2%;
  top: 4%;
  transform: rotate(4deg);
}

.object,
.door-hitbox {
  position: absolute;
  z-index: 5;
  border: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.object {
  width: 54px;
  height: 54px;
  padding: 0;
}

.object-cross {
  position: absolute;
  inset: 11px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(238, 234, 226, 0.8);
  background: rgba(0, 0, 0, 0.48);
  font: 25px/1 "Courier New", monospace;
  transition: transform 0.16s, background 0.16s, color 0.16s;
  animation: cross-jitter 3.4s steps(1) infinite;
}

@keyframes cross-jitter {
  0%, 93%, 100% { transform: translate(0); }
  95% { transform: translate(-2px, 1px); }
  97% { transform: translate(2px, -1px); }
}

.object:hover .object-cross,
.object:focus-visible .object-cross {
  color: #000;
  background: var(--paper);
  transform: rotate(45deg) scale(1.12);
  animation: none;
}

.object-name {
  position: absolute;
  left: 50%;
  top: 52px;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--paper);
  background: #0b0b0b;
  color: var(--paper);
  font: 12px/1 "Courier New", monospace;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 7px);
  transition: opacity 0.16s, transform 0.16s;
}

.object:hover .object-name,
.object:focus-visible .object-name {
  opacity: 1;
  transform: translate(-50%, 0);
}

.object.is-found .object-cross {
  border-color: var(--pink);
  background: var(--pink);
  color: #090909;
  animation: none;
}

.object.is-found .object-cross::after {
  content: "✓";
  position: absolute;
  font-size: 18px;
}

.object.is-found .object-cross {
  font-size: 0;
}

.object-lamp { left: 34%; top: 12%; }
.object-wallpaper { left: 9%; top: 38%; }
.object-switch { left: 23%; top: 53%; }
.object-pillow { left: 71%; top: 62%; }
.object-shadow { left: 61%; top: 29%; }

.door-hitbox {
  right: 2.8%;
  top: 15%;
  width: 12%;
  height: 63%;
}

.door-hitbox span {
  position: absolute;
  left: 50%;
  bottom: 2%;
  padding: 0.38rem 0.5rem;
  border: 1px dashed rgba(238, 234, 226, 0.68);
  background: rgba(0, 0, 0, 0.64);
  font: 12px/1 "Courier New", monospace;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-2deg);
}

.door-hitbox.is-open span {
  border-color: var(--pink);
  color: var(--pink);
  animation: open-label 0.85s ease-in-out infinite alternate;
}

@keyframes open-label {
  to { transform: translateX(-50%) rotate(2deg) scale(1.05); }
}

.room-frame.door-rattle {
  animation: door-rattle 0.32s steps(2);
}

@keyframes door-rattle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.click-burst {
  position: absolute;
  z-index: 9;
  width: 8px;
  height: 8px;
  border: 2px solid var(--pink);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.click-burst.play {
  animation: click-burst 0.48s ease-out;
}

@keyframes click-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(9); }
}

.room-footer {
  min-height: 70px;
  align-items: flex-start;
  color: var(--faded);
  font-size: 13px;
}

.room-footer p {
  margin: 0;
}

.found-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.found-chip {
  padding: 0.28rem 0.42rem;
  border: 1px solid rgba(238, 234, 226, 0.2);
  color: rgba(238, 234, 226, 0.45);
  text-decoration: line-through;
}

.found-chip.is-found {
  border-color: rgba(255, 79, 154, 0.6);
  color: var(--pink);
  text-decoration: none;
}

.photo-credit {
  color: rgba(238, 234, 226, 0.52);
  font-size: 12px;
}

.memory-window {
  position: fixed;
  z-index: 40;
  top: 14vh;
  left: calc(50% - min(45vw, 245px));
  width: min(90vw, 490px);
  border: 1px solid #171717;
  background: var(--paper);
  color: #121212;
  box-shadow: 14px 16px 0 rgba(0, 0, 0, 0.7), 18px 20px 0 var(--pink);
  animation: window-pop 0.28s cubic-bezier(.16,.85,.25,1.2) both;
}

@keyframes window-pop {
  from { opacity: 0; transform: translateY(25px) rotate(2deg) scale(0.92); }
  to { opacity: 1; transform: translateY(0) rotate(-0.5deg) scale(1); }
}

.window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding-left: 0.8rem;
  border-bottom: 1px solid #171717;
  background: #1a1a1a;
  color: var(--paper);
  font: 13px/1 "Courier New", monospace;
  cursor: move;
  touch-action: none;
}

.window-bar button {
  align-self: stretch;
  width: 42px;
  border: 0;
  border-left: 1px solid rgba(238, 234, 226, 0.4);
  background: transparent;
  color: var(--paper);
  font-size: 23px;
  cursor: pointer;
}

.window-bar button:hover {
  background: var(--pink);
  color: #111;
}

.window-body {
  position: relative;
  min-height: 385px;
  padding: 1.7rem clamp(1.3rem, 5vw, 2.4rem) 2rem;
  overflow: hidden;
}

.window-number {
  margin: 0 0 2.1rem;
  font: 13px/1 "Courier New", monospace;
}

.window-stamp {
  position: absolute;
  top: 55px;
  right: 27px;
  color: var(--pink);
  font: 70px/1 "Times New Roman", serif;
  transform: rotate(10deg);
  animation: stamp-in 0.35s 0.12s both;
}

@keyframes stamp-in {
  from { opacity: 0; transform: scale(2.4) rotate(22deg); }
}

.window-body h2 {
  max-width: 75%;
  margin: 0 0 1.1rem;
  font: 700 clamp(2.6rem, 7vw, 4.2rem) / 0.85 "Times New Roman", serif;
  letter-spacing: -0.06em;
}

.window-body > p:not(.window-number):not(.fill-later) {
  max-width: 35ch;
  font: 16px/1.55 "Courier New", monospace;
}

.memory-links {
  display: flex;
  max-width: 38ch;
  margin: 1rem 0 0;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.memory-links[hidden] {
  display: none;
}

.memory-link {
  padding: 0.55rem 0.65rem;
  border: 1px solid #111;
  background: #fff;
  color: #111;
  box-shadow: 3px 3px 0 var(--pink);
  font: 700 13px/1.2 "Courier New", monospace;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.memory-link:hover,
.memory-link:focus-visible {
  box-shadow: 5px 5px 0 var(--pink);
  transform: translate(-2px, -2px);
}

.fill-later {
  margin: 1.4rem 0;
  padding: 0.65rem 0;
  border-top: 1px dashed #777;
  border-bottom: 1px dashed #777;
  color: #5e5a55;
  font: 13px/1.3 "Comic Sans MS", cursive;
  transform: rotate(-1deg);
}

.back-button {
  padding: 0.72rem 0.85rem;
  border: 1px solid #111;
  border-radius: 0;
  background: #111;
  color: var(--paper);
  font: 700 13px/1 "Courier New", monospace;
  cursor: pointer;
}

.back-button:hover {
  background: var(--pink);
  color: #111;
}

.ending {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #080808;
  color: var(--paper);
  animation: ending-in 0.65s steps(6) both;
}

@keyframes ending-in {
  from { opacity: 0; filter: invert(1); }
}

.ending-close {
  position: absolute;
  top: 22px;
  right: 28px;
  border: 0;
  background: transparent;
  color: var(--paper);
  font-size: 32px;
  cursor: pointer;
}

.ending-copy {
  position: relative;
  z-index: 2;
  width: min(88vw, 800px);
  text-align: center;
}

.ending-copy > p:first-child {
  color: var(--pink);
  font: 16px/1 "Comic Sans MS", cursive;
  transform: rotate(-2deg);
}

.ending-copy h2 {
  margin: 1rem 0;
  font: 400 clamp(4rem, 12vw, 9rem) / 0.78 "Times New Roman", serif;
  letter-spacing: -0.07em;
}

.ending-small {
  max-width: 39ch;
  margin: 2rem auto;
  color: var(--faded);
  font: 15px/1.6 "Courier New", monospace;
}

.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background: var(--paper);
  opacity: 0;
}

.screen-flash.play {
  animation: screen-flash 0.38s ease-out;
}

@keyframes screen-flash {
  0% { opacity: 0; }
  12% { opacity: 0.78; }
  100% { opacity: 0; }
}

.cursor-label {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--paper);
  background: #0a0a0a;
  color: var(--paper);
  font: 11px/1 "Courier New", monospace;
  pointer-events: none;
  opacity: 0;
  transform: translate(15px, 15px);
  transition: opacity 0.12s;
}

.cursor-label.show {
  opacity: 1;
}

@media (max-width: 760px) {
  .front-copy {
    top: 46%;
    left: 1.4rem;
  }

  .front-copy h1 {
    font-size: clamp(4.5rem, 24vw, 7rem);
  }

  .front-copy h1 i {
    margin-left: 1.7rem;
  }

  .front-intro {
    max-width: 20rem;
    font-size: 15px;
  }

  .front-tip {
    display: none;
  }

  .room-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .room-controls {
    width: 100%;
  }

  .room-controls .found-count {
    margin-right: auto;
  }

  .room-scroll {
    padding-bottom: 0.35rem;
  }

  .room-frame {
    width: 800px;
    min-height: 450px;
    margin-left: 0.75rem;
  }

  .room-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .found-list {
    justify-content: flex-start;
  }

  .memory-window {
    top: 10vh !important;
    left: 5vw !important;
    transform: none !important;
  }

  .window-bar {
    cursor: default;
  }

  .cursor-label {
    display: none;
  }
}

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

  .room-photo {
    transform: scale(1.02);
  }
}
