:root {
  color-scheme: dark;
  font-family: "Courier New", Consolas, monospace;
  background: #050706;
  color: #e6ddc7;
  --gold: #c99b49;
  --red: #bd4b42;
  --line: #5b513a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  min-height: 560px;
  overflow: hidden;
  margin: 0;
  background: #050706;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #121713eb;
  color: #e6ddc7;
  font: 700 0.72rem "Courier New", monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
}

button:hover {
  border-color: #c49a4e;
  background: #20241d;
}

button:focus-visible {
  outline: 3px solid #f0c56c;
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

kbd {
  padding: 0.12rem 0.3rem;
  border: 1px solid #756644;
  border-radius: 2px;
  background: #070907;
  color: #e4ae52;
  font: 0.62rem Consolas, monospace;
}

[hidden] {
  display: none !important;
}

.game {
  position: relative;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 34px;
  width: 100%;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background: #080b09;
  isolation: isolate;
}

.hud {
  z-index: 30;
  display: flex;
  border-bottom: 1px solid #62573c;
  background: #090d0beF;
}

.hud > div {
  display: grid;
  min-width: 130px;
  align-content: center;
  padding: 0.35rem 1rem;
  border-right: 1px solid #393729;
}

.hud small {
  color: #8f866f;
  font-size: 0.54rem;
  letter-spacing: 0.13em;
}

.hud strong {
  color: #ead7ae;
  font-size: 1rem;
}

.hud strong.critical {
  color: #e46b5d;
  animation: pulse 0.8s steps(2) infinite;
}

.hud .usage {
  margin-right: auto;
}

.usage span {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}

.usage i {
  width: 17px;
  height: 8px;
  border: 1px solid #55503d;
  background: #10130f;
}

.usage i.active {
  box-shadow: 0 0 7px #c99b4955;
  background: var(--gold);
}

.icon-button {
  min-width: 112px;
  margin: 7px 7px 7px 0;
}

.office {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #090a08;
}

.office-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.74) contrast(1.12) brightness(0.78);
  image-rendering: pixelated;
}

.office::after,
.office-rain,
.office-light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
}

.office::after {
  z-index: 7;
  background:
    linear-gradient(90deg, #000b, transparent 16% 84%, #000b),
    linear-gradient(0deg, #000b, transparent 32% 77%, #0008);
}

.office-rain {
  z-index: 3;
  inset: 8% 29% 38% 29%;
  opacity: 0.24;
  background: repeating-linear-gradient(105deg, transparent 0 17px, #dce7d337 18px 19px, transparent 20px 38px);
  animation: rain 1.4s linear infinite;
}

.office-light {
  z-index: 4;
  background: radial-gradient(circle at 50% 10%, #e4d58b1c, transparent 33%);
  animation: fluorescent 8s steps(1) infinite;
}

.office.light-on .office-light {
  background:
    radial-gradient(ellipse at 50% 42%, #f1df9a3d, transparent 31%),
    radial-gradient(circle at 50% 10%, #e4d58b2d, transparent 40%);
}

.office.power-out .office-image {
  filter: saturate(0.35) brightness(0.25);
}

.radio-card {
  position: absolute;
  z-index: 15;
  top: 1rem;
  left: 1rem;
  width: min(390px, 42vw);
  padding: 0.8rem;
  border: 1px solid #80704a;
  box-shadow: 8px 12px 30px #000a;
  background: #0b0e0bd9;
}

.radio-card small,
.radio-card strong {
  display: block;
}

.radio-card small {
  color: var(--gold);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
}

.radio-card strong {
  margin: 0.25rem 0;
  font-family: Georgia, serif;
  font-size: 1.15rem;
}

.radio-card p {
  margin: 0;
  color: #aaa391;
  font-size: 0.7rem;
  line-height: 1.45;
}

.desk-control,
.monitor-toggle {
  position: absolute;
  z-index: 18;
  bottom: 0.9rem;
  min-width: 170px;
  box-shadow: 0 8px 24px #000b, inset 0 1px #77705a;
  background: linear-gradient(#24271f, #0d100d);
}

.light-control {
  left: 1rem;
}

.shutter-control {
  right: 1rem;
}

.monitor-toggle {
  left: 50%;
  transform: translateX(-50%);
}

.desk-control.active {
  border-color: #e2ae54;
  box-shadow: 0 0 18px #e2ae5455;
  color: #f0c56d;
}

.shutter {
  position: absolute;
  z-index: 12;
  inset: 7% 28% 32%;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  border: 7px solid #161713;
  background: #22231d;
  box-shadow: 0 16px 38px #000e;
  transform: translateY(-115%);
  transition: transform 180ms ease-in;
}

.shutter i {
  border-bottom: 3px solid #0a0b09;
  box-shadow: inset 0 -2px #555244;
  background: linear-gradient(#393a31, #20221d);
}

.office.shutter-down .shutter {
  transform: translateY(0);
}

.window-threat {
  position: absolute;
  z-index: 10;
  top: 18%;
  left: 50%;
  width: 180px;
  height: 360px;
  opacity: 0;
  filter: drop-shadow(0 25px 18px #000);
  pointer-events: none;
  transform: translateX(-50%) scale(0.85);
  transition: opacity 100ms linear, transform 1.4s ease-out;
}

.window-threat::before,
.window-threat::after {
  position: absolute;
  content: "";
}

.window-threat::before {
  top: 0;
  left: 55px;
  width: 72px;
  height: 82px;
  border-radius: 45% 48% 36% 38%;
  background: #030403;
}

.window-threat::after {
  inset: 64px 8px 0;
  background: linear-gradient(90deg, #020302, #0b0d0a 50%, #020302);
  clip-path: polygon(28% 0, 72% 0, 100% 100%, 0 100%);
}

.window-threat.visible {
  opacity: 0.95;
  transform: translateX(-50%) scale(1);
}

.eye {
  position: absolute;
  z-index: 2;
  top: 31px;
  width: 8px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 0 13px #dcaa57;
  background: #f0c36e;
}

.eye.left {
  left: 76px;
}

.eye.right {
  right: 76px;
}

.camera-monitor {
  position: absolute;
  z-index: 24;
  inset: 66px 3.5% 32px;
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr) 88px;
  min-height: 0;
  overflow: hidden;
  border: 17px solid #171914;
  border-bottom-width: 34px;
  border-radius: 8px 8px 3px 3px;
  box-shadow: 0 32px 65px #000f, 0 0 0 2px #514a35;
  background: #080b09;
  opacity: 0;
  pointer-events: none;
  transform: translateY(112%) rotateX(9deg);
  transform-origin: bottom;
  visibility: hidden;
  transition: transform 230ms ease-out, opacity 130ms linear, visibility 0s 230ms;
}

.camera-monitor.open {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}

.camera-monitor > header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 0.8rem;
  border-bottom: 1px solid #5b513a;
  background: #0c100d;
  font-size: 0.68rem;
}

.camera-monitor > header span {
  margin-right: auto;
  color: #ddd2b7;
}

.camera-monitor > header b {
  color: #d75e51;
}

.camera-monitor > header time {
  color: #98917e;
}

.camera-feed {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #11130f;
  isolation: isolate;
}

.scene-layer,
.camera-geometry,
.static {
  position: absolute;
  inset: 0;
}

.scene-layer {
  z-index: 1;
  background-image:
    linear-gradient(90deg, #0009, transparent 20% 78%, #000a),
    url("../assets/booth.webp");
  background-repeat: no-repeat;
  background-position: 50% 32%;
  background-size: 170%;
  filter: grayscale(0.45) saturate(0.55) brightness(0.52) contrast(1.28);
  image-rendering: pixelated;
}

.camera-feed[data-camera="hall"] .scene-layer {
  background-position: 8% 48%;
  background-size: 145%;
  transform: scaleX(-1.02);
}

.camera-feed[data-camera="ascensor"] .scene-layer {
  background-position: 93% 39%;
  background-size: 155%;
  filter: grayscale(0.7) sepia(0.18) brightness(0.42) contrast(1.4);
}

.camera-feed[data-camera="pasillo"] .scene-layer {
  background-position: 50% 25%;
  background-size: 220%;
  filter: grayscale(0.55) brightness(0.34) contrast(1.5);
}

.camera-geometry {
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(115deg, #070807d9 0 13%, transparent 13% 87%, #070807d9 87%),
    linear-gradient(0deg, #000a, transparent 36% 86%, #0008);
}

.camera-feed[data-camera="hall"] .camera-geometry {
  background:
    linear-gradient(73deg, #070807e8 0 22%, transparent 22% 73%, #090a08e8 73%),
    linear-gradient(0deg, #000a, transparent 45%);
}

.camera-feed[data-camera="ascensor"] .camera-geometry {
  box-shadow: inset 26vw 0 #090a08a8, inset -24vw 0 #090a08a8;
  background: linear-gradient(0deg, #000a, transparent 40%);
}

.camera-feed[data-camera="pasillo"] .camera-geometry {
  background:
    linear-gradient(100deg, #070807ef 0 26%, transparent 26% 74%, #070807ef 74%),
    linear-gradient(0deg, #000a, transparent 32%);
}

.camera-geometry i {
  position: absolute;
  top: 13%;
  bottom: 9%;
  width: 2px;
  background: #5c584552;
}

.camera-geometry i:nth-child(1) {
  left: 26%;
}

.camera-geometry i:nth-child(2) {
  left: 50%;
}

.camera-geometry i:nth-child(3) {
  right: 26%;
}

.static {
  z-index: 9;
  opacity: 0.22;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, #000 4px),
    repeating-linear-gradient(92deg, transparent 0 11px, #dce4d214 12px);
  mix-blend-mode: screen;
  animation: static-shift 0.22s steps(2) infinite;
}

.camera-feed > p {
  position: absolute;
  z-index: 12;
  right: 0.8rem;
  bottom: 0.7rem;
  max-width: 42%;
  margin: 0;
  padding: 0.45rem 0.6rem;
  background: #060806cc;
  color: #c2baa5;
  font-size: 0.62rem;
  line-height: 1.4;
}

.intruder {
  position: absolute;
  z-index: 7;
  bottom: 2%;
  left: 55%;
  width: 170px;
  height: 78%;
  opacity: 0;
  filter: drop-shadow(18px 15px 13px #000);
  transform: translateX(-50%) scale(0.65);
  transform-origin: bottom;
  transition: opacity 80ms linear;
}

.intruder.visible {
  opacity: 0.92;
}

.intruder .head,
.intruder .body {
  position: absolute;
  display: block;
  background: #050605;
}

.intruder .head {
  top: 0;
  left: 52px;
  width: 66px;
  height: 76px;
  border-radius: 48% 46% 38% 40%;
}

.intruder .body {
  inset: 62px 8px 0;
  clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%);
  background: linear-gradient(90deg, #020302, #121510 52%, #020302);
}

.intruder .head b {
  position: absolute;
  top: 31px;
  width: 7px;
  height: 4px;
  border-radius: 50%;
  box-shadow: 0 0 11px #d3a557;
  background: #eac06c;
}

.intruder .head b:first-child {
  left: 19px;
}

.intruder .head b:last-child {
  right: 19px;
}

.camera-feed[data-camera="calle"] .intruder {
  left: 67%;
  transform: translateX(-50%) scale(0.58);
}

.camera-feed[data-camera="hall"] .intruder {
  left: 38%;
  transform: translateX(-50%) scale(0.72);
}

.camera-feed[data-camera="ascensor"] .intruder {
  left: 52%;
  transform: translateX(-50%) scale(0.84);
}

.camera-feed[data-camera="pasillo"] .intruder {
  left: 58%;
  transform: translateX(-50%) scale(1);
}

.camera-monitor > footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #504934;
  background: #0b0f0c;
}

.camera-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.camera-map button {
  min-width: 0;
  border-color: #34382e;
  color: #8f8d80;
}

.camera-map button[aria-selected="true"] {
  border-color: #c89b4c;
  box-shadow: inset 0 -3px #c89b4c;
  color: #f0dfb9;
}

.lure-button {
  border-color: #725e38;
  color: #dbb064;
}

.controls-help {
  z-index: 29;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  border-top: 1px solid #45402f;
  background: #080b09;
  color: #8e8979;
  font-size: 0.58rem;
  text-transform: uppercase;
}

.overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, #0004 4px),
    #030504e8;
}

.overlay-card {
  width: min(560px, 100%);
  padding: clamp(1.3rem, 4vw, 2.5rem);
  border: 1px solid #857044;
  box-shadow: 0 35px 90px #000;
  background: #0d100df2;
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--gold);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
}

.overlay h1 {
  margin: 0;
  color: #eee1c2;
  font: 700 clamp(3.2rem, 11vw, 6.5rem)/0.76 Georgia, serif;
  letter-spacing: -0.08em;
}

.overlay p,
.overlay li {
  color: #b8b09d;
  font-size: 0.78rem;
  line-height: 1.55;
}

.overlay ul {
  padding-left: 1.2rem;
}

.overlay .primary {
  width: 100%;
  min-height: 54px;
  margin-top: 0.5rem;
  border-color: #bd9143;
  background: #211f17;
  color: #f0c570;
}

.overlay-card > small {
  display: block;
  margin-top: 0.75rem;
  color: #777466;
  font-size: 0.58rem;
  text-align: center;
}

.pause-label {
  position: fixed;
  z-index: 60;
  inset: 50% auto auto 50%;
  padding: 1rem 2rem;
  border: 1px solid #b38b48;
  box-shadow: 0 18px 55px #000;
  background: #0a0d0bed;
  color: #e5b965;
  font-size: 1.5rem;
  transform: translate(-50%, -50%);
}

.jumpscare {
  position: fixed;
  z-index: 70;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle, #2b3326, #030403 62%);
}

.jumpscare.visible {
  opacity: 1;
  animation: jump 0.12s steps(2) infinite;
}

.jump-eye,
.jump-mouth {
  position: absolute;
  background: #e7bc66;
}

.jump-eye {
  top: 30%;
  width: 14vw;
  height: 8vw;
  border-radius: 50%;
  box-shadow: 0 0 80px #e7bc66;
}

.jump-eye.left {
  left: 22%;
}

.jump-eye.right {
  right: 22%;
}

.jump-mouth {
  bottom: 18%;
  left: 25%;
  width: 50%;
  height: 18%;
  clip-path: polygon(0 0, 10% 65%, 20% 0, 30% 65%, 40% 0, 50% 65%, 60% 0, 70% 65%, 80% 0, 90% 65%, 100% 0, 92% 100%, 8% 100%);
}

@keyframes rain {
  to {
    transform: translate(-30px, 125px);
  }
}

@keyframes fluorescent {
  0%, 74%, 78%, 100% { opacity: 1; }
  75%, 77% { opacity: 0.58; }
  76% { opacity: 0.86; }
}

@keyframes static-shift {
  to {
    transform: translate(3px, -2px);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

@keyframes jump {
  50% {
    transform: scale(1.08) translate(2%, -1%);
    filter: contrast(1.8) invert(0.12);
  }
}

@media (max-width: 720px) {
  html,
  body {
    min-height: 620px;
  }

  .game {
    grid-template-rows: 50px minmax(0, 1fr) 42px;
    min-height: 620px;
  }

  .hud > div {
    min-width: 0;
    flex: 1;
    padding: 0.25rem 0.45rem;
  }

  .hud strong {
    font-size: 0.78rem;
  }

  .hud .usage {
    display: none;
  }

  .icon-button {
    min-width: 48px;
    width: 48px;
    overflow: hidden;
    margin: 5px 4px 5px 0;
    padding: 0.3rem;
    font-size: 0;
  }

  .icon-button kbd {
    font-size: 0.62rem;
  }

  .office-image {
    object-position: center;
  }

  .radio-card {
    top: 0.55rem;
    left: 0.55rem;
    width: calc(100% - 1.1rem);
    padding: 0.6rem;
  }

  .radio-card p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .desk-control,
  .monitor-toggle {
    bottom: 0.5rem;
    min-width: 0;
    width: 31%;
    padding: 0.4rem;
    font-size: 0.57rem;
  }

  .light-control {
    left: 1%;
  }

  .monitor-toggle {
    width: 34%;
  }

  .shutter-control {
    right: 1%;
  }

  .shutter {
    inset: 14% 12% 32%;
  }

  .window-threat {
    top: 22%;
    height: 280px;
  }

  .camera-monitor {
    inset: 50px 0 41px;
    grid-template-rows: 38px minmax(0, 1fr) 128px;
    border-width: 7px;
    border-bottom-width: 20px;
    border-radius: 0;
  }

  .camera-monitor > footer {
    grid-template-columns: 1fr;
    grid-template-rows: 62px 46px;
  }

  .camera-map button {
    padding: 0.25rem;
    font-size: 0.55rem;
  }

  .camera-feed > p {
    max-width: 70%;
    font-size: 0.55rem;
  }

  .controls-help {
    gap: 0.55rem;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0 0.5rem;
    white-space: nowrap;
  }

  .overlay-card {
    max-height: calc(100svh - 2rem);
    overflow-y: auto;
  }
}

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