/* ==========================================================================
   Cuenta: pantalla para entrar, botón de cuenta, tu cuenta e importar una copia
   ========================================================================== */

/* ---------- Pantalla para entrar ---------- */
body.login-open { overflow: hidden; }
body.login-open .app { visibility: hidden; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  align-content: safe center; /* safe: si no cabe (móvil apaisado), se ve desde arriba y se desplaza; centrado se cortaría */
  gap: 18px;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  /* Casi negro y limpio, con un velo del latón de la marca arriba */
  background:
    radial-gradient(60vmax 34vmax at 50% -12%, color-mix(in srgb, var(--brass) 13%, transparent), transparent 66%),
    var(--bg);
}
/* «Volver» (cuando se abre desde una portada) */
.login-back { position: fixed; left: max(16px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); z-index: 1; min-height: 40px; }
/* Sin sitio a los lados de la tarjeta, encima de ella y no flotando sobre lo que hay al desplazarse */
@media (max-width: 700px), (max-height: 700px) { .login-back { position: static; justify-self: start; } }

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 30px 28px 26px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--e-3), var(--hairline-top);
}

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.login-brand .k-mark { width: 26px; height: 26px; }
.login-brand .k-word { font-size: 22px; }

.login-card h1 { margin: 0; font-family: var(--serif); font-size: 32px; font-weight: 450; line-height: 1.1; letter-spacing: -.02em; }
.login-lead { margin: -4px 0 4px; color: var(--text-2); line-height: 1.55; font-size: var(--fs-md); }
.login-lead b { color: var(--text); font-weight: 600; word-break: break-all; }

.login-msg { margin: 0; padding: 10px 12px; border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.45; }
.login-msg.bad { background: var(--bad-soft); color: var(--bad-2); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.login-msg.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok-2); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }

.login-google {
  height: 44px;
  background: #fff;
  color: #1f1f1f;
  border-color: #fff;
  font-weight: 600;
  font-size: var(--fs-md);
  gap: 10px;
}
.login-google:hover { background: #f1f3f4; border-color: #f1f3f4; }
.login-google svg { width: 18px; height: 18px; }

.login-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: var(--fs-xs); }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }

.login-form { display: grid; gap: 12px; }
.login-form .input { height: 44px; font-size: var(--fs-lg); }
.login-form .btn { height: 44px; font-size: var(--fs-md); }
.login-code { letter-spacing: .3em; font-variant-numeric: tabular-nums; font-weight: 600; }
.login-code::placeholder { letter-spacing: .3em; color: var(--line-2); }
.login-help { margin: 0; color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; text-align: center; }
/* Turnstile (captcha.js): sin clave, vacío y fuera; con ella, la casilla solo sale si hace falta */
.login-captcha { display: flex; justify-content: center; max-width: 100%; overflow: hidden; }
.login-captcha:empty { display: none; }

.login-mail {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--accent-2);
}
.login-mail .i { width: 26px; height: 26px; }

.login-alt { display: flex; justify-content: center; gap: 10px; color: var(--muted); font-size: var(--fs-sm); }
.login-alt .link-btn:disabled { color: var(--muted); cursor: default; text-decoration: none; }

.login-foot { margin: 0; max-width: 400px; text-align: center; color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; }

.spinner.sm { width: 16px; height: 16px; border-width: 2px; margin: 0; border-color: rgba(0, 0, 0, .18); border-top-color: currentColor; }

/* ---------- Botón de cuenta ---------- */
.account-btn {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  transition: border-color .15s, box-shadow .15s;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { border-color: var(--line-3); box-shadow: 0 0 0 3px rgba(255, 255, 255, .05); }
.account-btn.local .avatar { background: transparent; color: var(--text-2); }

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--brass);
  color: var(--ink-950);
  font-size: var(--fs-xs);
  font-weight: 700;
  object-fit: cover;
}
.avatar .i { width: 18px; height: 18px; }
.avatar.sm { width: 32px; height: 32px; }
.avatar.lg { width: 52px; height: 52px; font-size: var(--fs-lg); }

.menu-account { display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; padding: 2px 0; }
.menu-account > span:last-child { display: grid; min-width: 0; }
.menu-account b { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-account small { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tu cuenta ---------- */
.account-dialog { width: min(520px, calc(100vw - 32px)); }
.acc-who { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.acc-who > div { display: grid; gap: 2px; min-width: 0; }
.acc-who b { font-size: var(--fs-lg); }
.acc-who > div > span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.acc-who small { color: var(--muted); font-size: var(--fs-xs); }
.acc-sec { padding: 18px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.acc-sec:last-child { border-bottom: 0; padding-bottom: 4px; }
.acc-sec h3 { margin: 0; font-size: var(--fs-2xs); font-weight: 600; font-stretch: var(--label-stretch); letter-spacing: var(--label-track); text-transform: uppercase; color: var(--muted); }
.acc-sec p { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.55; }
.acc-sec.danger h3 { color: var(--bad); }
.acc-sec .switch { justify-self: start; margin-top: 2px; }
.acc-note { display: flex; align-items: center; gap: 8px; color: var(--muted) !important; font-size: var(--fs-xs) !important; }
.acc-note .i { width: 14px; height: 14px; flex: none; color: var(--muted); }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
/* El ranking de la sala de juegos: tu apodo, cambiarlo aquí mismo y si sales en él (account.js) */
.acc-rk-nick { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; }
.acc-rk-nick b { min-width: 0; color: var(--text); font-size: var(--fs-lg); font-weight: 600; overflow-wrap: anywhere; }
.acc-rk-nick .btn { margin-left: auto; }
.acc-rk-nick .btn .i { width: 14px; height: 14px; }
.acc-sec .acc-rk-when, .acc-sec .acc-rk-hint { color: var(--muted); font-size: var(--fs-xs); }
.acc-rk-form { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-2); }
.acc-rk-row { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-rk-row .input { flex: 1 1 180px; min-width: 0; }
.acc-rk-row .btn { flex: none; }
.acc-rk-default { justify-self: start; font-size: var(--fs-sm); }
@media (pointer: coarse) { .acc-rk-default { min-height: 40px; } }
/* En el móvil, el campo en su fila y los dos botones juntos debajo */
@media (max-width: 600px) { .acc-rk-row .input { flex-basis: 100%; } }
.acc-warn { margin: 0 0 14px; color: var(--text-2); line-height: 1.55; }
.acc-warn b { color: var(--bad); }

/* ---------- Importar una copia ---------- */
.import-dialog { width: min(480px, calc(100vw - 32px)); }
.import-dialog .dlg-body { display: grid; gap: 10px; }
.imp-sum { margin: 0; color: var(--text); line-height: 1.5; }
.imp-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 12px; background: var(--bg-2); }
.imp-list li { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); color: var(--text-2); }
.imp-list li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.imp-note { margin: 0; display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; }
.imp-note .i { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--ok); }
/* «¿Cómo quieres empezar?» (start-dialog.js): tres caminos como filas grandes, el primero con el acento */
.start-dialog { width: min(520px, calc(100vw - 32px)); }
.start-dialog .dlg-body { display: grid; gap: 12px; }
.st-ways { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.st-way { width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 12px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text); text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.st-way:hover, .st-way:focus-visible { border-color: var(--accent-line); background: var(--surface-3); }
.st-way:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.st-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--surface-4); color: var(--accent-2); }
.st-ways li:first-child .st-ic { background: var(--accent-soft); }
.st-ic .i { width: 20px; height: 20px; }
.st-txt { flex: 1; min-width: 0; display: grid; gap: 3px; }
.st-txt b { font-size: var(--fs-md); }
.st-txt span { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.45; }
.st-go { flex: none; color: var(--muted); }
.st-go .i { width: 16px; height: 16px; }
.st-note { margin: 0; display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; }
.st-note .i { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--ok); }
.start-dialog .dlg-foot { align-items: center; }
@media (max-width: 480px) { .st-way { gap: 12px; padding: 12px 10px; } .st-ic { width: 34px; height: 34px; } }

/* En pantallas estrechas, la cuenta va en la primera fila, a la derecha (las herramientas de cada
   sección bajan a la segunda) */
@media (max-width: 900px) {
  body:not([data-section="album"]) .account-btn { order: 2; margin-left: auto; }
}
@media (max-width: 700px) {
  .login-card { padding: 24px 20px 22px; }
  .login-card h1 { font-size: 26px; }
  .account-btn { order: 2; width: 40px; height: 40px; }
}

/* ---------- Idioma: botón de la barra y selector del login (las banderas, en base.css) ---------- */
.lang-btn {
  flex: none;
  height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-stretch: var(--label-stretch);
  letter-spacing: .08em;
  transition: border-color .15s, box-shadow .15s, color .15s;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { border-color: var(--line-3); background: var(--surface-2); color: var(--text); }

.lang-switch {
  display: inline-flex;
  margin: 0 auto;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-2);
}
.lang-switch button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 560;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); cursor: default; }
.login-screen .lang-switch { display: flex; width: max-content; }
@media (pointer: coarse) { .lang-switch button { min-height: 40px; } }

@media (max-width: 900px) {
  body:not([data-section="album"]) .lang-btn { order: 2; margin-left: auto; }
  body:not([data-section="album"]) .lang-btn + .account-btn { margin-left: 6px; }
}
@media (max-width: 700px) {
  .lang-btn { order: 2; height: 40px; padding: 0 10px; }
  .lang-btn .lang-code { display: none; }
}

/* La contraseña, con su botón para verla (account.js) */
.pw-field { position: relative; }
.pw-field .input { padding-right: 46px; }
.pw-eye { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
.pw-eye:hover { color: var(--text); background: var(--surface-2); }
.pw-eye:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.pw-eye .i { width: 17px; height: 17px; }
.login-form > .field[for] { margin-bottom: -6px; }
.field-opt { margin-left: 2px; color: var(--faint, var(--muted)); font-weight: 450; }
.login-forgot { justify-self: center; font-size: var(--fs-sm); }
.login-switch { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.login-switch .link-btn { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.login-switch .link-btn .i { width: 14px; height: 14px; }
.login-msg .link-btn { font-weight: 600; color: inherit; text-decoration: underline; }
.pw-dialog { width: min(460px, calc(100vw - 32px)); }
.pw-lead { margin: 0 0 14px; color: var(--text-2); line-height: 1.55; }
.pw-form { display: grid; gap: 6px; }
.pw-form .pw-field + .field { margin-top: 8px; }
.pw-form .login-msg { margin-top: 8px; }
.acc-name { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.acc-name .field { flex: 1 1 220px; }
@media (pointer: coarse) {
  .login-forgot, .login-switch .link-btn { min-height: 40px; }
}

/* ---------- Sin cuenta (modo invitado: guest/guest-ui.js, docs/nube.md) ---------- */
/* «Crear cuenta», siempre a mano en la barra, junto al botón de la cuenta */
.guest-signup { flex: none; gap: 6px; }
.guest-signup .i { width: 15px; height: 15px; }
@media (max-width: 900px) {
  .topbar > .guest-signup { order: 2; }
  body:not([data-section="album"]) .lang-btn + .guest-signup { margin-left: 6px; }
}
/* En el móvil, en el sitio del botón de la cuenta: en el álbum, la primera fila es del nombre del binder,
   así que «Crear cuenta» va más justo y el botón de la cuenta baja a la fila de las herramientas */
@media (max-width: 700px) {
  .topbar > .guest-signup { height: 40px; padding: 0 10px; gap: 5px; font-size: var(--fs-xs); }
  body[data-section="album"] .topbar > .account-btn.guest { order: 6; }
}
/* En la pantalla de entrar: lo de este navegador pasará a la cuenta */
.login-guest { display: flex; gap: 8px; align-items: flex-start; margin: 16px 0 0; color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; text-align: left; }
.login-guest .i { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--ok); }
/* Los diálogos: «Crea una cuenta para…» y pasar lo de este navegador a la cuenta */
.guest-need, .guest-merge { width: min(480px, calc(100vw - 32px)); }
.guest-need .dlg-body p, .guest-merge .dlg-body > p:first-child { margin: 0 0 10px; color: var(--text-2); line-height: 1.6; }
.guest-moves { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); }
.guest-moves .i { width: 16px; height: 16px; flex: none; margin-top: 3px; color: var(--ok); }
.guest-merge .dlg-body { display: grid; gap: 10px; }
.guest-merge-check { color: var(--text); font-weight: 600; font-size: var(--fs-md); }
.guest-merge .imp-note .i { color: var(--ok); }
.guest-merge .guest-merge-keep .i { color: var(--muted); }
.guest-merge .login-msg { margin: 0; }
