:root {
  --bg: #0f1020;
  --bg-card: #1a1b35;
  --bg-card-hover: #232544;
  --text: #f1f1f5;
  --text-dim: #9b9bb0;
  --accent: #ff6fa8;
  --holo-blue: #00a3ee;

  --bang:   #ff3b3b;
  --wife:   #facc15;
  --friend: #5fc9f8;

  --border: #2c2e4f;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at top, #1c1e3f 0%, #0f1020 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.site-header {
  text-align: center;
  padding: 28px 16px 8px;
}

.site-header h1 {
  margin: 0;
  font-size: 2.6rem;
  letter-spacing: 0.08em;
  color: var(--holo-blue);
  text-shadow: 0 0 18px rgba(0,163,238,0.35);
  font-weight: 800;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
}

/* ---------- Category legend ---------- */
.legend {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin: 20px auto 28px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.legend-item        { text-shadow: 0 0 14px currentColor; }
.legend-bang        { color: var(--bang);   }
.legend-wife        { color: var(--wife);   }
.legend-friend      { color: var(--friend); }

@media (max-width: 540px) {
  .legend { gap: 18px; font-size: 1.2rem; letter-spacing: 0.12em; }
}

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 32px;
}

@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  user-select: none;
}

.card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card.cat-bang   { border-color: var(--bang);   box-shadow: 0 0 0 2px var(--bang)   inset, var(--shadow); }
.card.cat-wife   { border-color: var(--wife);   box-shadow: 0 0 0 2px var(--wife)   inset, var(--shadow); }
.card.cat-friend { border-color: var(--friend); box-shadow: 0 0 0 2px var(--friend) inset, var(--shadow); }

.card-image-wrap {
  aspect-ratio: 1 / 1;
  background: #0a0b18;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--text);
  background: linear-gradient(135deg, var(--placeholder-a, #6f6fff), var(--placeholder-b, #ff6fa8));
  letter-spacing: 0.05em;
}

.placeholder small {
  margin-top: 12px;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
}

.badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  pointer-events: none;
}

.badge.cat-bang   { background: var(--bang);   }
.badge.cat-wife   { background: var(--wife);   color: #1a1300; text-shadow: none; }
.badge.cat-friend { background: var(--friend); }

.card-info {
  padding: 12px 16px 16px;
  text-align: center;
}

.card-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.card-meta {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: 32px;
}

.btn {
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 12px 28px;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--holo-blue);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-left: 36px;
  padding-right: 36px;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-tertiary {
  background: transparent;
  color: var(--text-dim);
  border-color: transparent;
}

.btn-tertiary:hover { color: var(--text); }

/* Secondary actions row (scoring buttons) */
.actions-secondary {
  margin-top: -16px;
  padding-bottom: 16px;
}

/* Locked button (Global Scores until enabled) */
.btn-locked {
  background: transparent;
  color: var(--text-dim);
  border: 2px dashed var(--border);
  cursor: not-allowed;
  position: relative;
}
.btn-locked:hover { transform: none !important; }
.btn-locked[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #0f1029;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
  z-index: 80;
}
.btn-locked[data-tooltip]:hover::before,
.btn-locked[data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

footer {
  text-align: center;
  color: var(--text-dim);
  padding: 16px;
}

/* ---------- Level ticker ---------- */
.ticker {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 22px 18px;
  margin: 8px auto 16px;
  max-width: 760px;
}

.ticker-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 12px;
}

.ticker-level {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ticker-label {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ticker-level-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--holo-blue);
  text-shadow: 0 0 12px rgba(0,163,238,0.5);
  display: inline-block;
  transition: transform 0.25s ease-out;
}
.ticker-level-num.maxed { color: #ffd84d; text-shadow: 0 0 14px rgba(255,216,77,0.6); }
.ticker-level-num.bump { transform: scale(1.4); }

.ticker-progress-text {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--text);
  letter-spacing: 0.04em;
}
.ticker-progress-text .ticker-sep { color: var(--text-dim); margin: 0 4px; }
.ticker-progress-text .ticker-suffix { color: var(--text-dim); margin-left: 6px; font-size: 0.85rem; }
#ticker-current { font-weight: 700; transition: transform 0.2s ease-out; display: inline-block; }
#ticker-current.bump { transform: scale(1.25); color: var(--holo-blue); }

.ticker-bar {
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.ticker-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--holo-blue), #6fe0ff);
  border-radius: 999px;
  transition: width 0.55s cubic-bezier(0.2, 0.7, 0.25, 1);
  box-shadow: 0 0 12px rgba(0,163,238,0.5);
}
.ticker-fill.maxed {
  background: linear-gradient(90deg, #facc15, #ffe97a, #facc15);
  background-size: 200% 100%;
  animation: maxedShimmer 2.4s linear infinite;
  box-shadow: 0 0 16px rgba(250,204,21,0.55);
}

@keyframes maxedShimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ---------- Level-up banner ---------- */
.level-up-banner {
  position: fixed;
  top: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px) scale(0.85);
  pointer-events: none;
  padding: 14px 36px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--holo-blue), #7ee0ff);
  color: #06223a;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1.1rem;
  box-shadow: 0 12px 40px rgba(0,163,238,0.45), 0 0 0 2px rgba(255,255,255,0.15) inset;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  z-index: 100;
}
.level-up-banner.show {
  opacity: 1;
  animation: bannerPop 0.6s cubic-bezier(0.2, 1.2, 0.4, 1) forwards;
}
.level-up-banner.maxed {
  background: linear-gradient(135deg, #facc15, #ffe97a);
  color: #2a1d00;
  box-shadow: 0 12px 40px rgba(250,204,21,0.5), 0 0 0 2px rgba(255,255,255,0.2) inset;
}

@keyframes bannerPop {
  0%   { transform: translateX(-50%) translateY(-16px) scale(0.85); }
  60%  { transform: translateX(-50%) translateY(8px)   scale(1.06); }
  100% { transform: translateX(-50%) translateY(0)     scale(1.00); }
}

/* ---------- Personal scoring modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 18, 0.7);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  padding: 28px 32px 32px;
  max-width: 980px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalPop 0.28s cubic-bezier(0.2, 1.1, 0.4, 1);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.modal-title {
  margin: 0 0 4px;
  font-size: 1.6rem;
  color: var(--holo-blue);
  letter-spacing: 0.04em;
}

.modal-subtitle {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 720px) {
  .rank-grid { grid-template-columns: 1fr; }
}

.rank-col {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 18px;
}

.rank-col-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 0 12px currentColor;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 22px 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}

.rank-pos {
  color: var(--text-dim);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rank-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: #0a0b18;
  display: block;
}
.rank-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rank-name {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.rank-empty {
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
  margin: 24px 0 8px;
}
.rank-empty-all {
  grid-column: 1 / -1;
  font-size: 1.05rem;
  padding: 32px 0;
}

.modal-subtitle .dot { color: var(--border); margin: 0 6px; }
#my-scores-title-name { color: var(--holo-blue); font-weight: 700; }

/* ---------- Badges row ---------- */
.badges-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  padding: 14px 4px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
@media (max-width: 720px) {
  .badges-row { grid-template-columns: repeat(5, 1fr); }
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: help;
}

.badge-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
  transition: transform 0.2s, box-shadow 0.2s;
}

.badge-item.earned .badge-icon {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--holo-blue), #7ee0ff);
  box-shadow: 0 4px 14px rgba(0,163,238,0.4);
}
.badge-item.earned.latest .badge-icon {
  background: linear-gradient(135deg, #facc15, #ffe97a);
  color: #2a1d00;
  box-shadow: 0 0 20px rgba(250,204,21,0.55);
  animation: badgePulse 2.4s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.badge-item.locked .badge-icon {
  border-style: dashed;
  opacity: 0.5;
}

.badge-name {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.04em;
  line-height: 1.1;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-item.earned .badge-name { color: var(--text); font-weight: 600; }
.badge-item.earned.latest .badge-name { color: #ffe97a; }

.badge-unlock {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--holo-blue);
  text-align: center;
  margin-top: 1px;
  font-weight: 700;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-item.locked .badge-unlock { opacity: 0.55; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  position: relative;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--holo-blue);
  border-bottom-color: var(--holo-blue);
}
.tab.locked {
  color: var(--text-dim);
  opacity: 0.85;
}
.tab.locked::after {
  content: "•";
  margin-left: 6px;
  color: var(--wife);
  font-size: 1.4rem;
  line-height: 0.5;
  vertical-align: middle;
}
.tab[data-tooltip] {
  position: relative;
}
.tab.locked[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f1029;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  z-index: 10;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Locked pane (Stat Rankings before Lv5) ---------- */
.locked-pane {
  text-align: center;
  padding: 48px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
}
.locked-pane h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  color: var(--wife);
  letter-spacing: 0.06em;
}
.locked-pane p { margin: 8px 0; color: var(--text-dim); }
.locked-pane .locked-pane-hint {
  max-width: 540px;
  margin: 18px auto 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- Stat Rankings table ---------- */
.stats-blurb {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
}

.stats-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat-rankings {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.stat-rankings th, .stat-rankings td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.stat-rankings th {
  background: #0f1029;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
  position: sticky;
  top: 0;
}
.stat-rankings th.sorted { color: var(--text); }
.stat-rankings th.sorted::after { content: " ▼"; font-size: 0.7rem; }
.stat-rankings th.sorted.asc::after { content: " ▲"; }

.stat-rankings tbody tr:hover { background: rgba(255,255,255,0.025); }

.stat-talent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.stat-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  background: #0a0b18;
  display: block;
  flex: 0 0 auto;
}
.stat-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.stat-talent-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-impressions {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  text-align: center;
  width: 60px;
}

.stat-cell {
  min-width: 130px;
}
.stat-cell .stat-bar {
  display: inline-block;
  width: 64px;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.stat-bar-bang   { background: linear-gradient(90deg, #4a2034, var(--bang));   box-shadow: 0 0 8px rgba(255,59,59,0.4); }
.stat-bar-wife   { background: linear-gradient(90deg, #4a3820, var(--wife));   box-shadow: 0 0 8px rgba(250,204,21,0.4); }
.stat-bar-friend { background: linear-gradient(90deg, #1f3a4a, var(--friend)); box-shadow: 0 0 8px rgba(95,201,248,0.4); }
.stat-bar-favor  { background: linear-gradient(90deg, #003355, var(--holo-blue), #7ee0ff); box-shadow: 0 0 10px rgba(0,163,238,0.55); }

/* Favor column header: room for a category-toggle pill on the right */
.stat-rankings th[data-sort="favorScore"] {
  position: relative;
  padding-right: 80px;
  min-width: 220px;
}

.favor-cat-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 10px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transition: transform 0.1s, filter 0.15s;
}
.favor-cat-toggle:hover { filter: brightness(1.15); transform: translateY(-50%) scale(1.05); }
.favor-cat-toggle:active { transform: translateY(-50%) scale(0.96); }

.favor-cat-toggle.cat-bang   { background: var(--bang);   color: #fff;     }
.favor-cat-toggle.cat-wife   { background: var(--wife);   color: #1a1300;  }
.favor-cat-toggle.cat-friend { background: var(--friend); color: #052636;  }

/* Hide the toggle pill while the column is locked */
.stat-rankings th[data-sort="favorScore"].locked .favor-cat-toggle { display: none; }

/* Locked Favor column (below Lv7) */
.stat-rankings th.locked {
  cursor: not-allowed;
  color: var(--text-dim);
  opacity: 0.7;
  position: relative;
  border-bottom: 1px dashed var(--border);
}
.stat-rankings th.locked.sorted::after { content: ""; }
.stat-rankings th.locked[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f1029;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  z-index: 10;
}

.stat-cell.stat-locked {
  text-align: center;
  background: rgba(255,255,255,0.015);
  border-left: 1px dashed var(--border);
}
.stat-locked-text {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border);
}

.stat-num {
  display: inline-block;
  min-width: 28px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
}
.stat-count {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-left: 4px;
}

/* ---------- Matchmaker Reveal ---------- */
.matchmaker-intro {
  text-align: center;
  margin-bottom: 18px;
}
.matchmaker-intro h3 {
  margin: 0 0 4px;
  color: var(--holo-blue);
  font-size: 1.3rem;
  letter-spacing: 0.06em;
}
.matchmaker-intro p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.present-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px 0 32px;
  transition: opacity 0.4s, transform 0.4s, max-height 0.4s ease;
}

#matchmaker-content.opened .present-stage {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
  max-height: 0;
  padding: 0;
  overflow: hidden;
}

/* Present box (CSS-only; no images / emoji) */
.present-box {
  position: relative;
  width: 180px;
  height: 180px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  outline: none;
  animation: presentBob 2.4s ease-in-out infinite;
}
.present-box:hover { filter: brightness(1.08); }
.present-box:focus-visible { outline: 2px solid var(--holo-blue); outline-offset: 6px; border-radius: 12px; }

.present-shadow {
  position: absolute;
  bottom: -18px;
  left: 10%;
  right: 10%;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.55), transparent 70%);
  filter: blur(4px);
}

.present-base {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 130px;
  background: linear-gradient(135deg, var(--holo-blue), #6fb6ee 60%, #2a82c8);
  border-radius: 8px;
  box-shadow: inset 0 -8px 14px rgba(0,0,0,0.25), 0 8px 22px rgba(0,163,238,0.35);
}

.present-lid {
  position: absolute;
  left: -4%; right: -4%;
  top: 30px;
  height: 38px;
  background: linear-gradient(135deg, #29bfff, var(--holo-blue) 60%, #006fad);
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.35), inset 0 -3px 6px rgba(0,0,0,0.25);
  transform-origin: center bottom;
  transition: transform 0.55s cubic-bezier(0.4, -0.2, 0.6, 1.4), opacity 0.55s;
}

.present-ribbon-v {
  position: absolute;
  left: 50%; top: 30px; bottom: 0;
  width: 22px;
  margin-left: -11px;
  background: linear-gradient(90deg, #ffd84d, #ffe97a, #ffd84d);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15) inset;
  transition: opacity 0.4s;
}

.present-ribbon-h {
  position: absolute;
  left: 0; right: 0;
  top: 90px;
  height: 22px;
  background: linear-gradient(180deg, #ffd84d, #ffe97a, #ffd84d);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15) inset;
  transition: opacity 0.4s;
}

.present-bow {
  position: absolute;
  left: 50%; top: 16px;
  width: 56px; height: 36px;
  margin-left: -28px;
  background: radial-gradient(circle at 30% 30%, #ffe97a, #ffd84d 60%, #c69d00);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset -3px -3px 6px rgba(0,0,0,0.2);
  transition: transform 0.55s cubic-bezier(0.5, 0, 0.5, 1.4), opacity 0.55s;
  z-index: 2;
}
.present-bow::before, .present-bow::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 22px; height: 26px;
  background: radial-gradient(circle at 30% 30%, #ffe97a, #ffd84d 70%);
  border-radius: 50%;
  transform: translateY(-50%);
}
.present-bow::before { left: -14px; }
.present-bow::after  { right: -14px; }

.present-sparkles {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}
.present-sparkles span {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ffe97a;
  box-shadow: 0 0 12px #ffe97a;
  opacity: 0;
}
.present-sparkles span:nth-child(1) { left: 10%; top: 14%; }
.present-sparkles span:nth-child(2) { left: 88%; top: 22%; }
.present-sparkles span:nth-child(3) { left: 4%;  top: 60%; }
.present-sparkles span:nth-child(4) { left: 96%; top: 70%; }
.present-sparkles span:nth-child(5) { left: 30%; top: 4%; }
.present-sparkles span:nth-child(6) { left: 70%; top: 92%; }
.present-sparkles span:nth-child(7) { left: 50%; top: 10%; }
.present-sparkles span:nth-child(8) { left: 50%; top: 96%; }

@keyframes presentBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Opened state: lid pops, bow flies, sparkles burst */
#matchmaker-content.opened .present-lid {
  transform: translateY(-90px) rotate(-22deg);
  opacity: 0;
}
#matchmaker-content.opened .present-bow {
  transform: translateY(-130px) rotate(35deg) scale(1.4);
  opacity: 0;
}
#matchmaker-content.opened .present-ribbon-v,
#matchmaker-content.opened .present-ribbon-h {
  opacity: 0;
}
#matchmaker-content.opened .present-sparkles span {
  animation: sparkleBurst 1.1s ease-out forwards;
}
#matchmaker-content.opened .present-sparkles span:nth-child(2n) { animation-delay: 0.08s; }
#matchmaker-content.opened .present-sparkles span:nth-child(3n) { animation-delay: 0.16s; }

@keyframes sparkleBurst {
  0%   { opacity: 1; transform: scale(0.5); }
  60%  { opacity: 1; transform: scale(1.6); }
  100% { opacity: 0; transform: scale(0.4); }
}

.present-open-btn {
  font-size: 1rem;
  letter-spacing: 0.18em;
}

/* Reveal cards */
.matchmaker-reveal {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease 0.5s, transform 0.5s ease 0.5s;
  pointer-events: none;
}
#matchmaker-content.opened .matchmaker-reveal {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 720px) {
  .matchmaker-reveal { grid-template-columns: 1fr; }
}

.reveal-card {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.reveal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 14px;
  box-shadow: 0 0 0 2px transparent inset;
  transition: box-shadow 0.3s;
}
.reveal-card-bang::before   { box-shadow: 0 0 24px rgba(255,59,59,0.18) inset, 0 0 0 1px rgba(255,59,59,0.35) inset; }
.reveal-card-wife::before   { box-shadow: 0 0 24px rgba(250,204,21,0.18) inset, 0 0 0 1px rgba(250,204,21,0.35) inset; }
.reveal-card-friend::before { box-shadow: 0 0 24px rgba(95,201,248,0.18) inset, 0 0 0 1px rgba(95,201,248,0.35) inset; }

.reveal-label {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 14px;
  text-shadow: 0 0 12px currentColor;
}

.reveal-thumb {
  width: 130px;
  height: 130px;
  margin: 0 auto 12px;
  border-radius: 50%;
  overflow: hidden;
  background: #0a0b18;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  border: 3px solid rgba(255,255,255,0.08);
}
.reveal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.reveal-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 2px;
}
.reveal-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 14px;
}

.reveal-favorability {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(0,163,238,0.15), rgba(0,163,238,0.05));
  border: 1px solid rgba(0,163,238,0.35);
  border-radius: 999px;
}
.reveal-fav-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.reveal-fav-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--holo-blue);
  font-variant-numeric: tabular-nums;
}
.reveal-fav-delta {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.reveal-personal {
  margin: 12px 0 14px;
  padding: 10px 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}
.reveal-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--holo-blue);
  font-variant-numeric: tabular-nums;
  display: block;
}
.reveal-stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}

.reveal-global {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  text-align: left;
}
.reveal-global-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.reveal-global-key   { color: var(--text-dim); }
.reveal-global-value {
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.reveal-global-note {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
}

.reveal-empty {
  padding: 32px 12px;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.9rem;
}

/* ---------- Simulation modal ---------- */
.sim-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 6px 0 18px;
}
@media (max-width: 540px) {
  .sim-summary { grid-template-columns: repeat(2, 1fr); }
}
.sim-stat-box {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.sim-stat-key {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sim-stat-val {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sim-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.sim-legend {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.sim-band {
  display: inline-block;
  width: 20px;
  height: 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-right: 6px;
}

.sim-table .sim-count-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.sim-count-num {
  font-weight: 800;
  font-size: 1rem;
}
.sim-count-delta {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-left: 6px;
}

.sim-table .sim-distribution { width: 50%; }
.sim-bar {
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.sim-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}
.sim-bar-low    { background: linear-gradient(90deg, #4a2034, var(--bang));   box-shadow: 0 0 8px rgba(255,59,59,0.4); }
.sim-bar-normal { background: linear-gradient(90deg, #1f3a4a, var(--friend)); box-shadow: 0 0 8px rgba(95,201,248,0.35); }
.sim-bar-high   { background: linear-gradient(90deg, #4a3820, var(--wife));   box-shadow: 0 0 8px rgba(250,204,21,0.4); }

/* ---------- Global Scores modal ---------- */
.modal-content-wide { max-width: min(1900px, 98vw); }

.global-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  gap: 18px;
  color: var(--text-dim);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(0,163,238,0.2);
  border-top-color: var(--holo-blue);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.global-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.global-table-wrap {
  /* visible so the Favor header tooltip can extend above the table without
     getting clipped (overflow-x:auto silently clips both axes in browsers). */
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.global-table { font-size: 0.9rem; width: 100%; table-layout: fixed; }
.global-table th, .global-table td { padding: 7px 10px; }
.global-table .stat-talent { width: 18%; }
.global-table th[data-sort^="bang"],
.global-table th[data-sort^="wife"],
.global-table th[data-sort^="friend"] { width: 13.6%; }
.global-table .stat-thumb { width: 32px; height: 32px; }
.global-table .stat-talent-name { font-size: 0.9rem; }

.stat-cell-compact {
  white-space: nowrap;
  min-width: 80px;
}
.stat-cell-compact .stat-bar {
  width: 44px;
  height: 7px;
  margin-right: 6px;
}
.stat-cell-compact .stat-num { min-width: 22px; font-size: 0.85rem; }
.stat-cell-compact .stat-count { font-size: 0.7rem; margin-left: 3px; }

/* Visually pair each Favor cell with its category percentage cell. */
.stat-cell-favor {
  background: rgba(255,255,255,0.025);
  border-left: 1px dashed rgba(255,255,255,0.05);
}

/* Generic tooltip for table headers in the global table.
   No `position: relative` — the th is already `position: sticky`, which acts
   as the containing block for the absolutely-positioned ::before. */
.global-table th[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f1029;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  z-index: 100;
  pointer-events: none;
}

/* ---------- Medals podium row (above the table) ---------- */
.medals-podium-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
@media (max-width: 980px) {
  .medals-podium-row { grid-template-columns: 1fr; }
}

.podium {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px 16px;
  min-width: 0; /* let grid cell shrink instead of overflowing */
}

.podium-heading {
  margin: 0 0 14px;
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 0 12px currentColor;
}

.podium-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  min-height: 240px;
  padding-bottom: 4px;
}

.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 0 0 auto;
}

/* Vertical stagger: gold highest, silver below, bronze lowest. */
.podium-spot.podium-gold   { margin-bottom: 36px; }
.podium-spot.podium-silver { margin-bottom: 18px; }
.podium-spot.podium-bronze { margin-bottom: 0; }

.podium-image-wrap {
  position: relative;
  border-radius: 50%;
}
.podium-spot.podium-gold   .podium-image-wrap { width: 176px; height: 176px; }
.podium-spot.podium-silver .podium-image-wrap,
.podium-spot.podium-bronze .podium-image-wrap { width: 132px; height: 132px; }

/* Mid-width screens: scale spots down so the row still fits in one viewport. */
@media (max-width: 1500px) and (min-width: 981px) {
  .podium-spot.podium-gold   .podium-image-wrap { width: 140px; height: 140px; }
  .podium-spot.podium-silver .podium-image-wrap,
  .podium-spot.podium-bronze .podium-image-wrap { width: 100px; height: 100px; }
  .podium-spot.podium-gold   { margin-bottom: 28px; }
  .podium-spot.podium-silver { margin-bottom: 14px; }
}

.podium-image-wrap img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #0a0b18;
  border: 3px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
}
.podium-spot.podium-gold .podium-image-wrap img {
  border-color: rgba(255,215,0,0.55);
  box-shadow: 0 10px 32px rgba(255,200,0,0.35), 0 0 0 4px rgba(255,215,0,0.18);
}
.podium-spot.podium-silver .podium-image-wrap img {
  border-color: rgba(200,200,200,0.4);
  box-shadow: 0 8px 24px rgba(220,220,220,0.18);
}
.podium-spot.podium-bronze .podium-image-wrap img {
  border-color: rgba(205,127,50,0.4);
  box-shadow: 0 8px 24px rgba(205,127,50,0.18);
}

.podium-medal {
  position: absolute;
  bottom: 4px;
  left: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #1a1300;
  border: 3px solid var(--bg-card);
  box-shadow: 0 4px 10px rgba(0,0,0,0.55);
  font-variant-numeric: tabular-nums;
}
.podium-spot.podium-gold .podium-medal {
  width: 50px; height: 50px;
  font-size: 1.4rem;
  bottom: 6px; left: -2px;
}
.podium-spot.podium-silver .podium-medal,
.podium-spot.podium-bronze .podium-medal {
  width: 38px; height: 38px;
  font-size: 1.1rem;
}

.podium-medal-gold {
  background: radial-gradient(circle at 30% 25%, #fff5b8, #ffd700 50%, #b8860b);
}
.podium-medal-silver {
  background: radial-gradient(circle at 30% 25%, #ffffff, #d8d8d8 50%, #909090);
}
.podium-medal-bronze {
  background: radial-gradient(circle at 30% 25%, #ffd9a0, #cd7f32 50%, #6b3a16);
  color: #fff5e6;
}

.podium-name {
  margin-top: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-spot.podium-gold .podium-name {
  font-size: 1.1rem;
  max-width: 200px;
  color: #ffd966;
}
.podium-spot.podium-silver .podium-name { color: #d8d8d8; }
.podium-spot.podium-bronze .podium-name { color: #d4a37a; }

.podium-rating {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
