/* ========================================================================
   arena.css — leaderboard / tiers / reward-pool page.
   This page SCROLLS (the game grid does not). We override the locked
   html/body overflow from styles.css and use a flow layout instead of
   the fixed #app game grid. Colors/typography reuse the shared theme.
   ======================================================================== */

html.arena-html,
body.arena-body {
  height: auto;
  min-height: 100%;
  overflow: hidden auto; /* scrolling page, not the game grid */
}

/* sticky shared header, full width */
.arena-header {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* main scrolling column */
#arena {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.arena-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  overflow: hidden;
}
.arena-panel .panel-head {
  border-bottom: 1px solid var(--border);
  position: static; /* not sticky inside cards */
}

/* ---------------- 1) reward-pool hero ---------------- */
.hero-card {
  position: relative;
  border: 1px solid var(--border-2);
  border-radius: 14px;
  background:
    radial-gradient(900px 300px at 0% 0%, rgba(153, 69, 255, 0.16), transparent 60%),
    radial-gradient(900px 300px at 100% 100%, rgba(20, 241, 149, 0.12), transparent 60%),
    var(--panel);
  padding: 22px 24px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sol-purple), var(--sol-green));
}
.hero-main {
  min-width: 280px;
  flex: 1 1 360px;
}
.hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-dim);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.hero-tag {
  color: var(--text-faint);
  font-weight: 600;
}
.hero-number {
  font-size: 54px;
  line-height: 1.02;
  font-weight: 800;
  margin: 8px 0 6px;
  letter-spacing: -1px;
  background: linear-gradient(90deg, var(--sol-purple), var(--sol-green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}
.hero-sub {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 520px;
}
.hero-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
}
.hero-side-block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  text-align: right;
}
.hero-side-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  font-weight: 700;
}
.hero-countdown {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}
.hero-side-sub {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
}
.hero-yours {
  font-size: 22px;
  font-weight: 800;
  color: var(--sol-green);
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
}

.policy-note {
  margin: -4px 2px 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-dim);
  border-left: 2px solid var(--sol-purple);
  padding: 6px 0 6px 12px;
}
.policy-note strong {
  color: var(--text);
}

/* ---------------- 2) tier ladder ---------------- */
.tier-ladder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tier-rung {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  position: relative;
}
.tier-rung.you-are-here {
  outline: 1.5px solid var(--sol-green);
  outline-offset: -1px;
  background: linear-gradient(90deg, rgba(20, 241, 149, 0.08), transparent 70%),
    var(--panel-2);
}
.tier-rung .tr-ico {
  font-size: 22px;
  width: 30px;
  text-align: center;
  flex: 0 0 auto;
}
.tier-rung .tr-mid {
  flex: 1;
  min-width: 0;
}
.tier-rung .tr-name {
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tier-rung .tr-here-pill {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #06210f;
  background: var(--sol-green);
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 800;
}
.tier-rung .tr-range {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.tier-rung .tr-need {
  color: var(--sol-green);
  font-weight: 700;
}
.tier-rung .tr-stats {
  display: flex;
  gap: 18px;
  flex: 0 0 auto;
  text-align: right;
}
.tier-rung .tr-stat .k {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 700;
}
.tier-rung .tr-stat .v {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tier-rung .tr-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--tc, var(--accent));
  opacity: 0.7;
}

/* ---------------- 4) leaderboard table ---------------- */
.board-wrap {
  overflow-x: auto;
}
table.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.board thead th {
  position: sticky;
  top: 46px; /* under sticky header */
  background: var(--panel);
  color: var(--text-dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 3;
}
table.board thead th.col-rank,
table.board thead th.col-office,
table.board thead th.col-tier,
table.board thead th.col-seen {
  text-align: left;
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  color: var(--text);
}
th.sortable.sort-active {
  color: var(--sol-green);
}
th.sortable .arrow {
  font-size: 8px;
  opacity: 0.9;
}

table.board tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.board tbody td.col-rank,
table.board tbody td.col-office,
table.board tbody td.col-tier,
table.board tbody td.col-seen {
  text-align: left;
}
table.board tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

td.col-rank {
  color: var(--text-faint);
  font-weight: 700;
  width: 34px;
}
td.col-rank .medal {
  font-size: 13px;
}

.office-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.office-cell .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 5px var(--dc, transparent);
}
.office-cell .o-name {
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.office-cell a.o-addr {
  color: var(--text-faint);
  text-decoration: none;
  font-size: 10px;
}
.office-cell a.o-addr:hover {
  color: var(--sol-green);
  text-decoration: underline;
}
.verified {
  color: var(--sol-green);
  font-size: 11px;
}

/* your-row highlight (persistent) */
tr.you-row td {
  background: var(--panel-3) !important;
  border-bottom-color: var(--border);
}
tr.you-row td.col-rank {
  border-left: 3px solid var(--sol-green);
  padding-left: 7px;
}
tr.you-row .o-name::after {
  content: " · you";
  color: var(--sol-green);
  font-size: 10px;
  font-weight: 700;
}

/* last-seen */
.seen-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 11px;
}
.seen-cell .live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sol-green);
  box-shadow: 0 0 6px var(--sol-green);
  flex: 0 0 auto;
  animation: seenPulse 1.6s ease-in-out infinite;
}
.seen-cell.recent .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--work);
  flex: 0 0 auto;
}
.seen-cell.stale .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}
.seen-cell.recent {
  color: var(--text-dim);
}
@keyframes seenPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.col-score-v {
  color: var(--text);
  font-weight: 700;
}
.col-life-v {
  color: var(--sol-green);
  font-weight: 700;
}

/* row flash when score climbs (mirrors the office tx ticker "live" feel) */
@keyframes rowFlash {
  0% { background: rgba(20, 241, 149, 0.22); }
  100% { background: transparent; }
}
tr.row-flash td {
  animation: rowFlash 1.1s ease;
}
tr.you-row.row-flash td {
  animation: rowFlash 1.1s ease;
}

/* ---------------- 5) your-rank spotlight ---------------- */
.yr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}
.yr-stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
}
.yr-stat .k {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 700;
}
.yr-stat .v {
  font-size: 18px;
  font-weight: 800;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.yr-stat .v.big {
  background: linear-gradient(90deg, var(--sol-purple), var(--sol-green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.yr-rival {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.yr-rival .txt {
  font-size: 12px;
  color: var(--text-dim);
}
.yr-rival .txt b {
  color: var(--text);
}
.yr-rival .txt .gap {
  color: var(--accent-2);
  font-weight: 700;
}
.yr-cta {
  display: inline-block;
  text-decoration: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(90deg, var(--sol-purple), #6f3fd6);
}
.yr-cta:hover {
  filter: brightness(1.12);
}

/* empty state */
.yr-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.yr-empty .txt {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}
.yr-empty .txt b {
  color: var(--text);
}

/* ---------------- 6) per-achievement world records ---------------- */
.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.record-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 11px 12px;
}
.record-card.you-hold {
  outline: 1.5px solid var(--sol-green);
  outline-offset: -1px;
}
.record-head {
  display: flex;
  align-items: center;
  gap: 9px;
}
.record-head .ico {
  font-size: 20px;
  flex: 0 0 auto;
}
.record-head .nm {
  font-weight: 700;
  font-size: 12px;
}
.record-head .pts {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
}
.record-wr {
  margin-top: 9px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.record-wr .time {
  font-size: 22px;
  font-weight: 800;
  color: var(--sol-green);
  font-variant-numeric: tabular-nums;
}
.record-wr .day {
  font-size: 10px;
  color: var(--text-faint);
}
.record-wr.empty .time {
  color: var(--text-faint);
}
.record-holder {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.record-holder a {
  color: var(--accent);
  text-decoration: none;
}
.record-holder a:hover {
  text-decoration: underline;
}
.record-you {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.record-you b {
  color: var(--text);
}
.record-you.locked b {
  color: var(--text-faint);
}

.your-key {
  color: var(--sol-green);
  font-weight: 700;
}

.arena-foot {
  text-align: center;
  color: var(--text-faint);
  font-size: 10px;
  padding: 10px 0 0;
}

/* responsive */
/* ── winner-takes-all hero additions ── */
.hero-leader {
  margin-top: 12px;
  padding: 9px 13px;
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--sol-green);
  border-radius: 8px;
  background: rgba(20, 241, 149, 0.06);
  font-size: 14px;
  color: var(--text-dim);
}
.hero-leader .crown { font-size: 16px; }
.hero-leader b { color: var(--text); }

.hero-countdown.urgent {
  color: var(--bad);
  animation: pulseUrgent 1s ease-in-out infinite;
}
@keyframes pulseUrgent {
  50% { opacity: 0.55; }
}

.winner-banner {
  margin: 14px 0 0;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #1c5a3a;
  background: linear-gradient(90deg, rgba(153, 69, 255, 0.18), rgba(20, 241, 149, 0.14));
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.winner-banner.show { opacity: 1; transform: translateY(0); }

.recent-winners {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 11px;
}
.recent-winners .rw-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}
.rw-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  color: var(--text-dim);
}
.rw-chip .rw-ep { color: var(--text-faint); }
.rw-chip b { color: var(--sol-green); }
.rw-chip .rw-pool { color: var(--work); margin-left: 4px; }

/* responsive */
@media (max-width: 720px) {
  .hero-number { font-size: 40px; }
  .tier-rung .tr-stats { display: none; }
}
