/* ==========================================================================
   ACIDVERSE LEADERBOARD — neon retro-futuristic scoreboard
   Styling for the "Psychonauts" boards shown in the lobby and the exit screen,
   the name modal, and the glitch flourish that fires when a player climbs.
   Leans on the site's existing tokens (--cyan / --magenta / --violet) so it
   reads as part of the same lattice.
   ========================================================================== */

/* Let the lobby + death overlays scroll once the board is added, so neither
   can trap content off-screen on short viewports. */
.g3d-intro, .g3d-death { overflow-y: auto; }

.lb-board{
  width: min(440px, 92vw);
  margin: 22px auto 4px;
  padding: 16px 16px 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(139,92,246,.06), rgba(0,240,255,.03)),
    rgba(9,7,18,.72);
  box-shadow: inset 0 0 40px rgba(139,92,246,.06), 0 0 0 1px rgba(0,240,255,.05);
  position: relative;
  overflow: hidden;
}
/* faint scanlines for the CRT feel */
.lb-board::before{
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px);
  pointer-events: none;
  opacity: .5;
}

.lb-head{ display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.lb-glyph{ color: var(--magenta); font-size: 1rem; text-shadow: 0 0 12px var(--magenta); }
.lb-title{
  font-family: var(--f-display); font-weight: 800;
  font-size: .95rem; letter-spacing: .18em; margin: 0;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  position: relative;
}
.lb-week{
  margin-left: auto;
  font-family: var(--f-mono); font-size: .6rem; letter-spacing: .08em;
  color: var(--text-faint); text-transform: uppercase;
}

/* ---- tabs ---------------------------------------------------------------- */
.lb-tabs{ display: flex; gap: 6px; margin-bottom: 12px; }
.lb-tab{
  flex: 1;
  padding: 7px 4px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--f-mono); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.lb-tab:hover{ color: var(--text); border-color: var(--violet); }
.lb-tab.active{
  color: #05040c;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-color: transparent;
  box-shadow: 0 0 16px rgba(0,240,255,.35);
}

/* ---- rows ---------------------------------------------------------------- */
.lb-list{ list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.lb-row, .lb-self, .lb-search-hit{
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .78rem;
  background: rgba(255,255,255,.015);
  border: 1px solid transparent;
}
.lb-rank{ color: var(--violet); font-weight: 500; text-align: center; }
.lb-name{
  color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-score{ color: var(--cyan); font-weight: 500; text-shadow: 0 0 10px rgba(0,240,255,.35); }

.lb-row.top1 .lb-rank{ color: var(--magenta); text-shadow: 0 0 12px var(--magenta); }
.lb-row.top1{ border-color: rgba(255,47,216,.35); background: rgba(255,47,216,.06); }
.lb-row.top2 .lb-rank{ color: var(--cyan); }
.lb-row.top3 .lb-rank{ color: var(--violet); }

.lb-row.me{
  border-color: rgba(0,240,255,.5);
  background: rgba(0,240,255,.07);
  box-shadow: 0 0 14px rgba(0,240,255,.12);
}
.lb-row.me .lb-name::after{ content: " · you"; color: var(--text-faint); font-size: .66rem; }

/* Unclaimed positions on the ten-deep ladder — dimmed and dashed so the board
   always reads as a full top 10 without pretending the slots are taken. */
.lb-row.lb-open{
  background: transparent;
  border: 1px dashed var(--line);
}
.lb-row.lb-open .lb-rank{ color: var(--text-faint); }
.lb-row.lb-open .lb-name{ color: var(--text-faint); font-style: italic; }
.lb-row.lb-open .lb-score{ color: var(--text-faint); text-shadow: none; }

.lb-empty{
  padding: 16px 8px; text-align: center; color: var(--text-faint);
  font-family: var(--f-mono); font-size: .7rem; line-height: 1.5;
}

/* skeleton shimmer while the first fetch lands */
.lb-skeleton{ grid-template-columns: 34px 1fr; }
.lb-skeleton span{
  height: 9px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.1), rgba(255,255,255,.04));
  background-size: 200% 100%;
  animation: lbShimmer 1.2s linear infinite;
}
.lb-skeleton span:last-child{ width: 40%; }
@keyframes lbShimmer{ from{ background-position: 200% 0; } to{ background-position: -200% 0; } }

/* the player's own standing when they fall outside the visible top 10 */
.lb-self{
  position: relative;
  margin-top: 8px;
  border: 1px dashed rgba(0,240,255,.4);
  background: rgba(0,240,255,.05);
}
.lb-self .lb-rank{ color: var(--cyan); }

/* ---- friend / shared link banner ---------------------------------------- */
.lb-friend{
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px; padding: 8px 10px;
  border: 1px solid rgba(139,92,246,.4);
  border-radius: var(--radius);
  background: rgba(139,92,246,.08);
  font-family: var(--f-mono); font-size: .7rem; color: var(--text-dim);
}
.lb-friend strong{ color: var(--violet); }
.lb-friend-cap{ text-transform: uppercase; font-size: .58rem; letter-spacing: .1em; color: var(--text-faint); }
.lb-friend button{ margin-left: auto; }

/* ---- search -------------------------------------------------------------- */
.lb-search{ margin-top: 12px; position: relative; }
.lb-search-input{
  width: 100%; box-sizing: border-box;
  padding: 9px 11px;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--f-mono); font-size: .72rem;
}
.lb-search-input::placeholder{ color: var(--text-faint); }
.lb-search-input:focus{ outline: none; border-color: var(--cyan); box-shadow: 0 0 12px var(--cyan-soft); }
.lb-search-results{ margin-top: 6px; display: grid; gap: 3px; }
.lb-search-hit{ cursor: pointer; text-align: left; width: 100%; }
.lb-search-hit:hover{ border-color: var(--violet); background: rgba(139,92,246,.08); }
.lb-search-empty{
  padding: 8px; text-align: center; color: var(--text-faint);
  font-family: var(--f-mono); font-size: .68rem;
}

/* ---- identity row -------------------------------------------------------- */
.lb-id{
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 13px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono); font-size: .7rem; color: var(--text-dim);
}
.lb-id strong{ color: var(--cyan); }
.lb-mini{
  padding: 5px 10px;
  background: transparent; border: 1px solid var(--cyan); color: var(--cyan);
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer; transition: box-shadow .15s ease, background .15s ease;
}
.lb-mini:hover{ box-shadow: 0 0 14px var(--cyan-soft); background: var(--cyan-soft); }
.lb-mini.ghost{ border-color: var(--line); color: var(--text-dim); }
.lb-mini.ghost:hover{ border-color: var(--magenta); color: var(--magenta); box-shadow: none; }
.lb-join{
  width: 100%;
  padding: 11px;
  background: var(--magenta-soft); border: 1px solid var(--magenta); color: var(--magenta);
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; transition: box-shadow .2s ease;
}
.lb-join:hover{ box-shadow: 0 0 22px rgba(255,47,216,.35); }

/* ---- glitch on a new high score ----------------------------------------- */
.lb-glitch{ animation: lbShake .32s steps(2) 0s 2; }
.lb-glitch .lb-title{ animation: lbChroma .3s steps(2) 0s 3; }
@keyframes lbShake{
  0%{ transform: translate(0,0); }
  25%{ transform: translate(-2px,1px); }
  50%{ transform: translate(2px,-1px); }
  75%{ transform: translate(-1px,-1px); }
  100%{ transform: translate(0,0); }
}
@keyframes lbChroma{
  0%{ text-shadow: 2px 0 var(--magenta), -2px 0 var(--cyan); }
  50%{ text-shadow: -3px 0 var(--magenta), 3px 0 var(--cyan); }
  100%{ text-shadow: 0 0 transparent; }
}
/* clipped ghost of the title flickering during a glitch */
.lb-glitch .lb-title::after{
  content: attr(data-text);
  position: absolute; left: 0; top: 0;
  -webkit-text-fill-color: var(--magenta); color: var(--magenta);
  clip-path: inset(0 0 55% 0);
  animation: lbSlice .3s steps(2) infinite;
}
@keyframes lbSlice{
  0%{ transform: translate(-2px,0); opacity: .9; }
  50%{ transform: translate(3px,-1px); opacity: .5; }
  100%{ transform: translate(-2px,1px); opacity: .8; }
}

/* ---- name modal ---------------------------------------------------------- */
.lb-modal{
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4,3,9,.78);
  backdrop-filter: blur(7px);
  animation: lbFade .2s ease;
}
@keyframes lbFade{ from{ opacity: 0; } to{ opacity: 1; } }
.lb-modal-card{
  width: min(420px, 94vw);
  padding: 26px 24px 22px;
  border: 1px solid var(--violet);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(139,92,246,.16), transparent 60%),
    rgba(9,7,18,.96);
  box-shadow: 0 0 44px rgba(139,92,246,.28), inset 0 0 30px rgba(0,240,255,.05);
  text-align: center;
}
.lb-modal-eyebrow{
  margin: 0 0 6px; font-family: var(--f-mono); font-size: .64rem;
  letter-spacing: .22em; text-transform: uppercase; color: var(--magenta);
}
.lb-modal-title{
  font-family: var(--f-display); font-weight: 800; font-size: 1.15rem; letter-spacing: .1em;
  margin: 0 0 8px; position: relative; display: inline-block;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lb-modal-sub{ margin: 0 0 18px; color: var(--text-dim); font-size: .8rem; line-height: 1.5; }
.lb-modal-inputrow{ display: flex; gap: 8px; }
.lb-modal-input{
  flex: 1; box-sizing: border-box;
  padding: 12px 14px;
  background: rgba(0,0,0,.4); border: 1px solid var(--cyan);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--f-mono); font-size: .95rem; letter-spacing: .04em;
  text-align: center;
}
.lb-modal-input:focus{ outline: none; box-shadow: 0 0 16px var(--cyan-soft); }
.lb-modal-shuffle{
  width: 46px; flex: none;
  background: var(--violet-soft); border: 1px solid var(--violet); color: var(--violet);
  border-radius: var(--radius); font-size: 1.1rem; cursor: pointer;
  transition: transform .3s ease, box-shadow .2s ease;
}
.lb-modal-shuffle:hover{ transform: rotate(180deg); box-shadow: 0 0 16px var(--violet-soft); }
.lb-modal-err{ margin: 10px 0 0; color: #ff5b7a; font-family: var(--f-mono); font-size: .7rem; }
.lb-modal-welcome{
  margin: 12px 0 0; padding: 9px 11px;
  border: 1px solid var(--cyan); border-radius: var(--radius);
  background: var(--cyan-soft); color: var(--cyan);
  font-family: var(--f-mono); font-size: .72rem; line-height: 1.4;
  box-shadow: 0 0 16px var(--cyan-soft);
}
.lb-modal-welcome[hidden]{ display: none; }
.lb-modal-actions{ display: flex; gap: 10px; margin-top: 18px; }
.lb-modal-cancel, .lb-modal-go{
  flex: 1; padding: 12px;
  border-radius: var(--radius);
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; transition: box-shadow .2s ease;
}
.lb-modal-cancel{ background: transparent; border: 1px solid var(--line); color: var(--text-dim); }
.lb-modal-cancel:hover{ border-color: var(--text-dim); color: var(--text); }
.lb-modal-go{
  background: linear-gradient(90deg, var(--cyan), var(--violet)); border: none; color: #05040c; font-weight: 600;
}
.lb-modal-go:hover{ box-shadow: 0 0 24px rgba(0,240,255,.4); }
.lb-modal-go:disabled{ opacity: .6; cursor: progress; box-shadow: none; }

@media (max-width: 520px){
  .lb-board{ margin-top: 16px; padding: 13px; }
  .lb-row, .lb-self, .lb-search-hit{ font-size: .72rem; padding: 6px 8px; }

  /* On phones the lobby + death overlays are taller than the screen. Centring
     them (justify-content: center) pushes the top of the stack above the
     scroll origin, so the board — now sitting near the top — got clipped.
     Anchor the content to the top instead: everything, board and buttons
     alike, becomes reachable by scrolling. */
  .g3d-intro, .g3d-death{ justify-content: flex-start; padding-top: 28px; padding-bottom: 36px; }
}
