/* ── Profile dropdown (click the header avatar while signed in) ─────────── */
.profile-menu {
  position: absolute;
  top: 62px;
  right: 8px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 9999;
  min-width: 190px;
  padding: 6px 0;
  animation: rl-pop 0.15s ease-out;
}
.profile-menu.hidden { display: none; }

.profile-menu-email {
  padding: 8px 14px;
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  border-bottom: 1px solid var(--border, #eee);
  word-break: break-all;
}

.profile-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  text-align: start;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary, #111);
  transition: background 0.12s;
}
.profile-menu-item:hover { background: var(--bg-surface, #f5f5f5); }
.profile-menu-signout { color: #c0392b; }

/* ── Sign-in window (redesign) ────────────────────────────────────────────────
   Desktop: a two-pane dialog, the arena and the Professor's three promises on one side, the form on the
   other. Phone: a bottom sheet with a short arena strip on top. Square corners, ink is the one action
   colour; the orange appears once, on the focus ring. Tokens only, so light and dark both follow. */
#auth-modal { position: fixed; inset: 0; z-index: 9998; display: flex; align-items: center; justify-content: center; }
#auth-modal .pm-overlay { position: absolute; inset: 0; background: rgba(5, 8, 15, .62); }
.au-dialog {
  position: relative; display: flex; overflow: hidden; box-sizing: border-box;
  width: min(880px, calc(100% - 40px)); max-height: calc(100dvh - 40px);
  background: var(--ds-card); color: var(--ds-ink); font-family: var(--ds-font);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  animation: au-in var(--ds-t-layer) ease-out;
}
@keyframes au-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.au-aside { position: relative; flex: 0 0 340px; display: flex; flex-direction: column; overflow: hidden; background: #0C111C; color: #F4F6FA; }
.au-aside-bg {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8, 11, 19, .2) 0%, rgba(8, 11, 19, .7) 48%, rgba(8, 11, 19, .95) 100%),
              url("/assets/arena-hero.jpg") 50% 40% / cover no-repeat;
}
.au-aside-body { position: relative; margin-top: auto; display: flex; flex-direction: column; gap: 14px; padding: 28px 26px 30px; }
.au-logo { inline-size: 76px; block-size: 76px; object-fit: contain; }
.au-aside-title { font: 900 28px/1.15 var(--ds-font); letter-spacing: -.02em; text-wrap: balance; }
.au-perks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.au-perks li { display: flex; align-items: center; gap: 10px; font: 600 var(--ds-fs-14)/1.4 var(--ds-font); color: #DCE3F2; }
.au-tick { flex: none; inline-size: 20px; block-size: 20px; display: grid; place-items: center; background: #F4F6FA; color: #0C111C; }
.au-form-col { position: relative; flex: 1; min-width: 0; overflow-y: auto; box-sizing: border-box; display: flex; flex-direction: column; gap: 14px; padding: 30px 32px 26px; }
.au-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.au-title { margin: 0; font: 900 var(--ds-fs-24)/1.2 var(--ds-font); letter-spacing: -.01em; }
.au-sub { margin: 4px 0 0; font: 500 var(--ds-fs-14)/1.5 var(--ds-font); color: var(--ds-ink2); }
.au-close {
  flex: none; inline-size: var(--ds-h-btn); block-size: var(--ds-h-btn); display: grid; place-items: center;
  border: 1.5px solid var(--ds-line); background: transparent; color: var(--ds-ink); cursor: pointer;
  position: static; padding: 0; font-size: 1rem;
}
.au-close:hover { background: var(--ds-soft); }
.au-close--sheet { display: none; }
.au-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--ds-ink); }
.au-tab { min-block-size: var(--ds-h-btn); border: 0; background: transparent; color: var(--ds-ink); font: 800 var(--ds-fs-14) var(--ds-font); cursor: pointer; }
.au-tab[aria-selected="true"] { background: var(--ds-ink); color: var(--ds-card); }
.au-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; font: 600 var(--ds-fs-14)/1.5 var(--ds-font); border: 1.5px solid; }
.au-banner svg { flex: none; margin-top: 1px; }
.au-banner.is-err { color: var(--ds-live); border-color: var(--ds-live); background: color-mix(in srgb, var(--ds-live) 9%, transparent); }
.au-banner.is-ok { color: var(--ds-ok); border-color: var(--ds-ok); background: color-mix(in srgb, var(--ds-ok) 10%, transparent); }
.au-google {
  inline-size: 100%; min-block-size: var(--ds-h-btn-l); box-sizing: border-box; border: 1.5px solid var(--ds-ink);
  background: transparent; color: var(--ds-ink); font: 800 15px var(--ds-font); cursor: pointer;
}
.au-google:hover { background: var(--ds-soft); }
.au-legal { margin: 0; font: 500 13.5px/1.55 var(--ds-font); color: var(--ds-ink2); }
.au-legal a, .au-consent a { color: var(--ds-ink); font-weight: 700; }
.au-or { display: flex; align-items: center; gap: 12px; font: 600 var(--ds-fs-13) var(--ds-font); color: var(--ds-ink2); }
.au-or span { flex: 1; block-size: 1px; background: var(--ds-line); }
.au-form { display: flex; flex-direction: column; gap: 14px; }
.au-field { display: flex; flex-direction: column; gap: 6px; font: 700 var(--ds-fs-14) var(--ds-font); }
.au-field .am-input {
  inline-size: 100%; min-block-size: var(--ds-h-btn-l); box-sizing: border-box; padding: 0 14px;
  border: 1.5px solid var(--ds-line); border-radius: 0; background: var(--ds-bg); color: var(--ds-ink); font: 500 15px var(--ds-font);
}
.au-field .am-input:focus { outline: 2px solid var(--ds-ink); outline-offset: 2px; border-color: var(--ds-ink); }
.au-pass { position: relative; display: block; }
.au-pass .am-input { padding-inline-end: 52px; }
.au-eye { position: absolute; inset-block: 0; inset-inline-end: 0; inline-size: var(--ds-h-btn); border: 0; background: transparent; color: var(--ds-ink2); cursor: pointer; display: grid; place-items: center; }
.au-eye[aria-pressed="true"] { color: var(--ds-ink); }
.au-forgot { display: flex; justify-content: flex-end; margin-block: -6px 0; }
.au-link { border: 0; background: transparent; color: var(--ds-ink); font: 700 var(--ds-fs-14) var(--ds-font); text-decoration: underline; cursor: pointer; min-block-size: var(--ds-h-btn); padding: 0 6px; }
.au-consent { display: flex; align-items: flex-start; gap: 10px; font: 500 13.5px/1.55 var(--ds-font); color: var(--ds-ink2); cursor: pointer; }
.au-consent input { flex: none; inline-size: 20px; block-size: 20px; margin: 2px 0 0; accent-color: var(--ds-ink); }
.au-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px; inline-size: 100%; min-block-size: var(--ds-h-btn-l);
  border: 0; border-radius: 0; background: var(--ds-ink); color: var(--ds-card); font: 800 15px var(--ds-font); cursor: pointer;
}
.au-primary:hover { opacity: 1; }
.au-primary:disabled { opacity: .45; cursor: default; }
.au-primary[aria-busy="true"] { opacity: .75; }
.au-primary[aria-busy="true"]::before { content: ""; inline-size: 18px; block-size: 18px; box-sizing: border-box; border: 2.5px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: au-spin .8s linear infinite; }
@keyframes au-spin { to { transform: rotate(360deg); } }
.au-foot { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; font: 500 var(--ds-fs-14) var(--ds-font); color: var(--ds-ink2); }
.au-dialog :focus-visible { outline: 2px solid var(--ds-ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .au-dialog { animation: none; } .au-primary[aria-busy="true"]::before { animation-duration: 2.4s; } }

@media (max-width: 719px) {
  #auth-modal { align-items: flex-end; }
  .au-dialog { flex-direction: column; inline-size: 100%; max-height: 94dvh; border-radius: var(--ds-r-sheet) var(--ds-r-sheet) 0 0; box-shadow: 0 -14px 40px rgba(0, 0, 0, .35); }
  .au-aside { flex: none; block-size: 120px; }
  .au-aside-bg { background: linear-gradient(180deg, rgba(8, 11, 19, .15), rgba(8, 11, 19, .7)), url("/assets/arena-hero.jpg") 50% 45% / cover no-repeat; }
  .au-aside-body { margin: 0; padding: 0; position: absolute; inset-inline-start: 18px; inset-block-end: -18px; }
  .au-aside-title, .au-perks { display: none; }
  .au-logo { inline-size: 60px; block-size: 60px; }
  .au-close--desk { display: none; }
  .au-close--sheet { display: grid; position: absolute; inset-block-start: 10px; inset-inline-end: 10px; background: rgba(8, 11, 19, .55); border-color: rgba(255, 255, 255, .5); color: #F4F6FA; }
  .au-form-col { padding: 30px 18px 26px; }
}

/* ── Favorite teams (redesign) ───────────────────────────────────────────────
   A square dialog (a bottom sheet on a phone): one block per league, each team a 60px tile with its crest;
   a ticked team gets the orange frame and its star sets the league colour. */
#auth-favorites-modal { position: fixed; inset: 0; z-index: 9998; display: flex; align-items: center; justify-content: center; }
.pm-overlay { position: absolute; inset: 0; background: rgba(5, 8, 15, .62); }
.pm-modal {
  position: relative; display: flex; flex-direction: column; gap: 14px; box-sizing: border-box;
  width: min(640px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 26px 28px 24px;
  background: var(--ds-card); color: var(--ds-ink); font-family: var(--ds-font);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4); animation: au-in var(--ds-t-layer) ease-out;
}
.pm-title { margin: 0; font: 900 var(--ds-fs-24)/1.2 var(--ds-font); letter-spacing: -.01em; color: var(--ds-ink); text-align: start; }
.pm-sub { margin: -8px 0 0; font: 500 var(--ds-fs-14)/1.5 var(--ds-font); color: var(--ds-ink2); text-align: start; }
.pm-sections { display: flex; flex-direction: column; gap: 22px; }
.pm-league-section { margin: 0; }
.pm-league-title { margin-bottom: 4px; font: 800 var(--ds-fs-17) var(--ds-font); color: var(--ds-ink); }
.pm-league-hint { margin: 0 0 10px; font: 500 var(--ds-fs-13)/1.5 var(--ds-font); color: var(--ds-ink2); }
.pm-team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; padding: 2px; border: 0; }
.pm-team-row {
  display: flex; align-items: center; gap: 10px; min-block-size: 60px; padding: 8px 10px; box-sizing: border-box;
  border: 1.5px solid var(--ds-line); border-radius: 0; background: transparent; cursor: pointer;
  transition: border-color var(--ds-t-ctrl) ease, background-color var(--ds-t-ctrl) ease;
}
.pm-team-row:hover { background: var(--ds-soft); }
.pm-team-row.checked { border: 2px solid var(--ds-lg-el); background: color-mix(in srgb, var(--ds-lg-el) 10%, transparent); padding: 7.5px 9.5px; }
.pm-team-checkbox { inline-size: 20px; block-size: 20px; flex: none; margin: 0; cursor: pointer; accent-color: var(--ds-ink); }
.pm-crest { flex: none; }
.pm-team-name { flex: 1; min-width: 0; font: 600 var(--ds-fs-14)/1.25 var(--ds-font); color: var(--ds-ink); overflow-wrap: break-word; }
.pm-primary-star {
  flex: none; inline-size: 36px; block-size: 36px; display: grid; place-items: center; border: 0; background: transparent;
  font-size: 1.15rem; color: var(--ds-line); cursor: pointer; visibility: hidden; transition: color var(--ds-t-ctrl) ease;
}
.pm-team-row.checked .pm-primary-star { visibility: visible; }
.pm-primary-star.active { color: var(--ds-warn); }
.pm-done {
  position: sticky; inset-block-end: 0; display: block; inline-size: 100%; min-block-size: var(--ds-h-btn-l);
  border: 0; border-radius: 0; background: var(--ds-ink); color: var(--ds-card); font: 800 15px var(--ds-font); cursor: pointer;
}
.pm-done:hover { opacity: .9; }
#auth-favorites-modal :focus-visible { outline: 2px solid var(--ds-ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .pm-modal { animation: none; } }
@media (max-width: 719px) {
  #auth-favorites-modal { align-items: flex-end; }
  .pm-modal { inline-size: 100%; max-height: 88dvh; padding: 22px 18px 20px; border-radius: var(--ds-r-sheet) var(--ds-r-sheet) 0 0; box-shadow: 0 -14px 40px rgba(0, 0, 0, .35); }
  .pm-team-grid { grid-template-columns: 1fr; }
}

/* ── Auth Avatar (top nav) ─────────────────────────────────────────────── */
#auth-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg-surface, #eee);
  color: var(--text-muted, #888);
  border: 1.5px solid var(--border, #ddd);
  transition: border-color 0.15s;
  flex-shrink: 0;
}

#auth-avatar.signed-in {
  background: var(--team-accent, #1d428a);
  color: var(--accent-fg, #fff);
  border-color: var(--team-accent, #1d428a);
}

/* ── App content-column width ──────────────────────────────────────────
   The whole app is laid out as a centered column (header, nav, every
   screen's outer wrap) capped at a phone-sized 480px — on a wide desktop
   browser that reads as a cramped strip with dead space on both sides.
   Widen the column on larger viewports via one shared variable instead of
   the ~15 places that used to hardcode "480px" independently, so desktop
   and mobile only ever need to agree in one place. */
:root {
  --app-max-width: 480px;
}

@media (min-width: 700px) {
  :root {
    --app-max-width: 900px;
  }
}

/* ── Team accent colors (applied via JS) ───────────────────────────────── */
:root {
  --team-accent: #1d428a;
  --team-accent-bg: #1d428a22;
}

/* ── Basketball term tooltips ──────────────────────────────────────────── */
.term-link {
  color: var(--accent-ink, #1d428a);
  text-decoration: underline dotted;
  cursor: pointer;
  position: relative;
  display: inline;
}

.term-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  max-width: 280px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-primary, #111);
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  z-index: 9999;
  text-align: start;
  white-space: normal;
  pointer-events: none;
}
html[dir="rtl"] .term-popup { direction: rtl; }

/* ── Rate limit modal — Google button ─────────────────────────────────── */
.rl-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px;
  background: #fff;
  border: 1.5px solid #dadce0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #3c4043;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.rl-google-btn:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.rl-google-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.rl-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-muted, #aaa);
  font-size: 0.8rem;
}

.rl-divider::before,
.rl-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border, #eee);
}

/* ── Global search (magnifying glass in the header) ──────────────────────── */
#global-search-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.search-modal {
  text-align: center;
}

.search-close {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted, #888);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.search-close:hover { color: var(--text-primary, #111); }

.search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border, #ddd);
  background: var(--bg-input, #f5f5f5);
  color: var(--text-primary, #111);
  font-size: 1rem;
  margin-bottom: 14px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent1, #2563eb);
}

.search-results {
  text-align: start;
  max-height: 50vh;
  overflow-y: auto;
}

.search-hint {
  color: var(--text-muted, #888);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

.search-group-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-ink, #1d428a);
  margin: 10px 0 6px;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.search-row:hover { background: var(--bg-card-hover, rgba(0,0,0,0.04)); }

.search-row-icon { font-size: 1.1rem; flex-shrink: 0; }
.search-row-name {
  flex: 1;
  font-size: 0.95rem;
  color: var(--text-primary, #111);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-row-league {
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

/* Consent: a line under the Google button, and a required checkbox on sign-up. */
.am-legal { font-size: .74rem; line-height: 1.5; color: var(--text-muted, #666); text-align: center; margin: 8px 0 2px; }
.am-legal a, .am-consent a { color: var(--accent-ink, #1a3a6b); text-decoration: underline; }
.am-consent { display: flex; align-items: flex-start; gap: 8px; font-size: .78rem; line-height: 1.5; color: var(--text-primary, #111); margin: 2px 0 4px; cursor: pointer; }
.am-consent input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--accent-ink, #1a3a6b); }
