/* Account panel — uses each page's theme variables so it follows the theme. */
.account-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 5px; min-height: 36px;
  border-radius: 999px; border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel, #151d34) 72%, transparent);
  color: var(--text, #eef2fb); cursor: pointer; font: inherit;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.account-btn:hover {
  border-color: var(--accent, #ffd257); transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
}
.account-btn-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.account-avatar {
  border-radius: 50%; object-fit: cover; flex: none;
  border: 1px solid color-mix(in srgb, var(--accent, #ffd257) 55%, transparent);
  background: var(--panel2, #1e2946);
}
/* Clickable avatar with hover-to-reveal edit pencil */
.account-avatar-wrap {
  position: relative; display: inline-flex; flex: none;
  padding: 0; border: none; background: transparent; cursor: pointer;
  border-radius: 50%; line-height: 0;
}
.account-avatar-wrap .account-avatar { display: block; }
.avatar-edit-hint {
  position: absolute; right: -2px; bottom: -2px;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; color: #0b1020; font-weight: 700;
  background: var(--accent, #ffd257);
  border: 2px solid var(--panel, #151d34);
  opacity: 0; transform: scale(.6); transition: opacity .16s, transform .16s;
  pointer-events: none;
}
.account-avatar-wrap:hover .avatar-edit-hint,
.account-avatar-wrap:focus-visible .avatar-edit-hint,
.account-avatar-wrap.open .avatar-edit-hint { opacity: 1; transform: scale(1); }
.account-avatar-wrap:hover .account-avatar { filter: brightness(.82); }
.account-avatar-wrap.open .avatar-edit-hint { background: var(--accent2, #6fa8ff); }
.avatar-edit-tools.hidden { display: none; }
.avatar-edit-tools { margin-top: 2px; }
.account-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent, #ffd257), var(--accent2, #6fa8ff));
  color: #0b1020; font-weight: 800; font-size: 13px;
}
.guest-badge {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 6px 12px; min-height: 30px; border-radius: 999px;
  border: 1px dashed var(--line, #334264);
  background: color-mix(in srgb, var(--panel, #151d34) 55%, transparent);
  color: var(--muted, #9aa9c9); font-size: 12px;
}
.guest-badge.hidden { display: none; }

.account-mask {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(3, 6, 14, .68);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
}
.account-mask.hidden { display: none; }
.account-panel {
  position: relative; width: min(470px, 100%);
  max-height: min(92vh, 900px);
  display: flex; flex-direction: column; overflow: hidden;
  padding: 26px; border-radius: 18px;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel, #151d34) 94%, transparent);
  color: var(--text, #eef2fb);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
/* Keep the profile header/nickname/avatar/stats fixed; only the recent-duel
   list scrolls. The login form is small enough that it just flows normally. */
.account-body-profile { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.account-body-login { flex: 1; min-height: 0; overflow-y: auto; }
.account-profile-fixed { flex: none; }
.account-history-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.account-section-title { flex: none; }
.account-close {
  position: absolute; top: 12px; right: 14px; z-index: 3;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 70%, transparent);
  color: var(--muted, #9aa9c9); font-size: 20px; line-height: 1; cursor: pointer;
  transition: color .16s, border-color .16s, background .16s, transform .16s;
}
.account-close:hover {
  color: #fff; border-color: #ff6b6b;
  background: color-mix(in srgb, #ff6b6b 26%, transparent);
  transform: rotate(90deg);
}
.account-panel h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: .5px; }
.account-sub, .account-tip { color: var(--muted, #9aa9c9); font-size: 12.5px; line-height: 1.6; }
.account-sub { margin: 0 0 18px; }
.account-tip { margin: 12px 0 0; }
.account-panel label {
  display: block; margin: 12px 0 6px;
  color: var(--muted, #9aa9c9); font-size: 12px; font-weight: 600;
}
.account-panel input:not([type="file"]) {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 88%, transparent);
  color: var(--text, #eef2fb); font: inherit; outline: none;
}
.account-panel input:focus { border-color: var(--accent, #ffd257); }
.account-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.account-row input { flex: 1; min-width: 0; }
.account-row button, .account-primary, .account-footer button {
  white-space: nowrap; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 85%, transparent);
  color: var(--text, #eef2fb); font: inherit; cursor: pointer;
}
.account-row button:hover, .account-footer button:hover { border-color: var(--accent, #ffd257); }
.account-primary {
  width: 100%; margin-top: 14px; padding: 12px; font-weight: 700;
  border-color: var(--accent, #ffd257);
  background: linear-gradient(120deg, var(--accent, #ffd257), var(--accent2, #6fa8ff));
  color: #0b1020;
}
.account-primary:disabled, .account-row button:disabled { opacity: .55; cursor: wait; }
.account-note { min-height: 18px; margin-top: 10px; font-size: 12.5px; color: var(--accent, #ffd257); }
.account-note.err { color: #ff7b7b; }
.account-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0 10px; color: var(--muted, #9aa9c9); font-size: 12px;
}
.account-divider::before, .account-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line, #334264);
}
.account-profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.account-profile-head strong { display: block; font-size: 19px; }
.account-profile-head small { display: block; margin-top: 4px; color: var(--muted, #9aa9c9); }
.account-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px;
}
.account-stats div {
  padding: 12px; border-radius: 12px; text-align: center;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 62%, transparent);
}
.account-stats b { display: block; font-size: 20px; color: var(--accent, #ffd257); }
.account-stats span { font-size: 11px; color: var(--muted, #9aa9c9); }
.account-section-title {
  margin: 20px 0 8px; font-size: 13px; font-weight: 700;
  color: var(--muted, #9aa9c9);
}
.account-history {
  display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-height: 0; overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin; scrollbar-color: var(--line, #334264) transparent;
}
.account-history::-webkit-scrollbar { width: 6px; }
.account-history::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--line, #334264) 90%, transparent);
  border-radius: 6px;
}
.account-history::-webkit-scrollbar-track { background: transparent; }
.account-hist {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 10px; border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 52%, transparent);
  font-size: 12.5px;
}
.account-result {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: #0b1020;
}
.account-result.win { background: #f7c948; }
.account-result.lose { background: #8fa3c8; }
.account-result.draw { background: #59d6c0; }
.account-hist-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-hist-main small { display: block; color: var(--muted, #9aa9c9); font-size: 11px; }
.account-hist time { color: var(--muted, #9aa9c9); font-size: 11px; white-space: nowrap; }
.account-footer { display: flex; gap: 8px; margin-top: 18px; }
.account-footer button { flex: 1; }

/* ---- Built-in anime avatar picker ------------------------------------- */
.av-toggle { color: var(--accent, #ffd257) !important; }
.av-picker {
  margin-top: 10px; padding: 10px; border-radius: 12px;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 45%, transparent);
  max-height: 230px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line, #334264) transparent;
}
.av-picker.hidden { display: none; }
.av-gen + .av-gen { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line, #334264); }
.av-gen-title { font-size: 11px; font-weight: 700; color: var(--muted, #9aa9c9); margin-bottom: 6px; }
.av-gen-row { display: flex; gap: 8px; flex-wrap: wrap; }
.av-choice {
  width: 46px; height: 46px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; background: transparent; overflow: hidden;
  transition: transform .14s, border-color .14s;
}
.av-choice img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-choice:hover { transform: translateY(-2px); border-color: var(--muted, #9aa9c9); }
.av-choice.on { border-color: var(--accent, #ffd257); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #ffd257) 35%, transparent); }

/* ---- Interactive avatar cropper --------------------------------------- */
.crop-mask {
  position: fixed; inset: 0; z-index: 260;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(3, 6, 14, .78);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.crop-mask.hidden { display: none; }
.crop-panel {
  width: min(360px, 100%); padding: 20px; border-radius: 18px;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel, #151d34) 96%, transparent);
  color: var(--text, #eef2fb);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.crop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.crop-head h3 { margin: 0; font-size: 17px; }
.crop-x {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 70%, transparent);
  color: var(--muted, #9aa9c9); font-size: 18px; line-height: 1; cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}
.crop-x:hover { color: #fff; border-color: #ff6b6b; background: color-mix(in srgb, #ff6b6b 26%, transparent); }
.crop-stage {
  position: relative; width: 220px; height: 220px; margin: 0 auto;
  border-radius: 50%; overflow: hidden; cursor: grab; touch-action: none;
  background: #111827; border: 2px solid var(--accent, #ffd257);
  box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, .05);
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img {
  position: absolute; top: 0; left: 0; max-width: none; user-select: none;
  -webkit-user-drag: none; pointer-events: none;
}
.crop-tip { margin: 12px 0 8px; font-size: 12px; line-height: 1.5; color: var(--muted, #9aa9c9); text-align: center; }
.crop-zoom { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted, #9aa9c9); }
.crop-zoom input { flex: 1; accent-color: var(--accent, #ffd257); }
.crop-actions { display: flex; gap: 8px; margin-top: 16px; }
.crop-actions button {
  flex: 1; padding: 10px 14px; border-radius: 10px; cursor: pointer; font: inherit;
  border: 1px solid var(--line, #334264);
  background: color-mix(in srgb, var(--panel2, #1e2946) 85%, transparent);
  color: var(--text, #eef2fb);
}
.crop-actions .account-primary {
  border-color: var(--accent, #ffd257); font-weight: 700;
  background: linear-gradient(120deg, var(--accent, #ffd257), var(--accent2, #6fa8ff));
  color: #0b1020;
}

@media (max-width: 620px) {
  .account-panel { padding: 20px; }
  .account-btn-name { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
}
