/* ============================================================================
 * ATLAS PROFILE  —  styles (premium college-football locker, dark theme)
 * Built on the app's existing design tokens (--nv/--bl/--cm/--w…) with safe
 * fallbacks so it renders correctly even if loaded standalone. Everything is
 * namespaced under .ap-* to guarantee zero collision with the existing app.
 * Fully responsive → the same layout carries into the mobile app.
 * ========================================================================== */
.ap-page, #ap-modal-root {
  --ap-nv:  var(--nv,  #080C18);
  --ap-nv2: var(--nv2, #0D1526);
  --ap-nv3: var(--nv3, #131E30);
  --ap-nv4: var(--nv4, #1A2540);
  --ap-bl:  var(--bl,  #1A6CF5);
  --ap-bl2: var(--bl2, #2E7FFF);
  --ap-cm:  var(--cm,  #FFBC3B);
  --ap-gr:  var(--gr,  #3ECF70);
  --ap-rd:  var(--rd,  #F24B4B);
  --ap-w:   var(--w,   #F8F9FF);
  --ap-w2:  var(--w2,  #C4CBE0);
  --ap-sl:  var(--sl,  #8B9BB8);
  --ap-bd:  var(--bd,  rgba(255,255,255,.07));
  --ap-bd2: var(--bd2, rgba(255,255,255,.04));
  --ap-r:   var(--r,   8px);
  --ap-r2:  var(--r2,  12px);
  --ap-fi:  var(--fi,  "Inter", system-ui, sans-serif);
  --ap-fd:  var(--fd,  "Barlow Condensed", Impact, sans-serif);
}

/* ---- generic page frame -------------------------------------------------- */
.ap-page { color: var(--ap-w); font-family: var(--ap-fi); }
.ap-wrap { max-width: 940px; margin: 0 auto; padding: 28px 18px 80px; }
.ap-muted { color: var(--ap-sl); }

/* ---- buttons ------------------------------------------------------------- */
.ap-btn {
  font: 600 14px/1 var(--ap-fi); border: 1px solid var(--ap-bd);
  background: var(--ap-nv3); color: var(--ap-w); padding: 11px 18px;
  border-radius: var(--ap-r); cursor: pointer; transition: .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.ap-btn:hover { border-color: rgba(255,255,255,.18); transform: translateY(-1px); }
.ap-btn-primary { background: linear-gradient(180deg, var(--ap-bl2), var(--ap-bl)); border-color: transparent; box-shadow: 0 6px 18px -6px var(--ap-bl); }
.ap-btn-primary:hover { filter: brightness(1.07); }
.ap-btn-ghost { background: transparent; }
.ap-btn-danger { background: transparent; border-color: rgba(242,75,75,.4); color: #ff8a8a; }
.ap-btn-danger:hover { background: rgba(242,75,75,.12); }
.ap-full { width: 100%; }
.ap-btn.ap-loading { opacity: .6; pointer-events: none; position: relative; }
.ap-btn.ap-loading::after { content:""; width:14px; height:14px; border:2px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius:50%; animation: ap-spin .7s linear infinite; }
@keyframes ap-spin { to { transform: rotate(360deg); } }

/* ---- header chip --------------------------------------------------------- */
.ap-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--ap-nv3); border: 1px solid var(--ap-bd); color: var(--ap-w);
  border-radius: 999px; padding: 5px 12px 5px 6px; font: 600 13px var(--ap-fi);
  transition: .15s; margin-left: 8px; white-space: nowrap; flex: 0 0 auto;
}
.ap-chip:hover { border-color: rgba(255,255,255,.2); }
.ap-chip-float { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); z-index: 900; }
.ap-chip-signin { padding: 0 6px; color: var(--ap-w2); }
.ap-chip-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; }
.ap-chip-av-ph { background: linear-gradient(135deg, var(--ap-bl2), var(--ap-cm)); color: #04070f; font-weight: 800; font-size: 13px; }
.ap-chip-meta { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.ap-chip-name { font-weight: 700; }
.ap-chip-lvl { font-size: 10px; letter-spacing: .04em; color: var(--ap-cm); text-transform: uppercase; }

/* ---- profile hero -------------------------------------------------------- */
.ap-hero { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; }
.ap-hero-av { width: 92px; height: 92px; border-radius: 22px; overflow: hidden; flex: none;
  background: linear-gradient(135deg, var(--ap-nv4), var(--ap-nv2)); border: 1px solid var(--ap-bd);
  display: grid; place-items: center; box-shadow: 0 10px 30px -12px #000; }
.ap-hero-av img { width: 100%; height: 100%; object-fit: cover; }
.ap-hero-av span { font: 800 40px var(--ap-fd); color: var(--ap-cm); }
/* Team-logo avatar (fallback when no photo): contain + padding so the logo isn't cropped. */
.ap-hero-av-team { box-sizing: border-box; padding: 16px; }
.ap-hero-av-team img { object-fit: contain; }
.ap-hero-main { flex: 1; min-width: 0; }
.ap-hero-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ap-hero-top h1 { font: 800 30px/1 var(--ap-fd); letter-spacing: .01em; margin: 0; text-transform: uppercase; }
.ap-hero-handle { color: var(--ap-sl); font-size: 14px; }
.ap-hero-settings { margin-left: auto; padding: 7px 14px; }
.ap-hero-team { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; color: var(--ap-w2); font-weight: 600; }
.ap-hero-team img, .ap-logo-fallback { width: 22px; height: 22px; border-radius: 4px; }
.ap-logo-fallback { display: inline-grid; place-items: center; background: var(--ap-nv4); font-size: 11px; font-weight: 800; }

/* ---- level / xp bar ------------------------------------------------------ */
.ap-level-row { display: flex; align-items: center; gap: 12px; }
.ap-level-badge { font: 800 12px var(--ap-fd); letter-spacing: .06em; background: rgba(255,188,59,.14);
  color: var(--ap-cm); border: 1px solid var(--cmborder, rgba(255,188,59,.25)); padding: 4px 9px; border-radius: 6px; text-transform: uppercase; }
.ap-xpbar { flex: 1; height: 8px; background: var(--ap-nv3); border-radius: 999px; overflow: hidden; border: 1px solid var(--ap-bd2); }
.ap-xpbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--ap-bl), var(--ap-cm)); border-radius: 999px; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.ap-xp-num { font-size: 12px; color: var(--ap-sl); white-space: nowrap; }

/* ---- quick stats --------------------------------------------------------- */
.ap-quickstats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 22px; }
.ap-stat { background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r2); padding: 14px 10px; text-align: center; }
.ap-stat-v { display: block; font: 800 22px var(--ap-fd); color: var(--ap-w); }
.ap-stat-l { display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ap-sl); margin-top: 4px; }

/* ---- tabs ---------------------------------------------------------------- */
.ap-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ap-bd); margin-bottom: 18px; overflow-x: auto; }
.ap-tab { background: none; border: none; color: var(--ap-sl); font: 700 14px var(--ap-fi); padding: 12px 16px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.ap-tab:hover { color: var(--ap-w2); }
.ap-tab.on { color: var(--ap-w); border-bottom-color: var(--ap-cm); }

/* ---- lists / activity / history ------------------------------------------ */
.ap-sec-h { font: 700 13px var(--ap-fi); letter-spacing: .04em; text-transform: uppercase; color: var(--ap-sl); margin: 22px 0 10px; }
.ap-sec-h:first-child { margin-top: 4px; }
.ap-activity, .ap-hist, .ap-proj { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ap-activity li, .ap-hist li, .ap-proj li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r); }
.ap-act-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ap-cm); flex: none; }
.ap-act-t, .ap-proj-title { flex: 1; font-weight: 600; }
.ap-act-when, .ap-hist-when, .ap-proj-when { color: var(--ap-sl); font-size: 12px; }
.ap-hist-wk { font-weight: 700; min-width: 90px; }
.ap-hist-season { color: var(--ap-sl); flex: 1; }
.ap-proj-kind { font: 700 10px var(--ap-fd); text-transform: uppercase; letter-spacing: .06em; color: var(--ap-bl2); background: var(--bldim, rgba(26,108,245,.12)); padding: 3px 7px; border-radius: 5px; }
.ap-badge-pub { font-size: 10px; color: var(--ap-gr); border: 1px solid rgba(62,207,112,.3); padding: 2px 7px; border-radius: 999px; }
.ap-emptyrow, .ap-loading-row { padding: 20px; text-align: center; color: var(--ap-sl); background: var(--ap-nv2); border: 1px dashed var(--ap-bd); border-radius: var(--ap-r); font-size: 14px; }

/* ---- XP leaderboard ------------------------------------------------------ */
.ap-lb-me { background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r2); padding: 12px 16px; margin-bottom: 14px; font: 500 14px var(--ap-fi); color: var(--ap-w2); }
.ap-lb-me b { color: var(--ap-cm); font-weight: 800; }
.ap-lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ap-lb-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r); }
.ap-lb-row.me { border-color: var(--cmborder, rgba(255,188,59,.4)); background: rgba(255,188,59,.06); }
.ap-lb-rank { min-width: 40px; font: 800 15px var(--ap-fd); color: var(--ap-sl); text-align: center; }
.ap-lb-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-lb-xp { font: 700 13px var(--ap-fi); color: var(--ap-cm); white-space: nowrap; }

/* ---- achievements grid --------------------------------------------------- */
.ap-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.ap-badge { background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r2); padding: 18px 10px; text-align: center; transition: .15s; }
.ap-badge.off { opacity: .4; filter: grayscale(.7); }
.ap-badge.on { border-color: rgba(255,188,59,.3); box-shadow: 0 8px 24px -14px var(--ap-cm); }
.ap-badge-ic { font-size: 30px; display: block; }
.ap-badge-nm { display: block; font-weight: 700; font-size: 13px; margin-top: 8px; }
.ap-badge-tier { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ap-sl); margin-top: 3px; }

/* ---- empty state --------------------------------------------------------- */
.ap-empty { text-align: center; max-width: 460px; margin: 60px auto; }
.ap-empty-mark { font-size: 44px; color: var(--ap-cm); opacity: .8; }
.ap-empty h2 { font: 800 28px var(--ap-fd); text-transform: uppercase; margin: 12px 0 8px; }
.ap-empty p { color: var(--ap-w2); line-height: 1.55; margin-bottom: 22px; }

/* ---- settings ------------------------------------------------------------ */
.ap-settings-title { font: 800 30px var(--ap-fd); text-transform: uppercase; margin: 0 0 20px; }
.ap-card { background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r2); padding: 20px; margin-bottom: 16px; }
.ap-card-h { font: 700 12px var(--ap-fi); letter-spacing: .06em; text-transform: uppercase; color: var(--ap-sl); margin: 0 0 16px; }
.ap-card-sub { font: 400 13px var(--ap-fi); color: var(--ap-sl); margin: -6px 0 16px; line-height: 1.5; }
.ap-field { display: block; margin-bottom: 14px; }
.ap-field-l { display: block; font-size: 13px; color: var(--ap-w2); margin-bottom: 6px; font-weight: 600; }
.ap-input { width: 100%; background: var(--ap-nv); border: 1px solid var(--ap-bd); color: var(--ap-w); border-radius: var(--ap-r); padding: 11px 12px; font: 500 14px var(--ap-fi); }
.ap-input:focus { outline: none; border-color: var(--ap-bl2); box-shadow: 0 0 0 3px var(--bldim, rgba(26,108,245,.18)); }
textarea.ap-input { resize: vertical; }
.ap-handle { display: flex; align-items: center; background: var(--ap-nv); border: 1px solid var(--ap-bd); border-radius: var(--ap-r); padding-left: 12px; }
.ap-handle span { color: var(--ap-sl); font-weight: 700; }
.ap-handle .ap-input { border: none; background: transparent; }
.ap-hint { font-size: 12px; margin-top: 5px; display: inline-block; color: var(--ap-sl); }
.ap-hint-ok { color: var(--ap-gr); }
.ap-hint-bad { color: var(--ap-rd); }

/* Password field with show/hide eye */
.ap-pass { position: relative; margin-top: 6px; }
.ap-pass .ap-input { margin-top: 0; padding-right: 44px; }
.ap-eye { position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; margin: 0;
  background: transparent; border: 0; color: var(--ap-sl); cursor: pointer; border-radius: 6px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.ap-eye:hover { color: var(--ap-w2); }
.ap-eye:focus-visible { outline: 2px solid var(--ap-bl2); outline-offset: 1px; }
.ap-eye svg { width: 18px; height: 18px; display: block; }

/* Favorite-team searchable dropdown */
.ap-teamsel { position: relative; margin-top: 6px; }
.ap-teamsel .ap-input { margin-top: 0; }
.ap-teamsel-menu { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--ap-nv2); border: 1px solid var(--ap-bd); border-radius: var(--ap-r);
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.6); max-height: 264px; overflow-y: auto; padding: 4px; }
.ap-teamsel-opt { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--ap-w); padding: 8px 10px; border-radius: 6px;
  cursor: pointer; font: 500 14px var(--ap-fi); }
.ap-teamsel-opt:hover, .ap-teamsel-opt.on { background: var(--ap-nv4); }
.ap-teamsel-opt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-teamsel-opt img, .ap-teamsel-opt .ap-logo-fallback { width: 20px; height: 20px; flex: 0 0 20px; object-fit: contain; border-radius: 3px; }
.ap-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--ap-bd2); }
.ap-toggle-row:last-child { border-bottom: none; }
.ap-toggle-l { font-weight: 600; }
.ap-toggle-h { font-size: 12px; color: var(--ap-sl); margin-top: 2px; }
.ap-public-url { font-size: 13px; color: var(--ap-cm); margin-top: 8px; word-break: break-all; }
.ap-identities { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ap-identity { background: var(--ap-nv3); border: 1px solid var(--ap-bd); border-radius: 999px; padding: 6px 14px; font-size: 13px; text-transform: capitalize; }
.ap-link-list { display: flex; gap: 8px; flex-wrap: wrap; }
.ap-card .ap-btn { margin-right: 8px; margin-top: 4px; }

/* switch */
.ap-switch { position: relative; width: 44px; height: 24px; flex: none; }
.ap-switch input { opacity: 0; width: 0; height: 0; }
.ap-switch span { position: absolute; inset: 0; background: var(--ap-nv4); border: 1px solid var(--ap-bd); border-radius: 999px; transition: .2s; cursor: pointer; }
.ap-switch span::before { content:""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.ap-switch input:checked + span { background: var(--ap-bl); border-color: transparent; }
.ap-switch input:checked + span::before { transform: translateX(20px); }

/* ======================================================================= */
/*  AUTH MODAL                                                              */
/* ======================================================================= */
body.ap-modal-open { overflow: hidden; }
.ap-modal-overlay { position: fixed; inset: 0; z-index: 10000; background: rgba(4,7,15,.72);
  backdrop-filter: blur(6px); display: grid; place-items: center; animation: ap-fade .2s ease;
  /* keep the card clear of the notch / home indicator on iPhone */
  padding: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); }
@keyframes ap-fade { from { opacity: 0; } }
.ap-modal-card { position: relative; width: 100%; max-width: 400px; background: var(--ap-nv2);
  border: 1px solid var(--ap-bd); border-radius: 18px; padding: 30px 26px 26px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto;  /* never clip the form on short/landscape phones */
  box-shadow: 0 40px 90px -30px #000, 0 0 0 1px rgba(255,255,255,.03) inset; animation: ap-pop .22s cubic-bezier(.2,.8,.2,1); }
@keyframes ap-pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.ap-modal-x { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--ap-sl); font-size: 26px; line-height: 1; cursor: pointer; }
.ap-modal-x:hover { color: var(--ap-w); }
.ap-modal-back { position: absolute; top: 24px; left: 16px; background: none; border: none; color: var(--ap-sl); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.ap-modal-back:hover { color: var(--ap-w); }
.ap-modal-back:focus-visible { outline: 2px solid var(--ap-bl2); outline-offset: 1px; }
.ap-modal-back ~ .ap-modal-brand { padding-left: 26px; }   /* make room for the arrow on the same row */
.ap-modal-brand { font: 800 13px var(--ap-fd); letter-spacing: .22em; color: var(--ap-w2); display: flex; align-items: center; gap: 6px; }
.ap-modal-mark { color: var(--ap-cm); }
.ap-modal-title { font: 800 25px/1.1 var(--ap-fd); text-transform: uppercase; margin: 12px 0 6px; }
.ap-modal-sub { color: var(--ap-w2); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.ap-oauth-list { display: flex; flex-direction: column; gap: 10px; }
.ap-oauth { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 12px; border-radius: var(--ap-r); border: 1px solid var(--ap-bd); background: #fff; color: #111;
  font: 700 14px var(--ap-fi); cursor: pointer; transition: .15s; }
.ap-oauth:hover { transform: translateY(-1px); }
.ap-oauth.ap-loading { opacity: .6; pointer-events: none; }
.ap-apple { background: #000; color: #fff; border-color: #333; }
.ap-or { display: flex; align-items: center; gap: 12px; color: var(--ap-sl); font-size: 12px; margin: 16px 0; }
.ap-or::before, .ap-or::after { content:""; flex: 1; height: 1px; background: var(--ap-bd); }
.ap-form { display: flex; flex-direction: column; gap: 12px; }
.ap-label { display: block; font-size: 13px; color: var(--ap-w2); font-weight: 600; }
.ap-label .ap-input { margin-top: 6px; }
.ap-err { color: #ff8a8a; font-size: 13px; min-height: 0; }
.ap-err:empty { display: none; }
.ap-modal-foot { text-align: center; font-size: 13px; color: var(--ap-sl); margin: 14px 0 0; }
.ap-modal-foot a { color: var(--ap-bl2); cursor: pointer; text-decoration: none; }
.ap-modal-foot a:hover { text-decoration: underline; }
.ap-fineprint { text-align: center; font-size: 11px; color: var(--ap-sl); margin: 14px 0 0; opacity: .8; }

/* ---- toast (only if the app has none) ------------------------------------ */
.ap-toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translate(-50%, 20px);
  background: var(--nv4, #1A2540); color: #fff; border: 1px solid var(--bd, rgba(255,255,255,.1));
  padding: 12px 20px; border-radius: 999px; font: 600 14px var(--fi, sans-serif); z-index: 10001;
  opacity: 0; transition: .3s; box-shadow: 0 20px 50px -20px #000; }
.ap-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 640px) {
  .ap-wrap { padding: 20px 14px 90px; }
  .ap-hero { flex-direction: column; text-align: center; align-items: center; gap: 14px; }
  .ap-hero-top { justify-content: center; }
  .ap-hero-settings { margin: 0; }
  .ap-hero-team { justify-content: center; }
  .ap-quickstats { grid-template-columns: repeat(2, 1fr); }
  .ap-quickstats .ap-stat:nth-child(5) { grid-column: span 2; }
  .ap-modal-card { max-width: 100%; }
  .ap-chip-meta { display: none; }
}
