/* =============================================================
   AUTH GATE — tabbed sign-in / sign-up modal.
   Namespace: .ag-* (avoid collisions with .sg-, .auth-, .pm-).
   Visual style: profile-modal Balatro (settings sub-modal pattern).
   ============================================================= */

:root {
  --ag-bg: #1a1f2e;
  --ag-surface: #252b3d;
  --ag-surface-lit: #2f3750;
  --ag-border: rgba(255,255,255,0.06);
  --ag-border-lit: rgba(255,255,255,0.12);
  --ag-accent: #e9c46a;
  --ag-text: #f0f0f0;
  --ag-text-sec: #9ca3af;
  --ag-text-dim: #6b7280;
  --ag-red: #e76f51;
}

/* Scoped emoji treatment — only on elements explicitly tagged with .ag-emoji.
   Avoids the universal `*` selector that was causing font-rendering artifacts. */
.ag-emoji {
  font-variant-emoji: text;
  font-family: 'Segoe UI Symbol', 'Apple Symbols', 'Noto Sans Symbols', 'Noto Sans Symbols 2', 'Noto Emoji', sans-serif;
  color: var(--ag-text);
  filter: grayscale(1);
}

/* ---- Overlay ---- */
.ag-overlay {
  display: none; position: fixed; inset: 0; z-index: 9500;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  align-items: center; justify-content: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding: 1rem;
}
.ag-overlay.active { display: flex; animation: agFade 0.25s ease; }

/* ---- Modal container ---- */
.ag-modal {
  width: 780px; max-width: 100%;
  max-height: calc(100vh - 2rem);
  background: var(--ag-bg); border-radius: 16px;
  border: 1px solid var(--ag-border);
  box-shadow: 0 16px 80px rgba(0,0,0,0.7), 0 0 40px rgba(233,196,106,0.04);
  overflow: hidden auto;
  display: flex; flex-direction: column;
  font-family: inherit;
  animation: agSlideIn 0.55s cubic-bezier(0.22, 0.68, 0.35, 1);
}

/* ---- Tabs ---- */
.ag-tabs {
  display: flex; border-bottom: 1px solid var(--ag-border);
  flex-shrink: 0; background: linear-gradient(135deg, rgba(233,196,106,0.04), transparent 70%);
}
.ag-tab {
  flex: 1; padding: 0.95rem 0;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 2px;
  text-transform: uppercase; text-align: center;
  background: none; border: none; cursor: var(--cur-pointer, pointer);
  color: var(--ag-text-dim);
  position: relative; font-family: inherit;
  transition: color 0.2s;
}
.ag-tab:hover { color: var(--ag-text-sec); }
.ag-tab.active { color: var(--ag-accent); }
.ag-tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 22%; right: 22%;
  height: 2px; background: var(--ag-accent); border-radius: 1px;
}

/* ---- Reason banner (for active-mode triggers) ---- */
.ag-reason {
  padding: 0.7rem 1.2rem;
  background: rgba(233,196,106,0.06);
  border-bottom: 1px solid var(--ag-border);
  font-size: 0.78rem; color: var(--ag-accent);
  text-align: center; font-weight: 600; letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* Shown to a guest on the Sign In tab: signing in as someone else walks away
   from the progress sitting on their guest account. */
.ag-guest-warn {
  margin: 0 0 0.9rem;
  padding: 0.6rem 0.75rem;
  background: rgba(233,196,106,0.07);
  border: 1px solid rgba(233,196,106,0.28);
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--ag-accent);
}

/* ---- Panels ---- */
.ag-panel { display: none; flex-direction: column; margin: 0; }
.ag-panel.active { display: flex; }

.ag-body {
  padding: 1.1rem 1.25rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.55rem;
}

/* ---- Inputs & labels ---- */
.ag-label {
  font-size: 0.6rem; font-weight: 700; color: var(--ag-text-dim);
  text-transform: uppercase; letter-spacing: 1.2px;
  margin: 0.25rem 0 -0.15rem;
}
.ag-input {
  width: 100%; padding: 0.6rem 0.8rem; box-sizing: border-box;
  background: var(--ag-surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: var(--ag-text);
  font-size: 0.85rem; font-family: inherit;
  outline: none; transition: border-color 0.2s, background 0.2s;
}
.ag-input::placeholder { color: var(--ag-text-dim); }
.ag-input:focus { border-color: var(--ag-accent); background: #2a3146; }
textarea.ag-input { resize: none; line-height: 1.4; }

/* Forgot link (mini button) */
.ag-forgot {
  display: inline-block; align-self: flex-end;
  margin-top: 0.15rem; padding: 0.15rem 0.3rem;
  font-size: 0.62rem; font-weight: 700; color: var(--ag-text-sec);
  text-transform: uppercase; letter-spacing: 1px;
  background: none; border: none; cursor: var(--cur-pointer, pointer);
  font-family: inherit; transition: color 0.2s;
}
.ag-forgot:hover { color: var(--ag-accent); }

/* Error banner */
.ag-error {
  background: rgba(231,111,81,0.08); border: 1px solid rgba(231,111,81,0.25);
  border-radius: 8px; padding: 0.5rem 0.75rem;
  font-size: 0.72rem; color: var(--ag-red); line-height: 1.45;
  text-align: center;
}
.ag-field { display: flex; flex-direction: column; gap: 0.35rem; }
.ag-field-err {
  font-size: 0.65rem; color: var(--ag-red);
  padding-left: 0.15rem;
}
.ag-field-list > .ag-field-err {
  padding: 0 1rem 0.25rem;
}

/* ---- Social login buttons ---- */
.ag-social {
  display: flex; flex-direction: column; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.ag-social-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0.6rem 1rem; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600; text-decoration: none;
  cursor: var(--cur-pointer, pointer); transition: all 0.2s;
  border: 1px solid var(--ag-border);
}
.ag-social-google {
  background: #fff; color: #3c4043;
}
.ag-social-google:hover { background: #f7f8f8; }
.ag-social-github {
  background: #24292e; color: #f0f0f0;
  border-color: #3a3f47;
}
.ag-social-github:hover { background: #2f363d; }
.ag-social-icon { flex-shrink: 0; }
.ag-social-pulse {
  animation: agSocialPulse 0.6s ease 4;
}
@keyframes agSocialPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233,196,106,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(233,196,106,0); }
}
.ag-social-compact {
  flex-direction: row; gap: 0.5rem;
}
.ag-social-compact .ag-social-btn {
  flex: 1; padding: 0.45rem 0.6rem; font-size: 0.72rem;
}
.ag-divider {
  display: flex; align-items: center; gap: 0.75rem;
  margin: 0.25rem 0 0.5rem;
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--ag-dim);
}
.ag-divider::before, .ag-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--ag-border);
}

/* ---- Foot ---- */
.ag-foot {
  padding: 0.75rem 1.2rem 0.95rem;
  border-top: 1px solid var(--ag-border);
  display: flex; gap: 0.5rem; justify-content: center;
  flex-wrap: wrap;
}
.ag-btn {
  padding: 0.5rem 1.5rem; border-radius: 8px;
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  cursor: var(--cur-pointer, pointer); transition: all 0.2s;
  font-family: inherit; border: 1px solid transparent;
  text-decoration: none; display: inline-block; text-align: center;
  line-height: 1.2;
}
.ag-btn:disabled { opacity: 0.5; cursor: var(--cur-ban, not-allowed); }
/* Loading spinner state — replaces text with a spinning circle */
.ag-btn-loading {
  color: transparent !important; position: relative;
  pointer-events: none;
}
.ag-btn-loading::after {
  content: ''; position: absolute;
  left: 50%; top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2.5px solid rgba(26,26,26,0.25);
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: agSpin 0.6s linear infinite;
}
@keyframes agSpin { to { transform: rotate(360deg); } }
.ag-btn-back {
  background: none; border-color: var(--ag-border-lit);
  color: var(--ag-text-sec);
}
.ag-btn-back:hover { border-color: rgba(255,255,255,0.22); color: var(--ag-text); }
.ag-btn-go {
  background: var(--ag-accent); border-color: var(--ag-accent); color: #1a1a1a;
}
.ag-btn-go:hover:not(:disabled) { filter: brightness(1.1); transform: scale(1.02); color: #1a1a1a; }

/* =============================================================
   SIGN UP — Full profile-page preview
   ============================================================= */

/* Profile hero (mirrors pm-hero — 3 columns: avatar | identity | bio) */
.ag-profile-hero {
  padding: 1.2rem 1.4rem 1.1rem;
  border-bottom: 1px solid var(--ag-border);
  display: flex; align-items: center; gap: 1.1rem;
  position: relative; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(233,196,106,0.04), transparent 60%);
  overflow: hidden;
}
.ag-identity { flex: 0 1 auto; min-width: 0; }
/* Default: subtle radial gradient suggests a banner is there; real upload replaces it */
.ag-hero-banner {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 75% 30%, rgba(233,196,106,0.08), transparent 55%),
              radial-gradient(circle at 25% 70%, rgba(42,157,143,0.06), transparent 55%);
  background-size: cover; background-position: center;
  z-index: 0; pointer-events: none;
}
.ag-hero-banner.has-image {
  background-size: cover; background-position: center;
  opacity: 0.22;
}
.ag-hero-banner::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--ag-bg) 0%, transparent 50%);
}
.ag-profile-hero > *:not(.ag-hero-banner) { position: relative; z-index: 1; }

/* Hero avatar — flat flag / user photo in a rounded-square tile */
.ag-avatar-static {
  width: 72px; height: 72px;
  background: var(--ag-surface); border: 2px solid var(--ag-border);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
  position: relative;
}
/* Flag image inside the tile is rotated slightly; container stays straight */
.ag-avatar-static img,
.ag-hero-avatar-img {
  width: 120%; height: 120%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  transform: rotate(6deg);
  transform-origin: center;
}
.ag-avatar-glyph { font-size: 2rem; color: var(--ag-text-dim); line-height: 1; }

/* Member-since line under meta row (mirrors pm-member-since) */
.ag-member-since {
  font-size: 0.6rem; color: var(--ag-text-dim);
  margin-top: 0.25rem; letter-spacing: 0.2px;
}


.ag-identity { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.ag-name-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ag-username {
  font-size: 1.3rem; font-weight: 800; color: var(--ag-text);
  letter-spacing: 0.5px; line-height: 1.15;
}

/* Country card — holds flag + code as a prominent card next to username */
.ag-country-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 800; color: var(--ag-text);
  letter-spacing: 0.6px;
  padding: 0.35rem 0.6rem; border-radius: 8px;
  background: var(--ag-surface);
  border: 1px solid var(--ag-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.ag-country-flag {
  width: 18px; height: 18px; border-radius: 3px;
  background-size: cover; background-position: center; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}
.ag-country-code { line-height: 1; }

.ag-meta-row {
  display: flex; align-items: center; gap: 0.7rem;
  margin-top: 0.2rem; flex-wrap: wrap;
}
.ag-elo {
  font-size: 1.3rem; font-weight: 800; color: var(--ag-accent);
  letter-spacing: 0.5px; line-height: 1;
}
.ag-elo-peak {
  font-size: 0.62rem; color: var(--ag-text-dim);
  font-weight: 500; letter-spacing: 0.3px;
}
.ag-career-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.55rem; background: var(--ag-surface);
  border: 1px solid var(--ag-border); border-radius: 6px;
  font-size: 0.6rem; color: var(--ag-text-sec);
  font-weight: 600; letter-spacing: 0.4px;
}
.ag-career-ico { font-size: 0.8rem; }

/* Bio panel — centered quote on the right side of the hero, no separator, no dots */
.ag-bio-panel {
  flex: 1; min-width: 140px; max-width: 260px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0 0.4rem;
  align-self: stretch;
}
.ag-bio-text {
  font-size: 0.75rem; color: var(--ag-text-sec);
  line-height: 1.5; font-style: italic; font-weight: 500;
  text-align: center;
  /* Up to 4 lines, then ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =============================================================
   Signup body row: sidebar + content (mirrors pm-body)
   Distinct from .ag-body which is the padded area in sign-in panel.
   ============================================================= */
.ag-signup-body {
  display: flex; align-items: stretch;
  min-height: 0;
}

.ag-sidebar {
  width: 170px; flex-shrink: 0;
  border-right: 1px solid var(--ag-border);
  padding: 0.85rem 0.6rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.ag-cat-card {
  background: var(--ag-surface); border: 1px solid var(--ag-border);
  border-radius: 10px; padding: 0.75rem 0.7rem;
  cursor: var(--cur-pointer, pointer); transition: all 0.25s ease; position: relative;
  display: flex; align-items: center; gap: 0.5rem;
}
.ag-cat-card:hover {
  background: var(--ag-surface-lit); border-color: rgba(255,255,255,0.12);
}
.ag-cat-card.active {
  border-color: var(--ag-accent); background: var(--ag-surface-lit);
  box-shadow: 0 0 12px rgba(233,196,106,0.08);
}
.ag-cat-card.active::before {
  content: ''; position: absolute; left: 0; top: 15%; bottom: 15%;
  width: 3px; background: var(--ag-accent); border-radius: 0 3px 3px 0;
}
.ag-cat-icon { font-size: 1.1rem; flex-shrink: 0; }
.ag-cat-info { min-width: 0; }
.ag-cat-label {
  font-size: 0.72rem; font-weight: 700; color: var(--ag-text);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.ag-cat-sub {
  font-size: 0.55rem; color: var(--ag-text-dim);
  margin-top: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* =============================================================
   Content area: stats + rank + form + nav cards
   ============================================================= */
.ag-content {
  flex: 1; min-width: 0;
  padding: 0.95rem 1.2rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}

.ag-stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}
.ag-stat-box {
  background: var(--ag-surface); border: 1px solid var(--ag-border);
  border-radius: 8px; padding: 0.55rem 0.4rem; text-align: center;
}
.ag-stat-val { font-size: 1.15rem; font-weight: 800; color: var(--ag-text-dim); line-height: 1; }
.ag-stat-label {
  font-size: 0.55rem; color: var(--ag-text-dim); letter-spacing: 0.5px;
  text-transform: uppercase; margin-top: 0.25rem;
}

/* Rank progress */
.ag-rank-wrap {
  padding: 0.7rem 0.9rem; background: var(--ag-surface);
  border: 1px solid var(--ag-border); border-radius: 10px;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.ag-rank-label { font-size: 0.72rem; font-weight: 700; color: var(--ag-text); }
.ag-rank-bar {
  width: 100%; height: 6px; background: rgba(0,0,0,0.3);
  border-radius: 3px; overflow: hidden;
}
.ag-rank-fill {
  height: 100%; background: linear-gradient(90deg, var(--ag-accent), #f0d785);
  border-radius: 3px; transition: width 0.3s;
}
.ag-rank-meta { font-size: 0.6rem; color: var(--ag-text-dim); text-align: right; }

/* Form pills */
.ag-form-card {
  padding: 0.55rem 0.9rem; background: var(--ag-surface);
  border: 1px solid var(--ag-border); border-radius: 10px;
  display: flex; align-items: center; gap: 0.75rem;
}
.ag-form-label {
  font-size: 0.6rem; font-weight: 700; color: var(--ag-text-dim);
  text-transform: uppercase; letter-spacing: 1px; flex-shrink: 0;
}
.ag-form-pills { display: flex; gap: 0.3rem; flex: 1; justify-content: center; }
.ag-form-pill {
  width: 22px; height: 22px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: #fff;
}
.ag-form-pill.empty { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.25); }

/* Nav cards — mirror pm-nav-card: narrow, centered, emoji on first row */
.ag-nav-cards {
  display: flex; flex-direction: column; gap: 0.5rem;
  margin-top: 0.4rem; align-items: center;
}
.ag-nav-card {
  position: relative;
  width: 80%; max-width: 360px;
  padding: 0.75rem 1rem; border-radius: 10px;
  cursor: var(--cur-pointer, pointer); transition: all 0.3s ease;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.2rem; text-align: center;
  font-family: inherit; border: 1px solid transparent;
}
.ag-nav-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.28);
}
.ag-nav-card-profile {
  background: rgba(42,157,143,0.08); border-color: rgba(42,157,143,0.2);
}
.ag-nav-card-profile:hover { background: rgba(42,157,143,0.14); border-color: rgba(42,157,143,0.4); }
.ag-nav-card-account {
  background: rgba(69,123,157,0.08); border-color: rgba(69,123,157,0.2);
}
.ag-nav-card-account:hover { background: rgba(69,123,157,0.14); border-color: rgba(69,123,157,0.4); }
.ag-nav-card.completed { border-color: rgba(233,196,106,0.45); background: rgba(233,196,106,0.06); }
.ag-nav-card.completed:hover { background: rgba(233,196,106,0.11); }

.ag-nav-icon {
  font-size: 1.3rem; line-height: 1; margin-bottom: 0.1rem;
}
.ag-nav-body { display: flex; flex-direction: column; align-items: center; gap: 0.12rem; width: 100%; }
.ag-nav-label {
  font-size: 0.7rem; font-weight: 800; color: var(--ag-text);
  text-transform: uppercase; letter-spacing: 0.9px;
}
.ag-nav-sub {
  font-size: 0.58rem; color: var(--ag-text-dim); line-height: 1.35;
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-nav-status {
  position: absolute; top: 0.45rem; right: 0.55rem;
  font-size: 0.75rem; color: var(--ag-accent);
}

/* =============================================================
   Profile sub-modal — field row list (mirrors pm-field-row)
   ============================================================= */
.ag-field-list {
  padding: 1rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.ag-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 0.75rem;
  background: rgba(0,0,0,0.3); border: 1px solid var(--ag-border);
  border-radius: 8px; cursor: var(--cur-pointer, pointer);
  transition: background 0.2s, border-color 0.2s;
  font-family: inherit; width: 100%;
}
.ag-row:hover { background: rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.1); }
.ag-row-label {
  font-size: 0.72rem; color: var(--ag-text-dim);
  font-weight: 500; letter-spacing: 0.2px;
}
.ag-row-value {
  display: inline-flex; align-items: center; gap: 0.4rem;
  max-width: 60%;
}
.ag-row-text {
  font-size: 0.9rem; font-weight: 700; color: var(--ag-text);
  letter-spacing: 0.3px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 30ch;
}
.ag-row-text-dim { font-size: 0.75rem; color: var(--ag-text-dim); font-weight: 400; font-style: italic; }
.ag-row-edit {
  font-size: 0.5rem; color: var(--ag-text-dim); margin-left: 0.35rem;
  opacity: 0; transition: opacity 0.2s;
}
.ag-row:hover .ag-row-edit { opacity: 0.7; }

.ag-avatar-mini {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,0.3); border: 1.5px solid var(--ag-border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; overflow: hidden; flex-shrink: 0;
  transition: border-color 0.2s;
}
.ag-row:hover .ag-avatar-mini { border-color: rgba(255,255,255,0.15); }
.ag-avatar-mini img { width: 100%; height: 100%; object-fit: cover; }

.ag-banner-mini {
  width: 80px; height: 28px; border-radius: 4px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--ag-border);
  overflow: hidden; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ag-banner-mini img { width: 100%; height: 100%; object-fit: cover; }

/* =============================================================
   Per-field edit sub-sub-modals (mirror pm-edit-box)
   Uses .ag-sub-overlay backdrop but with a compact centered box.
   ============================================================= */
.ag-edit-box {
  width: 460px; max-width: 92vw;
  background: var(--ag-bg); border: 1px solid var(--ag-border);
  border-radius: 16px; padding: 1.4rem 1.5rem;
  box-shadow: 0 12px 50px rgba(0,0,0,0.6);
  font-family: inherit;
}
.ag-edit-label {
  font-size: 0.65rem; font-weight: 700; color: var(--ag-text-dim);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.6rem;
  text-align: center;
}
.ag-edit-actions {
  display: flex; gap: 0.5rem; margin-top: 0.9rem; justify-content: center;
}
.ag-edit-save {
  background: var(--ag-accent); border: none; color: #1a1a1a;
  padding: 0.45rem 1.5rem; border-radius: 6px; font-size: 0.75rem;
  font-weight: 700; cursor: var(--cur-pointer, pointer); transition: all 0.2s;
  text-transform: uppercase; letter-spacing: 0.5px; font-family: inherit;
  position: relative; overflow: hidden;
}
.ag-edit-save:hover { filter: brightness(1.1); transform: scale(1.02); }
.ag-edit-save:not(:disabled)::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg,
    transparent 35%, rgba(255,255,255,0.25) 45%,
    rgba(255,255,255,0.45) 50%, rgba(255,255,255,0.25) 55%,
    transparent 65%);
  animation: agBtnShine 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes agBtnShine {
  0%   { transform: translateX(-180%); }
  100% { transform: translateX(180%); }
}
.ag-edit-cancel {
  background: none; border: 1px solid var(--ag-border);
  color: var(--ag-text-sec); padding: 0.45rem 1.2rem;
  border-radius: 6px; font-size: 0.75rem; cursor: var(--cur-pointer, pointer);
  transition: all 0.2s; font-family: inherit;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.ag-edit-cancel:hover { border-color: rgba(255,255,255,0.18); color: var(--ag-text); }
.ag-edit-save:disabled { opacity: 0.5; cursor: var(--cur-default, default); filter: none; }
.ag-edit-save:disabled::before { display: none; }
/* Upload error pill */
.ag-upload-error {
  background: rgba(231,111,81,0.1);
  border: 1px solid rgba(231,111,81,0.25);
  border-radius: 6px; padding: 0.35rem 0.7rem;
  font-size: 0.65rem; color: var(--ag-red);
  font-weight: 600; letter-spacing: 0.3px;
  text-align: center; margin-top: 0.3rem;
}
.ag-err-shake {
  animation: agErrShake 0.4s ease;
}
@keyframes agErrShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* Password reset hint */
.ag-reset-hint {
  font-size: 0.72rem; color: var(--ag-text-sec);
  text-align: center; margin: 0 0 0.7rem; line-height: 1.45;
}
.ag-reset-hint.ag-reset-sent { color: var(--ag-teal, #2a9d8f); }

/* Drag hint (avatar + banner reposition) */
.ag-drag-hint {
  text-align: center; font-size: 0.55rem; color: var(--ag-text-dim);
  margin-bottom: 0.6rem;
}

/* Banner viewport (shown inside the ag-edit-box for banner uploads) */
.ag-banner-viewport {
  position: relative; width: 100%; height: 100px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a1f2e, #0f3460);
  border: 1px solid var(--ag-border);
  overflow: hidden; user-select: none; cursor: var(--cur-grab, grab);
  margin-bottom: 0.55rem;
}
.ag-banner-viewport img { position: absolute; left: 0; width: 100%; height: auto; pointer-events: none; }
.ag-banner-viewport-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; color: var(--ag-text-dim);
}

/* Shared file picker (dashed label) — used by banner editor */
.ag-file-picker {
  display: block; text-align: center; cursor: var(--cur-pointer, pointer);
  padding: 0.55rem; background: var(--ag-surface);
  border: 1px dashed rgba(255,255,255,0.15); border-radius: 8px;
  transition: all 0.2s;
}
.ag-file-picker:hover { border-color: var(--ag-accent); background: var(--ag-surface-lit); }
.ag-file-picker-label {
  display: block; font-size: 0.72rem; color: var(--ag-text-sec);
}
.ag-file-picker-hint {
  display: block; font-size: 0.55rem; color: var(--ag-text-dim); margin-top: 0.2rem;
}

/* Pill-shaped BACK button (matches pm-back-btn) */
.ag-btn-pill {
  padding: 0.5rem 2.5rem; border-radius: 8px;
  font-size: 0.8rem; letter-spacing: 1px;
}

/* =============================================================
   Avatar tile (legacy — kept in case the cropper needs it; sub-modal no longer uses)
   ============================================================= */
.ag-pf-media {
  display: flex; gap: 0.6rem; align-items: stretch;
  margin-bottom: 0.4rem;
}
.ag-avatar-tile {
  position: relative; flex-shrink: 0;
  width: 84px; height: 84px;
  background: var(--ag-surface); border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: var(--cur-pointer, pointer); overflow: hidden; transition: all 0.2s;
  font-family: inherit;
}
.ag-avatar-tile:hover { border-color: var(--ag-accent); background: var(--ag-surface-lit); }
.ag-avatar-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.ag-avatar-placeholder { font-size: 1.6rem; color: var(--ag-text-dim); line-height: 1; font-weight: 300; }
.ag-avatar-hint {
  font-size: 0.5rem; color: var(--ag-text-dim);
  text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700;
  margin-top: 0.2rem;
}
.ag-avatar-tile.has-image .ag-avatar-placeholder,
.ag-avatar-tile.has-image .ag-avatar-hint { display: none; }
.ag-avatar-tile.has-image { border-style: solid; border-color: rgba(233,196,106,0.35); }

.ag-banner-tile {
  flex: 1; min-width: 0; height: 84px;
  background: var(--ag-surface); border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: var(--cur-pointer, pointer); overflow: hidden; transition: all 0.2s;
  font-family: inherit;
}
.ag-banner-tile:hover { border-color: var(--ag-accent); background: var(--ag-surface-lit); }
.ag-banner-tile img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.ag-banner-placeholder { font-size: 1.6rem; color: var(--ag-text-dim); line-height: 1; font-weight: 300; }
.ag-banner-tile.has-image .ag-banner-placeholder,
.ag-banner-tile.has-image .ag-avatar-hint { display: none; }
.ag-banner-tile.has-image { border-style: solid; border-color: rgba(233,196,106,0.35); }

/* Country chip inside profile sub-modal (full-width row) */
.ag-country-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.8rem; border-radius: 8px;
  background: var(--ag-surface); border: 1px solid rgba(255,255,255,0.1);
  color: var(--ag-text-sec); font-size: 0.85rem; font-weight: 500;
  cursor: var(--cur-pointer, pointer); transition: all 0.2s; font-family: inherit;
  width: 100%; box-sizing: border-box;
}
.ag-country-chip:hover { border-color: var(--ag-accent); background: #2a3146; color: var(--ag-text); }
.ag-country-badge {
  width: 18px; height: 18px; border-radius: 3px;
  background-size: cover; background-position: center; flex-shrink: 0;
}
.ag-country-caret { font-size: 0.8rem; opacity: 0.5; margin-left: auto; }

/* =============================================================
   Progress line + error banner position
   ============================================================= */
.ag-progress {
  padding: 0.35rem 1.35rem 0.75rem;
  font-size: 0.68rem; color: var(--ag-text-dim);
  text-align: center; letter-spacing: 0.3px;
  font-style: italic;
}
.ag-progress.ready { color: var(--ag-accent); font-style: normal; font-weight: 600; }

/* =============================================================
   Sub-overlay (mirrors pm-sub-overlay) — stacks on top of ag-modal
   ============================================================= */
.ag-sub-overlay {
  display: none; position: fixed; inset: 0; z-index: 9650;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  align-items: center; justify-content: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 1rem;
}
/* Stacks on top of another sub-overlay (e.g. text editor opened from Account sub-modal) */
.ag-sub-overlay.ag-sub-top { z-index: 9800; }
.ag-sub-overlay.active { display: flex; animation: agFade 0.25s ease; }
@keyframes agFade { from { opacity: 0; } to { opacity: 1; } }
.ag-sub-modal {
  width: 720px; max-width: 92vw;
  max-height: calc(100vh - 2rem);
  background: var(--ag-bg); border-radius: 16px;
  border: 1px solid var(--ag-border);
  box-shadow: 0 12px 60px rgba(0,0,0,0.7);
  overflow: hidden auto; display: flex; flex-direction: column;
  animation: agSlideIn 0.4s cubic-bezier(0.22, 0.68, 0.35, 1);
}
@keyframes agSlideIn {
  from { transform: translateY(60px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.ag-sub-head {
  padding: 1rem 1.2rem 0.8rem; text-align: center;
  border-bottom: 1px solid var(--ag-border); flex-shrink: 0;
  background: linear-gradient(135deg, rgba(233,196,106,0.04), transparent 70%);
}
.ag-sub-head-icon { font-size: 1.3rem; margin-bottom: 0.15rem; line-height: 1; }
.ag-sub-head h3 {
  font-size: 1rem; font-weight: 800; color: var(--ag-accent);
  letter-spacing: 2px; text-transform: uppercase; margin: 0;
  font-family: inherit;
}
.ag-sub-body {
  padding: 1.1rem 1.25rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
/* When the body IS a field-row list, match pm-sub-body + pm-field-row gaps exactly */
.ag-sub-body.ag-field-list {
  padding: 1rem 1.2rem;
  gap: 0.25rem;
}
.ag-sub-foot {
  padding: 0.7rem 1.2rem 0.95rem;
  border-top: 1px solid var(--ag-border);
  display: flex; gap: 0.5rem; justify-content: center;
  flex-shrink: 0;
}

/* =============================================================
   AVATAR SUB-MODAL — 80px circular preview + file picker
   ============================================================= */
.ag-avatar-preview-wrap { text-align: center; margin-bottom: 0.8rem; }
.ag-avatar-preview {
  position: relative;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(0,0,0,0.3); border: 2px solid var(--ag-border);
  margin: 0 auto; overflow: hidden; cursor: var(--cur-grab, grab); user-select: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--ag-text-dim);
}
.ag-avatar-preview img { position: absolute; pointer-events: none; }

/* (legacy cropper styles kept in case we reintroduce drag+zoom later) */
.ag-crop-stage {
  margin: 0.4rem auto;
  position: relative;
  width: 220px; height: 220px;
  background: #0d1017;
  border-radius: 50%;
  overflow: hidden;
  cursor: var(--cur-grab, grab);
  box-shadow: inset 0 0 0 2px rgba(233,196,106,0.3), 0 0 0 1px rgba(255,255,255,0.04);
}
.ag-crop-controls { margin-top: 0.8rem; }
.ag-crop-stage:active { cursor: var(--cur-grabbing, grabbing); }
.ag-crop-stage img {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  user-select: none; -webkit-user-drag: none; pointer-events: none;
  max-width: none;
}
.ag-crop-mask {
  position: absolute; inset: 0; border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.35);
  pointer-events: none;
}
.ag-crop-controls {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
}
.ag-crop-zoom-ico { color: var(--ag-text-dim); font-size: 0.9rem; }
#agCropZoom {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--ag-surface); border-radius: 3px; outline: none;
}
#agCropZoom::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ag-accent); cursor: var(--cur-grab, grab);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}
#agCropZoom::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ag-accent); cursor: var(--cur-grab, grab); border: none;
}
/* =============================================================
   NATIONALITY SLIDER — faithful port of pm-nat-overlay from
   chess/templates/chess/profile_modal.html.
   Rounded-rectangle bar (85vw / 700px / 80h), diamond center
   marker, and pills whose opacity/scale/blur/label-color are
   smoothly interpolated by distance to center (done in JS).
   ============================================================= */
.ag-nat-overlay {
  display: none; position: fixed; inset: 0; z-index: 9700;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  align-items: center; justify-content: center;
  flex-direction: column;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ag-nat-overlay.active { display: flex; animation: agFade 0.25s ease; }
.ag-nat-title {
  font-size: 1rem; font-weight: 700; color: var(--ag-text);
  text-transform: uppercase; letter-spacing: 2px;
  margin-bottom: 1.5rem;
}
.ag-nat-bar {
  position: relative; width: 85vw; max-width: 700px; height: 80px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; overflow: hidden; cursor: var(--cur-default, default);
}
.ag-nat-bar, .ag-nat-bar *, .ag-nat-pill, .ag-nat-pill * { cursor: var(--cur-default, default) !important; }
.ag-nat-track {
  position: absolute; top: 50%; left: 0;
  transform: translateY(-50%) translateX(0px);
  display: flex; gap: 2.2rem; align-items: center;
  white-space: nowrap; padding: 0 42%;
  transition: none;
}

/* Diamond center marker */
.ag-nat-marker {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 0; pointer-events: none; z-index: 2;
  transform: translateX(-50%);
}
.ag-nat-marker::before, .ag-nat-marker::after {
  content: ''; position: absolute; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  filter: drop-shadow(0 0 3px rgba(233,196,106,0.35));
}
.ag-nat-marker::before { top: 0; border-top: 5px solid rgba(233,196,106,0.3); }
.ag-nat-marker::after { bottom: 0; border-bottom: 5px solid rgba(233,196,106,0.3); }

/* Pills — class-based transitions (matches profile modal) */
.ag-nat-pill {
  flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; gap: 0.15rem;
  padding: 0.2rem 0.4rem; border-radius: 8px;
  cursor: var(--cur-default, default);
  opacity: 0.15;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.25,0.1,0.25,1);
}
.ag-nat-pill .country-badge-wrapper {
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.25,0.1,0.25,1);
}
.ag-nat-pill .country-badge-wrapper:hover { transform: none !important; }
.ag-nat-pill.near-center { opacity: 0.4; }
.ag-nat-pill.near-center .country-badge-wrapper { transform: scale(0.95); }
.ag-nat-pill.centered { opacity: 1; }
.ag-nat-pill.centered .country-badge-wrapper { transform: scale(1.25); }
/* Suppress all transitions while track is settling (prevents pill "jump" on open) */
.ag-nat-track.no-anim .ag-nat-pill,
.ag-nat-track.no-anim .ag-nat-pill .country-badge-wrapper,
.ag-nat-track.no-anim .ag-nat-pill .cont-icon,
.ag-nat-track.no-anim .ag-nat-pill .ag-nat-label {
  transition: none !important;
}
/* Faster transitions during drag */
.ag-nat-bar.is-dragging .ag-nat-pill {
  transition: opacity 0.12s cubic-bezier(0.25,0.1,0.25,1);
}
.ag-nat-bar.is-dragging .ag-nat-pill .country-badge-wrapper {
  transition: transform 0.12s cubic-bezier(0.25,0.1,0.25,1);
}
.ag-nat-pill .ag-nat-label {
  font-size: 0.42rem; color: rgba(255,255,255,0.3); font-weight: 700;
  white-space: nowrap; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; text-align: center;
  text-transform: uppercase; letter-spacing: 1.5px;
  transition: color 0.4s ease, text-shadow 0.4s ease, font-size 0.4s ease;
}
.ag-nat-pill.centered .ag-nat-label {
  color: var(--ag-accent, #e9c46a);
  font-size: 0.48rem;
  text-shadow: 0 0 10px rgba(233,196,106,0.3);
}
.ag-nat-pill.near-center .ag-nat-label {
  color: rgba(255,255,255,0.45);
}
/* Title as back button in continent-first flow */
.ag-nat-title.clickable { cursor: var(--cur-pointer, pointer); transition: color 0.2s; }
.ag-nat-title.clickable:hover { color: var(--ag-accent, #e9c46a); }
/* Continent pill icon */
.ag-nat-pill .cont-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; line-height: 1;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.25,0.1,0.25,1);
}
.ag-nat-pill.centered .cont-icon { transform: scale(1.25); }
.ag-nat-pill.near-center .cont-icon { transform: scale(0.95); }
/* Wider gap for continent flow */
.ag-nat-track { gap: 3.5rem; }

/* =============================================================
   Mobile
   ============================================================= */
@media (max-width: 640px) {
  /* All auth gate overlays above bottom bar (z-index 9999) on mobile */
  .ag-overlay { z-index: 10000; }
  .ag-sub-overlay { z-index: 10100; }
  .ag-sub-overlay.ag-sub-top { z-index: 10200; }
  .ag-nat-overlay { z-index: 10150; }
  .ag-modal { width: 100%; overflow: hidden; }
  .ag-panel.active { overflow-y: auto; flex: 1; min-height: 0; }

  /* --- Sign-in panel: tighter padding --- */
  .ag-body { padding: 0.9rem 1rem 0.7rem; gap: 0.45rem; }
  .ag-foot { padding: 0.55rem 1rem 0.7rem; }

  /* --- Sign-up panel: compact hero --- */
  .ag-profile-hero {
    flex-direction: column; align-items: center; text-align: center;
    gap: 0.5rem; padding: 0.8rem 1rem 0.7rem;
  }
  .ag-avatar-static { width: 56px; height: 56px; border-radius: 11px; }
  .ag-identity { align-items: center; }
  .ag-name-row { justify-content: center; }
  .ag-username { font-size: 1.1rem; }
  .ag-meta-row { justify-content: center; margin-top: 0.1rem; }
  .ag-elo { font-size: 1.1rem; }
  .ag-elo-peak { font-size: 0.58rem; }
  .ag-career-pill { font-size: 0.55rem; padding: 0.15rem 0.4rem; }
  .ag-member-since { font-size: 0.55rem; margin-top: 0.15rem; }
  .ag-country-line { justify-content: center; }
  /* Hide bio panel on mobile — not essential for signup flow */
  .ag-bio-panel { display: none; }

  /* --- Signup body: compact sidebar + content --- */
  .ag-signup-body { flex-direction: column; }
  .ag-sidebar {
    width: 100%; border-right: none;
    border-bottom: 1px solid var(--ag-border);
    flex-direction: row; overflow-x: auto;
    padding: 0.5rem 0.5rem;
  }
  .ag-cat-card { flex-shrink: 0; padding: 0.5rem 0.6rem; }
  .ag-cat-label { font-size: 0.68rem; }
  .ag-cat-sub { font-size: 0.5rem; }
  .ag-content { padding: 0.7rem 1rem 0.4rem; gap: 0.5rem; }
  .ag-nav-cards { grid-template-columns: 1fr; gap: 0.4rem; margin-top: 0.2rem; }
  .ag-nav-card { padding: 0.55rem 0.8rem; gap: 0.15rem; }
  .ag-nav-icon { font-size: 1.1rem; margin-bottom: 0; }
  .ag-nav-label { font-size: 0.65rem; }
  .ag-nav-sub { font-size: 0.58rem; }

  /* --- Progress + footer compact --- */
  .ag-progress { padding: 0.25rem 1rem 0.5rem; font-size: 0.62rem; }

  /* --- Sub-modals: scrollable body, sticky footer --- */
  .ag-sub-modal { overflow: hidden; }
  .ag-sub-body { overflow-y: auto; flex: 1; min-height: 0; }
  .ag-crop-stage { width: 220px; height: 220px; }
  .ag-nat-bar { width: 95vw; }

  /* Touch targets: 44px minimum + 16px to prevent iOS zoom */
  .ag-input { padding: 0.75rem 0.9rem; font-size: 16px; }
  .ag-btn { padding: 0.65rem 1.5rem; font-size: 0.78rem; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .ag-social-btn { padding: 0.7rem 1rem; font-size: 0.82rem; min-height: 44px; }
  .ag-social-compact .ag-social-btn { padding: 0.6rem 0.6rem; font-size: 0.75rem; min-height: 44px; }
  .ag-label { font-size: 0.65rem; }
  .ag-tab { font-size: 0.75rem; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .ag-tabs { padding: 0 0.5rem; }
  .ag-edit-save, .ag-edit-cancel { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}

/* Required badge on field labels */
.ag-required {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #e9c46a;
  background: rgba(233,196,106,0.1);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Password criteria checklist */
.ag-pw-criteria {
  margin: 0.5rem 0 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ag-pw-rule {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.25s ease;
}
.ag-pw-rule.pass { color: #52b788; }
.ag-pw-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
  transition: background 0.25s ease;
}
.ag-pw-rule.pass .ag-pw-dot { background: #52b788; }
.ag-edit-save:disabled {
  opacity: 0.3;
  cursor: var(--cur-ban, not-allowed);
  pointer-events: none;
}
// deploy-sync 1778793716
