/* ═══════════════════════════════════════════════════════════════════════════════
   Mahjong Statistics & Personal Records · Modal Styles
   Clean, Apple Fitness-inspired metrics & layout leaderboard.
   ═══════════════════════════════════════════════════════════════════════════════ */

.stats-modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 22, 0.82);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 991;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.stats-modal.hidden {
  display: none !important;
}

.stats-modal-card {
  width: min(520px, 100%);
  background: #fffdf8;
  border: 1px solid #e1d9c9;
  border-radius: 24px;
  padding: 28px 26px;
  box-shadow: 0 28px 70px rgba(9, 20, 15, 0.45);
  position: relative;
  text-align: center;
  animation: statsCardPop 0.32s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes statsCardPop {
  0% { transform: scale(0.92) translateY(12px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.stats-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fffaf1;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.stats-close-btn:hover {
  background: #f4eee2;
  color: var(--ink);
  transform: scale(1.08);
}

.stats-header-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e3f2eb, #c5e4d5);
  color: var(--jade);
  font-size: 26px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 14px rgba(21, 61, 50, 0.2);
}

.stats-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--jade);
  margin: 0 0 4px;
}

.stats-modal-card h2 {
  font: 700 26px/1.15 'Playfair Display', serif;
  color: var(--ink);
  margin: 0 0 16px;
}

/* ── 4-Metric Grid ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.stats-tile {
  background: #f8f4eb;
  border: 1px solid #e7ded0;
  border-radius: 16px;
  padding: 12px 14px;
  text-align: left;
}
.stats-tile span {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.stats-tile strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  margin-top: 4px;
}
.stats-tile small {
  display: block;
  font-size: 10px;
  color: var(--jade);
  font-weight: 600;
  margin-top: 2px;
}

/* ── Layout Personal Bests Table ─────────────────────────────────────────── */
.stats-table-heading {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  margin: 0 0 8px 4px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: #faf6ed;
  border: 1px solid #e8e1d3;
  border-radius: 16px;
  overflow: hidden;
  font-size: 11px;
  margin-bottom: 20px;
}
.stats-table th {
  background: #f1ebd9;
  padding: 8px 10px;
  font-weight: 700;
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stats-table td {
  padding: 8px 10px;
  border-top: 1px solid #ede5d7;
  text-align: left;
  color: var(--ink);
}
.stats-table tr:hover td {
  background: #f6f0df;
}
.stats-table .layout-name-cell {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stats-reset-link {
  font-size: 10px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 6px;
  transition: color 0.15s;
}
.stats-reset-link:hover {
  color: #c0392b;
}

@media(max-width: 600px) {
  .stats-modal-card {
    padding: 20px 16px;
    border-radius: 18px;
  }
  .stats-tile strong {
    font-size: 18px;
  }
}
