:root {
  --bg: #050508;
  --metal: #15171d;
  --metal-2: #2a2e38;
  --cyan: #3dfff3;
  --cyan-dim: #1a8f88;
  --mag: #ff2d95;
  --red: #ff3344;
  --amber: #ffbf3c;
  --text: #e8eef5;
  --muted: #7a8294;
  --card: rgba(8, 10, 16, 0.86);
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Source Han Sans SC",
    sans-serif;
  --mono: "DIN Alternate", "Courier New", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: #030304;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

#monitor {
  position: relative;
  width: min(980px, 100vw);
  height: min(680px, 100dvh);
  margin: 0 auto;
  background: radial-gradient(120% 80% at 50% 20%, #141820 0%, var(--bg) 55%);
  overflow: hidden;
  box-shadow: 0 0 0 10px #0c0d12, 0 0 0 12px #2a3140, 0 30px 80px #000;
}

.scanlines,
.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 20;
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.18) 0,
    rgba(0, 0, 0, 0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.45;
  animation: scan-drift 9s linear infinite;
}

.vignette {
  box-shadow: inset 0 0 120px 28px #000, inset 0 0 40px rgba(61, 255, 243, 0.05);
}

@keyframes scan-drift {
  to {
    background-position: 0 12px;
  }
}

.hud {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px 8px;
  border-bottom: 1px solid rgba(61, 255, 243, 0.18);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent);
}

.led,
.clock {
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-shadow: 0 0 10px var(--cyan), 0 0 24px rgba(61, 255, 243, 0.4);
  color: var(--cyan);
}

.led {
  font-size: 13px;
}

.led b {
  font-weight: 700;
  font-size: 22px;
  margin-left: 8px;
}

.clock {
  font-size: 42px;
  font-weight: 700;
  min-width: 4.2ch;
  text-align: center;
  line-height: 1;
}

.clock.danger {
  color: var(--red);
  text-shadow: 0 0 12px var(--red), 0 0 28px rgba(255, 51, 68, 0.5);
  animation: pulse 0.6s ease-in-out infinite;
}

.vitals {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: flex-end;
}

.hearts {
  display: flex;
  gap: 4px;
  font-size: 20px;
  color: var(--red);
  text-shadow: 0 0 10px var(--red);
}

.hearts.low {
  animation: pulse 0.62s ease-in-out infinite;
}

.hearts .off {
  opacity: 0.2;
  filter: grayscale(1);
}

.stress {
  width: 92px;
}

.stress label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}

.stress-bar {
  height: 8px;
  background: #111;
  border: 1px solid var(--metal-2);
  display: flex;
  overflow: hidden;
}

.stress-bar i {
  flex: 1;
  background: #1c1f28;
  border-right: 1px solid #050508;
}

.stress-bar i.on {
  background: linear-gradient(to top, #7a1a3a, var(--mag));
  box-shadow: 0 0 8px var(--mag);
}

.stress-bar.max i.on {
  background: var(--red);
  animation: pulse 0.5s infinite;
}

#mute {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-size: 11px;
  padding: 6px 8px;
  letter-spacing: 0.08em;
}

#mute:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(61, 255, 243, 0.3);
}

.cabin {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 92px 1fr;
  height: calc(100% - 78px);
}

.panel {
  padding: 16px 10px;
  background: linear-gradient(90deg, #0b0c10, #171a22);
  border-right: 1px solid #2c3340;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.panel span {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.3em;
  margin-bottom: 6px;
}

#panelBtns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  width: 100%;
}

.pbtn {
  width: 48px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid #3a4150;
  background: #0e1016;
  color: #5c6578;
  font-family: var(--mono);
  font-size: 11px;
  box-shadow: inset 0 -2px 0 #000;
}

.pbtn.done {
  color: var(--cyan-dim);
  border-color: var(--cyan-dim);
}

.pbtn.now {
  color: #04110f;
  background: var(--cyan);
  border-color: #fff;
  box-shadow: 0 0 12px var(--cyan);
}

.shaft {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 8%, transparent 92%, rgba(0, 0, 0, 0.35)),
    linear-gradient(#2a2118, #1a1612 40%, #121015);
}

.fluorescent {
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 10px;
  background: #d7f6ff;
  box-shadow: 0 10px 40px rgba(180, 240, 255, 0.35);
  opacity: 0.7;
  animation: flicker 5.5s infinite;
  z-index: 3;
}

.mirror {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 12%;
  height: 38%;
  background: linear-gradient(180deg, #2a3344, #141820);
  border: 4px solid #3a322c;
  box-shadow: inset 0 0 30px rgba(61, 255, 243, 0.08);
  opacity: 0.55;
}

.doors {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background:
    linear-gradient(90deg, transparent 0, rgba(255, 255, 255, 0.06) 8%, transparent 18%),
    repeating-linear-gradient(
      90deg,
      #3a404c 0 2px,
      #2c313c 2px 14px,
      #333846 14px 16px
    );
  box-shadow: inset 0 0 30px #000;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.door.left {
  left: 0;
  border-right: 3px solid #111;
}

.door.right {
  right: 0;
  border-left: 3px solid #111;
}

.doors.closed .door.left {
  transform: translateX(0);
}
.doors.closed .door.right {
  transform: translateX(0);
}
.doors.open .door.left {
  transform: translateX(-96%);
}
.doors.open .door.right {
  transform: translateX(96%);
}
.doors.ajar .door.left {
  transform: translateX(-18%);
}
.doors.ajar .door.right {
  transform: translateX(18%);
}

.win-light {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, #f4fff8 0%, #8fffe8 28%, transparent 62%);
  opacity: 0;
  z-index: 4;
  pointer-events: none;
  transition: opacity 1.2s ease;
}

.win-light.on {
  opacity: 0.95;
}

.stage {
  position: relative;
  z-index: 7;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 28px 36px;
}

.card,
.title-card,
.end-card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid rgba(61, 255, 243, 0.28);
  box-shadow: 0 0 0 1px #000, 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 40px rgba(61, 255, 243, 0.08);
  padding: 22px 22px 18px;
  backdrop-filter: blur(6px);
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--amber);
  margin-bottom: 8px;
}

h1 {
  font-size: 42px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(61, 255, 243, 0.55);
  margin-bottom: 10px;
}

.tagline {
  font-size: 14px;
}

h2 {
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--text);
}

.tagline,
.body,
.taunt,
.reason {
  color: #c5ccd8;
  line-height: 1.7;
  font-size: 15px;
}

.hint {
  margin-top: 18px;
  color: var(--cyan);
  letter-spacing: 0.18em;
  font-size: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.choices button {
  text-align: left;
  background: #0c1018;
  color: var(--text);
  border: 1px solid #3a4658;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  transition: 0.12s ease;
}

.choices button:hover,
.choices button:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 14px rgba(61, 255, 243, 0.2);
  outline: none;
}

.choices button .n {
  display: inline-block;
  width: 1.4em;
  color: var(--amber);
  font-family: var(--mono);
}

.choices button:disabled {
  opacity: 0.45;
  cursor: default;
}

.banner {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  z-index: 8;
  min-width: min(520px, 86%);
  padding: 10px 16px;
  background: #07131a;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  text-align: center;
}

.banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.banner.hurt {
  border-color: var(--amber);
  color: var(--amber);
  background: #1a1206;
}

.banner.death {
  border-color: var(--red);
  color: var(--red);
  background: #1a0608;
}

.end-card h1 {
  font-size: 34px;
  letter-spacing: 0.16em;
  text-indent: 0;
}

.end-card.dead h1 {
  color: var(--red);
  text-shadow: 0 0 18px rgba(255, 51, 68, 0.5);
}

.end-card.win h1 {
  color: var(--cyan);
}

.taunt {
  margin: 10px 0;
  color: var(--amber);
}

.reason {
  color: #9aa3b5;
  margin-bottom: 8px;
}

.stats {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.primary {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  padding: 10px 18px;
  letter-spacing: 0.2em;
}

.primary:hover {
  background: var(--cyan);
  color: #04110f;
}

.hidden {
  display: none !important;
}

#monitor.shake {
  animation: shake 0.42s linear;
}

#monitor.glitch .stage {
  animation: glitch 0.45s steps(2);
  filter: hue-rotate(90deg) contrast(1.4);
}

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

@keyframes flicker {
  0%,
  19%,
  21%,
  100% {
    opacity: 0.72;
  }
  20% {
    opacity: 0.15;
  }
  80% {
    opacity: 0.55;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-10px) rotate(-0.4deg);
  }
  40% {
    transform: translateX(12px);
  }
  60% {
    transform: translateX(-7px);
  }
  80% {
    transform: translateX(6px);
  }
}

@keyframes glitch {
  0% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
  20% {
    clip-path: inset(10% 0 40% 0);
    transform: translate(-8px, 2px);
  }
  40% {
    clip-path: inset(50% 0 10% 0);
    transform: translate(7px, -3px);
  }
  60% {
    clip-path: inset(20% 0 30% 0);
    transform: translate(-4px, 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
  }
}

@media (max-width: 720px) {
  #monitor {
    width: 100vw;
    height: 100dvh;
    box-shadow: none;
  }
  .cabin {
    grid-template-columns: 1fr;
    height: calc(100% - 92px);
  }
  .panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px;
    gap: 4px;
    border-right: 0;
    border-bottom: 1px solid #2c3340;
  }
  .panel span {
    display: none;
  }
  .pbtn {
    width: 28px;
    height: 22px;
    font-size: 10px;
  }
  #panelBtns {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  h1 {
    font-size: 28px;
    letter-spacing: 0.16em;
  }
  .clock {
    font-size: 28px;
  }
  .hud {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .clock {
    grid-column: 1 / -1;
    order: -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

.howto {
  list-style: none;
  text-align: left;
  margin: 14px auto 18px;
  padding: 12px 16px;
  max-width: 34em;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(61, 255, 243, 0.35);
  border-radius: 10px;
  color: #e8eef5;
  font-size: 15px;
  line-height: 1.55;
}
.howto li {
  margin: 6px 0;
  padding-left: 0.2em;
}
.start-btn {
  display: inline-block;
  margin: 8px 0 10px;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #3dfff3, #ff2d95);
  color: #050508;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.12em;
  box-shadow: 0 0 24px rgba(61, 255, 243, 0.45);
}
.start-btn:hover { filter: brightness(1.08); }
.title-card .tagline {
  opacity: 0.95;
  font-size: 15px;
  max-width: 36em;
  margin: 0 auto;
}
