/* ============================================================================
   Leaderboard styles - shared between the in-app modal and the projector page.
   The same .lb-table renderer drives both. .lb-mode-projector amplifies type.
   ========================================================================= */

.screen--leaderboard {
  z-index: 50;
  background: rgba(14, 24, 32, 0.65);
  backdrop-filter: blur(8px);
}

.leaderboard-panel {
  /* Notes Round 3: tighter modal so it sits cleanly inside the dark
     overlay instead of bleeding to the screen edges. */
  max-width: 580px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100dvh - 64px);
  margin: 24px auto;
}

.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.lb-header h2 {
  margin: 0;
  font-size: clamp(1.3rem, 4.6vw, 1.7rem);
  font-weight: 800;
  background: linear-gradient(180deg, #ffffff 0%, var(--enko-primary-light) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lb-counts {
  font-size: clamp(0.82rem, 2.8vw, 0.95rem);
  color: var(--text-soft);
  display: flex;
  gap: 8px;
  align-items: center;
}
.lb-counts strong { color: var(--text-on-dark); font-weight: 700; }
.dot-sep { color: var(--text-muted); }

.lb-close {
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: var(--text-on-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lb-close:hover { background: rgba(255,255,255,0.14); }
.lb-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(140, 217, 255, 0.5);
}

/* ---------------- Table ---------------- */

.lb-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  margin: 0;
  padding: 0;
}

.lb-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.lb-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: clamp(10px, 2.4vw, 14px) clamp(10px, 2.4vw, 14px);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  transition: background 0.18s, border-color 0.18s, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.lb-row.is-self {
  background: linear-gradient(180deg, rgba(41,166,156,0.22), rgba(41,166,156,0.10));
  border-color: rgba(41,166,156,0.55);
}
.lb-row.is-up    { animation: rowUp   0.6s ease-out; }
.lb-row.is-down  { animation: rowDown 0.6s ease-out; }
.lb-row.is-new   { animation: rowNew  0.6s ease-out; }
/* Placeholder row - shown on the big-screen leaderboard when fewer than
   10 valid runs exist, so the board always reads as exactly 10 slots.
   Notes Round 3: "should show the top 10 always". Muted styling so the
   real rows still pop visually. */
.lb-row.is-placeholder {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.05);
  opacity: 0.6;
}
.lb-row.is-placeholder .lb-rank {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
}
.lb-row.is-placeholder .lb-name { color: rgba(255, 255, 255, 0.55); font-style: italic; }
.lb-row.is-placeholder .lb-score-num { color: rgba(255, 255, 255, 0.4); }
/* Placeholders don't get gold/silver/bronze top-3 treatment. */
.lb-row.is-placeholder[data-rank="1"] .lb-rank,
.lb-row.is-placeholder[data-rank="2"] .lb-rank,
.lb-row.is-placeholder[data-rank="3"] .lb-rank {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
}
.lb-row.is-placeholder[data-rank="1"]:not(.is-up):not(.is-down):not(.is-new) {
  animation: none;
}
@keyframes rowUp   { 0% { box-shadow: 0 0 0 0 rgba(140,217,255,0.6); } 50% { box-shadow: 0 0 0 6px rgba(140,217,255,0.0); } }
@keyframes rowDown { 0% { box-shadow: 0 0 0 0 rgba(255,123,123,0.45); } 50% { box-shadow: 0 0 0 6px rgba(255,123,123,0); } }
@keyframes rowNew  { 0% { transform: translateY(-12px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Rank #1: continuous subtle gold pulse. Box-shadow only - no transform,
   no position shift, so the row never "jumps". The transient is-up class
   above overrides for ~0.6s when the player just took the lead. */
.lb-row[data-rank="1"]:not(.is-up):not(.is-down):not(.is-new) {
  animation: leadPulse 3.2s ease-in-out infinite;
}
@keyframes leadPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 224, 138, 0); }
  50%      { box-shadow: 0 0 22px 1px rgba(255, 224, 138, 0.22); }
}

.lb-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 8vw, 48px);
  height: clamp(36px, 8vw, 48px);
  border-radius: 50%;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.95rem, 3.4vw, 1.1rem);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  color: #fff;
}
.lb-row[data-rank="1"] .lb-rank {
  background: linear-gradient(180deg, #FFE08A 0%, #C09532 100%);
  border-color: #FFE08A;
  color: #1A272E;
  text-shadow: none;
}
.lb-row[data-rank="2"] .lb-rank {
  background: linear-gradient(180deg, #DDE3E8 0%, #8A98A6 100%);
  border-color: #DDE3E8;
  color: #1A272E;
}
.lb-row[data-rank="3"] .lb-rank {
  background: linear-gradient(180deg, #E0A476 0%, #8C5A33 100%);
  border-color: #E0A476;
  color: #1A272E;
}

.lb-id { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.lb-name {
  font-weight: 700;
  font-size: clamp(0.95rem, 3.2vw, 1.05rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-name .lb-self-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.66em;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #1A272E;
  background: var(--enko-signal);
  border-radius: 4px;
  vertical-align: middle;
}
.lb-company {
  font-size: clamp(0.78rem, 2.8vw, 0.86rem);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lb-score-num {
  font-size: clamp(1.05rem, 3.6vw, 1.25rem);
  font-weight: 800;
}
.lb-plays {
  font-size: clamp(0.7rem, 2.4vw, 0.78rem);
  color: var(--text-muted);
}

.lb-empty {
  padding: clamp(20px, 6vw, 40px);
  text-align: center;
  color: var(--text-soft);
  font-size: clamp(0.95rem, 3.4vw, 1.05rem);
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255,255,255,0.12);
}

.lb-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.lb-refresh-note {
  font-size: clamp(0.75rem, 2.6vw, 0.85rem);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lb-refresh-note::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--enko-secondary);
  box-shadow: 0 0 0 0 rgba(41, 166, 156, 0.6);
  animation: pulseDot 1.6s infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(41, 166, 156, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(41, 166, 156, 0); }
  100% { box-shadow: 0 0 0 0 rgba(41, 166, 156, 0); }
}

/* ---------------- Projector mode (.lb-mode-projector) ---------------- */
/* All sizes use clamp(min, vw, max) so the layout doesn't break at 4K
   (where pure 2.4vw would render the score at ~92 px and crowd the row). */

.lb-mode-projector {
  font-size: clamp(0.95rem, 1.4vw, 1.5rem);
}
.lb-mode-projector .lb-row {
  grid-template-columns: clamp(72px, 8vw, 132px) 1fr auto;
  padding: clamp(10px, 1.4vh, 22px) clamp(14px, 1.6vw, 28px);
  gap: clamp(12px, 1.4vw, 24px);
}
.lb-mode-projector .lb-rank {
  width:  clamp(56px, 4.6vw, 96px);
  height: clamp(56px, 4.6vw, 96px);
  font-size: clamp(1.4rem, 2.2vw, 2.6rem);
}
.lb-mode-projector .lb-name      { font-size: clamp(1.2rem, 1.8vw, 2.4rem); }
.lb-mode-projector .lb-company   { font-size: clamp(0.8rem, 1.1vw, 1.4rem); }
.lb-mode-projector .lb-score-num { font-size: clamp(1.5rem, 2.4vw, 3.2rem); }
.lb-mode-projector .lb-plays     { font-size: clamp(0.75rem, 1.0vw, 1.2rem); }

@media (prefers-reduced-motion: reduce) {
  .lb-row.is-up, .lb-row.is-down, .lb-row.is-new { animation: none; }
}

/* ---------------- Player-rank banner (in-app modal only) ---------------- */
/* Surfaces "Dein Platz: 12 von 87" prominently above the scrolling list so
   the player walks away knowing their standing even on a long Top 50. */
.lb-yourrank {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(140,217,255,0.18), rgba(41,166,156,0.18));
  border: 1px solid rgba(140,217,255,0.35);
  color: var(--text-on-dark);
  font-weight: 700;
  font-size: clamp(0.9rem, 3vw, 1rem);
  letter-spacing: 0.01em;
}
.lb-yourrank--top3 {
  background: linear-gradient(90deg, rgba(250,250,100,0.22), rgba(41,166,156,0.22));
  border-color: rgba(250,250,100,0.55);
  color: #FFFEC9;
  text-shadow: 0 0 12px rgba(250,250,100,0.45);
}
.lb-yourrank[hidden] { display: none; }

/* ============================================================================
   Mobile leaderboard tightening (Notes §9.1)
   ============================================================================
   The default row uses `grid-template-columns: 56px 1fr auto` and a fairly
   chunky padding. On phones the rank pill ends up too big, the "DU" badge
   crowds the name, and column widths cause the score to wrap. Squeeze the
   layout for ≤480 px so all three columns sit comfortably on one row. */
@media (max-width: 480px) {
  .leaderboard-panel { padding: 14px; gap: 12px; }
  .lb-header h2 { font-size: 1.25rem; }
  .lb-counts {
    font-size: 0.78rem;
    flex: 1 0 100%;
    order: 3;
    justify-content: flex-start;
  }
  .lb-table { gap: 4px; }
  .lb-row {
    grid-template-columns: 38px 1fr auto;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
  }
  .lb-rank {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  .lb-id { gap: 1px; }
  .lb-name {
    font-size: 0.92rem;
    /* Allow the "Du" badge to wrap to a second visual line when needed -
       earlier builds clipped it under the score column on narrow phones. */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.15;
  }
  .lb-name .lb-self-badge {
    margin-left: 4px;
    padding: 0 4px;
    font-size: 0.58em;
  }
  .lb-company {
    font-size: 0.72rem;
  }
  .lb-score-num { font-size: 1.05rem; }
  .lb-plays { font-size: 0.66rem; }
  .lb-yourrank {
    padding: 8px 12px;
    font-size: 0.88rem;
  }
  .lb-row[data-rank="1"] .lb-rank,
  .lb-row[data-rank="2"] .lb-rank,
  .lb-row[data-rank="3"] .lb-rank {
    /* Same gradient treatment but tighter font so the digit doesn't
       overflow the smaller circle. */
    font-size: 0.95rem;
  }
}

@media (max-width: 360px) {
  /* Very narrow phones: hide the company line below the name so the
     row stays a single visual block instead of stacking three lines. */
  .lb-row .lb-company { display: none; }
}

