/* Tela de login: noite em Niflheim. Sempre escura, independente do tema do sistema. */
:root {
  --noite: #050409;
  --vidro: rgba(13, 10, 24, .78);
  --borda: rgba(169, 139, 255, .28);
  --texto: #ece8ff;
  --suave: #a69ec9;
  --roxo: #8d6be0;
  --roxo-claro: #b9a3ff;
  --alma: #9ff5d8;
  --erro: #ff8f86;
  --chao: 7vh;
  --esc: 1;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--noite);
  color: var(--texto);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* ---------- Cenário ---------- */
.cena { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
/* A vila de Niflheim: a imagem cobre a tela mantendo o castelo à vista, com uma aproximação lenta. */
.fundo {
  position: absolute; inset: -2%;
  background: #120c1f url(niflheim/vila.webp) center 30% / cover no-repeat;
  filter: saturate(1.05) brightness(.82);
  animation: respirar 60s ease-in-out infinite alternate;
}
@keyframes respirar { from { transform: scale(1); } to { transform: scale(1.06) translate(-1%, -1%); } }
.sombra {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 55% 50% at 50% 42%, rgba(8, 5, 16, .55), transparent 75%), /* atrás do formulário */
    radial-gradient(ellipse 120% 90% at 50% 40%, transparent 50%, rgba(4, 2, 9, .85) 100%),  /* vinheta */
    linear-gradient(180deg, rgba(5, 3, 10, .55) 0%, transparent 22%, transparent 62%, rgba(12, 8, 22, .7) 80%, #07050d 100%); /* chão */
}

.nevoa {
  position: absolute; left: -50%; width: 200%;
  background:
    radial-gradient(40% 60% at 10% 60%, rgba(170, 150, 230, .16), transparent 70%),
    radial-gradient(30% 50% at 35% 40%, rgba(140, 200, 200, .10), transparent 70%),
    radial-gradient(45% 55% at 60% 65%, rgba(170, 150, 230, .14), transparent 70%),
    radial-gradient(35% 50% at 85% 45%, rgba(140, 200, 200, .10), transparent 70%);
  filter: blur(6px);
}
.nevoa-fundo { bottom: 14vh; height: 30vh; animation: deriva 70s linear infinite; }
.nevoa-frente { bottom: -4vh; height: 22vh; opacity: .9; animation: deriva 45s linear infinite reverse; }
@keyframes deriva { from { transform: translateX(0); } to { transform: translateX(25%); } }

/* ---------- Monstros (tiras recortadas do CDN do jogo) ---------- */
.monstros { position: absolute; inset: 0; }
.monstro {
  position: absolute;
  left: var(--x);
  bottom: calc(var(--chao) + var(--alto, 0px) - (var(--h) - var(--pe)) * var(--s) * var(--esc) * 1px);
  width: calc(var(--w) * var(--s) * var(--esc) * 1px);
  height: calc(var(--h) * var(--s) * var(--esc) * 1px);
  translate: -50% 0;
  z-index: var(--z, 1);
}
.monstro.virado { scale: -1 1; }
.monstro .quadro {
  width: 100%; height: 100%;
  background-repeat: no-repeat;
  background-size: calc(var(--w) * var(--n) * var(--s) * var(--esc) * 1px) 100%;
  image-rendering: pixelated;
  animation: quadros calc(var(--n) * var(--ms) * 1ms) steps(var(--n)) infinite;
  filter: var(--filtro, drop-shadow(0 0 10px rgba(130, 100, 220, .35)));
}
@keyframes quadros { to { background-position-x: calc(var(--w) * var(--n) * var(--s) * var(--esc) * -1px); } }
.monstro.flutua { animation: flutua 5s ease-in-out infinite; }
@keyframes flutua { 50% { transform: translateY(-14px); } }
.monstro::after { /* sombra no chão */
  content: ""; position: absolute; left: 20%; right: 20%;
  bottom: calc((var(--h) - var(--pe)) * var(--s) * var(--esc) * 1px - 5px);
  height: 10px; border-radius: 50%; background: rgba(0, 0, 0, .55); filter: blur(3px); z-index: -1;
}
.monstro.flutua::after { opacity: .5; }
.monstro.longe .quadro { --filtro: brightness(.62) saturate(.8) drop-shadow(0 0 22px rgba(150, 110, 255, .45)); }

/* ---------- Almas subindo ---------- */
.almas { position: absolute; inset: 0; }
.alma {
  position: absolute; bottom: -10px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--alma); box-shadow: 0 0 10px 3px rgba(159, 245, 216, .55);
  opacity: 0; animation: subir var(--dur) ease-in infinite; animation-delay: var(--atraso);
}
@keyframes subir {
  0% { opacity: 0; transform: translate(0, 0) scale(.6); }
  15% { opacity: .9; }
  60% { transform: translate(var(--vai), -55vh) scale(1); opacity: .6; }
  100% { opacity: 0; transform: translate(calc(var(--vai) * -1), -95vh) scale(.4); }
}

/* ---------- Formulário ---------- */
.login {
  position: relative; z-index: 5; min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px 22vh;
}
.marca { text-align: center; margin-bottom: 18px; }
.marca h1 {
  margin: 0; font: 700 clamp(2.6rem, 9vw, 4.4rem)/1 "Cinzel Decorative", Georgia, serif;
  letter-spacing: .04em; color: #e9e2ff; font-variant-ligatures: none; font-feature-settings: "liga" 0, "dlig" 0, "calt" 0, "clig" 0;
  text-shadow: 0 0 18px rgba(150, 120, 255, .65), 0 0 46px rgba(110, 80, 220, .45), 0 2px 0 #1a1330;
}
.marca h1 .quebra { margin-left: .04em; } /* separa o H do E: na fonte decorativa eles viram um desenho só */
.marca-sobre, .marca-sob { font-family: "Cinzel", Georgia, serif; letter-spacing: .22em; text-transform: uppercase; color: var(--suave); font-size: .76rem; }
.marca-sobre { margin-bottom: 8px; }
.marca-sob { margin-top: 10px; color: var(--alma); opacity: .85; }

.portao {
  width: min(360px, 100%);
  padding: 22px 22px 16px;
  background: var(--vidro);
  border: 1px solid var(--borda);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 18px 50px rgba(0, 0, 0, .7), 0 0 60px rgba(120, 90, 220, .18);
  backdrop-filter: blur(6px);
  position: relative;
}
.portao::before { /* filete dourado-envelhecido no topo, como as janelas do jogo */
  content: ""; position: absolute; left: 14px; right: 14px; top: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, #c9a45c, transparent); opacity: .7;
}
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-family: "Cinzel", Georgia, serif; font-size: .82rem; letter-spacing: .08em; color: var(--suave); }
.campo input {
  font: 15px system-ui, sans-serif; letter-spacing: normal;
  padding: 10px 12px; border-radius: 4px; border: 1px solid #3a3158;
  background: rgba(6, 5, 12, .85); color: var(--texto); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.campo input:focus { outline: none; border-color: var(--roxo-claro); box-shadow: 0 0 0 3px rgba(141, 107, 224, .3), 0 0 18px rgba(159, 245, 216, .15); }
.entrar {
  width: 100%; margin-top: 4px; padding: 11px; cursor: pointer;
  font: 600 .95rem "Cinzel", Georgia, serif; letter-spacing: .14em; text-transform: uppercase;
  color: #fff; border: 1px solid #a68cf0; border-radius: 4px;
  background: linear-gradient(180deg, #7354c9, #47308f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 0 22px rgba(120, 90, 220, .35);
  transition: filter .15s, transform .05s;
}
.entrar:hover { filter: brightness(1.15); }
.entrar:active { transform: translateY(1px); }
.entrar:focus-visible { outline: 2px solid var(--alma); outline-offset: 2px; }
.estado { margin: 10px 0 0; min-height: 1.4em; font-size: .9rem; color: var(--suave); text-align: center; }
.estado.erro { color: var(--erro); }
.nota { margin: 6px 0 0; font-size: .8rem; color: #8b83ad; text-align: center; }

/* ---------- Telas menores ---------- */
@media (max-width: 900px) { :root { --esc: .78; } .monstro.so-largo { display: none; } }
@media (max-width: 560px) { :root { --esc: .62; --chao: 5vh; } .monstro.so-medio { display: none; } .login { padding-bottom: 18vh; } }
@media (max-height: 640px) { .login { padding-bottom: 12vh; } .monstro.longe { display: none; } }

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