/* Leaderboard styles — matches the existing dark/classic palette */

/* ─── Floating top-right auth (used by all game pages) ───────────────────── */
.lb-auth-fixed {
  position: fixed;
  top:    max(0.6rem, env(safe-area-inset-top, 0rem));
  right:  max(0.6rem, env(safe-area-inset-right, 0rem));
  z-index: 1000;       /* above game-board (.message-container is z-index: 10) */
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  pointer-events: auto;
}
.lb-auth-fixed > * { pointer-events: auto; }

/* Home page account control: it occupies the space between the game title and
   score cards instead of floating over either element. */
.account-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  min-height: 0;
}
.account-row .lb-auth-fixed {
  position: static;
}
.account-row .lb-auth-fixed:empty { display: none; }
.account-row .lb-user-meta { display: flex; }
.account-row .lb-user-chip { padding: .3rem .7rem; border-radius: 999px; }
.account-row .lb-user-score { display: none; }
.account-row .lb-user-name { max-width: 11ch; }

/* Home page: show only the Google mark — no text, pill, or button chrome. */
.account-row .lb-google-icon {
  width: 28px; height: 28px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.account-row .lb-google-icon:hover { background: transparent; }
.account-row .lb-google-mark { width: 20px; height: 20px; }
/* On the home page, signed-out users get just the G; signed-in users get a
   round avatar chip + tiny ⋯ menu button — keep both compact there. */
.account-row .lb-user-chip img { width: 26px; height: 26px; }
.account-row .lb-signout { padding: .25rem .5rem; min-width: 1.6rem; font-size: .9rem; }

.lb-auth-slot {
  display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end;
  margin: 0 0 1rem;
}

/* Compact, slightly translucent so the page is not visually noisy. */
.lb-auth-btn {
  appearance: none; cursor: pointer; border: none; border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-weight: 600; font-size: 0.9rem; line-height: 1;
  background: linear-gradient(135deg, #4285f4, #1a73e8);
  color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18);
  transition: filter .15s ease, transform .05s ease;
}
.lb-auth-btn:hover  { filter: brightness(1.08); }
.lb-auth-btn:active { transform: translateY(1px); }
.lb-auth-btn:disabled { filter: grayscale(.5) opacity(.6); cursor: not-allowed; }
.lb-google-icon {
  width: 44px; height: 44px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: #4285f4; border: 1px solid #d8d4ca;
  box-shadow: 0 2px 5px rgba(0,0,0,.12);
}
.lb-google-icon:hover { background: #f8faff; }
.lb-google-mark { width: 20px; height: 20px; display: block; }
.lb-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.lb-signout {
  background: rgba(255,255,255,.85);
  color: #776e65; padding: 0.4rem 0.7rem;
  font-weight: 500;
  border-radius: 999px; font-size: 0.85rem;
}
.lb-signout:hover { color: #c33; }

/* Drop-shadow tinted for dark variants (halloween/christmas/doge). */
.halloween .lb-auth-btn,
.christmas .lb-auth-btn,
.doge      .lb-auth-btn,
.thanksgiving .lb-auth-btn,
.valentine .lb-auth-btn,
.july4th   .lb-auth-btn,
.stpatrick .lb-auth-btn,
.newyear   .lb-auth-btn {
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.lb-user-chip {
  display: inline-flex; align-items: center; gap: .55rem;
  background: rgba(250,248,239,.95);
  color: #776e65; border-radius: 999px;
  padding: .3rem .75rem; text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.12); font-weight: 500;
  backdrop-filter: blur(4px);
}
.lb-user-chip img {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  background: #eee;
}
.lb-user-meta { display: flex; flex-direction: column; line-height: 1.05; }
.lb-user-name { font-weight: 700; font-size: 0.9rem; max-width: 14ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-user-score { font-size: 0.75rem; color: #8f7a66; }

/* On the game page the chip is in the corner — keep it compact. */
.lb-auth-fixed .lb-user-meta { display: none; }          /* hide name+score */
.lb-auth-fixed .lb-user-chip  { padding: .25rem; border-radius: 50%; }  /* round avatar */
.lb-auth-fixed .lb-user-chip img { width: 32px; height: 32px; }
@media (min-width: 720px) {
  .lb-auth-fixed .lb-user-meta { display: flex; }                  /* show name on wide screens */
  .lb-auth-fixed .lb-user-chip  { padding: .3rem .75rem; border-radius: 999px; }
}

@media (max-width: 480px) {
  .account-row .lb-user-name { max-width: 7ch; }
  .lb-google-icon { width: 38px; height: 38px; }
  /* Home-page small variant stays small on mobile too. */
  .account-row .lb-google-icon { width: 26px; height: 26px; }
  .account-row .lb-google-mark { width: 18px; height: 18px; }
}

.lb-wrap { max-width: 720px; margin: 0 auto; padding: 1rem; }
.lb-tabs { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.lb-tab {
  appearance: none; border: 1px solid #d8d4ca; background: #fff; color: #776e65;
  padding: .55rem 1rem; cursor: pointer; border-radius: 8px;
  font-weight: 600; font-size: .9rem;
}
.lb-tab[aria-selected="true"] { background: #776e65; color: #faf8ef; border-color: #776e65; }
.lb-tab:focus-visible { outline: 2px solid #8f7a66; outline-offset: 2px; }

.lb-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.lb-table th, .lb-table td {
  padding: .65rem .8rem; text-align: left; font-size: .92rem;
  border-bottom: 1px solid #f0ebe1;
}
.lb-table th { background: #faf8ef; color: #776e65; font-weight: 700; }
.lb-table tbody tr:last-child td { border-bottom: 0; }
.lb-rank  { font-weight: 800; color: #776e65; width: 3ch; }
.lb-name  { font-weight: 600; }
.lb-name small { display: block; color: #8f7a66; font-weight: 400; font-size: .75rem; }
.lb-name img {
  width: 22px; height: 22px; border-radius: 50%; margin-right: .45rem;
  vertical-align: -5px; object-fit: cover; background: #eee;
}
.lb-score { font-weight: 700; color: #776e65; white-space: nowrap; }
.lb-empty { padding: 2rem; text-align: center; color: #8f7a66; }

.lb-mystats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap: .75rem; margin-top: 1.25rem;
}
.lb-stat {
  background: #faf8ef; padding: .75rem 1rem; border-radius: 10px;
  display: flex; flex-direction: column; line-height: 1.1;
}
.lb-stat .lbl { font-size: .75rem; text-transform: uppercase; color: #8f7a66; letter-spacing: .05em; }
.lb-stat .val { font-size: 1.4rem; font-weight: 800; color: #776e65; }

.lb-hint { color: #8f7a66; font-size: .85rem; margin: .25rem 0 1rem; }

/* Popover anchored under the floating auth chip on game pages. */
.lb-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 200px;
  background: #faf8ef;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
  padding: .35rem;
  font-size: .92rem;
  color: #776e65;
  text-align: left;
  z-index: 1001;
  animation: lb-pop-in .12s ease-out;
}
.lb-pop-head {
  padding: .55rem .7rem .4rem;
  border-bottom: 1px solid #eee4da;
  font-weight: 700;
  margin-bottom: .2rem;
  word-break: break-word;
}
.lb-pop-head small {
  display: block;
  font-weight: 500; font-size: .75rem; color: #8f7a66;
  margin-top: 2px;
}
.lb-pop-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
  padding: .55rem .7rem; border-radius: 6px;
  color: #776e65; font-weight: 500; font-size: .9rem;
  text-decoration: none;
}
.lb-pop-item:hover { background: #f1ebd9; color: #4b3e2a; }
.lb-pop-out { color: #b53030; font-weight: 600; }
.lb-pop-out:hover { background: #fde2e2; color: #8a1f1f; }
.lb-auth-fixed { position: fixed; }   /* anchor for popover */

@keyframes lb-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .lb-tab, .lb-auth-btn { transition: none; }
}
