@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Manrope:wght@400;500;600;700&display=swap');

:root {
  --void: #14151c;
  --void-2: #1b1d27;
  --silk: #eee9df;
  --silk-dim: #a8a49b;
  --gale: #7fa8a0;      /* Alabardieri accent (blue-teal, martial) */
  --gale-dim: #4d6a65;
  --plum: #c98aa0;      /* Farfalloidi accent (rose, feminine) */
  --plum-dim: #6a4d58;
  --ember: #c9945a;
  --seal: #a91e1e;      /* logo red */
  --line: #33364a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--silk);
  font-family: 'Manrope', system-ui, sans-serif;
  overflow: hidden;
}

.stage {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 36px 20px;
  position: relative;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 18px;
  gap: 20px;
}
.masthead .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.masthead .brand img { height: 40px; width: 40px; border-radius: 4px; }
.masthead .mark {
  font-family: 'Fraunces', serif;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--silk);
  line-height: 1.1;
}
.masthead .mark small { display: block; font-size: 11px; color: var(--silk-dim); font-family: 'Manrope', sans-serif; font-weight: 500; }

.category-banner {
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--gale-dim);
  color: var(--gale);
  white-space: nowrap;
}
.category-banner.women { border-color: var(--plum-dim); color: var(--plum); }

.season-banner { text-align: right; }
.season-banner .tag {
  font-size: 15px;
  color: var(--silk);
}
.season-banner .tag strong { color: var(--ember); font-weight: 700; }
.season-banner .tagline {
  font-size: 12px;
  color: var(--silk-dim);
  margin-top: 2px;
  font-style: italic;
}

.content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr minmax(300px, 360px);
  grid-template-rows: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

/* ---------- row 1: front + back, 50/50 ---------- */
.slot {
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}
.slot img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.slot .label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--silk-dim);
  background: linear-gradient(to top, rgba(20,21,28,0.85), transparent);
  pointer-events: none;
}
.slot .empty-msg { font-size: 12px; color: var(--silk-dim); }

.slot.front { grid-column: 1; grid-row: 1; }
.slot.back { grid-column: 2; grid-row: 1; }

/* ---------- row 2: square portrait + name/totals ---------- */
.portrait-cell {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}
.slot.portrait-square {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  margin: auto;
}
.slot.portrait-square img,
.slot.portrait-square img.active {
  opacity: 0;
  position: absolute;
  inset: 0;
  transition: opacity 0.8s ease;
}
.slot.portrait-square img.active { opacity: 1; position: relative; }
.slot.portrait-square .label { z-index: 2; }

.scorecard {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}
.participant-name {
  font-family: 'Fraunces', serif;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.05;
  margin: 0 0 10px;
}

/* ---------- dedicated side column: judges, full height, no scroll needed ---------- */
.judges-column {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.judges-column .round-label {
  font-size: 15px;
  color: var(--silk-dim);
  margin-bottom: 10px;
  flex-shrink: 0;
}
.judges-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  min-height: 0;
}
.judge-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 14px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 24px;
}
.judge-row.public { border-bottom-style: dashed; }
.judge-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.judge-avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--void-2);
  color: var(--silk-dim);
  font-family: 'Fraunces', serif;
  font-size: 20px;
  text-transform: uppercase;
}
.judge-row.public .judge-avatar.placeholder { background: rgba(127, 168, 160, 0.15); }
.judge-row .name { color: var(--silk-dim); flex: 1; }
.judge-row .score {
  font-family: 'Fraunces', serif;
  font-size: 40px;
  font-weight: 600;
  color: var(--ember);
  min-width: 56px;
  text-align: right;
}
.judge-row .score.pending { color: var(--line); }
.judge-row .score.pop { animation: dw-judge-scorepop 1.4s ease; }
@keyframes dw-judge-scorepop {
  0% { transform: scale(1); color: var(--ember); }
  15% { transform: scale(1.5); color: #ffe08a; text-shadow: 0 0 16px rgba(255, 224, 138, 0.8); }
  60% { transform: scale(1.15); color: #ffe08a; text-shadow: 0 0 10px rgba(255, 224, 138, 0.5); }
  100% { transform: scale(1); color: var(--ember); text-shadow: none; }
}

.totals {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
  font-size: 13px;
  color: var(--silk-dim);
}
.totals .row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.totals .num { color: var(--silk); font-weight: 600; font-family: 'Fraunces', serif; font-size: 16px; }
.totals .grand { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 6px; }
.totals .grand .num { font-size: 20px; color: var(--ember); }

/* ---------- footer: leaderboards ---------- */
.leaderboards {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.leaderboard-col .heading {
  font-size: 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lb-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.lb-status.progress { background: rgba(201, 148, 90, 0.15); color: var(--ember); }
.lb-status.final { background: rgba(127, 168, 160, 0.18); color: var(--gale); }
.leaderboard-col.men .heading { color: var(--gale); }
.leaderboard-col.women .heading { color: var(--plum); }
.leaderboard-col ol {
  list-style: none;
  display: flex;
  gap: 20px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.leaderboard-col li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
}
.leaderboard-col .rank {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  color: var(--silk-dim);
}
.leaderboard-col .lname { color: var(--silk); }
.leaderboard-col .lscore { color: var(--ember); font-weight: 600; }
.leaderboard-col .lprize { color: var(--silk-dim); font-size: 11px; }
.leaderboard-col .empty { color: var(--silk-dim); font-size: 12px; }

/* ---------- idle screen ---------- */
.idle-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  position: relative;
  background-image: linear-gradient(rgba(20,21,28,0.82), rgba(20,21,28,0.94)), url('/img/wave-motif.png');
  background-size: cover;
  background-position: center;
  border-radius: 8px;
}
.idle-screen img.mark-logo { height: 64px; width: 64px; border-radius: 8px; margin-bottom: 6px; }
.idle-screen .mark {
  font-family: 'Fraunces', serif;
  font-size: 34px;
  color: var(--silk);
}
.idle-screen p { color: var(--silk-dim); font-size: 14px; }

.fade-in { animation: fadeIn 0.5s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- comparison mode ---------- */
.compare-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 0;
}
.compare-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--void-2);
}
.compare-side.women { border-top: 3px solid var(--plum-dim); }
.compare-side.men { border-top: 3px solid var(--gale-dim); }
.compare-header { margin-bottom: 10px; }
.compare-name {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  color: var(--silk);
}
.compare-meta { font-size: 13px; color: var(--silk-dim); margin-top: 2px; }
.compare-images {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: 0;
}
.compare-images .slot.front { grid-column: 1; grid-row: 1; }
.compare-images .slot.back { grid-column: 2; grid-row: 1; }
.compare-images .slot.portrait { grid-column: 1 / 3; grid-row: 2; }
.compare-score {
  margin-top: 12px;
  font-size: 14px;
  color: var(--silk-dim);
  text-align: center;
}
.compare-score strong { color: var(--ember); font-family: 'Fraunces', serif; font-size: 18px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox.open { opacity: 1; visibility: visible; }
.lightbox img {
  max-width: 94vw;
  max-height: 94vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* ---------- full-page leaderboard mode (Regia-triggered) ---------- */
.leaderboard-fullpage {
  flex: 1;
  display: grid;
  gap: 32px;
  min-height: 0;
}
.leaderboard-fullpage.two-col { grid-template-columns: 1fr 1fr; }
.leaderboard-fullpage.one-col { grid-template-columns: 1fr; max-width: 720px; margin: 0 auto; width: 100%; }

.lb-full-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lb-full-col h2 {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 26px;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.lb-full-col.women h2 { color: var(--plum); }
.lb-full-col.men h2 { color: var(--gale); }

.lb-full-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.lb-full-row {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
}
.lb-full-rank {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  color: var(--silk-dim);
  min-width: 44px;
}
.lb-full-photos {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.lb-full-ph {
  width: 64px;
  height: 88px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--void);
  border: 1px solid var(--line);
}
.lb-full-ph img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.lb-full-name { flex: 1; font-size: 22px; }
.lb-full-score {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--ember);
}
.lb-full-prize { font-size: 13px; color: var(--silk-dim); min-width: 90px; text-align: right; }
.lb-full-empty { color: var(--silk-dim); font-size: 15px; padding: 20px 0; }
