/* ---------- themes ---------- */
:root, :root[data-theme="black"] {
  --bg: #08080b;
  --surface: #121218;
  --surface2: #1b1b23;
  --border: #24242e;
  --text: #f4f4f7;
  --muted: #9a9aab;
  --accent: #ffd21e;
  --accent-ink: #141414;
  --accent2: #ff5470;
  --green: #3ddc84;
  --ig: #ff5c8d;
  --shadow: 0 14px 40px rgba(0, 0, 0, .55);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, .35);
  --joke-bg: rgba(255, 210, 30, .07);
  --banner: linear-gradient(135deg, rgba(255,210,30,.13), rgba(255,84,112,.09));
  --hover-tint: rgba(255, 210, 30, .06);
  --rank-ink: #ffd21e;
  --radius: 16px;
}
:root[data-theme="white"] {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface2: #ececf1;
  --border: #dddde5;
  --text: #17171d;
  --muted: #6d6d7c;
  --accent: #f5b800;
  --accent-ink: #171717;
  --accent2: #e2325c;
  --green: #159f56;
  --ig: #d62f6d;
  --shadow: 0 14px 40px rgba(25, 25, 40, .16);
  --shadow-soft: 0 4px 14px rgba(25, 25, 40, .10);
  --joke-bg: rgba(245, 184, 0, .10);
  --banner: linear-gradient(135deg, rgba(245,184,0,.14), rgba(226,50,92,.08));
  --hover-tint: rgba(245, 184, 0, .09);
  --rank-ink: #8a6d00;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
html { color-scheme: dark; }
:root[data-theme="white"] { color-scheme: light; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }

/* ---------- nav ---------- */
nav {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brandLink { display: flex; align-items: center; gap: 10px; }
.navlogo { border-radius: 7px; display: block; flex: none; }
.brand { font-weight: 900; letter-spacing: .4px; font-size: 17px; }
.brand em { color: var(--accent); font-style: normal; }
:root[data-theme="white"] .brand em { color: var(--rank-ink); }
nav .links { display: flex; gap: 6px; margin-left: auto; align-items: center; }
nav .links a {
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
  color: var(--muted); transition: .15s;
}
nav .links a:hover { color: var(--text); background: var(--surface2); }
nav .links a.active { color: var(--accent-ink); background: var(--accent); }
.themeToggle {
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.themeToggle:hover { border-color: var(--accent); transform: rotate(15deg); }

main { max-width: 1060px; margin: 0 auto; padding: 26px 18px 90px; }
h1 { font-size: 30px; font-weight: 900; letter-spacing: .2px; margin-bottom: 6px; }
h1 em { color: var(--accent); font-style: normal; }
:root[data-theme="white"] h1 em { color: var(--rank-ink); }
.sub { color: var(--muted); margin-bottom: 22px; font-size: 15px; line-height: 1.5; }

/* ---------- chips / filters ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; align-items: center; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 700;
  transition: .15s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- search ---------- */
.searchBox {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); padding: 10px 14px; font-size: 14px; outline: none; transition: .15s;
  margin-bottom: 14px;
}
.searchBox:focus { border-color: var(--accent); }
.searchBox::placeholder { color: var(--muted); }

/* ---------- stat chips ---------- */
.statChips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.statChip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px; box-shadow: var(--shadow-soft);
}
.statChip b { font-size: 18px; color: var(--rank-ink); display: block; }
.statChip span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }

/* ---------- person card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; width: 100%; box-shadow: var(--shadow-soft);
  transition: transform .12s, border-color .12s, box-shadow .12s;
  position: relative;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.card.won { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 40%, transparent); }
.card.lost { opacity: .35; filter: grayscale(.8); }
.photo {
  width: 100%; aspect-ratio: 4/4.4; background: var(--surface2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.photo img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.fallback {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 18px; text-align: center;
}
.fallback .initials {
  width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 900; color: #141414;
}
.fallback .fbBlurb { color: var(--muted); font-size: 13px; line-height: 1.45; max-width: 260px; }
.meta { padding: 14px 16px 16px; }
.meta .name { font-weight: 800; font-size: 18px; }
.meta .role { display: inline-block; margin: 6px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .8px;
  text-transform: uppercase; padding: 3px 9px; border-radius: 999px; }
.role.panel { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--rank-ink); }
.role.contestant { background: color-mix(in srgb, var(--accent2) 15%, transparent); color: var(--accent2); }
.panelchips { display: flex; gap: 5px; flex-wrap: wrap; margin: 4px 0 8px; }
.panelchips span {
  font-size: 11px; font-weight: 700; color: var(--text); opacity: .8; background: var(--surface2);
  border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px;
}
.meta .blurb { color: var(--muted); font-size: 13px; line-height: 1.5; }
.meta .joke {
  margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--accent);
  background: var(--joke-bg); border-radius: 0 8px 8px 0;
  font-style: italic; font-size: 13px; color: var(--text); opacity: .92; line-height: 1.5;
}
.meta .ig {
  display: inline-block; margin-top: 9px; font-size: 12px; font-weight: 800;
  color: var(--ig); background: color-mix(in srgb, var(--ig) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ig) 35%, transparent);
  padding: 4px 11px; border-radius: 999px; transition: .15s;
}
.meta .ig:hover { background: var(--ig); color: #fff; }

/* ---------- faceoff ---------- */
.arena { display: grid; grid-template-columns: 1fr 64px 1fr; gap: 16px; align-items: start; }
.arena > *, #slotA, #slotB { min-width: 0; }   /* let cards shrink below image min-content */
.arena { touch-action: pan-y; transition: transform .25s ease; }
.card.picking {
  transform: translateY(-3px) scale(1.035);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 50%, transparent), var(--shadow);
}
.card.picking::after {
  content: 'FUNNIER'; position: absolute; top: 8px; right: 8px; z-index: 4;
  background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 900; letter-spacing: .5px; padding: 3px 8px; border-radius: 999px;
}
.vs { text-align: center; font-size: 26px; font-weight: 900; color: var(--accent); align-self: center; }
:root[data-theme="white"] .vs { color: var(--rank-ink); }
.toolbar { display: flex; gap: 10px; margin-top: 18px; justify-content: center; align-items: center; }
button.btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 10px 20px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: .15s;
}
button.btn:hover { border-color: var(--accent); }
button.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.btn:disabled { opacity: .4; cursor: default; }
.sessionNote { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }
.eloDelta {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  background: var(--green); color: #08240f; font-weight: 900; font-size: 14px;
  padding: 4px 11px; border-radius: 999px; animation: pop .25s ease-out;
}
.eloDelta.neg { background: var(--accent2); color: #fff; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- judge mode ---------- */
.judgeWrap { max-width: 560px; margin: 0 auto; }
.scoreRow { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin: 20px 0 8px; }
.scoreBtn {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 17px; font-weight: 800; cursor: pointer; transition: .12s;
}
.scoreBtn:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); transform: translateY(-2px); }
.scoreBtn.picked { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.reveal {
  margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; text-align: center; box-shadow: var(--shadow-soft);
}
.reveal .big { font-size: 40px; font-weight: 900; color: var(--rank-ink); }
.reveal .cap { color: var(--muted); font-size: 13px; margin-top: 4px; }
.reveal .match { margin-top: 10px; font-weight: 800; }
.match.yes { color: var(--green); }
.match.no { color: var(--muted); }
.progress { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 14px; }

/* ---------- tables / leaderboard ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-soft); }
th, td { text-align: left; padding: 11px 14px; font-size: 14px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .7px; }
tr:last-child td { border-bottom: none; }
td.rank { font-weight: 900; color: var(--rank-ink); width: 44px; }
td .mini { display: flex; align-items: center; gap: 10px; font-weight: 700; position: relative; }
td .mini img, td .mini .dot {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; object-position: top center;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 900; color: #141414;
  flex: none; transition: transform .18s;
}
.section { margin-bottom: 42px; }
.section h2 { font-size: 20px; font-weight: 900; margin-bottom: 4px; }
.section .note { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.badge.win { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.badge.dim { background: var(--surface2); color: var(--muted); }
.winnerBanner {
  background: var(--banner);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px;
}
.winnerBanner .who { font-size: 18px; font-weight: 900; }
.winnerBanner .why { color: var(--muted); font-size: 13px; margin-top: 3px; }
.empty { color: var(--muted); font-size: 14px; padding: 18px; background: var(--surface); border-radius: var(--radius); }

/* clickable rows: hover animation so users know to click */
tr.rowClick { cursor: pointer; }
tr.rowClick td { transition: background .15s; }
tr.rowClick:hover td { background: var(--hover-tint); }
tr.rowClick .mini span:last-child { transition: transform .18s, color .18s; }
tr.rowClick:hover .mini span:last-child { transform: translateX(5px); color: var(--rank-ink); }
tr.rowClick:hover .mini img, tr.rowClick:hover .mini .dot { transform: scale(1.18); }
tr.rowClick .mini::after {
  content: 'view profile →';
  font-size: 11px; font-weight: 800; color: var(--rank-ink);
  opacity: 0; transform: translateX(-6px); transition: opacity .18s, transform .18s;
  white-space: nowrap; margin-left: 4px;
}
tr.rowClick:hover .mini::after { opacity: 1; transform: translateX(0); }

/* ---------- person modal ---------- */
.modalOverlay {
  position: fixed; inset: 0; background: rgba(4, 4, 8, .72); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
:root[data-theme="white"] .modalOverlay { background: rgba(30, 30, 45, .45); }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  max-width: 780px; width: 100%; max-height: 90vh; overflow: auto;
  display: grid; grid-template-columns: 320px 1fr; position: relative;
  box-shadow: var(--shadow);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal .mPhoto { background: var(--surface2); min-height: 380px; }
.modal .mPhoto img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.modal .mPhoto .fallback { height: 100%; }
.modal .mBody { padding: 24px 26px; }
.modal .mName { font-size: 26px; font-weight: 900; margin-bottom: 4px; }
.modal .mStats { display: flex; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.modal .mStat { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; text-align: center; }
.modal .mStat b { display: block; font-size: 18px; color: var(--rank-ink); }
.modal .mStat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.modal .mBlurb { color: var(--text); opacity: .85; font-size: 14px; line-height: 1.6; margin-top: 6px; }
.modal .mClose {
  position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none; font-size: 17px; cursor: pointer; z-index: 2;
}
.modal .mClose:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .modal { grid-template-columns: 1fr; }
  .modal .mPhoto { min-height: 280px; aspect-ratio: 16/10; }
  tr.rowClick .mini::after { display: none; }
}

/* phones */
@media (max-width: 560px) {
  html { -webkit-text-size-adjust: 100%; }
  nav { padding: 11px 12px; gap: 8px; flex-wrap: nowrap; }
  .brand { display: none; }                  /* logo carries the brand on phones */
  .navword { display: none; }                /* links collapse to their emoji + count */
  .navlogo { width: 30px; height: 30px; }
  nav .links { gap: 6px; margin-left: auto; flex: none; }
  nav .links a { padding: 8px 11px; font-size: 14px; white-space: nowrap; }
  .themeToggle { width: 36px; height: 36px; flex: none; }

  main { padding: 18px 14px 80px; }
  h1 { font-size: 25px; }
  .sub { font-size: 14px; }

  /* face-off stays side-by-side and fully fits the screen — no scrolling to compare */
  .sub { font-size: 13px; margin-bottom: 14px; }
  .arena { grid-template-columns: 1fr 30px 1fr; gap: 8px; }
  .vs { font-size: 17px; }
  .arena .meta { padding: 9px 10px 11px; }
  .arena .meta .name { font-size: 15px; line-height: 1.2; }
  .arena .meta .role { margin: 5px 0 0; padding: 2px 7px; font-size: 10px; }
  /* only the photo, name and role on the tiny cards — full detail is a tap away in the modal */
  .arena .panelchips, .arena .meta .blurb, .arena .meta .joke, .arena .meta .ig { display: none; }
  .arena .photo { aspect-ratio: 3/3.4; }
  .toolbar { flex-wrap: wrap; }
  button.btn { padding: 11px 18px; }        /* comfortable tap targets */
  .eloDelta { font-size: 12px; padding: 3px 8px; top: 7px; left: 7px; }

  /* chips + search fill the row */
  .chips { gap: 6px; margin-bottom: 16px; }
  .chip { padding: 8px 13px; }               /* >=44px tall tap targets */
  .searchBox { max-width: none; }
  .statChips { gap: 8px; }
  .statChip { flex: 1 1 40%; padding: 10px 12px; }
  .statChip b { font-size: 16px; }

  /* leaderboard: turn rows into flex rows on phones so nothing overflows */
  table { display: block; font-size: 15px; box-shadow: none; background: transparent; }
  table tbody { display: block; }
  table tr:not(.rowClick) { display: none; }             /* hide the header row */
  tr.rowClick {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 13px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  tr.rowClick:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
  tr.rowClick:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
  td { display: block; padding: 0; border: none; }
  td.rank { width: 22px; flex: none; }
  td:nth-child(2) { flex: 1; min-width: 0; }              /* WHO takes the space */
  td:nth-child(2) .mini > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  td:nth-child(3), td:nth-child(5) { display: none; }     /* Panels + W-L (both in the profile modal) */
  td:nth-child(4) { flex: none; font-weight: 900; color: var(--rank-ink); font-size: 15px; }
  td .mini img, td .mini .dot { width: 34px; height: 34px; }

  .modal .mBody { padding: 20px 18px; }
  .modal .mName { font-size: 22px; }
  .lockNotice { margin: 28px auto; padding: 26px 20px; }
}

/* very small phones */
@media (max-width: 360px) {
  .brand { font-size: 12px; letter-spacing: 0; }
  nav .links a { padding: 6px 8px; font-size: 12px; }
  .arena { gap: 6px; grid-template-columns: 1fr 26px 1fr; }
}

/* ---------- gated leaderboard link ---------- */
nav .links a.lockedLink {
  opacity: .55; cursor: not-allowed; position: relative;
}
nav .links a.lockedLink:hover { background: transparent; color: var(--muted); }
nav .links a.lockedLink::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 13px; font-size: 12px; font-weight: 600; line-height: 1.45;
  width: 232px; white-space: normal; text-align: left;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(-4px);
  pointer-events: none; transition: opacity .15s, transform .15s; z-index: 30;
}
nav .links a.lockedLink::before {
  content: ''; position: absolute; top: calc(100% + 4px); right: 26px;
  border: 6px solid transparent; border-bottom-color: var(--border);
  opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 30;
}
nav .links a.lockedLink:hover::after,
nav .links a.lockedLink:hover::before { opacity: 1; transform: translateY(0); }
.lockNotice {
  max-width: 460px; margin: 40px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px 28px; box-shadow: var(--shadow-soft);
}
.lockNotice .lockIcon { font-size: 40px; margin-bottom: 10px; }
.lockNotice h2 { font-weight: 900; margin-bottom: 8px; }
.lockNotice p { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 18px; }
.lockBar { height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.lockBar > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
