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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
  color: #b8b0a4;
  cursor: default;
  user-select: none;
}

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

/* El canvas 3D se renderiza a baja resolución y se escala: da grano sucio y sensación de VHS */
#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* Capa de efectos: sustos a pantalla completa, sangre, distorsión */
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
}

/* ---------------- HUD ---------------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#objective {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 15px;
  letter-spacing: 3px;
  color: #8d8578;
  text-shadow: 0 0 8px #000, 0 0 2px #000;
  opacity: 0;
  transition: opacity 0.9s ease;
}
#objective.show { opacity: 0.85; }

#subtitle {
  position: absolute;
  bottom: 56px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 17px;
  letter-spacing: 1px;
  font-style: italic;
  color: #9c9084;
  text-shadow: 0 0 10px #000;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#subtitle.show { opacity: 0.9; }

#battery-wrap {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 4px;
  background: rgba(255, 255, 255, 0.07);
  opacity: 0;
  transition: opacity 0.4s ease;
}
#battery-wrap.show { opacity: 0.55; }
#battery-fill {
  height: 100%;
  width: 100%;
  background: #c8b98a;
  transition: width 0.25s linear;
}

/* Lo que te queda antes de caer: tres marcas que se apagan a golpes */
#wounds {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.4s ease;
}
#wounds.show { opacity: 0.75; }
#wounds span {
  width: 42px;
  height: 3px;
  background: #3d1616;
}
#wounds span.ok { background: #b04141; }

/* ---------------- Flashes ---------------- */

#flash-white, #flash-red {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 6;
}
#flash-white { background: #fff; }
#flash-red { background: radial-gradient(circle at 50% 50%, rgba(120,0,0,0) 30%, rgba(90,0,0,0.85) 100%); }

/* ---------------- Pantallas ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: #000;
  text-align: center;
  padding: 20px;
}
.screen.hidden { display: none; }

.screen h1 {
  font-size: clamp(38px, 9vw, 96px);
  letter-spacing: 14px;
  color: #cfc6b8;
  font-weight: normal;
  text-shadow: 0 0 30px rgba(160, 20, 20, 0.5);
}

.tag {
  font-size: 15px;
  letter-spacing: 4px;
  color: #6e675c;
  font-style: italic;
}

.warn {
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: 1px;
  color: #7a3030;
  max-width: 460px;
}

button {
  background: transparent;
  border: 1px solid #4a453d;
  color: #cfc6b8;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 6px;
  padding: 14px 46px;
  cursor: pointer;
  transition: all 0.25s ease;
}
button:hover {
  background: #1a0505;
  border-color: #8a1f1f;
  color: #fff;
  letter-spacing: 10px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  justify-content: center;
  max-width: 620px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #4f4a42;
  margin-top: 10px;
}
.controls b { color: #857c6e; }

#death-sub, #win-sub {
  font-size: 14px;
  letter-spacing: 2px;
  color: #6b6259;
  max-width: 520px;
  line-height: 1.8;
  white-space: pre-line;
}

#screen-death h1 { color: #9e1616; text-shadow: 0 0 40px #500; }
#screen-win  h1 { color: #8ba98b; text-shadow: 0 0 40px #030; }

/* ---------------- Co-op: lobby, equipo, reanimación ---------------- */

.btn-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

button.ghost {
  border-color: #2a2722;
  color: #6b6259;
  font-size: 12px;
  letter-spacing: 4px;
  padding: 9px 26px;
}

.screen h1.small {
  font-size: clamp(22px, 4vw, 40px);
  letter-spacing: 10px;
}

#screen-lobby input {
  background: #0a0908;
  border: 1px solid #3a352e;
  color: #cfc6b8;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  padding: 12px 18px;
  width: 190px;
  outline: none;
}
#screen-lobby input:focus { border-color: #8a1f1f; }
#screen-lobby input::placeholder { color: #4a453d; letter-spacing: 4px; }

#lobby-entrada, #lobby-sala {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
#lobby-entrada.hidden, #lobby-sala.hidden, #lobby-wait.hidden, #btn-launch.hidden { display: none; }

#lobby-code {
  font-size: clamp(40px, 8vw, 74px);
  letter-spacing: 18px;
  color: #cfc6b8;
  text-shadow: 0 0 30px rgba(160, 20, 20, 0.45);
  padding-left: 18px;
}

#lobby-players {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  letter-spacing: 4px;
  color: #6e675c;
  min-height: 22px;
}
#lobby-players .host { color: #b3a893; }

#lobby-msg {
  font-size: 12px;
  letter-spacing: 2px;
  color: #8a2626;
  min-height: 16px;
}

#team {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
  font-size: 11px;
  letter-spacing: 3px;
  color: #6e675c;
  opacity: 0;
  transition: opacity 0.5s;
}
#team.show { opacity: 0.75; }
#team .down { color: #9e3b3b; }
#team .dead { color: #4a3030; text-decoration: line-through; }

#revive-wrap {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  z-index: 8;
  text-align: center;
  pointer-events: none;
}
#revive-wrap.hidden { display: none; }
#revive-text {
  font-size: 11px;
  letter-spacing: 6px;
  color: #9a9082;
  margin-bottom: 7px;
}
#revive-bar {
  width: 190px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
}
#revive-fill {
  height: 100%;
  width: 0%;
  background: #b3a893;
  transition: width 0.1s linear;
}

/* Chat: por encima de las pantallas, para que también se lea en el lobby */
#chat {
  position: absolute;
  left: 18px;
  bottom: 64px;
  z-index: 12;
  width: min(48vw, 430px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#chat-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  letter-spacing: 1px;
}
#chat-log div {
  color: #9c9084;
  text-shadow: 0 0 8px #000, 0 0 3px #000;
  opacity: 0.92;
  transition: opacity 1s ease;
  word-break: break-word;
}
#chat-log div.fade { opacity: 0; }
#chat-log b { color: #b3a06a; font-weight: normal; }
#chat-log div.me b { color: #7fa08c; }
#chat-log div.sys { color: #6e675c; font-style: italic; }

#chat-input {
  pointer-events: auto;
  background: rgba(6, 5, 5, 0.9);
  border: 1px solid #3a352e;
  border-left: 2px solid #8a1f1f;
  color: #cfc6b8;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 9px 12px;
  outline: none;
  width: 100%;
}
#chat-input.hidden { display: none; }

/* La semilla es un número largo: no cabe con el espaciado de los códigos */
#screen-lobby #in-seed {
  width: 210px;
  letter-spacing: 2px;
  font-size: 13px;
}

/* Gana al estilo general de los inputs del lobby: aquí se escribe prosa */
#screen-lobby #lobby-chat {
  min-width: 280px;
  text-transform: none;
  text-align: left;
  letter-spacing: 2px;
  font-size: 13px;
}

/* El cartel no come clics: si no, tapa el canvas y la pausa no se quita */
#pause-hint {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  text-align: center;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  font-size: 15px;
  letter-spacing: 8px;
  color: #6e675c;
}
#pause-hint.hidden { display: none; }

/* Título con glitch cromático */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  overflow: hidden;
}
.glitch::before {
  color: #6d0f0f;
  animation: gl1 2.7s infinite steps(2, end);
}
.glitch::after {
  color: #123b3b;
  animation: gl2 3.9s infinite steps(2, end);
}
@keyframes gl1 {
  0%, 92%, 100% { transform: translate(0, 0); opacity: 0; }
  93% { transform: translate(-4px, 2px); opacity: 0.9; }
  96% { transform: translate(3px, -2px); opacity: 0.7; }
}
@keyframes gl2 {
  0%, 88%, 100% { transform: translate(0, 0); opacity: 0; }
  89% { transform: translate(5px, 1px); opacity: 0.8; }
  94% { transform: translate(-3px, -3px); opacity: 0.6; }
}
