/* Estilos — cavernícola / bosque */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #1a2418;
  color: #f5efe0;
  font-family: "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#contenedor {
  position: relative;
  width: 400px;
}

#hud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  font-size: 16px;
  letter-spacing: 1px;
}

#hud b {
  color: #ffd166;
}

#btn-ranking {
  background: transparent;
  border: 2px solid #e8d5a8;
  border-radius: 6px;
  color: #ffd166;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

#btn-ranking:hover {
  background: #e8d5a822;
}

#barra-tiempo-envoltura {
  flex: 1;
  height: 18px;
  background: #0d140c;
  border: 2px solid #e8d5a8;
  border-radius: 4px;
  overflow: hidden;
}

#barra-tiempo {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e63946, #f4a261, #2a9d8f);
  transition: width 0.08s linear;
}

#lienzo {
  display: block;
  width: 400px;
  height: 600px;
  background: #3d6b8a;
  border: 3px solid #5c3a1e;
  border-radius: 8px;
  box-shadow: 0 0 28px #00000088;
}

.pantalla {
  position: absolute;
  inset: 44px 0 0 0;
  background: #0d140cf2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  border-radius: 8px;
  z-index: 10;
  padding: 20px;
}

.pantalla.visible {
  display: flex;
}

.pantalla h1 {
  font-size: 40px;
  color: #ffd166;
  text-shadow: 3px 3px 0 #5c3a1e;
  letter-spacing: 3px;
}

.subtitulo {
  color: #cfe8cf;
  font-size: 16px;
}

.motivo {
  color: #ff8fa3;
  font-size: 17px;
  font-weight: 600;
  max-width: 300px;
}

.controles {
  line-height: 1.9;
  color: #a8c5a8;
  font-size: 14px;
}

.pista {
  color: #7a9a7a;
  font-size: 13px;
}

.pantalla button {
  background: #e76f51;
  color: #fff;
  border: none;
  padding: 14px 40px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #a44a2f;
  transition: 0.1s;
}

.pantalla button:hover {
  filter: brightness(1.08);
}

.pantalla button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a44a2f;
}

/* ---------- Registro + envío ---------- */
.form-registro,
.form-enviar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  align-items: stretch;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.campo span {
  font-size: 12px;
  color: #a8c5a8;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.form-registro input,
.form-enviar input {
  background: #1a2418;
  border: 2px solid #e8d5a8;
  border-radius: 6px;
  color: #f5efe0;
  font-size: 16px;
  padding: 10px 12px;
  text-align: left;
  outline: none;
}

.form-registro input:focus,
.form-enviar input:focus {
  border-color: #ffd166;
}

.form-registro button,
.form-enviar button {
  padding: 12px 20px;
  font-size: 15px;
}

.form-registro button:disabled,
.form-enviar button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.cuenta-tag {
  color: #ffd166;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.ranking-caja {
  width: 100%;
  max-width: 300px;
  max-height: 180px;
  overflow-y: auto;
  background: #0a120acc;
  border: 2px solid #5c3a1e;
  border-radius: 8px;
  padding: 8px 12px;
  text-align: left;
}

.ranking-caja h2 {
  font-size: 14px;
  color: #ffd166;
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-align: center;
}

.ranking-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}

.ranking-lista li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 4px;
  border-bottom: 1px solid #ffffff11;
  color: #cfe8cf;
}

.ranking-lista li:nth-child(1) .rk-nick,
.ranking-lista li:nth-child(1) .rk-pts {
  color: #ffd166;
  font-weight: 700;
}

.ranking-lista li:nth-child(2) .rk-nick,
.ranking-lista li:nth-child(2) .rk-pts {
  color: #c0c0c0;
}

.ranking-lista li:nth-child(3) .rk-nick,
.ranking-lista li:nth-child(3) .rk-pts {
  color: #cd7f32;
}

.rk-pos {
  color: #7a9a7a;
  min-width: 1.6em;
}

.rk-nick {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rk-pts {
  color: #ffd166;
  font-weight: 600;
}

.ranking-vacia {
  color: #7a9a7a;
  font-size: 13px;
  text-align: center;
  padding: 8px 0;
}

.msg-error {
  color: #ff8fa3 !important;
  font-weight: 700;
  min-height: 1.2em;
}

.check-terminos {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
  font-size: 12px;
  color: #a8c5a8;
  line-height: 1.4;
  cursor: pointer;
}

.check-terminos input {
  margin-top: 2px;
  accent-color: #ffd166;
  flex-shrink: 0;
}

.check-terminos a {
  color: #ffd166;
  text-decoration: underline;
}

.pantalla a {
  color: #ffd166;
  text-decoration: underline;
}

/* ---------- Anuncio automático tras cada muerte (pantalla completa, sin recuadro) ---------- */
.anuncio-overlay {
  inset: 0;
  z-index: 50;
  background: #050805fa;
  padding: 0;
  gap: 0;
}

.anuncio-overlay[hidden] {
  display: none !important;
}

.anuncio-zona {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: linear-gradient(160deg, #1e3a2f, #0f2418 55%, #0a1a12);
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.anuncio-fake-titulo {
  color: #ffd166;
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 1px;
}

.anuncio-fake-texto {
  color: #cfe8cf;
  font-size: 14px;
  margin: 0;
}

.anuncio-fake-texto b {
  color: #ffd166;
}

.anuncio-cuenta {
  color: #7a9a7a;
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 0;
}

/* ---------- Cebo anti-adblock (invisible si no hay bloqueador) ---------- */
#adblock-bait {
  position: absolute;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Bloqueador de anuncios: aviso y bloqueo ---------- */
.adblock-overlay {
  inset: 0;
  z-index: 60;
  background: #050805fa;
}

.adblock-overlay[hidden] {
  display: none !important;
}

.adblock-caja {
  width: 100%;
  max-width: 340px;
  background: #121a10;
  border: 3px solid #ff8fa3;
  border-radius: 12px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  box-shadow: 0 0 40px #ff8fa333;
}

.adblock-icono {
  font-size: 36px;
  margin: 0;
}

.adblock-caja h2 {
  color: #ff8fa3;
  font-size: 22px;
  margin: 0;
  letter-spacing: 1px;
}

.adblock-texto {
  color: #cfe8cf;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

.adblock-texto b {
  color: #ffd166;
}

#btn-revisar-adblock {
  background: #2a9d8f;
  color: #fff;
  border: none;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1f6f66;
}

#btn-revisar-adblock:hover {
  filter: brightness(1.08);
}

#btn-revisar-adblock:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1f6f66;
}

/* ---------- Controles táctiles (móvil) ---------- */
#controles-tactiles {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
}

#controles-tactiles[hidden] {
  display: none !important;
}

#btn-tactil-izq,
#btn-tactil-der {
  flex: 1;
  min-height: 64px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  background: #e76f51;
  border: 3px solid #e8d5a8;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 5px 0 #a44a2f;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#btn-tactil-der {
  background: #2a9d8f;
  box-shadow: 0 5px 0 #1f6f66;
}

#btn-tactil-izq:active,
#btn-tactil-der:active {
  transform: translateY(3px);
  filter: brightness(1.1);
}

/* ---------- PWA / móvil ---------- */
html,
body {
  height: 100%;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overscroll-behavior: none;
}

#lienzo {
  max-width: 100%;
  height: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 440px) {
  body {
    align-items: flex-start;
    padding-top: env(safe-area-inset-top, 0px);
  }

  #contenedor {
    width: 100%;
    max-width: 100%;
    padding: 0 6px;
  }

  #lienzo {
    width: 100%;
    height: auto;
    aspect-ratio: 400 / 600;
    border-width: 2px;
  }

  #hud {
    font-size: 13px;
    gap: 8px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }

  .pantalla {
    inset: 44px 0 0 0;
    padding: 12px;
    gap: 12px;
    overflow-y: auto;
  }

  .pantalla h1 {
    font-size: 28px;
  }

  .pantalla button {
    padding: 14px 28px;
    font-size: 16px;
  }

  #btn-tactil-izq,
  #btn-tactil-der {
    min-height: 72px;
    font-size: 15px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  body {
    align-items: flex-start;
  }

  #contenedor {
    width: min(100%, 400px);
  }
}
