:root {
  color-scheme: dark;
  --gold: #f1c66d;
  --gold-soft: #ffe5a3;
  --ink: #080706;
  --panel: rgba(18, 13, 9, 0.9);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(248, 211, 122, 0.18), transparent 34%),
    linear-gradient(180deg, #050507 0%, #11100e 45%, #050403 100%);
  color: #f9ebc8;
  font-family: Georgia, "Times New Roman", serif;
}

button {
  font: inherit;
}

.game-shell {
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.elevator-card {
  width: min(100%, 470px);
  height: min(100%, 920px);
  aspect-ratio: 9 / 16;
  max-height: 100%;
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(255, 219, 139, 0.68);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 12% 88%, rgba(255, 255, 255, 0.05)),
    linear-gradient(180deg, #201812, #090706);
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.62),
    inset 0 0 0 5px rgba(75, 43, 18, 0.72),
    inset 0 0 28px rgba(255, 201, 103, 0.18);
}

.topbar {
  position: absolute;
  z-index: 30;
  top: 12px;
  left: 12px;
  right: 12px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--gold-soft);
  pointer-events: none;
}

.topbar span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.76;
}

.topbar strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  line-height: 1;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

.topbar button {
  pointer-events: auto;
  border: 1px solid rgba(255, 223, 155, 0.55);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(16, 10, 6, 0.7);
  color: #ffe8af;
  font-size: 12px;
  font-weight: 700;
}

.stage,
.room {
  position: absolute;
  inset: 0;
}

.room {
  background:
    url("./assets/elevator-scenes/elevator-frame-mobile.png") center / cover no-repeat,
    linear-gradient(180deg, #211913, #090706);
  transform-origin: 50% 46%;
}

.room.is-moving {
  animation: cabinRide calc(520ms + var(--distance, 1) * 90ms) ease-in-out infinite;
}

.display {
  position: absolute;
  z-index: 10;
  top: 11.6%;
  left: 35%;
  width: 30%;
  height: 6%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 221, 143, 0.52);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 15%, rgba(255, 226, 141, 0.24), transparent 58%), #110b07;
  color: #ffd978;
  font-family: "Courier New", monospace;
  font-size: clamp(24px, 8vw, 40px);
  font-weight: 900;
  box-shadow: inset 0 0 16px rgba(255, 176, 51, 0.18), 0 0 18px rgba(0, 0, 0, 0.56);
}

.cabin {
  position: absolute;
  inset: 0;
  transform-origin: 50% 45%;
  --opening-top: 22.6%;
  --opening-left: 22.3%;
  --opening-width: 55.4%;
  --opening-height: 66.9%;
  --door-bottom-bleed: 0.4%;
  --scene-bleed-x: 7%;
  --scene-bleed-top: 8%;
  --scene-bleed-bottom: 7%;
  --door-open-duration: 3.26s;
  --door-close-duration: 3.15s;
}

.view {
  position: absolute;
  z-index: 1;
  top: var(--opening-top);
  left: var(--opening-left);
  width: var(--opening-width);
  height: var(--opening-height);
  overflow: hidden;
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255, 250, 214, 0.96), rgba(252, 218, 122, 0.7) 48%, rgba(102, 205, 255, 0.35)),
    #111;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.42);
}

.view.has-image {
  background:
    linear-gradient(180deg, #19100b 0%, #080504 100%),
    #080504;
}

.view.has-image::before {
  content: "";
  position: absolute;
  inset: calc(var(--scene-bleed-top) * -1) calc(var(--scene-bleed-x) * -1) calc(var(--scene-bleed-bottom) * -1);
  background: var(--scene) center bottom / cover no-repeat;
}

.view.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 5, 9, 0.04), rgba(4, 5, 9, 0.14));
  pointer-events: none;
}

.scene-effects {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.fx-shimmer {
  position: absolute;
  inset: -12% -26%;
  opacity: 0.28;
  mix-blend-mode: screen;
  background: linear-gradient(104deg, transparent 0 42%, rgba(255, 221, 141, 0.22) 48%, transparent 55% 100%);
  animation: brassShimmer 6.8s ease-in-out infinite;
}

.smoke {
  position: absolute;
  display: block;
  width: 34%;
  height: 20%;
  border-radius: 999px;
  background: radial-gradient(circle at 45% 45%, rgba(230, 226, 210, 0.34), rgba(170, 166, 154, 0.13) 48%, transparent 72%);
  filter: blur(7px);
  mix-blend-mode: screen;
  transform-origin: center;
}

.puff-a {
  right: 14%;
  top: 18%;
  animation: smokeDrift 7.4s ease-in-out infinite;
}

.puff-b {
  right: 4%;
  top: 27%;
  width: 42%;
  animation: smokeDrift 9s ease-in-out -2.2s infinite;
}

.puff-c {
  left: 38%;
  top: 30%;
  width: 26%;
  height: 15%;
  opacity: 0.75;
  animation: smokeDrift 8.2s ease-in-out -4s infinite;
}

.gauge-needle {
  position: absolute;
  left: 50%;
  top: 34.2%;
  width: 2px;
  height: 5.6%;
  border-radius: 999px;
  background: #f8d47c;
  box-shadow: 0 0 10px rgba(255, 202, 102, 0.9);
  transform-origin: 50% 90%;
  animation: needleTremble 520ms steps(2, end) infinite;
}

.indicator {
  position: absolute;
  top: 33%;
  width: 9.5%;
  aspect-ratio: 1;
  border-radius: 999px;
  mix-blend-mode: screen;
}

.indicator.amber {
  left: 39%;
  background: radial-gradient(circle, rgba(255, 231, 137, 0.95), rgba(242, 147, 34, 0.36) 48%, transparent 72%);
  animation: bulbPulse 1.45s ease-in-out infinite;
}

.indicator.teal {
  right: 35%;
  background: radial-gradient(circle, rgba(146, 248, 255, 0.95), rgba(35, 185, 204, 0.38) 48%, transparent 72%);
  animation: bulbPulse 620ms steps(2, end) infinite;
}

.spark {
  position: absolute;
  width: 17%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(139, 245, 255, 0.95), transparent);
  box-shadow: 0 0 14px rgba(100, 237, 255, 0.9);
  opacity: 0;
  transform-origin: center;
}

.spark-a {
  right: 26%;
  top: 35%;
  transform: rotate(-34deg);
  animation: sparkFlash 2.1s steps(1, end) infinite;
}

.spark-b {
  left: 22%;
  top: 47%;
  transform: rotate(18deg);
  animation: sparkFlash 3.2s steps(1, end) -1.1s infinite;
}

.spark-c {
  right: 18%;
  top: 52%;
  transform: rotate(48deg);
  animation: sparkFlash 2.7s steps(1, end) -0.5s infinite;
}

.sun-band,
.shadow-band {
  position: absolute;
  left: -20%;
  right: -20%;
  transform: rotate(-11deg);
  transform-origin: center;
}

.sun-band {
  top: 41%;
  height: 28%;
  opacity: 0.42;
  mix-blend-mode: screen;
  background: linear-gradient(90deg, transparent 0 34%, rgba(255, 220, 113, 0.32) 45%, rgba(255, 241, 181, 0.24) 53%, transparent 66% 100%);
  animation: sunBreathe 4.8s ease-in-out infinite;
}

.shadow-band {
  height: 18%;
  opacity: 0.22;
  background: repeating-linear-gradient(90deg, transparent 0 12%, rgba(0, 0, 0, 0.62) 12% 19%, transparent 19% 31%);
  filter: blur(1px);
  animation: shadowSlide 7s ease-in-out infinite;
}

.shadow-a {
  top: 38%;
}

.shadow-b {
  top: 58%;
  opacity: 0.18;
  animation-delay: -3.5s;
}

.gear-glint {
  position: absolute;
  width: 22%;
  aspect-ratio: 1;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 128, 0.28);
  box-shadow: 0 0 22px rgba(255, 186, 72, 0.18), inset 0 0 18px rgba(255, 220, 140, 0.13);
  mix-blend-mode: screen;
  opacity: 0.24;
  animation: gearGlint 7s linear infinite;
}

.glint-a {
  left: 18%;
  top: 24%;
}

.glint-b {
  right: 19%;
  top: 33%;
  width: 16%;
  animation-duration: 5.6s;
  animation-direction: reverse;
}

.pendulum-sweep {
  position: absolute;
  left: 52%;
  top: 24%;
  width: 2px;
  height: 28%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 223, 140, 0), rgba(255, 223, 140, 0.4), rgba(255, 223, 140, 0));
  transform-origin: 50% 8%;
  animation: pendulumSweep 2.4s ease-in-out infinite;
}

.mirror-sheen {
  position: absolute;
  top: -12%;
  bottom: -12%;
  width: 18%;
  opacity: 0.26;
  mix-blend-mode: screen;
  background: linear-gradient(90deg, transparent, rgba(183, 247, 246, 0.28), rgba(255, 220, 144, 0.17), transparent);
  transform: skewX(-13deg);
  animation: mirrorSheen 7.6s ease-in-out infinite;
}

.sheen-a {
  left: -22%;
}

.sheen-b {
  right: -26%;
  animation-delay: -3.8s;
}

.cold-mist {
  position: absolute;
  left: -12%;
  right: -12%;
  height: 18%;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 48%, rgba(196, 237, 255, 0.22), rgba(108, 182, 215, 0.11) 44%, transparent 72%);
  filter: blur(9px);
  mix-blend-mode: screen;
  opacity: 0;
}

.mist-a {
  bottom: 2%;
  animation: coldMist 8.4s ease-in-out infinite;
}

.mist-b {
  bottom: 16%;
  animation: coldMist 10s ease-in-out -4.6s infinite;
}

.frost-glow {
  position: absolute;
  inset: 0;
  opacity: 0.22;
  mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 70%, rgba(142, 218, 255, 0.28), transparent 50%);
  animation: frostPulse 5.8s ease-in-out infinite;
}

.glass-glint {
  position: absolute;
  top: 18%;
  bottom: 18%;
  width: 10%;
  opacity: 0.22;
  mix-blend-mode: screen;
  background: linear-gradient(90deg, transparent, rgba(255, 242, 188, 0.3), transparent);
  transform: skewX(-10deg);
  animation: glassGlint 6.4s ease-in-out infinite;
}

.glint-left {
  left: 22%;
}

.glint-right {
  right: 20%;
  animation-delay: -3.1s;
}

.counterweight-glow {
  position: absolute;
  left: 43%;
  bottom: 9%;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 999px;
  opacity: 0.28;
  mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255, 226, 142, 0.42), rgba(255, 179, 72, 0.16) 46%, transparent 70%);
  animation: counterweightPulse 3.8s ease-in-out infinite;
}

.electric-arc {
  position: absolute;
  width: 18%;
  height: 2px;
  opacity: 0;
  mix-blend-mode: screen;
  background: linear-gradient(90deg, transparent, rgba(154, 242, 255, 0.98), transparent);
  box-shadow: 0 0 16px rgba(92, 219, 255, 0.92);
  transform-origin: center;
  animation: transformerArc 1.9s steps(1, end) infinite;
}

.arc-a {
  left: 19%;
  top: 22%;
  transform: rotate(28deg);
}

.arc-b {
  right: 20%;
  top: 24%;
  transform: rotate(-24deg);
  animation-delay: -0.7s;
}

.arc-c {
  left: 42%;
  top: 42%;
  transform: rotate(-8deg);
  animation-delay: -1.2s;
}

.oil-drip {
  position: absolute;
  width: 2.2%;
  height: 8%;
  border-radius: 999px;
  opacity: 0;
  background: linear-gradient(180deg, rgba(255, 222, 126, 0), rgba(161, 102, 34, 0.58), rgba(255, 206, 99, 0.22));
  box-shadow: 0 0 8px rgba(255, 177, 72, 0.34);
  animation: oilDrip 5.6s ease-in-out infinite;
}

.drip-a {
  left: 28%;
  top: 42%;
}

.drip-b {
  right: 31%;
  top: 35%;
  animation-delay: -2.8s;
}

.oil-sheen {
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 5%;
  height: 18%;
  opacity: 0.2;
  mix-blend-mode: screen;
  background: radial-gradient(ellipse at 50% 70%, rgba(255, 213, 122, 0.32), transparent 68%);
  animation: oilSheen 4.8s ease-in-out infinite;
}

.view.final-light {
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 1) 0 18%, rgba(255, 247, 192, 0.94) 34%, rgba(104, 210, 255, 0.42) 62%, rgba(255, 255, 255, 0.1) 80%),
    linear-gradient(180deg, rgba(255, 250, 214, 0.98), rgba(252, 218, 122, 0.72) 48%, rgba(102, 205, 255, 0.42));
}

.doors {
  position: absolute;
  z-index: 5;
  top: var(--opening-top);
  left: var(--opening-left);
  width: var(--opening-width);
  height: calc(var(--opening-height) + var(--door-bottom-bleed));
  overflow: hidden;
  border-radius: 5px;
  pointer-events: none;
}

.door {
  position: absolute;
  top: -3px;
  bottom: calc(var(--door-bottom-bleed) * -1 - 4px);
  width: 51%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent 16% 84%, rgba(0, 0, 0, 0.34)),
    repeating-linear-gradient(90deg, rgba(176, 123, 53, 0.85) 0 4px, rgba(78, 46, 22, 0.95) 4px 9px),
    linear-gradient(180deg, #a56f31, #442513);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.55);
  transition: transform var(--door-open-duration) cubic-bezier(0.52, 0, 0.16, 1);
}

.door.left {
  left: 0;
  border-right: 1px solid rgba(255, 225, 148, 0.42);
}

.door.right {
  right: 0;
  border-left: 1px solid rgba(255, 225, 148, 0.42);
}

.doors.open .left {
  transform: translateX(-98%);
}

.doors.open .right {
  transform: translateX(98%);
}

.doors.closing .door {
  transition-duration: var(--door-close-duration);
  transition-timing-function: cubic-bezier(0.7, 0, 0.28, 1);
}

.modal {
  position: absolute;
  z-index: 22;
  left: 5.2%;
  right: 5.2%;
  bottom: 4.6%;
  padding: 14px;
  border: 1px solid rgba(255, 223, 155, 0.55);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 233, 177, 0.1), transparent 22%),
    rgba(16, 10, 7, 0.92);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.58), inset 0 0 18px rgba(255, 194, 91, 0.12);
}

.modal .eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #e7b95d;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.modal strong {
  display: block;
  color: #fff0bf;
  font-size: 18px;
  line-height: 1.1;
}

.modal p {
  margin: 9px 0 0;
  color: #f5dfad;
  font-size: 13px;
  line-height: 1.35;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.actions button {
  flex: 1;
  min-height: 42px;
  border: 1px solid rgba(255, 218, 132, 0.64);
  border-radius: 10px;
  background: linear-gradient(180deg, #d58b2c, #7e3e17);
  color: #fff5ce;
  font-size: 13px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 7px 18px rgba(0, 0, 0, 0.34);
}

.actions button.secondary {
  background: linear-gradient(180deg, #775d44, #2b1b12);
}

.wait {
  position: absolute;
  z-index: 18;
  left: 8%;
  right: 8%;
  top: 44%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 223, 155, 0.42);
  background: rgba(10, 7, 5, 0.78);
  text-align: center;
  color: #ffe9b3;
  font-size: 13px;
}

.video,
.final-image {
  position: absolute;
  z-index: 16;
  inset: 0;
  background: #050403;
}

.video video,
.final-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@keyframes cabinRide {
  0%,
  100% { transform: translateY(0); }
  18% { transform: translateY(calc(var(--direction, -1) * -7px)); }
  48% { transform: translateY(calc(var(--direction, -1) * 5px)); }
  72% { transform: translateY(calc(var(--direction, -1) * -4px)); }
}

@keyframes brassShimmer {
  0%,
  38%,
  100% { transform: translateX(-28%); opacity: 0; }
  52% { opacity: 0.3; }
  74% { transform: translateX(28%); opacity: 0; }
}

@keyframes smokeDrift {
  0% { transform: translate3d(0, 10px, 0) scale(0.82); opacity: 0; }
  18% { opacity: 0.7; }
  62% { opacity: 0.48; }
  100% { transform: translate3d(-18px, -34px, 0) scale(1.26); opacity: 0; }
}

@keyframes needleTremble {
  0%,
  100% { transform: rotate(-12deg); }
  30% { transform: rotate(9deg); }
  58% { transform: rotate(-3deg); }
  78% { transform: rotate(14deg); }
}

@keyframes bulbPulse {
  0%,
  100% { opacity: 0.38; transform: scale(0.9); }
  42% { opacity: 0.95; transform: scale(1.12); }
}

@keyframes sparkFlash {
  0%,
  72%,
  100% { opacity: 0; }
  74% { opacity: 1; }
  78% { opacity: 0.28; }
}

@keyframes sunBreathe {
  0%,
  100% { opacity: 0.24; transform: rotate(-11deg) translateX(-2%); }
  52% { opacity: 0.48; transform: rotate(-11deg) translateX(3%); }
}

@keyframes shadowSlide {
  0%,
  100% { transform: rotate(-11deg) translateX(-3%); }
  50% { transform: rotate(-11deg) translateX(5%); }
}

@keyframes gearGlint {
  0% { transform: rotate(0deg) scale(0.96); opacity: 0.16; }
  50% { opacity: 0.34; }
  100% { transform: rotate(360deg) scale(1.04); opacity: 0.16; }
}

@keyframes pendulumSweep {
  0%,
  100% { transform: rotate(-8deg); opacity: 0.2; }
  50% { transform: rotate(8deg); opacity: 0.42; }
}

@keyframes mirrorSheen {
  0%,
  100% { transform: translateX(0) skewX(-13deg); opacity: 0; }
  28% { opacity: 0.2; }
  62% { transform: translateX(560%) skewX(-13deg); opacity: 0.28; }
  78% { opacity: 0; }
}

@keyframes coldMist {
  0% { transform: translate3d(-8%, 12px, 0) scale(0.94); opacity: 0; }
  24% { opacity: 0.48; }
  70% { opacity: 0.34; }
  100% { transform: translate3d(10%, -18px, 0) scale(1.18); opacity: 0; }
}

@keyframes frostPulse {
  0%,
  100% { opacity: 0.14; }
  52% { opacity: 0.3; }
}

@keyframes glassGlint {
  0%,
  100% { transform: translateX(-60%) skewX(-10deg); opacity: 0; }
  34% { opacity: 0.24; }
  66% { transform: translateX(160%) skewX(-10deg); opacity: 0.32; }
  82% { opacity: 0; }
}

@keyframes counterweightPulse {
  0%,
  100% { opacity: 0.16; transform: scale(0.92); }
  50% { opacity: 0.34; transform: scale(1.08); }
}

@keyframes transformerArc {
  0%,
  62%,
  100% { opacity: 0; }
  64% { opacity: 1; }
  68% { opacity: 0.22; }
  70% { opacity: 0.74; }
  74% { opacity: 0; }
}

@keyframes oilDrip {
  0% { transform: translateY(-12px) scaleY(0.2); opacity: 0; }
  20% { opacity: 0.54; }
  58% { transform: translateY(32px) scaleY(1); opacity: 0.4; }
  100% { transform: translateY(72px) scaleY(0.5); opacity: 0; }
}

@keyframes oilSheen {
  0%,
  100% { opacity: 0.12; transform: scaleX(0.92); }
  50% { opacity: 0.27; transform: scaleX(1.06); }
}

@media (max-width: 520px) {
  .game-shell {
    padding: 0;
  }

  .elevator-card {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    aspect-ratio: auto;
  }

  .topbar {
    top: max(8px, env(safe-area-inset-top));
  }

  .modal {
    left: 3.5%;
    right: 3.5%;
    bottom: max(8px, env(safe-area-inset-bottom));
    padding: 12px;
  }

  .modal p {
    font-size: 12px;
  }
}
