* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #b7b3a2;
  color: #f2f0e6;
  font-family: "Courier New", "Nimbus Mono PS", "Liberation Mono", ui-monospace, monospace;
  overscroll-behavior: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #b7b3a2;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }

#vignette-soft {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 100% at 50% 46%, rgba(0,0,0,0) 52%, rgba(42,42,30,0.22) 100%);
  mix-blend-mode: multiply;
}

#warm {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(110% 100% at 50% 50%, rgba(255,168,74,0) 42%, rgba(255,146,52,0.20) 78%, rgba(180,84,20,0.32) 100%);
  mix-blend-mode: screen;
  transition: opacity 220ms linear;
}

#sticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  display: none;
}
#sticks.shown { display: block; }

.stick {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  opacity: 0.82;
  transition: opacity 220ms ease;
}
.stick.active { opacity: 1; }
#stickMove { left: calc(16px + env(safe-area-inset-left)); }
#stickLook { right: calc(16px + env(safe-area-inset-right)); }

.stick-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(244, 242, 230, 0.52);
  background: radial-gradient(circle at 50% 50%, rgba(24,26,20,0.30), rgba(24,26,20,0.14) 66%, rgba(24,26,20,0) 72%);
  box-shadow: inset 0 0 22px rgba(24,26,20,0.26), 0 2px 14px rgba(20,22,18,0.16);
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 1px solid rgba(245, 243, 231, 0.68);
  background: rgba(238, 236, 223, 0.24);
  box-shadow: 0 2px 12px rgba(20,22,18,0.34), inset 0 0 10px rgba(255,255,255,0.10);
  will-change: transform;
}

.stick-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -17px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(244, 242, 231, 0.72);
  text-shadow: 0 1px 3px rgba(24, 26, 20, 0.6);
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #efeee4;
  text-shadow: 0 1px 4px rgba(30,32,24,0.55);
}

#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(245, 244, 232, 0.72);
  box-shadow: 0 0 0 0 rgba(255, 197, 120, 0);
  transition: background 240ms linear, box-shadow 300ms linear, transform 300ms ease;
}

#reticle.warm {
  background: rgba(255, 226, 178, 0.95);
}

.caption {
  position: absolute;
  left: 22px;
  top: 22px;
  max-width: min(72vw, 460px);
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: rgba(240, 239, 227, 0.88);
  opacity: 0;
  transition: opacity 1.6s ease;
  text-shadow: 0 1px 4px rgba(24, 26, 20, 0.55);
}

.caption.visible { opacity: 1; }

.hints {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(90vw, 560px);
  padding: 0 10px;
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.05em;
  color: rgba(238, 237, 224, 0.72);
  opacity: 0;
  transition: opacity 1.2s ease;
  text-shadow: 0 1px 4px rgba(24, 26, 20, 0.55);
}
.hints.visible { opacity: 1; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  max-width: min(84vw, 420px);
  padding: 7px 14px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  line-height: 1.6;
  color: rgba(244, 242, 230, 0.9);
  background: rgba(30, 32, 26, 0.34);
  border: 1px solid rgba(240, 239, 227, 0.12);
  opacity: 0;
  transition: opacity 600ms ease;
  text-shadow: 0 1px 4px rgba(24, 26, 20, 0.55);
  backdrop-filter: blur(3px);
}
.toast.visible { opacity: 1; }

.door-prompt {
  position: absolute;
  left: 50%;
  bottom: 30%;
  transform: translate(-50%, 0);
  padding: 12px 22px;
  border: 1px solid rgba(244, 242, 230, 0.5);
  background: rgba(30, 32, 26, 0.42);
  color: #f5f2e5;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 22px rgba(20, 22, 18, 0.25);
}
.door-prompt:hover { background: rgba(42, 44, 36, 0.62); }
.door-prompt:focus-visible { outline: 1px solid #fff; outline-offset: 3px; }
.door-prompt[hidden] { display: none; }

#helpBtn {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(240, 239, 227, 0.22);
  background: rgba(28, 30, 24, 0.22);
  color: rgba(240, 239, 227, 0.78);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 900ms ease, background 200ms ease;
}
#helpBtn.visible { opacity: 1; }
#helpBtn:hover { background: rgba(28, 30, 24, 0.4); }
#helpBtn:focus-visible { outline: 1px solid #f3f1e4; outline-offset: 2px; }

.help {
  position: absolute;
  right: 14px;
  top: 58px;
  width: min(78vw, 300px);
  padding: 16px 18px 14px;
  background: rgba(24, 26, 21, 0.66);
  border: 1px solid rgba(240, 239, 227, 0.16);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  color: rgba(240, 239, 227, 0.9);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.04em;
}
.help p { margin: 0 0 8px; }
.help .help-goal { color: #f6ecd8; }
.help .help-note { color: rgba(240, 239, 227, 0.6); }
.help button {
  margin-top: 2px;
  padding: 6px 12px;
  border: 1px solid rgba(240, 239, 227, 0.26);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.help button:hover { background: rgba(240, 239, 227, 0.08); }

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
}

#intro {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  transition: opacity 1.5s ease;
}
#intro.hidden {
  opacity: 0;
  pointer-events: none;
}

.intro-art {
  position: absolute;
  inset: -3%;
  background: url("assets/poster_corridor.webp") center 52% / cover no-repeat;
  filter: saturate(0.94) brightness(1.03);
  transform: scale(1.02);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to   { transform: scale(1.07) translate3d(-1.6%, -0.8%, 0); }
}

.intro-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(24,26,20,0.10) 0%, rgba(24,26,20,0) 28%, rgba(24,26,20,0.16) 58%, rgba(20,22,17,0.78) 100%),
    radial-gradient(120% 90% at 50% 50%, rgba(0,0,0,0) 55%, rgba(29,31,24,0.36) 100%);
}

.intro-copy {
  position: relative;
  z-index: 1;
  padding: 0 26px calc(30px + env(safe-area-inset-bottom)) 26px;
  max-width: 560px;
  margin-bottom: max(4vh, 16px);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(246, 244, 232, 0.72);
}

#intro h1 {
  margin: 0 0 18px;
  font-weight: 400;
  font-size: clamp(30px, 8vw, 54px);
  line-height: 1;
  letter-spacing: 0.16em;
  color: #f6f4e8;
  text-shadow: 0 2px 18px rgba(20, 22, 18, 0.5);
}

.intro-line {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.75;
  letter-spacing: 0.04em;
  color: rgba(240, 239, 227, 0.82);
  max-width: 34ch;
}
.intro-goal {
  margin: 0 0 22px;
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0.05em;
  color: #f5e7cd;
}

#startBtn, #againBtn {
  appearance: none;
  padding: 12px 26px;
  border: 1px solid rgba(242, 240, 229, 0.5);
  background: rgba(238, 235, 219, 0.08);
  color: #f5f3e8;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(3px);
  transition: background 240ms ease, border-color 240ms ease, color 240ms ease;
}
#intro.hide-start #startBtn { visibility: hidden; }
#startBtn:hover, #againBtn:hover {
  background: rgba(238, 235, 219, 0.2);
  border-color: rgba(242, 240, 229, 0.85);
}
#startBtn:focus-visible, #againBtn:focus-visible { outline: 1px solid #fff; outline-offset: 3px; }

.intro-controls {
  margin: 16px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  line-height: 1.7;
  color: rgba(240, 239, 227, 0.5);
  max-width: 42ch;
}

#foundScreen {
  background: #eef1ee;
  opacity: 0;
  transition: background 2600ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#foundScreen.visible {
  opacity: 1;
  pointer-events: auto;
}
#foundScreen.warm-white {
  background: #f3efe2;
}

.found-inner {
  text-align: center;
  padding: 24px;
  color: #3a3a30;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 2.4s ease 0.6s, transform 2.4s ease 0.6s;
}
#foundScreen.visible .found-inner {
  opacity: 1;
  transform: none;
}
.found-line {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #3d3a2c;
}
.found-sub {
  margin: 0 0 28px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #6a6655;
}
.found-inner button { margin-top: 6px; }
#againBtn {
  border-color: rgba(60, 58, 44, 0.4);
  background: transparent;
  color: #3d3a2c;
  opacity: 0;
  transition: opacity 1.2s ease;
}
#againBtn.shown { opacity: 1; }

@media (max-width: 520px) {
  .caption { left: 16px; top: 16px; font-size: 11.5px; max-width: 78vw; }
  .hints { bottom: 18px; font-size: 10.5px; }
  #helpBtn { right: 10px; top: 10px; width: 32px; height: 32px; }
  .help { right: 10px; top: 50px; }
  .intro-copy { padding-left: 20px; padding-right: 20px; }
}

@media (pointer: coarse) {
  #view { cursor: default; }
  .hints { bottom: calc(156px + env(safe-area-inset-bottom)); max-width: 84vw; }
  .toast { bottom: calc(158px + env(safe-area-inset-bottom)); }
  .door-prompt { bottom: 34%; }
}

@media (prefers-reduced-motion: reduce) {
  .intro-art { animation: none; }
}

/* ------------------------------------------------------------------ together */

[hidden] { display: none !important; }

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 4px;
}

#coopBtn {
  border-style: dashed;
  border-color: rgba(242, 240, 229, 0.42);
  background: transparent;
}

#coopLobby {
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(20,22,17,0.30) 0%, rgba(20,22,17,0.10) 35%, rgba(18,20,16,0.70) 100%),
    url(assets/poster_corridor.webp) center / cover no-repeat;
}

.coop-card {
  width: min(92vw, 470px);
  padding: 26px 24px 22px;
  background: rgba(24, 26, 21, 0.62);
  border: 1px solid rgba(240, 239, 227, 0.2);
  backdrop-filter: blur(5px);
  color: #f1efe3;
  box-shadow: 0 16px 60px rgba(18, 20, 16, 0.4);
}

.coop-card h2 {
  margin: 2px 0 10px;
  font-weight: 400;
  font-size: clamp(19px, 5.2vw, 27px);
  line-height: 1.3;
  letter-spacing: 0.06em;
  color: #f7f4e8;
}

.coop-status {
  margin: 0 0 18px;
  font-size: 11.5px;
  line-height: 1.8;
  letter-spacing: 0.04em;
  color: rgba(240, 239, 227, 0.76);
}

.invite {
  margin: 0 0 18px;
}

.invite-label {
  margin: 0 0 7px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(240, 239, 227, 0.55);
}

.invite-row {
  display: flex;
  gap: 7px;
}

#inviteLink {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(240, 239, 227, 0.24);
  background: rgba(10, 12, 9, 0.35);
  color: rgba(244, 242, 230, 0.9);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.02em;
}

#copyLink, .lobby-actions button {
  padding: 9px 14px;
  border: 1px solid rgba(240, 239, 227, 0.36);
  background: rgba(240, 239, 227, 0.06);
  color: #f1efe3;
  font-family: inherit;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
#inviteLink:focus-visible,
#copyLink:focus-visible,
#coopBack:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 2px;
}
#copyLink:hover, .lobby-actions button:hover {
  background: rgba(240, 239, 227, 0.16);
}

.lobby-actions {
  display: flex;
  justify-content: flex-end;
}

.crew {
  position: absolute;
  right: 58px;
  top: 18px;
  max-width: 55vw;
  padding: 5px 9px;
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-align: right;
  color: rgba(242, 240, 228, 0.78);
  background: rgba(28, 30, 24, 0.24);
  border: 1px solid rgba(240, 239, 227, 0.1);
  text-shadow: 0 1px 3px rgba(24, 26, 20, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 700ms ease;
}
.crew.visible { opacity: 1; }

#ghostLabels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}

.ghost-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 6px;
  border-radius: 2px;
  background: rgba(24, 26, 21, 0.28);
  color: rgba(242, 240, 230, 0.8);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(20, 22, 18, 0.6);
  opacity: 0;
  transition: opacity 300ms linear;
  will-change: left, top;
}
.ghost-label.visible { opacity: 1; }

.help #leaveBtn {
  display: none;
  margin-right: 8px;
}
.help.coop #leaveBtn { display: inline-block; }

@media (max-width: 520px) {
  .crew { right: 50px; top: 14px; font-size: 9.5px; max-width: 60vw; }
  .coop-card { padding: 22px 18px 18px; }
  .intro-actions { gap: 8px; }
}
