/* ── auth.css ─────────────────────────────────────────────────────────────────
 * Auth screen (sign-in / sign-up), settings gear button, registration
 * multi-step flow, mobile typography, password strength meter,
 * class selection carousel, avatar registration carousel, avatar carousel.
 * ─────────────────────────────────────────────────────────────────────────── */

  /* ── AUTH SCREEN ── */
  #auth-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
  }

  #auth-screen.hidden { display: none; }

  .auth-logo {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 36px;
    letter-spacing: 6px;
    color: var(--amber);
    text-shadow: 0 0 24px var(--amber);
    margin-bottom: 4px;
  }

  .auth-logo span { color: var(--rust); text-shadow: 0 0 16px var(--rust); }

  .auth-tagline {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 3px;
    margin-bottom: 40px;
    text-align: center;
  }

  .auth-tabs {
    display: flex;
    width: 100%;
    max-width: 360px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
  }

  .auth-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    font-family: 'Oswald', sans-serif;
    font-size: 13px;
    letter-spacing: 3px;
    color: var(--text-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
  }

  .auth-tab.active { color: var(--amber); border-bottom-color: var(--amber); }

  .auth-form {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .auth-form.hidden { display: none; }

  .auth-input {
    width: 100%;
    padding: 13px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    letter-spacing: 1px;
    outline: none;
  }

  .auth-input:focus { border-color: var(--amber); }
  .auth-input::placeholder { color: var(--text-dim); }

  /* Turnstile widget: invisible but functional (display:none breaks it) */
  [id^="cf-turnstile"] { visibility: hidden; height: 0; overflow: hidden; margin: 0 !important; }

  .auth-submit {
    width: 100%;
    padding: 14px;
    background: none;
    border: 1px solid var(--amber);
    color: var(--amber);
    font-family: 'Oswald', sans-serif;
    font-size: 15px;
    letter-spacing: 4px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  }

  .auth-submit::before {
    content: '';
    display: inline-block;
    width: 0; height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid var(--amber);
    margin-right: 8px;
    vertical-align: middle;
    transition: border-color 0.15s ease;
  }

  .auth-submit:hover { background: var(--amber); color: var(--bg); }
  .auth-submit:hover::before { border-left-color: var(--bg); }
  .auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }
  .auth-submit:disabled:hover { background: none; color: var(--amber); }

  .auth-mute-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: none;
    border: 1px solid rgba(232, 137, 12, 0.35);
    color: var(--amber);
    font-size: 16px;
    padding: 6px 10px;
    cursor: pointer;
    opacity: 0.55;
    border-radius: 2px;
    line-height: 1;
  }
  .auth-mute-btn:hover { opacity: 1; }

  .auth-error {
    font-size: 11px;
    color: var(--danger);
    letter-spacing: 1.5px;
    text-align: center;
    min-height: 16px;
  }

  .auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 2px;
  }

  .auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
  }

  .auth-demo-btn {
    width: 100%;
    padding: 12px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 2px;
    cursor: pointer;
  }

  .auth-demo-btn:hover { color: var(--text); border-color: var(--text-dim); }

  .auth-forgot-btn {
    background: none; border: none; color: var(--text-dim);
    font-family: 'Share Tech Mono', monospace; font-size: 11px;
    cursor: pointer; padding: 2px 0 6px; text-align: right;
    width: 100%; letter-spacing: 0.5px; display: block;
  }
  .auth-forgot-btn:hover { color: var(--amber); }

  .auth-version {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-align: center;
    margin-top: 28px;
    opacity: 0.45;
    font-family: 'Share Tech Mono', monospace;
    transition: opacity 0.15s ease, color 0.15s ease;
    cursor: default;
  }
  .auth-version:hover { opacity: 1; color: #ffffff; }

  /* Username edit in profile panel */
  .edit-username-btn   { background:none; border:none; color:var(--text-dim); cursor:pointer; font-size:13px; padding:0 4px; vertical-align:middle; }
  .edit-username-btn:hover { color:var(--amber); }
  .username-edit-wrap  { display:inline-flex; align-items:center; gap:4px; }
  .username-edit-input { background:#111; border:1px solid var(--amber); color:var(--text); font-family:'Share Tech Mono',monospace; font-size:12px; padding:2px 6px; width:110px; outline:none; }
  .username-save-btn, .username-cancel-btn { background:none; border:none; cursor:pointer; font-size:15px; padding:0 2px; }
  .username-save-btn   { color:var(--amber); }
  .username-cancel-btn { color:var(--text-dim); }

  /* Spinner */
  .spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
  }

  @keyframes spin { to { transform: rotate(360deg); } }

  /* Panel loading placeholder */
  .panel-loading {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    padding: 24px;
    letter-spacing: 0.1em;
  }

  /* Auth status indicator in HUD */
  /* ── SETTINGS GEAR BUTTON ── */
  #settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--amber);
    padding: 4px 6px;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.15s;
  }
  #settings-btn:hover { opacity: 1; }

  /* ── REGISTRATION MULTI-STEP ── */

  /*
   * Full-screen step flow:
   *   #auth-screen = fixed viewport, no global scroll
   *   logo/tagline/tabs = fixed-height top bar
   *   #auth-register-form = flex:1 fills remaining height, scrolls within
   *   Each step div fills the form; inactive ones are gone (KEY FIX)
   */
  #auth-screen {
    overflow: hidden;
    justify-content: flex-start;
    padding: 0;
    gap: 0;
  }

  /* Top bar elements get their own spacing */
  .auth-logo    { margin-top: 20px; }
  .auth-tagline { margin-bottom: 2px; }
  .auth-tabs    { width: 100%; max-width: 440px; padding: 0 20px; margin-bottom: 16px; }

  /* Login form stays compact and auto-sized */
  #auth-login-form { padding: 0 20px 24px; }

  /* Register form: fills remaining height of screen, independent scroll */
  #auth-register-form {
    flex: 1;
    width: 100%;
    max-width: 440px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 20px 40px;
    gap: 14px;
  }
  #auth-register-form::-webkit-scrollbar { display: none; }

  /* ════ 🔑 THE FIX: only the active step is in the layout ════ */
  #auth-register-form > div.hidden { display: none !important; }

  /* Step dots: sticky, full-width, dots centred via flex + flex-1 lines */
  .reg-steps {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    width: calc(100% + 40px);   /* counteract parent's 20px L+R padding */
    margin: 0 -20px 16px;
    padding: 12px 24px;
    background: rgba(8,8,6,0.97);
  }

  .reg-step-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    color: var(--text-dim);
    font-family: 'Oswald', sans-serif;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  }

  .reg-step-dot.active { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 8px rgba(232,137,12,0.3); }
  .reg-step-dot.done   { border-color: var(--amber-dim); background: rgba(232,137,12,0.1); color: var(--amber-dim); }

  .reg-step-line { flex: 1; height: 1px; background: var(--border); }

  .reg-step-title {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(22px, 5.5vw, 28px);
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--amber);
    margin-bottom: 4px;
    text-align: center;
    line-height: 1.1;
  }

  /* Avatar grid in registration */
  .reg-avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: 100%;
    margin-bottom: 14px;
  }

  .reg-avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    border: 2px solid var(--border);
    padding: 3px;
    transition: border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .reg-avatar-option.selected { border-color: var(--amber); box-shadow: 0 0 8px rgba(232,137,12,0.3); }

  .reg-avatar-option img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    object-position: top center;
    display: block;
  }

  .reg-avatar-label {
    font-size: 6px;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-align: center;
    text-transform: uppercase;
    line-height: 1.1;
  }

  .reg-avatar-option.selected .reg-avatar-label { color: var(--amber); }

  /* Navigation buttons (BACK / NEXT) */
  .reg-nav-btns {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .reg-back-btn {
    padding: 13px 14px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: 'Oswald', sans-serif;
    font-size: 13px;
    letter-spacing: 2px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s ease, color 0.15s ease;
  }

  .reg-back-btn:hover { border-color: var(--text-dim); color: var(--text); }
  .reg-next-btn { flex: 1; }

  /* Faction cards */
  #reg-faction-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-height: 52vh;
    overflow-y: auto;
    margin-bottom: 12px;
  }

  .faction-card {
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    background: var(--bg3);
    padding: 12px 12px 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .faction-card:active { background: rgba(255,255,255,0.03); }
  .faction-card.selected { background: rgba(255,255,255,0.04); box-shadow: inset 0 0 20px rgba(0,0,0,0.2); }

  .faction-card-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
  }

  .faction-card-icon { font-size: 26px; flex-shrink: 0; line-height: 1; }

  .faction-card-name {
    font-family: 'Oswald', sans-serif;
    font-size: 15px;
    letter-spacing: 3px;
    line-height: 1.1;
    margin-bottom: 2px;
  }

  .faction-card-tagline {
    font-size: 8px;
    letter-spacing: 2px;
    color: var(--text-dim);
    line-height: 1.3;
  }

  .faction-card-strengths {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
    padding-left: 4px;
  }

  .faction-strength {
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 1px;
    line-height: 1.4;
  }

  .faction-card-footer {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-dim);
    padding-top: 6px;
    border-top: 1px solid var(--border);
    opacity: 0.7;
  }

  /* ── MOBILE TYPOGRAPHY UPGRADES ── */
  /* 16px on inputs prevents iOS auto-zoom */
  .auth-input { font-size: 16px !important; }

  /* Registration subtitle / step description */
  .reg-step-sub {
    font-size: 12px;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-align: center;
    margin-top: -8px;
    margin-bottom: 14px;
    line-height: 1.4;
  }

  /* Bigger faction card text */
  .faction-card-name  { font-size: 18px !important; letter-spacing: 2px !important; }
  .faction-card-tagline { font-size: 11px !important; letter-spacing: 1.5px !important; }
  .faction-strength   { font-size: 12px !important; line-height: 1.6 !important; }
  .faction-card-footer { font-size: 11px !important; }

  /* ── PASSWORD STRENGTH ── */
  #reg-strength-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 8px;
  }
  #reg-strength-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
  }
  #reg-strength-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s, background 0.3s;
  }
  #reg-strength-label {
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-dim);
    min-width: 60px;
    text-align: right;
  }

  /* ── CLASS CAROUSEL (step 2 — gameplay meaningful, icon-based) ── */
  .class-carousel-wrap {
    width: 100%;
    margin-bottom: 10px;
    position: relative;
  }

  .class-carousel {
    display: flex;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .class-carousel::-webkit-scrollbar { display: none; }

  .class-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    background: var(--bg3);
    border: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .class-card.selected {
    border-color: var(--amber);
    box-shadow: 0 0 14px rgba(232,137,12,0.3);
  }

  .class-card-icon {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .class-card-name {
    font-family: 'Oswald', sans-serif;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--amber);
    line-height: 1;
  }

  .class-card-archetype {
    font-size: 10px;
    letter-spacing: 4px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 2px;
  }

  .class-card-desc {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    line-height: 1.5;
    font-style: italic;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    width: 100%;
  }

  .class-traits-title {
    font-size: 9px;
    letter-spacing: 3px;
    color: var(--text-dim);
    margin-top: 2px;
  }

  .class-trait {
    font-size: 13px;
    color: var(--text);
    letter-spacing: 0.5px;
    line-height: 1.55;
  }
  .class-trait span { color: var(--amber); }

  /* Class carousel dot row */
  .class-dots {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-bottom: 10px;
  }
  .class-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .class-dot.active { background: var(--amber); transform: scale(1.4); }

  /* ── AVATAR REG CAROUSEL (step 4 — cosmetic portrait, swipeable) ── */
  .avatar-reg-carousel-wrap {
    width: 100%;
    overflow: hidden;
    position: relative;
  }
  .avatar-reg-carousel {
    display: flex;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .avatar-reg-carousel::-webkit-scrollbar { display: none; }

  .avatar-reg-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 32px;
  }
  .avatar-reg-card img {
    width: 100%;
    max-width: 240px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    object-position: top center;
    display: block;
    border: 3px solid var(--border);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .avatar-reg-card.selected img {
    border-color: var(--amber);
    box-shadow: 0 0 20px rgba(232,137,12,0.4);
  }

  /* ── AVATAR CAROUSEL (step in avatar customisation panel — not reg step 4) ── */
  .avatar-carousel-wrap {
    width: 100%;
    margin-bottom: 10px;
    position: relative;
  }

  /* Swipe hint arrows — accessibility only, outside card area */
  .carousel-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 28px;
    height: 48px;
    background: rgba(8,8,8,0.7);
    border: 1px solid var(--border);
    color: var(--amber);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  #carousel-prev { left: 0; }
  #carousel-next { right: 0; }
  .carousel-nav-btn:disabled { opacity: 0.15; cursor: default; }
  .carousel-nav-btn:not(:disabled):hover { color: var(--bg); background: var(--amber); }

  /* The scroll track — CSS snap, swipe native */
  .avatar-carousel {
    display: flex;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
  }
  .avatar-carousel::-webkit-scrollbar { display: none; }

  /* Each avatar card — full width of track */
  .avatar-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;   /* prevent multi-card swipe skip */
    background: var(--bg3);
    border: 2px solid var(--border);
    padding: 0;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
  }
  .avatar-card.selected {
    border-color: var(--amber);
    box-shadow: 0 0 14px rgba(232,137,12,0.3);
  }

  .avatar-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    object-position: top center;
    display: block;
    max-height: 160px;
  }

  .avatar-card-body {
    padding: 12px 14px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .avatar-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }

  .avatar-card-name {
    font-family: 'Oswald', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--amber);
    line-height: 1;
  }

  .avatar-card-archetype {
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
  }

  .avatar-card-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
  }

  .avatar-card-traits-title {
    font-size: 9px;
    letter-spacing: 3px;
    color: var(--text-dim);
    margin-bottom: 2px;
  }

  .avatar-trait {
    font-size: 13px;
    color: var(--text);
    letter-spacing: 0.5px;
    line-height: 1.5;
    padding-left: 2px;
  }

  .avatar-trait span { color: var(--amber); font-weight: bold; }

  /* Dot row under carousel */
  .carousel-dots {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-bottom: 10px;
  }
  .carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .carousel-dot.active {
    background: var(--amber);
    transform: scale(1.35);
  }
