/* ── Stats Screen ───────────────────────────────────── */
/* Everything here is scoped under #screen-stats or classes used
 * exclusively on that screen. Do not add rules that leak outside. */

.stats-container {
  width: 100%;
  max-width: 880px;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 8px;
}

/* ── Profile header (avatar + name + member since) ───── */
.stats-profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}
.stats-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--surface);
}
.stats-profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats-profile-name {
  font-family: var(--font-retro);
  font-size: 16px;
  color: var(--text);
}
.stats-profile-member {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.stats-back {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1;
}

.stats-back:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.stats-header .screen-title {
  margin: 0;
}

/* Nav button on the menu */
.btn-stats-nav {
  background: rgba(0, 184, 255, 0.06);
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-stats-nav:hover {
  color: var(--accent2);
  border-color: var(--accent2);
  background: rgba(0, 184, 255, 0.12);
}

/* Empty state */
.stats-empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.stats-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.stats-empty-title {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.stats-empty-desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* Totals strip */
.stats-totals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}

.stat-tile-label {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-tile-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

/* Card used on the stats screen reuses .card primitives */
.stats-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Favorite system hero line + breakdown bars */
.fav-system {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 2px;
  padding: 4px 0;
  text-align: center;
}

.systems-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sys-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.sys-row-name {
  color: var(--text);
}

.sys-row-bar {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.sys-row-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.sys-row-value {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* Top-N cards (playtime / sessions) */
.stats-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stats-top-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.top-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface2);
  border-radius: 4px;
  font-size: 12px;
}

.top-row-rank {
  color: var(--text-dim);
  font-family: var(--font-pixel);
  font-size: 9px;
}

.top-row-title {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-row-value {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Recently played list */
.stats-recent {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: 4px;
  font-size: 12px;
}

.recent-row-title {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-row-sys {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.recent-row-when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

/* Favorites list — structurally the same as recently-played but the
 * meta column shows "X sessions" / "never played" instead of relative
 * time, and a ★ prefix makes the role obvious. */
.stats-favorites {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: 4px;
  font-size: 12px;
}

.fav-row-star {
  color: var(--accent);
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.fav-row-title {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-row-sys {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.fav-row-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}

.fav-row.unplayed .fav-row-meta {
  opacity: 0.5;
  font-style: italic;
}

/* Full games table */
.stats-games-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.games-table-header,
.games-table-row {
  display: grid;
  grid-template-columns: 60px 1fr 80px 60px 80px 80px 60px 110px;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 11px;
}

.games-table-header {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.games-table-row {
  background: var(--surface2);
  border-radius: 4px;
}

.games-table-row + .games-table-row {
  margin-top: 2px;
}

.games-table-row:hover {
  background: var(--border);
}

.top-row.clickable,
.recent-row.clickable,
.games-table-row.clickable {
  cursor: pointer;
}
.top-row.clickable:hover,
.recent-row.clickable:hover,
.games-table-row.clickable:hover {
  background: rgba(0, 229, 160, 0.08);
}

.col-system {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.col-title {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-playtime,
.col-sessions,
.col-first,
.col-last {
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.col-cheevos {
  color: var(--accent);
  font-family: var(--font-mono);
}

.col-high {
  text-align: right;
  color: var(--accent2);
  font-family: var(--font-mono);
  font-size: 11px;
}

.col-high.col-high-none {
  color: var(--text-dim);
  opacity: 0.5;
}

/* Responsive: collapse the grid on narrow viewports */
@media (max-width: 720px) {
  .stats-totals {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-top-row {
    grid-template-columns: 1fr;
  }
  .games-table-header {
    display: none;
  }
  .games-table-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title    sys"
      "stats    high"
      "cheevos  cheevos";
    gap: 4px;
    padding: 10px;
  }
  .col-title     { grid-area: title; }
  .col-system    { grid-area: sys; }
  .col-playtime  { grid-area: stats; }
  .col-sessions,
  .col-first,
  .col-last      { display: none; }
  .col-cheevos   { grid-area: cheevos; text-align: left; }
  .col-high      { grid-area: high; }
}
