/* Janela de login/cadastro no estilo da home (independente do tema claro/escuro) */
html.am-lock { overflow: hidden; }
.am { --game: "Lilita One", "Rajdhani", var(--font, system-ui), sans-serif; position: fixed; inset: 0; z-index: 96000; display: grid; padding: 20px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; color: #fff; }
.am[hidden] { display: none; }
.am-backdrop { position: fixed; inset: 0; background: rgba(5, 12, 26, 0.72); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.18s; }
.am.is-open .am-backdrop { opacity: 1; }

.am-box {
  position: relative; display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  width: min(940px, 100%); margin: auto;
  border: 4px solid #0a1528; border-radius: 28px; background: #15233a;
  box-shadow: 0 8px 0 #0a1528, 0 40px 80px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: translateY(18px) scale(0.96); transition: opacity 0.18s, transform 0.25s cubic-bezier(.3, 1.4, .5, 1);
}
.am.is-open .am-box { opacity: 1; transform: none; }

.am-x {
  position: absolute; top: -16px; right: -16px; z-index: 5; width: 46px; height: 46px; display: grid; place-items: center;
  border: 3px solid #fff; border-radius: 50%; background: linear-gradient(180deg, #ff6b5a, #d1281a); color: #fff;
  font: 400 1.8rem/1 var(--game); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); cursor: pointer;
  box-shadow: 0 4px 0 #7a1208, 0 8px 16px rgba(0, 0, 0, 0.4); transition: transform 0.12s;
}
.am-x:hover { transform: scale(1.08) rotate(6deg); }
.am-x:active { transform: scale(0.95); }

/* arte do lado esquerdo */
.am-art { position: relative; overflow: hidden; border-radius: 24px 0 0 24px; min-height: 520px; isolation: isolate; }
.am-art img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: 62% 35%; animation: amZoom 14s ease-out both; }
.am-art::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(8, 18, 38, 0.1) 0%, rgba(8, 18, 38, 0.35) 45%, rgba(8, 18, 38, 0.92) 100%); }
.am-art-copy { position: absolute; left: 28px; right: 28px; bottom: 30px; display: grid; gap: 10px; }
.am-ribbon {
  width: fit-content; padding: 5px 18px; background: linear-gradient(180deg, #ffd34d, #f0a019); color: #4a2a00; font: 400 0.85rem var(--game); letter-spacing: 0.04em;
  border-radius: 4px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 3px 0 #8a5300;
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%, 9px 50%);
}
.am-art-title { display: none; font: 400 2.3rem/1.02 var(--game); color: #fff; -webkit-text-stroke: 1.5px #1a1206; paint-order: stroke fill; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45); }
.am-art-title span { color: #ffd23f; }
.am-art-copy p { display: none; margin: 0; color: rgba(255, 255, 255, 0.88); font-size: 0.98rem; font-weight: 600; line-height: 1.5; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.am[data-pane="login"] [data-for="login"], .am[data-pane="signup"] [data-for="signup"], .am[data-pane="2fa"] [data-for="2fa"], .am[data-pane="verify"] [data-for="verify"] { display: block; }

/* tropa parada respirando no topo da arte */
.am-troop { position: absolute; top: 22px; right: 18px; --w: 74px; --h: 80px; --frames: 9; }
.am-troop b {
  display: block; width: var(--w); height: var(--h); transform: scale(1.5); transform-origin: 100% 0;
  background: url("../coc/troops/idle/valkyrie.webp") 0 0 / calc(var(--w) * var(--frames)) var(--h) no-repeat;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5)); animation: amFrames 0.75s steps(9) infinite, amBob 2.4s ease-in-out infinite;
}
.am[data-pane="signup"] .am-troop { --w: 45px; --h: 62px; --frames: 5; }
.am[data-pane="signup"] .am-troop b { background-image: url("../coc/troops/idle/goblin.webp"); transform: scale(1.8); animation: amFrames 0.42s steps(5) infinite, amBob 1.6s ease-in-out infinite; }
.am[data-pane="2fa"] .am-troop { --w: 109px; --h: 134px; --frames: 15; }
.am[data-pane="2fa"] .am-troop b { background-image: url("../coc/troops/idle/pekka.webp"); transform: scale(1.05); animation: amFrames 1.25s steps(15) infinite; }
.am[data-pane="verify"] .am-troop { --w: 45px; --h: 62px; --frames: 5; }
.am[data-pane="verify"] .am-troop b { background-image: url("../coc/troops/idle/goblin.webp"); transform: scale(1.8); animation: amFrames 0.42s steps(5) infinite, amBob 1.6s ease-in-out infinite; }
@keyframes amFrames { to { background-position: calc(var(--w) * var(--frames) * -1) 0; } }
@keyframes amBob { 50% { translate: 0 -6px; } }
@keyframes amZoom { from { transform: scale(1.1); } to { transform: scale(1); } }

/* formulário */
.am-main { display: flex; flex-direction: column; gap: 18px; padding: 30px 32px 28px; overflow-y: auto; }
.am-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border: 3px solid #0a1528; border-radius: 16px; background: #0e1a2e; }
.am[data-pane="2fa"] .am-tabs, .am[data-pane="verify"] .am-tabs { display: none; }
.am-tab {
  min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: rgba(255, 255, 255, 0.6);
  font: 400 1.05rem var(--game); letter-spacing: 0.02em; cursor: pointer; transition: color 0.15s, background-color 0.15s;
}
.am-tab:hover { color: #fff; }
.am-tab[aria-selected="true"] { background: linear-gradient(180deg, #ffc53d, #f0a019); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); box-shadow: 0 3px 0 #a35f00; }

.am-form { display: none; flex-direction: column; gap: 14px; }
.am[data-pane="login"] [data-form="login"], .am[data-pane="signup"] [data-form="signup"], .am[data-pane="2fa"] [data-form="2fa"], .am[data-pane="verify"] [data-form="verify"] { display: flex; }
.am-title { margin: 2px 0 0; font: 400 1.75rem/1.1 var(--game); color: #fff; -webkit-text-stroke: 1px #1a1206; paint-order: stroke fill; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.4); }
.am-sub { margin: -4px 0 0; color: rgba(255, 255, 255, 0.75); font-size: 0.92rem; line-height: 1.5; }
.am-sub b { color: #ffd23f; }

.am-field { display: grid; gap: 6px; }
.am-field > span:first-child { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); }
.am-field input {
  width: 100%; min-height: 50px; padding: 0 16px; border: 3px solid #0a1528; border-radius: 14px; background: #0e1a2e;
  color: #fff; font: 600 1rem var(--font, system-ui); outline: none; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.am-field input::placeholder { color: rgba(255, 255, 255, 0.35); font-weight: 500; }
.am-field input:focus { border-color: #f0a019; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(255, 197, 61, 0.2); }
.am-field input.is-bad { border-color: #e2412f; }
.am-pass { position: relative; display: block; }
.am-pass input { padding-right: 50px; }
.am-eye { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: rgba(255, 255, 255, 0.5); cursor: pointer; }
.am-eye svg { width: 19px; height: 19px; }
.am-eye:hover, .am-eye.is-on { color: #ffd23f; }
.am-code { font-family: ui-monospace, Consolas, monospace !important; font-size: 1.4rem !important; letter-spacing: 0.4em; text-align: center; }

.am-meter { display: flex; gap: 5px; margin-top: -4px; }
.am-meter i { flex: 1; height: 6px; border-radius: 3px; background: #0a1528; transition: background 0.2s; }
.am-form[data-score="1"] .am-meter i.on, .am-form[data-score="2"] .am-meter i.on { background: #ef4444; }
.am-form[data-score="3"] .am-meter i.on, .am-form[data-score="4"] .am-meter i.on { background: #f5a524; }
.am-form[data-score="5"] .am-meter i.on { background: #6cc93a; }
.am-rules { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 0; padding: 0; list-style: none; }
.am-rules li { padding: 3px 10px; border-radius: 999px; background: #0e1a2e; color: rgba(255, 255, 255, 0.5); font-size: 0.74rem; font-weight: 700; }
.am-rules li::before { content: "○ "; }
.am-rules li.is-ok { background: rgba(108, 201, 58, 0.16); color: #8ee05a; }
.am-rules li.is-ok::before { content: "✓ "; }

.am-err { padding: 11px 14px; border: 2px solid #7a1c0a; border-radius: 12px; background: rgba(226, 65, 47, 0.16); color: #ffb4a8; font-size: 0.9rem; font-weight: 700; }
.am-err.am-shake { animation: amShake 0.35s; }
.am-ok { padding: 11px 14px; border: 2px solid #2f6b12; border-radius: 12px; background: rgba(108, 201, 58, 0.16); color: #a6ec7e; font-size: 0.9rem; font-weight: 700; }
@keyframes amShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* botões 3D iguais aos da home */
.am-btn {
  --top: #8bd43f; --top-h: #9be04d; --base: #3f7d16;
  position: relative; top: 0; min-height: 56px; margin-top: 6px; border: 0; border-radius: 15px;
  background: var(--top); color: #fff; font: 400 1.3rem var(--game); letter-spacing: 0.02em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  box-shadow: 0 5px 0 var(--base); cursor: pointer;
  transition: top 0.12s cubic-bezier(.3, 1.6, .5, 1), box-shadow 0.12s, background-color 0.15s;
}
.am-btn:hover { top: -2px; background: var(--top-h); box-shadow: 0 7px 0 var(--base); }
.am-btn:active { top: 3px; box-shadow: 0 2px 0 var(--base); transition-duration: 0.05s; }
.am-btn--gold { --top: #ffb81f; --top-h: #ffc53d; --base: #a35f00; }
.am-btn:disabled { cursor: progress; opacity: 0.8; }
.am-btn.is-busy { color: transparent; text-shadow: none; }
.am-btn.is-busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: amSpin 0.7s linear infinite; }
@keyframes amSpin { to { transform: rotate(360deg); } }

.am-switch { margin: 2px 0 0; text-align: center; color: rgba(255, 255, 255, 0.65); font-size: 0.92rem; }
.am-switch button { padding: 0; border: 0; background: none; color: #ffd23f; font: inherit; font-weight: 800; cursor: pointer; }
.am-switch button:hover { text-decoration: underline; }
.am-switch button:disabled { opacity: 0.5; cursor: default; text-decoration: none; }

/* cursores do jogo também na janela */
.am :is(button, a) { cursor: url("../images/cursor-sword.svg") 3 3, pointer; }
.am .am-btn:disabled { cursor: progress; }

@media (max-width: 820px) {
  .am { padding: 22px 12px; }
  .am-box { grid-template-columns: 1fr; width: min(480px, 100%); }
  .am-art { min-height: 120px; border-radius: 24px 24px 0 0; }
  .am-art-copy { bottom: 16px; left: 20px; right: 20px; }
  .am-art-title { font-size: 1.6rem; }
  .am-art-copy p, .am-ribbon { display: none !important; }
  .am-troop { top: 12px; }
  .am-troop b { transform: scale(1); }
  .am-main { padding: 22px 20px 22px; }
  .am-x { top: -12px; right: -8px; }
}
@media (prefers-reduced-motion: reduce) {
  .am-art img, .am-troop b, .am-err.am-shake { animation: none; }
  .am-box, .am-backdrop { transition: none; }
}
[dir="rtl"] .am-x { right: auto; left: -16px; }
[dir="rtl"] .am-art { border-radius: 0 24px 24px 0; }
[dir="rtl"] .am-troop { right: auto; left: 18px; }
