.contest-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}
@media (max-height: 500px) {
  .contest-page { height: auto; overflow-y: auto; }
  .matchup-area { min-height: 0; overflow-y: auto; }
  .contest-panel { overflow-y: auto; }
}

/* ─── State screens ─── */
.contest-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}
.contest-state .state-icon { font-size: 64px; opacity: .5; }
.contest-state p { font-size: 18px; }
.contest-state .sub { font-size: 14px; }

/* ─── Vote count badge ─── */
.vote-count-badge {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 4px 14px;
}

/* ─── Contest tabs ─── */
.contest-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 32px;
  flex-shrink: 0;
}
.contest-tab {
  padding: 14px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color .2s;
}
.contest-tab.active { color: var(--accent); }
.contest-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
.contest-tab:hover:not(.active) { color: var(--text); }

/* ─── Contest main area ─── */
#contest-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.contest-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding-bottom: 24px;
}

/* ─── Matchup wrapper (relative for overlay) ─── */
.matchup-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: center;
}

/* ─── Matchup area ─── */
.matchup-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 1100px;
  padding: 24px 24px 0;
  overflow: hidden;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.matchup-area.fade-in { animation: fadeInUp .3s ease; }

/* ─── Photo card ─── */
.photo-card {
  flex: 1;
  max-width: 480px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  user-select: none;
}
.photo-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(108,99,255,0.3);
}

.card-photo {
  flex: 1;
  min-height: 0;
  background-size: cover;
  background-position: center top;
  background-color: var(--surface2);
}

.card-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.card-name   { font-size: 16px; font-weight: 600; }
.card-rating {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 50px;
  padding: 3px 12px;
  border: 1px solid var(--border);
}

/* ─── Rating delta overlay ─── */
.card-result {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 26px;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 12px;
  z-index: 5;
  pointer-events: none;
}
@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.card-result:not(.hidden) { animation: popIn .2s ease; }
.card-result.delta-positive { color: #4caf82; background: rgba(76,175,130,.18); border: 1px solid rgba(76,175,130,.4); }
.card-result.delta-negative { color: #ff5c72; background: rgba(255,92,114,.18); border: 1px solid rgba(255,92,114,.4); }

/* ─── Winner / loser states ─── */
.photo-card.winner {
  border-color: #4caf82 !important;
  box-shadow: 0 0 0 4px rgba(76,175,130,.25), 0 16px 48px rgba(76,175,130,.2) !important;
  transform: scale(1.03) translateY(-4px) !important;
}
.photo-card.loser {
  opacity: .5;
  transform: scale(0.96) !important;
}
.photo-card.loser::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,92,114,.1);
  pointer-events: none;
}

/* ─── VS divider ─── */
.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 72px;
}
.vs-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  box-shadow: 0 0 0 4px var(--bg);
}

/* ─── Next pair overlay ─── */
.next-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 23, 0.6);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.next-big-btn {
  padding: 20px 52px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 40px rgba(108,99,255,0.5);
  transition: background .2s, transform .15s, box-shadow .2s;
  letter-spacing: .02em;
}
.next-big-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
  box-shadow: 0 12px 48px rgba(108,99,255,0.65);
}
.next-big-btn:active { transform: scale(0.97); }

/* ─── Leaderboard ─── */
.leaders-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  width: 100%;
  max-width: 900px;
  padding: 32px;
  overflow-y: auto;
}
.leaders-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}
.leader-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: border-color .2s;
}
.leader-row:hover         { border-color: var(--accent); }
.leader-row.leader-me     { border-color: var(--accent); background: var(--accent-glow); }
.leader-rank              { font-size: 18px; width: 28px; flex-shrink: 0; }
.leader-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background-size: cover; background-position: center;
  flex-shrink: 0;
}
.leader-info              { flex: 1; display: flex; flex-direction: column; }
.leader-name              { font-size: 14px; font-weight: 600; }
.leader-stats             { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.leader-score             { font-size: 15px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.leaders-empty            { color: var(--text-muted); font-size: 14px; padding: 20px 0; }

/* ─── Vote button ─── */
.card-vote-btn {
  display: block;
  margin: 0 16px 16px;
  padding: 12px 0;
  width: calc(100% - 32px);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.card-vote-btn:hover  { background: var(--accent-hover); }
.card-vote-btn:active { transform: scale(0.97); }

/* ─── Photo lightbox ─── */
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-lightbox.hidden { display: none; }

.lightbox-photo {
  width: 92vw;
  height: 92vh;
  max-width: 700px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.lightbox-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lightbox-close-btn:hover { background: rgba(255,255,255,0.25); }

/* ─── Expand hint on photo ─── */
.card-photo {
  cursor: zoom-in;
}

/* ─── Responsive ─── */
@media (max-width: 700px) {
  .leaders-grid { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .contest-tabs { padding: 0 12px; }

  .matchup-area {
    padding: 24px 16px 0;
    gap: 12px;
    align-items: center;
  }

  /* Circular avatar card */
  .photo-card {
    flex: 1;
    max-width: 160px;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px 16px;
    border-radius: 24px;
    cursor: default;
    gap: 0;
  }
  .photo-card:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
  }
  .photo-card.winner {
    border-color: #4caf82 !important;
    box-shadow: 0 0 0 4px rgba(76,175,130,.25) !important;
    transform: none !important;
  }
  .photo-card.loser {
    transform: none !important;
    opacity: 0.5;
  }

  .card-photo {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    flex: none;
    border: 3px solid var(--border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  }

  .card-info {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px 0;
    border-top: none;
    text-align: center;
  }
  .card-name   { font-size: 14px; }
  .card-rating { font-size: 11px; padding: 2px 8px; }

  .card-vote-btn {
    margin: 12px 0 0;
    width: 100%;
    border-radius: 12px;
    font-size: 14px;
  }

  .vs-divider { width: 32px; }
  .vs-badge   { width: 32px; height: 32px; font-size: 10px; }

  .card-result { font-size: 20px; top: 10px; right: 10px; padding: 4px 10px; }
}

/* ─── Phone landscape ─── */
@media (max-height: 500px) and (max-width: 900px) {
  .contest-page {
    height: auto;
    overflow-y: auto;
  }
  .dash-header { height: 44px; padding: 0 12px; flex-shrink: 0; }
  .matchup-area {
    padding: 12px 8px 0;
    flex-wrap: nowrap;
  }
  .photo-card {
    max-width: 140px;
    padding: 10px 8px 10px;
  }
  .card-photo {
    width: 80px;
    height: 80px;
  }
  .card-info { padding: 6px 4px 0; }
  .card-name { font-size: 12px; }
  .card-rating { font-size: 10px; }
  .card-vote-btn {
    margin-top: 8px;
    padding: 7px 0;
    font-size: 12px;
  }
  .vs-badge { width: 28px; height: 28px; font-size: 9px; }
  .next-big-btn { font-size: 15px; padding: 14px 32px; }
}
