/* ---------- Statystyki gracza i historia gier (stats.js) ---------- */
.stats-screen { display: flex; flex-direction: column; align-items: center; padding: calc(var(--header-h) + 28px) 16px 56px; }
.stats-screen h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800; text-align: center;
  background: linear-gradient(#fffbe0, #eddb5e 50%, #a8872c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #000);
}
.stats-body { display: flex; flex-direction: column; gap: 38px; width: min(1040px, 100%); margin-top: 6px; }
.stats-body > .win { min-width: 0; }
.stats-empty { margin: 0; padding: 14px 6px; text-align: center; color: var(--text-2); line-height: 1.6; }

/* Kafelki podsumowania */
.stats-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: 10px; }
.stats-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 9px 8px 10px; text-align: center;
  border-radius: 8px; background: linear-gradient(#0c0d0d, #1c1a1e); box-shadow: var(--plate-shadow);
}
.stats-tile-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
/* Etykiety w jednej linii wysokości dwóch wierszy: wartości kafelków w rzędzie wyrównane mimo zawijania */
@media (min-width: 641px) { .stats-tile-label { display: flex; align-items: center; min-height: 2.4em; } }
.stats-tile-value {
  max-width: 100%; font-family: var(--font-display); font-size: 1.45rem; line-height: 1.25; color: var(--gold);
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stats-tile-sub { max-width: 100%; font-size: 0.74rem; color: var(--text-2); overflow-wrap: anywhere; }

/* Wykres słupkowy */
.stats-chart { display: flex; gap: 8px; padding: 6px 2px 0; }
.stats-axis { position: relative; flex: none; width: 52px; height: 170px; font-size: 0.7rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.stats-axis span { position: absolute; right: 0; line-height: 1; white-space: nowrap; }
.stats-axis span:first-child { top: -4px; }
.stats-axis span:nth-child(2) { transform: translateY(50%); }
.stats-axis .stats-axis-min { bottom: -4px; }
.stats-plot {
  position: relative; flex: 1; min-width: 0; height: 170px; display: flex; gap: 2px; align-items: stretch;
  border-top: 1px dashed rgba(213, 191, 116, 0.3);
  background:
    linear-gradient(rgba(213, 191, 116, 0.12), rgba(213, 191, 116, 0.12)) 0 25% / 100% 1px no-repeat,
    linear-gradient(rgba(213, 191, 116, 0.12), rgba(213, 191, 116, 0.12)) 0 50% / 100% 1px no-repeat,
    linear-gradient(rgba(213, 191, 116, 0.12), rgba(213, 191, 116, 0.12)) 0 75% / 100% 1px no-repeat,
    rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(174, 161, 161, 0.2);
}
.stats-plot-zero { position: absolute; left: 0; right: 0; bottom: var(--zero, 0); height: 1px; background: rgba(223, 217, 189, 0.6); z-index: 1; }
.stats-bar-col { position: relative; flex: 1 1 0; min-width: 0; max-width: 32px; cursor: default; }
.stats-bar {
  position: absolute; left: 12%; right: 12%; border-radius: 2px 2px 0 0; min-height: 2px;
  background: linear-gradient(#fff2a6, #d5bf74 45%, #9a7a1f); box-shadow: 0 0 6px rgba(237, 219, 94, 0.35);
  transition: filter 0.15s;
}
.stats-bar.negative { border-radius: 0 0 2px 2px; background: linear-gradient(#ff9a97, #f16462 45%, #8b1f1d); box-shadow: 0 0 6px rgba(241, 100, 98, 0.4); }
.stats-bar-col:hover .stats-bar { filter: brightness(1.3); }
.stats-caption { margin: 8px 0 2px; font-size: 0.78rem; color: var(--muted); text-align: center; }

/* Wiersze rekordów i listy TOP 5 */
.stats-rows { list-style: none; margin: 0; padding: 0; }
.stats-rows li {
  display: flex; gap: 10px; align-items: center; padding: 7px 12px; margin-bottom: 5px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.38); box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(174, 161, 161, 0.2); color: var(--title);
}
.stats-rows .name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-rows .detail { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.stats-rows .pts { min-width: 78px; text-align: right; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-rows .pts.negative { color: var(--red); }
.stats-rows li.empty .name { color: var(--muted); }
.stats-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 38px 28px; align-items: start; }
.stats-miss .pts { color: var(--red); }
.stats-pair .leaderboard-list li span:first-child { white-space: normal; overflow-wrap: anywhere; }

/* Historia: wiersz gry rozwijany do listy rund */
.stats-history { list-style: none; margin: 0; padding: 0; }
.stats-history > li { margin-bottom: 6px; }
.stats-game { border-radius: 8px; background: rgba(0, 0, 0, 0.38); box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(174, 161, 161, 0.2); }
.stats-game[open] { box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(237, 219, 94, 0.4); }
.stats-game summary {
  display: flex; gap: 12px; align-items: center; padding: 8px 12px; cursor: pointer; list-style: none; color: var(--title);
}
.stats-game summary::-webkit-details-marker { display: none; }
.stats-game summary::before { content: "▸"; flex: none; color: var(--gold-2); transition: transform 0.15s; }
.stats-game[open] summary::before { transform: rotate(90deg); }
.stats-game summary:hover { background: rgba(237, 219, 94, 0.07); border-radius: 8px; }
.stats-game-date { flex: none; color: var(--text-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.stats-game-mode { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; }
.stats-game .pts { flex: none; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-game .pts.negative { color: var(--red); }
.stats-rounds { list-style: none; margin: 0; padding: 2px 12px 10px 36px; counter-reset: r; }
.stats-rounds li {
  counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(174, 161, 161, 0.15);
}
.stats-rounds li::before {
  content: counter(r); flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-weight: 800; font-size: 0.75rem; color: #1b1405; background: linear-gradient(#fff2a6, #d5bf74 60%, #9a7a1f); box-shadow: 0 0 0 1px #000;
}
.stats-rounds .name { flex: 1; min-width: 0; color: var(--title); font-weight: 700; overflow-wrap: anywhere; }
.stats-rounds .miss { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.stats-rounds li.negative .pts { color: var(--red); }
.stats-rounds .pts { flex: none; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }

.stats-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 760px) {
  .stats-pair { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .stats-screen { padding-left: 8px; padding-right: 8px; }
  .stats-body { gap: 34px; }
  .stats-tiles { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stats-tile-value { font-size: 1.2rem; }
  .stats-axis { width: 44px; font-size: 0.64rem; }
  .stats-plot { gap: 1px; }
  .stats-game summary { flex-wrap: wrap; gap: 4px 10px; padding: 8px 10px; }
  .stats-game-mode { flex-basis: 100%; order: 3; }
  .stats-game-date { flex: 1; }
  .stats-rounds { padding-left: 14px; padding-right: 10px; }
  .stats-rows .detail { display: none; }
  .stats-actions .btn { flex: 1 1 100%; }
}

/* Przycisk otwierający statystyki w oknie Ranking na ekranie startowym */
.stats-open { display: block; width: 100%; margin-top: 12px; }

/* Zakładki ekranu statystyk: statystyki gier i atlas odkryć (atlas.js) */
.stats-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: -10px; }
.stats-tab {
  flex: 0 1 220px; padding: 9px 18px; font: inherit; font-weight: 700; color: var(--text-2); cursor: pointer;
  border: 0; border-radius: 8px; background: linear-gradient(#0c0d0d, #1c1a1e); box-shadow: var(--plate-shadow);
}
.stats-tab:hover { color: #fff; box-shadow: inset 0 0 0 1px var(--gold-2), inset 0 0 0 3px #0c0d0d; }
.stats-tab.active { color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-2), inset 0 0 0 3px #0c0d0d, 0 0 10px rgba(237, 219, 94, 0.25); }
@media (max-width: 640px) {
  .stats-tab { flex: 1 1 0; padding: 9px 8px; }
}
