/* Ghost Trap: a 1984 containment-control console for a live camera. */
:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1b1f26;
  --line: #2a303a;
  --text: #e8ecef;
  --muted: #8c95a3;
  --hazard: #f5c400;
  --slime: #8fe33a;
  --slime-dark: #2f5c0c;
  --red: #ff3b2f;
  --lcd: #9dffb0;
  --lamp: 44, 214, 196;          /* the trap light's teal glow, measured from the camera */
  --zap: 255, 120, 220;          /* the pink crackle in the trap beam */
  --radius: 14px;
  --mono: "Share Tech Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --display: "Bungee", "Arial Black", Impact, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

/* No pinch or double-tap zoom on phones: scrolling only. */
html, body {
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #151a20, transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color .5s ease;
}

/* While the trap is open the room lights up: teal glow with a little pink crackle. */
body.is-on { background-color: #0b1514; }
.glow {
  position: fixed;
  inset: -25% -25% auto -25%;
  height: 125vh;
  background:
    radial-gradient(closest-side at 50% 45%, rgba(var(--lamp), .30), rgba(var(--lamp), .10) 50%, rgba(var(--lamp), 0)),
    radial-gradient(closest-side at 60% 55%, rgba(var(--zap), .10), rgba(var(--zap), 0));
  opacity: 0;
  transition: opacity .5s ease;
  pointer-events: none;
  z-index: 0;
}
body.is-on .glow { opacity: 1; }

/* Hazard tape along the top */
.tape {
  position: relative;
  z-index: 1;
  height: 12px;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 14px, #111 14px 28px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .5);
}

.top, .stage { position: relative; z-index: 1; }

/* ---------- header ---------- */
.top {
  text-align: center;
  padding: 22px 16px 4px;
}

.wordmark {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 6.5vw, 3.2rem);
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.w-ghost { color: var(--slime); text-shadow: 0 3px 0 var(--slime-dark), 0 0 22px rgba(143, 227, 58, .35); }
.w-trap { color: var(--hazard); text-shadow: 0 3px 0 #6b5500; }

.mascot {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  filter: drop-shadow(0 0 10px rgba(143, 227, 58, .45));
  animation: float 3.2s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-5px) rotate(4deg); }
}

.tagline {
  margin: 10px auto 0;
  max-width: 34em;
  color: var(--muted);
}

/* ---------- layout ---------- */
.stage {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: center;
}
@media (max-width: 800px) {
  .stage { grid-template-columns: 1fr; gap: 16px; }
}

/* ---------- the CRT monitor ---------- */
.monitor {
  padding: 10px 12px 14px;
  border-radius: 20px;
  background: linear-gradient(#2b3038, #1a1d22);
  border: 1px solid #3a414b;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: box-shadow .5s ease;
}
body.is-on .monitor {
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 60px rgba(var(--lamp), .22), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.monitor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
  font: .8rem/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #aab3c0;
}

.rec { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #555c66; }
.rec.is-live { color: #ffb4ae; }
.rec.is-live .dot { background: var(--red); box-shadow: 0 0 8px var(--red); animation: rec 1.6s steps(1) infinite; }
@keyframes rec { 50% { opacity: .25; } }

.screen {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #030405;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px #0a0b0d, inset 0 0 40px rgba(0, 0, 0, .8);
}

#video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* CRT scanlines + vignette (static, no flicker) */
.scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, .45));
  border-radius: inherit;
}

.watching {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(5, 6, 8, .72);
  font: .8rem/1.2 var(--mono);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--lcd);
}

.toast {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(10, 12, 16, .85);
  border: 1px solid rgba(var(--lamp), .6);
  color: #dffff9;
  font: 600 .9rem/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  box-shadow: 0 0 24px rgba(var(--lamp), .35);
  animation: toast-in .25s ease-out;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(3, 4, 5, .82);
  color: #cfd4de;
  font-family: var(--mono);
  letter-spacing: .03em;
  transition: opacity .25s ease;
}
.overlay[hidden] { display: flex; opacity: 0; pointer-events: none; }
.overlay p { margin: 0; max-width: 26em; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, .15);
  border-top-color: var(--slime);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- the console ---------- */
.console {
  position: relative;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: linear-gradient(#20252d, #15181d);
  border: 1px solid #353c47;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .07);
}
/* rivets */
.console::before, .console::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #9aa3ae, #3b424c);
}
.console::before { left: 10px; }
.console::after { right: 10px; }
@media (max-width: 800px) {
  .console { width: 100%; max-width: 440px; margin: 0 auto; }
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 10px;
  font: .78rem/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #aab3c0;
}

.mute {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #3a414b;
  border-radius: 8px;
  background: #11141a;
  color: #cfd6df;
  cursor: pointer;
}
.mute .cross { display: none; }
.mute[aria-pressed="true"] .waves { display: none; }
.mute[aria-pressed="true"] .cross { display: inline; }
.mute:focus-visible { outline: 3px solid var(--hazard); outline-offset: 2px; }

/* P.K.E. meter */
.pke {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0b0d10;
  border: 1px solid #2a303a;
  font-family: var(--mono);
}
.pke-label { font-size: .8rem; color: var(--hazard); letter-spacing: .08em; }
.pke-num { width: 2.6em; text-align: right; font-size: .85rem; color: var(--lcd); }
.pke-bar { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.pke-bar i {
  height: 14px;
  border-radius: 2px;
  background: #1d2228;
  transition: background-color .12s linear, box-shadow .12s linear;
}
.pke-bar i.lit:nth-child(-n+4) { background: #4fe36a; box-shadow: 0 0 6px rgba(79, 227, 106, .6); }
.pke-bar i.lit:nth-child(n+5):nth-child(-n+7) { background: #ffd23c; box-shadow: 0 0 6px rgba(255, 210, 60, .6); }
.pke-bar i.lit:nth-child(n+8) { background: #ff4a3d; box-shadow: 0 0 6px rgba(255, 74, 61, .7); }

/* The trap (the button) */
.trap {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 0 0 12px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.trap:disabled { cursor: not-allowed; }
.trap:focus-visible { outline: 3px solid var(--hazard); outline-offset: 4px; border-radius: 12px; }

.trap-art {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}
.trap:disabled .trap-art { filter: saturate(.3) brightness(.65); }

.door { transform-box: fill-box; transition: transform .28s cubic-bezier(.2, 1.3, .5, 1); }
.door-l { transform-origin: left center; }
.door-r { transform-origin: right center; }
.trap.is-open .door-l { transform: rotate(-115deg); }
.trap.is-open .door-r { transform: rotate(115deg); }

.cone {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  opacity: 0;
  transition: transform .35s ease-out, opacity .2s ease;
}
.trap.is-open .cone { transform: scaleY(1); opacity: 1; }
.zap { opacity: 0; }
.trap.is-open .zap { animation: crackle 1.4s steps(1) infinite; }
.trap.is-open .z2 { animation-delay: .7s; }
@keyframes crackle {        /* slow, small flickers: well under 3 per second */
  0% { opacity: .9; } 18% { opacity: 0; } 55% { opacity: .6; } 70% { opacity: 0; }
}

.led { fill: #3a1010; }
.trap:not(:disabled) .led { fill: #ff3b2f; filter: drop-shadow(0 0 4px #ff3b2f); animation: armed 2s steps(1) infinite; }
.trap.is-open .led { fill: #6dff8a; filter: drop-shadow(0 0 5px #6dff8a); animation: none; }
@keyframes armed { 50% { fill: #5a1612; filter: none; } }

.trap:active:not(:disabled) .pedal { transform: translateY(3px); }
.pedal { transition: transform .08s ease; }

.trap-label {
  display: block;
  width: max-content;
  margin: 6px auto 0;
  padding: 10px 26px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font: 400 1.15rem/1 var(--display);
  letter-spacing: .06em;
  text-transform: uppercase;
  box-shadow: 0 5px 0 #8f1a12, 0 10px 18px rgba(0, 0, 0, .45);
  transition: transform .08s ease, box-shadow .08s ease, background-color .2s ease;
}
.trap:active:not(:disabled) .trap-label { transform: translateY(4px); box-shadow: 0 1px 0 #8f1a12, 0 4px 10px rgba(0, 0, 0, .45); }
.trap.is-open .trap-label { background: #1f6d5f; box-shadow: 0 5px 0 #0f3a33, 0 0 22px rgba(var(--lamp), .5); }
.trap.is-waiting .trap-label { background: #59606b; box-shadow: 0 5px 0 #2f343b; }
.trap:disabled .trap-label { background: #3a3f47; box-shadow: 0 5px 0 #23272d; color: #9aa2ad; }

/* LCD readout. Every line keeps its height so nothing jumps when the text changes. */
.lcd {
  padding: 10px 12px 12px;
  border-radius: 10px;
  background: #07120b;
  border: 1px solid #1f3a26;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .7);
  font-family: var(--mono);
  color: var(--lcd);
  text-shadow: 0 0 6px rgba(157, 255, 176, .45);
  text-align: center;
}
.lcd p { margin: 0; }
.lcd-main { min-height: 1.4em; font-size: 1.35rem; letter-spacing: .1em; text-transform: uppercase; }
.lcd-main.warn { color: #ffd23c; text-shadow: 0 0 6px rgba(255, 210, 60, .45); }
.lcd-main.bad { color: #ff7a70; text-shadow: 0 0 6px rgba(255, 74, 61, .45); }
.lcd-main.open { color: #b8fff4; text-shadow: 0 0 10px rgba(var(--lamp), .8); }
.lcd-sub { min-height: 1.5em; font-size: .9rem; color: #7fd497; }
.lcd-bar {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: #0f2416;
  overflow: hidden;
}
.lcd-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--lcd);
  box-shadow: 0 0 8px rgba(157, 255, 176, .6);
}
.lcd-bar.open span { background: rgb(var(--lamp)); box-shadow: 0 0 8px rgba(var(--lamp), .8); }

.tally {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
  font-family: var(--mono);
}
.tally > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #0b0d10;
  border: 1px solid #2a303a;
}
.tally-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tally-num { font-size: 1.1rem; color: var(--hazard); letter-spacing: .08em; text-shadow: 0 0 6px rgba(245, 196, 0, .35); }

@media (max-width: 800px) {
  .top { padding-top: 16px; }
  .trap-art { max-width: 220px; }
}

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